Performance drop when notifications popup

This subforum contains all the issues which we already resolved.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14071
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Performance drop when notifications popup

Post by Rseding91 »

I've got a strange issue: when I get notifications on my computer (orange blinking window) Factorio goes from a solid 60 FPS down to 40~ until I click on the notification and get it to stop blinking orange. The easiest way to reproduce is: load factorio, load steam, have anyone send you a message in steam. When the orange blinking starts the game drops performance wise.

Using: Factorio 0.10.3 x64 on Windows 7 x64 Pro.


Other information:

If I disable Desktop Composition (the aero effect on Windows vista/7) it doesn't slow Factorio but instead tears the game (acting as if VSync wasn't enabled - which it is).
Running full-size but not full-screen.
The steam messages aren't overlay - they're simple windows.
It happens with anything that triggers the windows "Needs attention!" behavior of a window.
If you want to get ahold of me I'm almost always on Discord.

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: Performance drop when notifications popup

Post by slpwnd »

Thanks for the report. Looks like issue with our graphical library. I put this to minor issues for now since it is not really a big problem.

SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: Performance drop when notifications popup

Post by SilverWarior »

Actually I have seen similar isues with many other games.
The reason why the orange window blinks is becouse Steam is forcingly rendering its window to overlay surface of Factorio's window. To do so Steam must temporarily take controll of Factorio window which then leads to reduced FPS.

That is why you need to use special SDK to sucsessfully integrate steam into your game. The purpose of Steam SDK amongs others is to synchronize rendering so that Steam windows are always rendered after the game sceen and therefore always stays on top.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Performance drop when notifications popup

Post by ssilk »

I turnend that off, cause that causes problems with nearly everything. On my MacBook for example it breaks the whole graphics.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Rseding91
Factorio Staff
Factorio Staff
Posts: 14071
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance drop when notifications popup

Post by Rseding91 »

SilverWarior wrote:Actually I have seen similar isues with many other games.
The reason why the orange window blinks is becouse Steam is forcingly rendering its window to overlay surface of Factorio's window. To do so Steam must temporarily take controll of Factorio window which then leads to reduced FPS.

That is why you need to use special SDK to sucsessfully integrate steam into your game. The purpose of Steam SDK amongs others is to synchronize rendering so that Steam windows are always rendered after the game sceen and therefore always stays on top.

Note the part where I said "The steam messages aren't overlay - they're simple windows." -> it's not steam's in-game notifications. It happens with any program that triggers the orange blinking "needs attention" state when you have desktop composition enabled.
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 14071
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance drop when notifications popup

Post by Rseding91 »

ssilk wrote:I turnend that off, cause that causes problems with nearly everything. On my MacBook for example it breaks the whole graphics.
That works for Windows 7 but I get massive screen tearing in Factorio with it off. Also, Desktop composition is *required* in Windows 8 - you literally cannot turn it off so it's not something that can just be dismissed as "desktop composition's fault - turn it off" :)
If you want to get ahold of me I'm almost always on Discord.

SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: Performance drop when notifications popup

Post by SilverWarior »

Rseding91 wrote:Note the part where I said "The steam messages aren't overlay - they're simple windows." -> it's not steam's in-game notifications. It happens with any program that triggers the orange blinking "needs attention" state when you have desktop composition enabled.
Actually they are.
The only way to show some kind of message from external application when you have game running in true FullScreen mode not just Maximized Borderless Window you need to create overlay surface and force showing it. You can't use any windows GDI window for that becouse when you have an application running in true FullScreen mode windows GUI is unloaded to free up more system resources. Thar is why Alt Tabbing can take so much time when using such applications.

I myself note similar performance drop when I change the sound volume on my laptop becouse laptops software creates overlay surface and force showing it. And yes the sould volume indication also flickers.

