Page 1 of 1

[0.18.3] UPS and FPS fluctuations when changing focus between Factorio and something else

Posted: Sat Feb 01, 2020 12:58 am
by dewiniaid
So I was updating one of my mods (TimeControl) for 0.18 and as a quick test I set it to run the game at 64x speed (i.e. /c game.speed=64). I immediately noticed some odd effects that I don't recall noticing in earlier versions of Factorio.

In a brand new save:

In-game, my reported UPS in fact hit near the expected 3840 with quite a bit of fluctuation, while FPS remained at a stable 60. (I do not have the vsync options turned on, but my monitor's refresh rate makes a higher-than-60 FPS wasted anyways.)... but moments later the the UPS promptly crashed down into the low hundreds with a lot of fluctuation.

I thought this was odd and unusual compared to what I've been able to observe in the past, so I alt-tabbed to Discord (on a second monitor, so Factorio was still fully visible). FPS immediately skyrocketed into the thousands(!), and UPS returned to the expected around-3840. Alt-tabbed back into the game and it was immediately back to before -- 60 FPS, low hundreds UPS.

What I've found so far is:
  • Alt-tabbing to anything restored full UPS/unlimited FPS -- even before switching tasks (i.e. the Windows 10 window showing what you're alt-tabbing to alone was enough to fix it
  • Simply clicking on Discord did not trigger this effect. Clicking on a Chrome window, however, did.
  • Sometimes the game would run at full 64x speed while focused, for awhile. This usually ended when autosave triggered (which is quite often when on a 5 minute interval that's sped up 64x) and usually would not recover.
To reiterate, I was getting more FPS and UPS when alt-tabbed out of the game than when in it, which seems completely backwards from what I'd expect. (Many games have an option to actually limit FPS when they're not focused. Factorio seems to only be limiting it when focused, aside from the fact that it is bounded by your current UPS)

Update times in show-detailed-info seem to be consistent regardless of the current reported UPS, but the slowdown is definitely real (i.e. the reported UPS is correct), as evidenced by noticeable changes in day length and cloud movement speed.

Re: [0.18.3] UPS and FPS fluctuations when changing focus between Factorio and something else

Posted: Sat Feb 01, 2020 1:01 am
by dewiniaid
Something edited it out of my original subject line as posted, but this also occurs in 0.17.79.

Re: [0.18.3] UPS and FPS fluctuations when changing focus between Factorio and something else

Posted: Sat Feb 01, 2020 1:03 am
by Loewchen
dewiniaid wrote:
Sat Feb 01, 2020 1:01 am
Something edited it out of my original subject line as posted, but this also occurs in 0.17.79.
See: 3638

Re: [0.18.3] UPS and FPS fluctuations when changing focus between Factorio and something else

Posted: Sat Feb 01, 2020 1:14 am
by dewiniaid
Loewchen wrote:
Sat Feb 01, 2020 1:03 am
dewiniaid wrote:
Sat Feb 01, 2020 1:01 am
Something edited it out of my original subject line as posted, but this also occurs in 0.17.79.
See: 3638
Makes sense. Also added the log file.

Since the issue also occured in 0.17.79, I thought that'd help narrow down when the issue in question was introduced.

Re: [0.18.3] UPS and FPS fluctuations when changing focus between Factorio and something else

Posted: Sun Feb 02, 2020 10:38 pm
by Klonan
Ok, this may be a neat observation, but I don't see anything that is a bug

Re: [0.18.3] UPS and FPS fluctuations when changing focus between Factorio and something else

Posted: Thu Feb 06, 2020 12:56 am
by dewiniaid
Klonan wrote:
Sun Feb 02, 2020 10:38 pm
Ok, this may be a neat observation, but I don't see anything that is a bug
I don't see why the game runs slower when it has focus versus when it does not. The reverse makes sense, this does not.

In my particular case it's observable at extremely high values of UPS, but it may be observable at standard game.speed = 1.0 cases on lower end hardware and/or a megabase.

It may not be a direct bug, per se, but it seems like something to investigate when making future performance improvements.