Fix Live Activity restart classification, foreground race, and add troubleshooting logs#615
Open
Fix Live Activity restart classification, foreground race, and add troubleshooting logs#615
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
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.