Weird Unity 6.3 LTS (DX12) periodic ~54ms CPU spikes from GfxDeviceD3D12.WaitForLastPresentation.WaitForGPU (Editor only, builds unaffected)

Hello!

First off, I wanted to start by saying that this is my first time posting here and I really didn’t want to have to resort to this, but for the life of me I just cannot get to the bottom of this issue.

I should start out by saying that my project is extremely simple - there’s nothing really there that should be causing such issues just because of the content (this is proven by the fact that it runs perfectly when built).

So, I’m running into this extremely weird issue where, while playing in the Editor, I’m getting consistent spiking of CPU time (going up to around 54ms) where the main contributor is GfxDeviceD3D12.WaitForLastPresentation.WaitForGPU. The spikes roughly happen every 75–79 frames and last about a frame each, but they happen in groups (a few each time). Though they do get exacerbated by moving around in game for example.

This results in huge drops in framerate, stuttering, and I can even hear them through my GPU’s coil whine. It’s important to mention that with task manager open, when the spikes happen the GPU usage goes down from about 98% to 60% and fluctuates like that.

I’ve tried everything: Windows and GPU drivers are up to date, different engine versions, different Game view resolutions, fidelity options, VSync options, turning every other program off, Windows power settings, Hardware-Accelerated GPU Scheduling — nothing helped.

Initially I found that restarting my PC would fix the issue temporarily until it came back again, however that no longer works.

Key details:

  • Windows 11 25H2 (26200.7840), NVIDIA 595.71 drivers
  • Ryzen 9 9950X3D, 64 GB DDR5 @ 6000, RTX 3090, NVMe drives
  • Unity 6000.3.8f1 on DX12 in HDRP
  • Doesn’t happen on Vulkan or DX11
  • Builds run perfectly (steady 99% GPU usage, no stutters, no framerate issues)
  • Lowering resolution and quality settings has no impact on the spikes
  • Forcing D3D11 produces the same issue but slightly less severe
  • Restarting my PC used to temporarily fix the issue but no longer does

Has anyone else experienced this or found a workaround? I’m completely stumped.

Any help is appreciated!


Edit:
Something worth mentioning is that I’m observing the same thing happening in another HDRP project I’ve got that is just for testing and literally has a sun, a sphere and a camera. Plus, the stuttering can also be felt in the scene view when flying around and such.

I’m thinking this is an important clue.

How long is the delta in ms? Is the jump in the CPU frame time only?

Hi, yes it’s CPU frame time time only and the delta varies slightly but is ~35ms, after closer inspection a ‘stutter’ consists of a few events, each taking about the same amount of time, for example this one:

first: GfxDeviceD3D12.WaitForGPU (37,211 ms)
second: GfxDeviceD3D12.WaitForLastPresentation.WaitForGPU (36,733 ms)
third: GfxDeviceD3D12.WaitForGPU (26,841 ms)
fourth: GfxDeviceD3D12.WaitForLastPresentation.WaitForGPU (26,065 ms)

and then 48 frames of nothing and another event (stutter) like that.

Add the GPU profiler module and see if that shows any more info about what’s going on.
WaitForGPU is the CPU waiting on the GPU, it’s not doing any real work.

Here is a screen grab from a session, it’s basically all other:

ErykD A lot of issues with DX12 were fixed in 6.3.9, check out the latest version which is 6.3.10

I just downloaded and tried it with Unity 6000.3.10f1 and sadly the issue persists.

I don’t recall, did you do the bug report?

No I didn’t actually! I’m new to Unity so I wasn’t really sure where I should go with stuff like this.

Ok let me explain a bit:
You can use this discussion site to report bugs but, in the end, they will tell you to report them thought the integrated Unity bug report window on Unity itself.
This way you will officially report the bug and send the entire unity project to them to check.
You can find this window under Help → Bug Report or something like this.

Just remember that if you edit the project after you open the window it will not register the changes you made.

Let me know if you have other questions.

Okay, awesome, thank you very much I’ll submit a report right away.

In the meantime however, a workaround I found is simply using Vulkan while working and then switching to DX12 for the build.

Do you have a monitor with GSync? If so, try disabling Gsync. It can sometimes cause issues, and so does DX12.

There have been infrequent similar reports and the jury is still out there what is causing these issues some experience.

I wager that most of them would be resolved with a fresh install of Windows - something got messed up and it may be tricky to figure it out. FWIW scrutinize each and every system tweak and tool you may have on your system, especially those dealing with graphics and monitor settings like nHancer.

If you have a multi-monitor setup it’s worth testing with just one monitor connected. If you have any windows overlapping into the other monitor and those monitors run at different frequencies it’s a sure way to mess with a game engine’s behaviour due to the variable timings. Ensuring all monitors run the exact same refresh rate is recommended.

Thank you so much!

I’ll start out by saying that I built this PC less than a few weeks ago, so the OS is pretty much a fresh install, I tested a bunch of things you mentioned (I do have a 3 monitor setup where 2x of them are the same model at 280 Hz and one is at 60 Hz) and I’m glad to report that one of the suggested fixes did work (it was turning OFF G-SYNC).

This is somewhat of a fix but I’m not sure if I should do something about the bug report I submited earlier as I don’t see this as a ‘final’ soution (although G-SYNC can be turned off on a per app basis making this more convenient - you have to use the NVIDIA Control Panel for this, not the NVIDIA App, and restart Unity after applying the changes).

What I can suggest to you is to add a comment to the Bug report you did, an email should have informed you that the bug report has been received, from that email you can go to the bug report page and submit a comment.

Great, thank you for letting me know, I’ll do that right away!

Welcome to Unity Discussion :waving_hand:

It’s only anecdotal, but I’ve found myself always switching my project over to DX11 and my app’s are faster and editor lag is resolved. DX12 always seems to bring these issues back and increase overhead in my apps.

I ran into the same problem. Regular CPU spikes: GfxDeviceD3D12.WaitForGPU around 50ms. Even if I disable everything in the scene.
Unity 6.3.10
In Editor
HDRP
DX12
Windows 11

I’m having the a similar issue in windows 6.3 with that same waitforgpu spike every second or so (in editor)

Glad it’s not just me!

Did you find a solution? I’m having the same issue, and I don’t have G-SYNC in my NVIDIA Control Panel.