[2.1.19][macOS] Factorio prevents display sleep while minimized

Things that has been reported already before.
MRI-One
Burner Inserter
Burner Inserter
Posts: 13
Joined: Tue Nov 19, 2024 9:59 pm
Contact:

[2.1.19][macOS] Factorio prevents display sleep while minimized

Post by MRI-One »

When I start Factorio in a window, and then minimize it before starting playing, Factorio stops its display updates, but it keeps its assertion active that prevents macOS from activating display sleep. I would have expected Factorio to disable this assertion while it is minimized.

The problem occurs always, already on loading, and persisting during gameplay. "pmset -g assertions" lists:
pid 20751(factorio): [0x0002841700019ea5] 08:36:17 PreventUserIdleSystemSleep named: "Factorio"
pid 20751(factorio): [0x0002841700059ea6] 08:36:17 PreventUserIdleDisplaySleep named: "Factorio: Space Age 2.1.19 using SDL_DisableScreenSaver"
Attachments
factorio-current.log
(7.84 KiB) Downloaded 19 times
Bilka
Factorio Staff
Factorio Staff
Posts: 3923
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [2.1.19][macOS] Factorio prevents display sleep while minimized

Post by Bilka »

Thanks for the report, this is intended behaviour. If you want the computer to go into sleep/passive mode exit the game: 85283
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
MRI-One
Burner Inserter
Burner Inserter
Posts: 13
Joined: Tue Nov 19, 2024 9:59 pm
Contact:

Re: [2.1.19][macOS] Factorio prevents display sleep while minimized

Post by MRI-One »

I am afraid there is a misunderstanding, I am not talking about what happens when you pause the game, but what happens when you minimize the game, so that nothing is visible apart from its dock icon, the use case being running Factorio in the background. I reported on the start screen because that's the minimal reproducible case I could find.

Would you enlighten me how to run factorio in the background without it blocking display sleep? I don't see how the current behavior can be intended, since blocking display sleep when nothing is visible serves no purpose.
Bilka
Factorio Staff
Factorio Staff
Posts: 3923
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [2.1.19][macOS] Factorio prevents display sleep while minimized

Post by Bilka »

The answer stays the same. The OS doesn't always restore textures properly when sleep happens while the game is open, so we don't support resuming from sleep (viewtopic.php?p=472462#p472462), so we tell the OS not to sleep while the game is open. The textures are still loaded and can still get corrupted when the game is minimized.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
MRI-One
Burner Inserter
Burner Inserter
Posts: 13
Joined: Tue Nov 19, 2024 9:59 pm
Contact:

Re: [2.1.19][macOS] Factorio prevents display sleep while minimized

Post by MRI-One »

Thanks, if I understand you correctly, you worry that the OS might decide to power off the GPU when you allow display sleep, but not system sleep, and that this causes GPU state corruption. I fully support the PreventUserIdleSystemSleep assertion, it is only the PreventUserIdleDisplaySleep I argue about. I understand that when you have multiple GPUs like in the old Intel MacBooks that this could cause problems, or in some Linux configurations, but on Apple Silicon, graphics state is stored in the same RAM used for the CPU, and so should not be corrupted when only turning off the display. In fact, when running factorio in the background, I often lock my screen, and then press ESC to turn off the display, and I have never seen any issues with the graphics when resuming factorio.

I, perhaps naively, figure that this would be at most 10 lines to change: disable PreventUserIdleDisplaySleep when game window minimized, enable again when restored, and so it would be a worthwhile change even if it is only for Apple Silicon. For context, Factorio running the simulation in the background is roughly 20W, while my display draws at least 40W.
Rseding91
Factorio Staff
Factorio Staff
Posts: 17584
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.1.19][macOS] Factorio prevents display sleep while minimized

Post by Rseding91 »

It looks like SDL by default disables the screensaver and independently we disable auto-system-sleep. However, the note about why it disables the screensaver also seems relevant: joysticks/controllers don't seem to keep the display active (untested).

I'll leave this up to others but I also don't think it makes sense to let the display power off while a game is running even in the described scenario. Exit the game if you want the PC to go into lower-power states.
If you want to get ahold of me I'm almost always on Discord.
StrangePan
Factorio Staff
Factorio Staff
Posts: 300
Joined: Fri Dec 07, 2018 3:41 pm
Contact:

Re: [2.1.19][macOS] Factorio prevents display sleep while minimized

Post by StrangePan »

I can't promise anything, but I can look more into this when I have time. I won't be able to prioritize without careful testing and community feedback, because I'm not confident how the different subsystems (graphics, controllers, audio, networking, non-blocking saving, etc.) will behave in this state, not to mention the OS itself.
Post Reply

Return to “Duplicates”