Perplexing issue with stuttering. PlayerLoop showing 99.9%, but nothing is consuming resources.

My game is a bullet heaven game. So I have dozens of enemies spawning and moving towards the player. I have weird stuttering, but it doesn’t appear to be based off number of enemies. So I am currently trying to debug, but my when the stutters happen, the debugger isn’t showing anything.

It’s showing the PlayerLoop has spiked in the category “Other”, but there’s no details on what’s consuming the resources.

Any help would be greatly appreciated.

What does the profiler timeline view look like for spikes like this?

  • Main Thread - Maxed Out (Wait for Target FPS)
  • Job - empty,
  • Loading - empty
  • Scripting Threads - empty,
  • background Job - empty,
  • Profiler - empty,
  • Other Threads - empty,
  • Audio - tiny items

9743389--1394068--upload_2024-4-1_14-25-4.png

When looking at the GPU at the same time, I see the exact same spike and a “PostLateUpdate.PresentAfterDraw”, which if I look for errors revolving around that, I see articles that are ~9 years old, but describe the same thing I’m experiencing, but the fixes they suggest either: don’t work or are for such an old editor that it’s no longer present.
9743389--1394071--upload_2024-4-1_14-25-39.png

I’m using Unity 2022.3.16f

Things I know are not causing it:

  • GC - I’ve disabled auto GC and am manually triggering it.
  • URP/HRP - I’ve completely removed both and it’s still occurring.

After completely gutting everything, I’ve identified it.

It was one of the flags on the Camera in scene.
For whatever reason if you leave the flag enabled for HRD Rendering and/or(I didn’t spend too much time after the stuttering stopped) MSAA to using the rendering settings, it causes the GPU to wait for some reason, causing the stutter.

By setting the options to “Disable” for both HRD Rendering and MSAA I don’t have any issues with the stuttering.

This is a solution for my 2d game (please note, I didn’t touch the settings in the Project settings so maybe that is a fix as well).

This looks awfully similar to Occasional performance spikes on DXGI.WaitOnSwapChain without a GPU bottleneck . Do you by any chance have any similar software running?

I don’t think the settings you mentioned can cause it.

My computer is about as overbuilt as you can make it (64gb memory, 4090 gpu, 12 core processor). Nothing is anywhere near resource max and nothing else running is consuming significant resources. I don’t have any RGB managers on my machine (which was the identified issue in the linked article).

Further, the second I toggle those settings the issue comes back immediately.

If you’d like to pursue this further, you can record an ETW trace (like I asked the other person in that other thread) and I will look at it and confirm/deny that it’s what is causing it. If you prefer, you can also report a bug with your project so we could investigate those options.