Sudden FPS Drop in 3D game

I’m working on an FPS and things are going smoothly, but suddenly I started having issues while testing where the fps drops for a couple of frames as I move the mouse (so yeah the camera rendering new things).

I checked a few things and ended up simply installing a newer version. The issue stopped for a while then just started happening 2 weeks ago.

This time I went more into details:

  1. Disabled VSync
  2. Remove lighting
  3. Checked task manager (nothing being used in high demand)
  4. Use lower quality
  5. Re-import all assets
  6. Remove EVERYTHING in the scene except the player and the ground
  7. Tested different unity version
  8. Hiding all gizmos

Sometimes I open it and it’s fine for maybe an hour, then it happens again.
Also, if I build the game, it runs perfectly fine.

Really anything that ChatGPT would recommend, I tried that.

Now I don’t understand the profiler too well, but i checked it and found spikes (and ChatGPT solutions where of no use) so I’m posting them here to see if anyone can help out

The image below is just to show the spike being from rendering, I removed everything else as they had no effect

The image below shows the heirarchy of what has the highest usage

The image below is different and it shows right before the player loop spike

Any help or suggestions appreciated! Also any suggestion of a video that can help me learn more about things related to this as I’m finding it hard to find and solve problems on my own regarding this.

So the big thing to notice is the Grfx.WaitForPresent. That’s usually an indicator that your CPU is waiting for the GPU to finish rendering the current frame so that it can upload new data for the next frame. However, it is quite odd that it would only pop up with short blips like that. My first suspicion would be that maybe some very heavy post processing or a complex shader on a model are running. But it seems odd that it would only happen for a very short time like that.

Perhaps you can also enable scripts for the profiler graph (the little blue square up in the top-left) so that we can see if anything odd it going on there.