Prevent stale foreground-restart latch from tearing down freshly renewed LA#656
Open
bjorkert wants to merge 1 commit into
Open
Prevent stale foreground-restart latch from tearing down freshly renewed LA#656bjorkert wants to merge 1 commit into
bjorkert wants to merge 1 commit into
Conversation
…wed LA pendingForegroundRestart could outlive the condition that triggered it: a brief foreground entry while the renewal overlay was up latched the intent, the user backgrounded before didBecomeActive ran, the background renewal then replaced the LA, and the next foreground entry minutes later fired the deferred restart against an already-fresh LA. - adoptPushToStartActivity clears pendingForegroundRestart on every adoption — a freshly-adopted LA resolves the renewal-window condition that latched the intent. - performForegroundRestart re-checks renewalFailed / overlayShowing / pushToStartLooksStuck before tearing down; bails if none still hold. - Deferred-foreground-restart push-to-start is tagged reason="deferred-foreground-restart" via a single-shot nextStartReasonOverride, so the stale-latch event is no longer indistinguishable from a real user start in logs.
bjorkert
added a commit
that referenced
this pull request
May 12, 2026
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
A 6.1.0 report showed a gratuitous Live Activity restart ~37 minutes
after a successful background renewal.
pendingForegroundRestartcouldoutlive the condition that triggered it: a brief foreground entry while
the renewal overlay was up latched the intent, the user backgrounded
before
didBecomeActiveran, the background renewal then replaced theLA, and the next foreground entry minutes later fired the deferred
restart against an already-fresh LA.
Changes
adoptPushToStartActivityclearspendingForegroundRestartonevery adoption. A freshly-adopted LA resolves the renewal-window
condition that latched the intent, so the deferred restart would be
needless work.
performForegroundRestartre-checks the latch conditions(
renewalFailed,overlayShowing,pushToStartLooksStuck) and bailsif none still hold. Belt-and-braces in case a future path latches the
intent without going through adoption.
reason="deferred-foreground-restart"via a single-shotnextStartReasonOverrideconsumed instartIfNeeded. The previous"user-start"label made the stale-latch event indistinguishable froma real user action in logs.
Replaces #638 (split into three independently reviewable PRs).