High FPS When "Unfocused" low fps when "Focused" (2022.3.5f1)

As the title suggests when my editor or build is “Focused” the fps is extremely low. Around 60ish, give or take. (I have V-Sync disabled)

When I click off the application or the editor window, FPS shoots up to 200-400.

I am using a completely empty scene.

Any idea what’s happening here?

First of all: 60 fps is not extremely low. It’s pretty much standard framerate. :wink:

I can’t reproduce this. In fact, when the editor is not the focused window it essentially stops rendering as it should, fps drops accordingly in the Game view’s Stats display.

How are you measuring fps?
Vsync may not always work reliably in the editor. It can also be overriden by the video driver, and Preferences => Editor => Interaction Mode may also factor into this.

It is extremely low for an empty scene in comparison to the 400 it gets when unfocused is the message I was trying to get across with my above statement. 60 FPS is certainly fine for an end product, for an empty scene with nothing in it but a camera, something seems to be off.

FPS is being measured using the stats window in one test, and on another test I am adding a script to an empty gameobject, which collects the average frames across a set time and prints them onto a UI element.

This also happens in builds of the project, not just the editor.

Hmmm that seems more likely to be an issue with your system than with Unity.
60 fps seems perfectly fine if Vsync is enabled. Like I said, it may still be enabled even if you unchecked that vsync box in game view and/or in quality settings. It may be forced by the driver. Speaking of which: perhaps try updating, and use the Nvideo stock drivers not the vendor drivers. You could also try the "Studio" version of the driver, I personally use that because I rather go for stability and compatibility.

In any case, try [Graphy] to get reliable fps results, many scripts out there aren't measuring correctly and it's just such a great tool to have in your toolbox.

I suspected it might be a local hardware issue, so I pushed a build on our developer page. 5 Other devs on the project tried it, all with the same results. It’s worth noting I never noticed this in Unity 2021. I recently installed 2022 LTS, now it’s a problem even on a fresh project that is completely empty.

URP or Builtin? I tested with URP. Not sure if that makes a difference.

If you can’t reproduce this in 2021.3 you could submit a bug report.

Did you try looking at your graphics driver settings? 60 FPS sounds like something is forcing VSync, GSync, FreeSync or some similar tech on. The fact that focusing away makes the frame rate go up reinforces this suspicion as these things generally work only when the window is in focus.

I assumed that would be the case, I disabled G-Sync and it was still happening. Oddly enough after I re-built the project and re-cached the shaders for whatever reason that problem doesn’t seem to be happening anymore. I have no idea why it’s no longer present. If it re-appears I will re-comment on this thread with the steps to reproduce.

Hi I’m experiencing this same issue and its very strange. What CPU and GPU have you got?

For me the only way to run at max FPS is to have the editor window unfocused and the Scene view not visible.

On an empty scene in 2022.3.12f1:

Unfocused, hidden scene view - 700 FPS
Focused, hidden scene view - 220 FPS
Focused, scene view visible - 110 FPS

I have a Ryzen 7950x + RTX 4090

Phew solved! For anyone who finds this thread this is 100% the fix.

It IS caused by G-SYNC if you have it enabled for both windowed and full screen mode. There are two options you can choose from to fix it:

  1. Set G-SYNC to full screen mode only
  2. Under Manage 3D settings you can set up Unity.exe to use "Fixed Refresh" for "Monitor Technology"

For either solution you need to restart Unity fully for it to take effect.

1 Like

Not surprising actually.

There is just no point in rendering more frames than the monitor can display with dynamic Vsync enabled. I suppose the monitor is running at 240 Hz with the “missing” 20 frames probably due to some editor overhead.

Going from 220 down to 110 fps makes sense if you consider that the game view and scene view both visible requires rendering two windows, and there’s probably a technical reason why the fps gets slashed in half in that case.

Again: there is no point in having the editor (or build) render 700+ frames. You don’t see them. This only wastes energy and adds extra costs to your electricity bill. Leave it at 220 fps, that’s way more than enough!

Yeah fair point on the increased energy usage. However in the case where the scene is not empty, I do prefer being able to reach higher than ~110 FPS on my 240Hz monitor as I always have a scene view visible next to the game view which always splits the FPS. The other added benefit is a more accurate CPU time in Stats rather than it being artificially increased by G-SYNC. Means I might notice I have accidentally increased it with some poor code.

If you monitor CPU time stats at 300+ fps scenarios you’ll be easily fooled into micro-optimizations. :wink:

As long as the build gets to 60 fps you have no reason to optimize, and even if you can spend a day or two close to release to make the two or three performance optimizations necessary (pareto principle works VERY well for performance optimizations once there actually IS an issue).

This solved it for me, thank you so much! <3