Skip to content

fix(ios): regain healthy timer leeway after the fast foreground beat - #21478

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/p21406-foreground-leeway
Oct 14, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/p21406-foreground-leeway

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Answers the one unresolved non-outdated thread on #21406 ("Restore healthy leeway after the fast foreground beat"): appBecameActive arms first: 1s, repeating: 4s, and a DispatchSourceTimer records a single leeway for the whole schedule — 50 ms for the fast first fire. Because progressIntervalArmed was recorded as 4 s, the tick handler's desired == armed check never retargeted, so every later healthy beat for the rest of the session kept the 50 ms coalescing tolerance the fast beat needed.

The pending fast first fire is now tracked explicitly (progressFastFirePending). After it emits, the timer retargets to the armed repeating cadence, regaining the 500 ms healthy leeway. If the capture state changed while the beat was pending, the retarget defers to the existing desired-cadence branch instead, preserving the fault-path behaviors pinned by the #21406 review (a preserved fast fire through recovery, a second fault before the fire).

cancelProgressTimer clears the flag with the rest of the timer state.

Product invariants

  • None of the indexed invariants are triggered by this path (no uplink pause, no capture-policy change: the tick still fires at the same deadlines; only the kernel coalescing tolerance after the first fast beat changes). The batch liveness contract is unchanged: healthy 4 s beat under Dart's 10 s stall deadline, one fast beat on foreground return.

Failure class

Failure-Class: none

Test plan

  • Behavior reasoning against syncProgressTimer/applyProgressCadence state machine; flag lifecycle covers arm/retarget/cancel
  • Pre-push gate (shared PR contract, hygiene, supplied PR body)
  • Full CI green on this exact head (iOS build lanes), then independent review before merge

View guided diff Turn on auto-fix

The fast foreground beat arms first=1s/repeating=4s with 50ms leeway (one
leeway serves the whole DispatchSourceTimer schedule), but recorded the armed
interval as 4s, so the tick handler's desired==armed check never retargeted
and every later healthy beat kept the 50 ms coalescing tolerance for the rest
of the session. Track the pending fast first fire explicitly, retarget to the
armed cadence after it emits (deferring to the desired-cadence branch when the
state changed while the beat was pending), and clear the flag on cancel.

Invariant: none triggered (liveness deadlines unchanged; coalescing tolerance
only).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T10:24:56.020658Z eedb756 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level merged commit 28b4d6d into main Oct 14, 2026
50 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/p21406-foreground-leeway branch October 14, 2026 10:50
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