Skip to content

Keep the macOS viewer out of App Nap while it runs - #902

Merged
SimonCropp merged 2 commits into
mainfrom
fix-app-nap
Sep 23, 2026
Merged

SimonCropp merged 2 commits into
mainfrom
fix-app-nap

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

Fixes the macOS App Nap item in todo.md.

Nothing opted out of App Nap, so a covered viewer could be napped: timers coalesced and priority lowered. This process's loop is driven from outside, one frame at a time, with a socket listener beside it. So a failing test's inline send could wait on it, and its window could come forward late.

Runtime.open now takes out a userInitiatedAllowingIdleSystemSleep activity, and shutdown ends it. Idle sleep is still allowed. Since #898 the loop only redraws on a change, so staying out of App Nap costs one event pump per frame. It also covers a hidden viewer that owns the queue, which still has to answer every send promptly.

Not verified: there's no Mac here, so CI compiling the Swift and running the macOS tests is the only check. The todo item's steps would confirm it: cover the viewer for a minute, check Activity Monitor no longer shows it napping, then time how long a failing inline test takes to bring it forward.

Binaries rebuilt by build-native (#900, fast-forwarded into this branch).

Merge #901 first. Both replace the macOS library, and #901 also moves the ABI to 9. After it merges, this branch needs main merged in and its binaries rebuilt, or it would put a version 8 library back.

SimonCropp and others added 2 commits September 23, 2026 21:30
Nothing opted out, so a covered viewer could be napped: timers coalesced and
priority lowered, for a process whose loop is driven from outside a frame at a
time and which answers a socket beside it. A failing test's inline send could
wait on it, and the window come forward late.

The runtime takes out a userInitiatedAllowingIdleSystemSleep activity when it
opens and ends it at shutdown. Idle sleep is still allowed, and since the loop
only redraws on a change, staying awake costs one event pump a frame.
@SimonCropp SimonCropp added this to the 20.5.0 milestone Sep 23, 2026
@SimonCropp
SimonCropp merged commit d24f024 into main Sep 23, 2026
14 checks passed
@SimonCropp
SimonCropp deleted the fix-app-nap branch September 23, 2026 11:39
This was referenced Sep 23, 2026
This was referenced Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant