Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Frame rate increases when game window is not in focus?

Discussion in 'Editor & General Support' started by ajh212000, Jun 22, 2020.

  1. ajh212000

    ajh212000

    Joined:
    Jan 27, 2020
    Posts:
    4
    I'm not sure if this is a Unity issues, or a hardware issue, but I haven't been able to find a clear answer anywhere. I've tried building my game with different window options, Vsync turned off and on in the build settings. I've tried setting my Nvidia to just about every different thing I can think of, and still it's always the same.

    I make a new build. Exit the Unity editor and just have a file folder open. Run my standalone build (This actually seems to happen when running the game in the editor as well) and let NPC's with wander AI and instaniated tree's get loaded in to the point where the frame rate starts dropping down to around 15FPS. If I now alt-tab to the windows file folder, my games frame rate jumps back up to 60FPS (I have it limited to this in the code) and all the animations and everything run super smooth. As soon as I switch back to the game window, frame rate instantly drops back down to what it was originally.

    In my mind it seems that when a program window has focus, that it would be getting more system resources than other programs and run smoother, not the other way around.

    Thanks in advance, I'm pretty new at this, just started using unity a few months ago but this almost feels like it might not be a unity issue, just figured someone else here may have ran into the same thing.
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,120
    You should probably start by attaching the profiler and see whether there's a difference in what's running in both cases.

    It's not clear to me whether you can still see the full game when you're focused on another app. If not, I could imagine maybe your game is GPU-bound, and not showing it causes it to reduce what it needs to draw, perhaps? Maybe not.
     
    ajh212000 and Joe-Censored like this.
  3. ajh212000

    ajh212000

    Joined:
    Jan 27, 2020
    Posts:
    4
    I'll hook up the profiler again when I get a chance and see if that helps me see what's going on, I didn't think of using it for this. As far as being able to see what's going on, yes I can. I have dual monitors, so I can alt-tab to a program on the second screen and see my game on the first screen jump up like 2-3x faster frame rate when not in focus. Even if I completely unplug my second monitor, and just alt-tab to a tiny file folder window in front of my game window I can see the exact same thing happening.

    I'll post an update when I get a chance to profile it, thank you for the suggestion!
     
  4. submarines414

    submarines414

    Joined:
    Apr 18, 2021
    Posts:
    1
    having the same issue -- would like to know if anyone understands this as the only thing I have found to adjust framerate is through scripting. My hardware runs the editor at 400+ frames per second when I am tabbed out and caps at about 50 when tabbed in. My gpu utilization is about 10% when tabbed in and 25% when tabbed out.