I have a game that runs at a steady 150 fps, vSynced 60 fps. It’s perfectly smooth and fine, except for the occasional lag spike that causes a hang that usually lasts between a second and half a second. When running at Vsync, this usually causes the vSync to default to 30fps for another few seconds afterwards.
Either this is the garbage collector, or it is gfx.waitForPresent (regardless of vSync). They happen randomly and I have absolutely no control over them.
They happen in the Editor too, and they happen when I autoconnect the profiler to the player build. But the Editor environment is different from the player build, so I’m unsure if what’s happening there is correct. And the autoconnected Player profiler makes absolutely sure the game will never run more than 55 fps ever, and all the time jittery and awful, making it very hard to debug and causing whatever I actually find to not be correct. (My game runs at 150 fps, not 55).
Another thing I tried was having the profiler write to an external file, but this is to no avail, and vSynced or not, it constantly results in it outputting ~150 frames per second. (even when my vSync is running at 30, and even when there are spikes that last a whole second).
I’m out of options and I’m out of ideas. I can’t turn the garbage collector off (not that that would be a good idea), and gfx.waitForPresent always comes absolutely out of nowhere. I have no leads on what causes either of them, let alone how to get rid of them.
Does anyone know how I’m able to get to the bottom of these spikes, without having the profiler interfere with them? Or does someone know how to fix these spikes?
I’m clueless, and it’s super annoying to constantly run into spikes that ruin gameplay. ![]()