The issue is that the shaders don’t get compiled until they are first rendered so even if you don’t add any at runtime, you can still be subject to stalls while they are compiled for the first time.
Ways to mitigate this:
-
If you only have a few lights that don’t change at runtime, try disabling clustered lighting in Project Settings → Rendering. There are some issues around DirectX renderer and Windows that can cause extended compile times with clustered lighting.
-
If you can get away with no shadows on omni and directional spotlights, disable shadows from clustered lighting in Project Settings → Rendering. This will reduce the size of the shader to compile.
-
Force shader compiling upfront by having a frame of rendering where all the materials are rendered for a frame. Some developers have a space where all the materials are on cubes and a second camera that is enabled for the first frame only. See this thread for an example: [SOLVED] Application will stutter in the Intro Animation - #21 by Vahrenhol3D