- Home /
Gfx.waitForPresent causing massive lag spikes in editor
Something is causing the editor to get unusably low framerates in the editor. Using the profiler, I can see that Gfx.waitForPresent is spinning for around 100ms at each lag spike. Now, I've been around Unity for a while now, and I know that Gfx.waitForPresent is VSync, but no matter what the target framerate is, it should never have to wait 100ms between frames. Here's a screenshot of the profiler on an empty scene in a new project when I just try to move the editor camera around:
This is a brand new system, here are the specs if that might help shed some light: - i7-6700k - GTX 980Ti - 16GB RAM - NvMe PCIe SSD - G-Sync monitor (2560x1440@165Hz)
I have already tried changing pretty much every VSync/G-Sync related setting I could find. Any ideas would be appreciated
Do you have anywhere in your code where you're setting Application.targetFrameRate(xamount);? This can cause the dreaded waitForPresent.
I know you said you've messed with VSync but when I set $$anonymous$$e to "Don't Sync" this issue went away.
this is an entirely blank project, I haven't written any code yet.
I was just messing with some other stuff, it seems that switching to DX9 ins$$anonymous$$d of DX11 fixes the problem. Not ideal, but it works for now until Unity can fix this bug
Ah gotcha.. Just making sure all the things that were effecting my game were not doing the same for you! :)
Why has Unity not addressed this issue yet!? It's causing me a massive headache trying to solve it, even an empty scene has it!
I don't have Graphics Jobs (Experimental) checked, yet still see 63% Gfx.WaitForPresent. I also don't even have a GPU. See attached. Any ideas?alt text
You don't have a GPU? Quite impressive that you're managing to render anything to the screen, really.... You mean you're using an integrated graphics card? Then that probably explains why the CPU is always having to wait for it to be ready. You might want to consider investing in a dedicated graphics card and your problems will go away.
Thanks for advice, I do plan on getting a proper machine but wanted to see how far I can optimize without. I was actually able to get up to 60 fps yesterday. I do run on linux which helps.
" I do run on linux which helps."
lol, no it doesnt.
DirectX is lightyears ahead of that garbage OpenGL.
Answer by pophead2 · Nov 08, 2017 at 02:35 PM
Turning off NVIDIA IN-GAME OVERLAY seemed to work for me.
Awesome! Thank you! I have had this problem for so long, and couldn't figure out what caused it.
I was afraid this might be the issue. It was great for screen caps and working fine up until last night when I made the mistake of installing updates. Now my fps is absolutely tanked unless this is disabled... Woe is me.
Answer by DarnVisages · Nov 07, 2017 at 12:42 AM
I found a solution for my computer. If you have a laptop with an NVIDIA GPU, check if the problem only happens when you have the AC unplugged. If so, open Geforce Experience and go to Settings > Games. There's a setting called "Battery Boost", turn that off completely or move the FPS setting within it up to 60 FPS.
Fixed it for me! Huge bottleneck while being unplugged and nothing else could fix it.
Answer by NinjaISV · Dec 29, 2016 at 06:34 AM
I believe I have found the solution; it worked on my project at least! This "Gfx.WaitForPresent" was being caused by a tiny checkbox in the "Player" settings. Uncheck "Graphics Jobs (Experimental)" and you should see that "Gfx.WaitForPresent" has either been completely removed or at least greatly reduced.
This is by default co$$anonymous$$g unchecked so this is not a point.
Answer by qulol · Dec 29, 2016 at 06:16 AM
Try Edit --> Project Settings --> Quality and V Sync Count to Don't Sync.
Gfx.waitForPresent is like the CPU is waiting till the rendering process is finished.
If the problem still exist u should check ur renderprocess in the profiler wich takes much time.
Answer by johnsolo · Apr 04, 2019 at 08:26 PM
If you are on MacOS disabling Metal might help with this. My Mac mini with integrated graphics was chugging along on simple scenes between 45-60fps. After disabling Metal my FPS is in the hundreds!
Project settings > Player > Other settings > Rendering > Auto Graphics API For Mac (uncheck) Then drag OpenGLCore above Metal in the list.