fix(macos): wake sleeping display at the beginning of capture session#5291
Open
martona wants to merge 1 commit into
Open
fix(macos): wake sleeping display at the beginning of capture session#5291martona wants to merge 1 commit into
martona wants to merge 1 commit into
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Wakes the display at the beginning of the capture session, and does not let it go to sleep while it's active.
macOS does not present any capture frames on a sleeping display, thus the capture thread hangs indefinitely at session start, never sending video data to Moonlight, and therefore is not able to receive any input to wake the display either. The end result is a forever "spinning on connect" Moonlight client, and a hung Sunshine process.
This PR fixes the problem by issuing an
IOPMAssertionDeclareUserActivitybefore capture start to handle the initial wake, and holding ankIOPMAssertPreventUserIdleDisplaySleepassertion for the lifetime of the capture object to prevent sleep.I realize it's chonky; I could cut this down to about 30-40% of the proposed size by eliminating the display diagnostic logging that I added to help me track down the issue. I think it's useful to have there though, so I'm leaving it in for the original PR; but very much open to reducing it if needed.
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage