Skip to content

Prevent stale foreground-restart latch from tearing down freshly renewed LA#656

Open
bjorkert wants to merge 1 commit into
devfrom
fix-foreground-restart-latch
Open

Prevent stale foreground-restart latch from tearing down freshly renewed LA#656
bjorkert wants to merge 1 commit into
devfrom
fix-foreground-restart-latch

Conversation

@bjorkert
Copy link
Copy Markdown
Member

Summary

A 6.1.0 report showed a gratuitous Live Activity restart ~37 minutes
after a successful background renewal. 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.

Changes

  • adoptPushToStartActivity clears pendingForegroundRestart on
    every adoption.
    A freshly-adopted LA resolves the renewal-window
    condition that latched the intent, so the deferred restart would be
    needless work.
  • performForegroundRestart re-checks the latch conditions
    (renewalFailed, overlayShowing, pushToStartLooksStuck) and bails
    if none still hold. Belt-and-braces in case a future path latches the
    intent without going through adoption.
  • Deferred-foreground-restart push-to-start is tagged
    reason="deferred-foreground-restart"
    via a single-shot
    nextStartReasonOverride consumed in startIfNeeded. The previous
    "user-start" label made the stale-latch event indistinguishable from
    a real user action in logs.

Replaces #638 (split into three independently reviewable PRs).

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant