Technical Explainer Gaming & Display
Why Does Shader Compilation Make Games Stutter Only the First Time?
Separating rendering preparation from GPU execution time in Android Vulkan games
- Level: Intermediate
- ~6 min read
- 5 primary sources
In Android Vulkan games, assembling the rendering state needed for a new visual effect on the spot can delay that frame's presentation. A practical clue is whether passing through the exact same spot with the same settings smooths out the second time. To confirm the root cause, match the delayed frame against timestamps of pipeline creation calls.
Who this helps
- Players wondering why a game freezes briefly at a new area or effect even when average FPS is high
- Readers who want to know what 'Compiling shaders' messages mean when launching a game
Decision checklist
- Repeat the exact same route with identical settings and record the difference between the first pass and the second pass
- Look at individual frame times in addition to average FPS
- During development, correlate delayed frames with Vulkan API call timestamps
Use the per-frame timeline model to see why even a brief preparation delay pushes a frame past its display deadline.
Check frame deadlines in the pipeline modelA boss’s very first attack makes the screen hitch, yet the exact same attack plays smoothly the second time. Before thinking about replacing your phone, the key question is whether drawing the attack is slow every time, or whether preparing to draw it for the first time took extra time. Khronos’s official Vulkan sample isolates preparation time by destroying previously built rendering setups and rebuilding them from scratch. Sample procedure (Source 1)
Even when shaders are bundled, what preparation remains on the device?
Shaders are programs that run on the GPU to calculate things like vertex positions and pixel colors. SPIR-V, used by Vulkan, is an intermediate representation that apps use to deliver those programs. Even though SPIR-V is packaged with the game, the device still has to translate the shader for its specific GPU and combine it with other rendering settings. Translating a program into executable form is called “compilation.” Role of SPIR-V (Source 2) Work performed during pipeline creation (Source 1)
For instance, layering fire over a background requires both the shader that computes the fire’s color and settings describing how that color blends with what lies behind it. Packaging these settings together into a ready-to-draw object creates a graphics pipeline. Even with the same shader, changing fixed pipeline states such as blending mode or depth testing requires a separate pipeline. Rendering states combined in the sample (Source 1)
- Specify how to draw
The game selects the shaders along with depth-testing and color-blending settings.
- Prepare the combination
The game requests pipeline creation. The driver reuses any compatible cached work and performs required compilation.
- Draw with the prepared state
The game binds the pipeline and draws. Drawing with the same configuration again can reuse the created object.
What differs between first pass and second pass is what can be reused
As long as a created pipeline stays alive inside the running game, drawing the next flame can reuse the exact same object. Once the game exits, however, those in-memory objects cannot simply be called directly on the next launch. That is where a pipeline cache helps: after creating pipelines, the game can retrieve internal driver data, save it to storage, and pass it back on the next launch to skip part of the expensive translation work. Saving and reusing across runs (Source 1)
| Scenario | What can be reused | Key point for display impact |
|---|---|---|
| Right before an unseen effect plays | The local cache may not yet hold data for that combination | If drawing waits for pipeline creation to finish, that frame is delayed |
| Drawing again with the same settings | The already-created pipeline kept in memory by the game | Creation is skipped, though GPU work to draw the fire still runs every time |
| Showing the same effect on the next launch | Compatible cache data saved and reloaded by the game | Pipeline creation is still required, but repeated internal compilation work can be reduced |
Building expected combinations at launch or during level loading shifts that wait out of active gameplay. Still, which combinations are actually needed can depend on player actions. Furthermore, the Vulkan specification ties cache compatibility to factors including vendor, device, and driver, falling back to an empty cache if incompatible initial data is passed. That makes updates a plausible reason preparation runs again, though confirming whether a specific update triggered a rebuild requires checking the game’s own logs or traces. Conditions for pre-building (Source 1) Cache creation and compatibility (Source 3)
What do the official sample’s 24.4 ms and 50.4 ms actually measure?
On a smartphone powered by a Mali G76 GPU displaying the Sponza scene, Khronos destroyed existing pipelines and recreated them. With 2 target pipelines, recreation took 24.4 ms with the pipeline cache enabled and 50.4 ms with it disabled. This is a controlled comparison of pipeline recreation under two settings on the same scene and device—it cannot be converted into overall average FPS or how long an effect will stall on a different GPU. Test conditions and results with screenshots (Source 1)
Whether a player notices this difference depends on when the work happens. If creation completes on a loading screen, gameplay drawing never has to wait. If creation happens right as an effect appears and pushes a frame past its presentation deadline, the previous image stays on screen longer. You can test how deadlines affect presentation timing in the frame pipeline timeline.
How to verify first-time stutter in your own game
-
Does the hitch disappear the second time you visit the same spot or trigger the same attack?
YesFirst-time preparation (shader compilation or first-time asset loading) is a leading candidate.
Compare the first and second passes again after restarting the app to see whether the improvement persists across launches. -
Does it still hitch on the second pass and get worse the longer you play?
YesCheck for sustained-performance drops from heat.Compare the same scene right after launch versus 15 to 20 minutes later. -
Does it stay heavy every single time a specific effect or reflection is on screen?
YesTest adjusting rendering settings or GPU workload.Step down resolution or quality by one notch and compare in the exact same scene. If the whole system feels unstable immediately after launch or app switching, investigate OS, memory, and storage bottlenecks instead.
- Pick a repeatable test point. Record the game version, device, graphics preset, and frame-rate cap. Standardize your actions—for example, walking through a stage entrance, facing the same direction, and triggering the same skill.
- Repeat without closing the game. If it stalls only on the first pass, preparation that can be reused within the same session is a strong candidate. Because first-time asset loading (Storage read performance) can look similar, this test alone cannot prove compilation was the cause. If the effect stays heavy every time, tweak one graphics setting at a time to test ongoing GPU load. If performance degrades over time, thermal throttling is another candidate.
- Compare against the next launch. If the game shows a preparation screen at startup, note whether it appears and how long it takes. Separating the first pass after a restart from the immediate second pass distinguishes improvements that last only within one session from improvements that carry over across restarts.
For developers starting an investigation, Google recommends Android Performance Analyzer (APA) for games and Vulkan graphics, which lets you compare traces from a first run and a second run side by side. APA scope and trace comparison (Source 5)
If you already use Android GPU Inspector (AGI), System Profiler can target your app and capture Vulkan API calls alongside CPU scheduling. Check whether the rendering thread spends time inside vkCreateGraphicsPipelines right before a delayed frame, and whether that call disappears on the second pass. If it ran concurrently on another thread, trace whether rendering actually waited on it. Available metrics depend on the device and capture configuration. Google trace metrics and interpretation (Source 4)
When reading reviews before buying a phone, frame-time graphs showing both the first pass and a repeat pass of the same game are far more informative than averages alone. You can check the SoC inside devices like the OnePlus 13 or vivo X200 Pro and cross-check specs in the Snapdragon 8 Elite vs. Dimensity 9400 comparison. Spec tables only show chip differences; knowing whether a specific effect stutters on one phone or another requires measurements from that actual game.
| Chip | GPU | Process Node |
|---|---|---|
| Snapdragon 8 EliteQualcomm Announced | Qualcomm Adreno Source | 3nm Source |
| Snapdragon 8 Elite Gen 5Qualcomm Announced | Qualcomm Adreno Source | 3nm Source Official generation name; foundry and sub-node details (such as N3P) are not listed. |
| Dimensity 9400MediaTek Announced | Arm Immortalis-G925 MC12 Source | 2nd-generation 3nm Source |
| Dimensity 9500MediaTek Announced | Arm Mali-G1 Ultra MC12 Source | N3P Source |
Frequently Asked Questions
What is a game doing when it displays 'Compiling shaders'?
In a Vulkan game, bundled SPIR-V shaders still need to be translated for the target GPU and combined with rendering states—such as color blending and depth testing—to build graphics pipelines. Exactly which tasks a commercial game performs during its progress screen depends on the title.
Why does it stutter only the first time and run smoothly on the second pass?
Once a graphics pipeline is created and kept in memory during the session, the game can reuse it whenever it draws with the same state. However, first-time asset loading can look similar, so that observation alone cannot prove shader compilation was the cause.
If a game uses a pipeline cache, will the next launch avoid stuttering completely?
Passing a saved cache lets the driver skip some expensive translation steps, though pipelines still have to be created. Under the Vulkan specification, cache compatibility depends on factors such as vendor, device, and driver; if incompatible data is supplied, the driver starts from an empty cache.
Are the 24.4 ms and 50.4 ms figures from the official sample how long a game freezes?
Those figures measure how long Khronos's sample took to recreate 2 pipelines on a Mali G76 smartphone (24.4 ms with cache enabled, 50.4 ms with cache disabled). They cannot be converted into overall game FPS or stutter durations on other GPUs.
What is SPIR-V?
SPIR-V is the intermediate representation Vulkan apps use to pass shaders—GPU programs that compute vertex positions, pixel colors, and more—to the driver. Even when SPIR-V is shipped inside the game, translating it for the device's specific GPU and combining it with other rendering settings still happens on the device.
Sources & Retrieval Dates
- [1]
- [2]
- [3]
- [4]
- [5]