Fix Live Activity restart classification, foreground race, and add troubleshooting logs#615
Merged
marionbarker merged 3 commits intodevfrom May 4, 2026
Merged
Conversation
- handleExpiredToken, endOnTerminate, forceRestart: mark endingForRestart before ending so the state observer does not misclassify the resulting .dismissed as a user swipe (which would set dismissedByUser=true and block auto-restart on the next background refresh). - Defer foreground restart from willEnterForeground to didBecomeActive so Activity.request() is not called before the scene is active (avoids the "visibility" failure). - Remove duplicate orphan LiveActivitySettingsView.swift under Settings/ (not referenced by the Xcode project).
- startIfNeeded: log entry state (authorized, activities, current, flags) and enrich Activity.request failure with NSError domain/code + scene state. - renewIfNeeded: enrich catch with NSError domain/code + authorization state. - handleForeground / handleDidBecomeActive: include applicationState and the existing activities count at entry. - observePushToken: log token fingerprint (last 8 chars) and prior value so token rotations are visible. - update: log when the direct ActivityKit update is skipped (app backgrounded) and when APNs is skipped because no push token has been received yet. - performRefresh: log the gate that blocks LA updates — especially dismissedByUser=true, which previously caused silent extended outages. - handleExpiredToken: log current id, activities count, and flags before ending so APNs 410/404 events are correlatable to the restart path. - bind: include activityState and the previous endingForRestart value so the dismissal-classification path is traceable.
…art-foreground-race
marionbarker
approved these changes
May 4, 2026
Collaborator
marionbarker
left a comment
There was a problem hiding this comment.
Approve by test that the app builds and LiveActivity shows on the watch and phone.
This has been used successfully by the developer on his personal phone.
MtlPhil
pushed a commit
to achkars-org/LoopFollow
that referenced
this pull request
May 6, 2026
Brings in all changes from loopandlearn/LoopFollow dev up to 6.1.0. Resolved conflicts by taking upstream throughout, except LogManager where both the watch and telemetry log categories are kept. Key changes from upstream: - Add iOS 17.2+ push-to-start for Live Activity renewal (loopandlearn#622) - Fix LA restart classification, foreground race, troubleshooting logs (loopandlearn#615) - Redact secrets from log output (loopandlearn#623) - Add anonymous telemetry (loopandlearn#626) - Add units selection (loopandlearn#558) - Fix stats inclusive date range (loopandlearn#629) - Deduplicate Nightscout treatment entries by id (loopandlearn#569) - Fix alarm sound session activation failures in background (loopandlearn#596) - Recognize Atlas DASH pod in Omnipod heartbeat scan (loopandlearn#633) - Default migrationStep to latest on fresh installs (loopandlearn#631) - Update to fastlane 2.233.1 (loopandlearn#632) https://claude.ai/code/session_01VK2furpEaEmysQvEd1h77f
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.
Summary
Two fixes plus diagnostics for Live Activity restart paths, split out from the broader background-renewal work so they can land independently.
Restart classification + foreground race
handleExpiredToken,endOnTerminate,forceRestart: markendingForRestartbefore ending so the state observer doesn't misclassify the resulting.dismissedas a user swipe (which would setdismissedByUser=trueand block auto-restart on the next background refresh).willEnterForegroundtodidBecomeActivesoActivity.request()isn't called before the scene is active (avoids the "visibility" failure).LiveActivitySettingsView.swiftunderSettings/(not referenced by the Xcode project).Troubleshooting logs
startIfNeeded: log entry state (authorized, activities, current, flags) and enrichActivity.requestfailure withNSErrordomain/code + scene state.renewIfNeeded: enrich catch withNSErrordomain/code + authorization state.handleForeground/handleDidBecomeActive: includeapplicationStateand the existing activities count at entry.observePushToken: log token fingerprint (last 8 chars) and prior value so token rotations are visible.update: log when the direct ActivityKit update is skipped (app backgrounded) and when APNs is skipped because no push token has been received yet.performRefresh: log the gate that blocks LA updates — especiallydismissedByUser=true, which previously caused silent extended outages.handleExpiredToken: log current id, activities count, and flags before ending so APNs 410/404 events are correlatable to the restart path.bind: includeactivityStateand the previousendingForRestartvalue so the dismissal-classification path is traceable.