Repository navigation
fix(ble): keep macOS App Nap from stalling a sync while the strap is connected - #2919
Open
matthiasthomas wants to merge 1 commit into
Open
matthiasthomas wants to merge 1 commit into
matthiasthomas wants to merge 1 commit into
Conversation
…connected When NOOP's window is hidden or covered, macOS App Nap coalesces the app's timers and clamps its work to background priority. A history drain decodes each chunk on a utility task before acking it, and the keep-alive, backfill watchdog and periodic-sync timers all run on the main queue, so a drain slowed to a stop whenever NOOP was not the front window, even with the app open all day. BLEManager now holds a ProcessInfo activity (.userInitiatedAllowingIdleSystemSleep) for as long as a strap link is up, driven by LiveState.connected so every connect and teardown path is covered. It only exempts the app from App Nap; the Mac can still idle-sleep. macOS only (#if os(macOS)); App Nap does not exist on iOS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jvascopf
added a commit
to jvascopf/noop
that referenced
this pull request
Nov 21, 2026
…p from stalling a sync while the strap is connected ryanbr#2919 Conflict: both sides were additive; kept ryanbr#2912's battery rated-life init call and ryanbr#2787's LinkIntent table alongside this PR's App Nap exemption. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What this PR does
On macOS, a history sync stalls whenever NOOP's window is hidden or covered, even with the app open all day. The Devices card then sits on "Syncing…" with the frontier frozen until NOOP is brought back to the front.
Cause: App Nap. For an app with no visible window, macOS coalesces its timers and clamps its work to background priority. The drain depends on both:
.utilitytask before its ack is sent.NOOP never opted out, so a napped app drained slowly or not at all.
Fix:
BLEManagerholds aProcessInfoactivity for as long as a strap link is up, using.userInitiatedAllowingIdleSystemSleep(BLEManager.appNapExemptionOptions).LiveState.connectedthrough Combine, so every connect and teardown path begins or ends it, including the radio-off teardown in fix(ble): end the link when the Mac's Bluetooth powers off or resets #2787, with no per-call-site bookkeeping.#if os(macOS)); App Nap does not exist on iOS.Type of change
How it was tested
Hardware: WHOOP 4.0, firmware 41.17.6.0, macOS 27. The strap had a large backlog (
Strap backlog pages behind: 9647). Before this change, the drain stopped whenever NOOP was not the front window. With this change, I hid NOOP (⌘H) and countedHistorical Data Resultacks per minute from the strap log:The drain held a steady ~32 chunks a minute for 12 minutes hidden, with no disconnects and no session restarts.
Unit tests:
AppNapExemptionTestspins the options: user-initiated, and never.idleSystemSleepDisabledor.idleDisplaySleepDisabled, so syncing can never keep the Mac awake.Full
StrandTests(macOS): 2,304 tests ran. Two failures are timezone-dependent and unrelated to this change:SkinTempAbsoluteDisplayTestsandSleepCarriedStampTestsfail in America/New_York (fixed by fix(dates): show day-keyed dates on their own day in every time zone #2723). After markingappNapExemptionOptionsnonisolatedto clear a Swift 6 isolation warning in the test, I re-ranAppNapExemptionTests: pass, with no warnings.Build and checks:
xcodegen generateplusxcodebuild(macOSStrandscheme) builds.Tools/doc_comment_lint.pyandTools/i18n_audit.py --ci upstream/mainpass.Checklist
swift testinPackages/<name>): n/a, no package touchedandroid/: n/a. App Nap is macOS-only, so there is no Android equivalentStrandDesigntokens: n/a, no UI changedocs/CONTRIBUTING.mdStrand.xcodeproj/) or any secrets/keystoresRelated issues
Refs #2787