ChasLui (#6261, and on X): with the screen locked, every request after a
quiet while got the 30s pre-routing 504 from the menu-bar app (160 in one
night). The app serves the gateway in its own process, and a locked
screen leaves it a background app, which macOS App Naps: priority band 4,
timers throttled, so parsing the 6MB catalog took ~800ms instead of 50ms
and requests queued behind it past unroutedUnknown. Keep-awake
(caffeinate) holds sleep off, not App Nap.
ListenAndServe now holds an NSProcessInfo activity for as long as it
serves (awake.NoNap): NSActivityUserInitiatedAllowingIdleSystemSleep,
Apple's App Nap opt-out without the idle-sleep hold. Held for the whole
life of the gateway, not only while a request is in flight: the request
that suffered is the first one after an idle stretch, which arrives at
an already napped process. NSActivityLatencyCritical is left out: it is
timer precision for audio/video, at an energy cost, and App Nap's
throttling is what the reporter measured. Sleep is still Keep's alone,
only while the user turned keep-awake on.
The command-line magpie is built without cgo and runs from a terminal or
launchd, where App Nap doesn't reach it; there NoNap does nothing.
Run:
- Real App Nap on mote (macOS 27.2): two copies of a throwaway AppKit
.app (regular policy, launched hidden with open -j -g), one holding
NoNap. Without it: runningboardd "Set AppNap state: active:Y
priority:Y timer:Tier5" and ps pri=4 (42 of 42 samples once napped).
With it: "active:N socket:N priority:N timer:Tier0" and pri=20, never
4. pmset -g assertions listed nothing for either pid.
- TestNoNapLetsTheMacSleep (darwin+cgo): holds NoNap, reads pmset -g
assertions, fails on a Prevent* assertion of its own pid. Broken by
hand with NSActivityUserInitiated: red ("PreventUserIdleSystemSleep
named: magpie serves the gateway ..."); green with the shipped option.
- go vet (darwin), GOOS=linux and GOOS=windows go vet -tags nogui of
awake, daemon, cli, gateway; CGO_ENABLED=0 nogui build; gofmt -l.
- go test -count=1 -timeout 45m . ./internal/{awake,daemon,cli,gateway,
proc,update,masking,plugin} on mote: all ok (gateway 908s, plugin 159s, cli 52s) at base 7eecbcc56; at the pushed head (rebased on 459d668b3, which touches none of these files) build, gofmt, linux and windows vet, and awake, daemon, cli tests ok again
Not tried: the real magpie.app with a real screen lock. mote and mica
were running other sessions' AppKit and simulator tests, which a lock
would break; the hidden-app case above is the same App Nap path
(runningboardd's AppNap state), reached without the lock. The full
suite: both machines' suite.lock queues were hours deep.