Stuttering when first traveling through a large, detailed level

We have a top-down HDRP game and a sizeable level for it filled with details. Buildings have over 20k vertices, and up to 6 4k materials (that is 4 4k textures per material), a tone of detailed meshes, cars (5k vertices) are rendered twice (first time with carpaint shader, second time - with dirt shader). On top of that the level is full of skeletal meshes. Up to 40-50 on the screeen at the same time. Offscreen skeletal meshes are deactivated. VFX graph grass with several hundred thousand quads

Here is the problem: after SceneManager.LoadScene, the scene loads fine, but any exploration produces stuttering. Once you have walked through the entire level, stuttering stops completely. I used to add a camera, that sees the entire level, load the level so that this camera loads first, deactivates and activates the normal player character, which helped, but now this causes the build to hang permanently.

The problem is not contained to this single level, it happens in other levels as they grow in size. The problem exists for at least 1.5 years already and survived many Unity version upgrades (actually it became worse, even though the level hardly changed).

Any ideas on how to identify the problem would be greatly appreciated.

You know you can’t ship with that issue but you chose to ignore it for 1.5 years? That’s terrible practice. Back then, it would have been far easier to analyze and identify the issue because it would have been a lot easier to track where it was coming from, what change introduced the issue.

But you can still go back with source control, try to find the very first commit where this issue is noticable and check what this commit added. It may provide the source if the profiler isn’t helpful.

You did check to rule out any of the gazillion HDRP render settings by trying with a low quality setting once? If the stuttering goes away, you know you’ll have to find that particular setting that causes the issue. Do note that there are HDRP settings that aren’t meant for realtime applications but rather cinematic rendering, these can incur an absurdly high performance penalty or high memory usage.

Stutter while panning around would indicate something like runtime shader compilation - but these get cached once compiled. It could be resource loading but unless you async load things on the fly yourself, this should not be the cause. Unless perhaps “texture streaming” is enabled. It could also be heavy initialization code in scripts of objects that get activated as the camera pans.

In any case: use the Profiler to figure out where the occassional high frame time originates from!

1 Like

For anyone having similar stuttering that go away afterwards:
this was due to Realtime Reflection Probes, that are set to render OnAwake. They only truly render when camera frustum clips them.

I found them using standard profiler (Ctrl+7), attached to a Dev build with autoconnect profiler option. The method was called “AddHDProbeRenderRequest”

Thank you, @CodeSmile for encouraging me to think in the right direction.

1 Like

Didn’t know Unity had an ADHD probe. :laughing:

2 Likes