@Developers
A quick workaround for these problems is to add the ability for Factorio to run in Borderless maximized window. This will alow other progarms to use GDI to show any messages. It could however lead to some problems by other programs causing Factorio to lose focus. Also on certain computer configuration this might lead to lower game performance either due to slower rendering to GDI window (shouldn't be much of a problem for Windows Vista and newer) or unability for AV software to detect when to properly switch into game mode.

Rseding91
Factorio Staff
Factorio Staff
Posts: 14071
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance drop when notifications popup

Post by Rseding91 »

SilverWarior wrote:
Rseding91 wrote:Note the part where I said "The steam messages aren't overlay - they're simple windows." -> it's not steam's in-game notifications. It happens with any program that triggers the orange blinking "needs attention" state when you have desktop composition enabled.
Actually they are.
The only way to show some kind of message from external application when you have game running in true FullScreen mode not just Maximized Borderless Window you need to create overlay surface and force showing it. You can't use any windows GDI window for that becouse when you have an application running in true FullScreen mode windows GUI is unloaded to free up more system resources. Thar is why Alt Tabbing can take so much time when using such applications.

I myself note similar performance drop when I change the sound volume on my laptop becouse laptops software creates overlay surface and force showing it. And yes the sould volume indication also flickers.

@Developers
A quick workaround for these problems is to add the ability for Factorio to run in Borderless maximized window. This will alow other progarms to use GDI to show any messages. It could however lead to some problems by other programs causing Factorio to lose focus. Also on certain computer configuration this might lead to lower game performance either due to slower rendering to GDI window (shouldn't be much of a problem for Windows Vista and newer) or unability for AV software to detect when to properly switch into game mode.
You've missed it twice now :\

I *DO NOT* run the game full screen. I am running Windowed and any program that triggers the orange blinking "needs attention" state triggers the slowdown. I uninstalled steam and it still happens when a window starts blinking orange.
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 14071
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance drop when notifications popup

Post by Rseding91 »

I really wish this was a higher priority :\

For all the performance optimizations you make this one bug just dumps all over the game and slows it way back down again.

Since FPS is directly tied to TPS (game tick rate) in Factorio this lags the game like crazy every time it happens.
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 14071
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance drop when notifications popup

Post by Rseding91 »

I did some more research into this issue and I don't believe it's related to the Factorio graphics library: Allegro.

I believe it's simply a fault of VSYNC and the mechanic behind it. VSYNC limits the refresh rate of the game to that of the monitor. If for any reason it can't keep it at a steady 60 FPS it will half it and try to keep it at 30. If it can't do 30 it goes half that and repeats. That's why different reports from people have shown up where the "Flip" timer is taking 30~ MS instead of the normal 15~ MS.

In order to fix that, the refresh rate would need to be controlled manually: timing how long since the last refresh and sleeping 15MS - time since last each frame (or something close to this effect).


Now, this is all speculation up to this point. I haven't done any actual tests (yet). If I find out anything else that might be useful i'll post it here.
If you want to get ahold of me I'm almost always on Discord.

Blackence
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Jun 05, 2014 4:03 pm
Contact:

Re: Performance drop when notifications popup

Post by Blackence »

Rseding91 wrote:I believe it's simply a fault of VSYNC and the mechanic behind it. VSYNC limits the refresh rate of the game to that of the monitor. If for any reason it can't keep it at a steady 60 FPS it will half it and try to keep it at 30. If it can't do 30 it goes half that and repeats. That's why different reports from people have shown up where the "Flip" timer is taking 30~ MS instead of the normal 15~ MS.
I haven't looked into vsync implementations yet. I'd assume that the sane way to implement it is…

* SwapBuffers() is called by the application (i.e. allegro)
* SwapBuffers tells the graphics driver to block execution until the next screen refresh happens
* screen gets refreshed, buffers get swapped, SwapBuffers() returns control to the app / allegro

Maybe there is a flaw with that.

However, if that is how it works, I don't see how flipping should take longer than 16ms. It's like having to wait 30 minutes for a train that is scheduled to arrive every 16 minutes.

I always thought that if my FPS drop down to 30 (from 60), that's because every single frame takes e.g. 17ms to render, so it's a little bit too late for vsync. Then it needs to wait 15ms for the next sync. And I get 30 FPS instead of 60. Maybe I was wrong and it actually limits the FPS to 30 in some cases?

Rseding91
Factorio Staff
Factorio Staff
Posts: 14071
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance drop when notifications popup

Post by Rseding91 »

Blackence wrote:I always thought that if my FPS drop down to 30 (from 60), that's because every single frame takes e.g. 17ms to render, so it's a little bit too late for vsync. Then it needs to wait 15ms for the next sync. And I get 30 FPS instead of 60. Maybe I was wrong and it actually limits the FPS to 30 in some cases?
I think that is what's happening. I just did a bad job of explaining it.
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 14071
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Performance drop when notifications popup

Post by Rseding91 »

This issue can be moved to the resolved section. With the addition of the disable-vsync option and the render getting split from the game logic it no longer happens.
If you want to get ahold of me I'm almost always on Discord.

kovarex
Factorio Staff
Factorio Staff
Posts: 8178
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Performance drop when notifications popup

Post by kovarex »

Great.

Post Reply

Return to “Resolved Problems and Bugs”