-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BizHawk does not inhibit display or system sleep while running #3644
Comments
To be clear, we do not support Windows XP and below at all (and Windows 7-8.1 is ""unsupported""), so the older solutions wouldn't really be applicable to us. On Linux usage, going off SDL's source, it seems |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
To be clear, this (I guess unintentionally) is now implemented in practice with SDL2 now (or well, since 78f5e75) being used for the OpenGL and D3D9 display methods, as on SDL video init, SDL will disable the screensaver by default. This probably should be adjusted in the future so we have some setting to un-disable the screensaver / give user control over this. EDIT: There's apparently also already code in BizHawk (present since 2011?) which appears to be intended to suppress the screensaver: https://github.com/TASEmulators/BizHawk/blob/20defc890bf4a257a057acd8f997ca81d3a3da11/src/BizHawk.Client.EmuHawk/ScreenSaver.cs Although it's Windows only and I don't know if it actually works (the fact that this issue exists probably indicates that it doesn't even work). |
SDL has an implementation for Linux but it doesn't seem to be working. (edit: This is in Plasma X11.) |
I suspect Linux might not work for all cases or maybe just requires some extra package (likely would need the libxss1 package installed) |
It is "installed" (there's a |
Not sure what you're talking about "closure", it's just calling a function pointer it gets from dlopen'ing that .so, and it doesn't do that if it's not available. |
It's Nix jargon, referring to the set of rundeps including transitive deps. |
I never had a particularly strong opinion about this one way or the other. There was only one person advocating for, and in all of their posts they never gave a single reason why this should be done, only how. It didn't seem that useful to me, and in the absence of any other advocates, I just closed it. |
fwiw, the fact we already had code to do this (but it seemed to just be broken) seems to mean SDL has fixed what was supposed to be happening (well, at least for Windows, Linux has seemingly gone from unimplemented to some broken implementation?). |
Summary
BizHawk does not inhibit display or system sleep while running. This is a common problem that plagues even AAA-gaming-industry titles, so don't feel bad.
Repro
Demonstrating lack of display sleep inhibition:
Solutions
There's 3 main methodologies you can use. I am not familiar with BizHawk's code so I don't know which is easiest to implement.
It's important to give this feature a GUI setting/toggle somewhere (probably under Config -> Customize -> General or Advanced), and the feature default to disabled (since that's how BizHawk has been behaving all this time).
Newer method (supported by Windows 7 onward)
Leverage the Windows Power Management API, specifically functions PowerCreateRequest() and PowerSetRequest() for a RequestType of PowerRequestDisplayRequired (inhibit display sleep) or PowerRequestSystemRequired (inhibit system sleep).
You can verify things are inhibited by launching a Command Prompt as Administrator and using
powercfg.exe /requests
. You should see the BizHawk process listed under DISPLAY, with the line "Video Wake Lock" under it. (For PowerRequestSystemRequired, it would be under SYSTEM).If you want to see how this manifests today, run Chrome and watch a video somewhere (YouTube, Twitch, etc.): you'll find chrome.exe listed under DISPLAY and SYSTEM (thus, inhibiting display and system sleep).
Older method 1 (supported by Windows XP onward)
Use SetThreadExecutionState(). This is described at the end of the nesdev forum thread mentioned below.
Older method 2 (supported by Windows 2000 onward)
In your main window handler, add support for handling the WM_SYSCOMMAND message to detect SC_SCREENSAVE or SC_MONITORPOWER messages:
You cannot verify this method using
powercfg.exe /requests
, given that window message handlers do not "register" with the Power Management API, but it (obviously) does work.I forget how to inhibit system sleep using this method.
SDL2 and/or Linux
There is discussion of how to implement this functionality in SDL2 and/or Linux in a nesdev forum thread I started nearly 10 years ago.
Important note
Please DO NOT implement a solution by changing system settings (Windows power profiles). I've lectured several emulator authors about this in the past. It is not the right solution and is extremely inappropriate to do, plus creates numerous problems in the case of an application crash or force-kill.
Host environment
The text was updated successfully, but these errors were encountered: