Skip to content
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

Don't prevent windows Display Sleep while paused #6704

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nico-abram
Copy link
Contributor

@nico-abram nico-abram commented Apr 22, 2024

Fixes #6703

I have not tested that this actually sleeps correctly, or that ryujinx can be restored correctly.
I just debugged and queried that the thread execution state is set correctly via SetThreadExecutionState(0).
Please leave a comment if you test it and it works as intended (Can sleep and wake up fine while paused).

Ran into an issue since AppHost.cs Pause/Resume are called from the "Main Thread" (The one running Program.Main and the WndProc) and the thread that currently calls DisplayState Restore/Prevent is another one (The one running AppHost.MainLoop).
I just put all DisplayState calls within a Dispatcher.UIThread.Post delegate (It was not needed for the ones called from Resume/Pause in my tests but I added them just in case).
I considered adding a private method on AppHost that handles that but since it's only used twice per method I wasn't sure if it was worth it.

@github-actions github-actions bot added the gui Related to Ryujinx.Ui label Apr 22, 2024
@ryujinx-mako ryujinx-mako bot requested review from AcK77, emmauss, TSRBerry and a team April 22, 2024 14:56
@KawaiiZapic
Copy link

No, this doesn't work.
We can debug this by use command powercfg /requests to find out what prevent system fall in to sleep. And in this build, the audio streaming is in used even game is paused. But I have no idea why monitor cannot turn off even command reported nothing prevent system turn off display.

@nico-abram
Copy link
Contributor Author

Thanks for testing it!

I think it's coming from SDL2 audio . I've tried both the SDL_HINT_VIDEO_ALLOW_SCREENSAVER hint and SDL_PauseAudioDevice and neither seems to prevent this from happening. I don't know if destroying and recreating the sdl audio devices/sessions would be an acceptable solution here (Seems a bit heavy handed).

I asked about it in an SDL discord server and a maintainer told me to report it, which I did in libsdl-org/SDL#9601

@AcK77 AcK77 added the do-not-merge DO NOT MERGE! label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge DO NOT MERGE! gui Related to Ryujinx.Ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Release wake up lock when simulation is paused / allow user disable wake up lock
3 participants