When displaying an effect that uses an Universal Render Pipeline/Unlit shader for the first time, the process of GpuProgramMetal.GetCachedPipeline on iOS and CreateGraphicsPipelineImpl on Android takes a lot of time.
In what cases does this occur and is there any way to avoid it?
Version of Unity: 2022.3.8f1
Version of URP: 14.0.8
Profiler result when the phenomenon occurred (iOS)
We’re having this issue too, 2022.3.29f1, URP 14.0.11. Did any of you find a good solution? Haven’t been able to get rid of it by shader warmup APIs (it doesn’t seem to be triggered by a gpu shader upload, at least it doesn’t log anything or have a profiler entry for gpu program creation).
this is happening when the app load the shaders for first time.
to make sure this only happen once, make sure you setup shader variant correctly which include all the shaders in the game, and set it to load when the game launch… this way, the spike for loading the shader first time only happen once during the game lunch
The solution was provided to my by unity internal team on different thread
I’ve already tried using Shader Variant Collections to load the scene, but unfortunately, it hasn’t resolved the issue I’m facing. The first-time shader loading spike still occurs, especially with Skinned Mesh Objects on iOS.
That’s exactly the problem. Even when I load the Shader Variant Collection at the start of the game using shaderVariantCollection.WarmUp(), it seems like Unity ignores this step. I’ve enabled shader compilation logging, and unfortunately, I still see shaders being uploaded to the GPU despite preloading them.