Add tolerance to the Apple live-session timer - #1053
Open
whisp0 wants to merge 1 commit into
Open
Conversation
whisp0
marked this pull request as ready for review
August 2, 2026 23:24
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
Timera 100 ms toleranceApple recommends setting tolerance on repeating timers so the system can combine wakeups and spend more time idle: https://developer.apple.com/documentation/foundation/timer/tolerance
Why
An active live session keeps this timer running once per second for UI and stale-stream checks. Those checks do not require an exact sub-second deadline. A 10% tolerance gives iOS/macOS room to coalesce the wake with nearby work without changing the engine's inputs or accumulating drift.
The timer cannot fire before its scheduled date, and Foundation calculates later repeating fire dates from the original schedule. The runner also computes elapsed time from
Date, rather than incrementing a counter on each timer callback.Verification
git diff --checkswiftc -frontend -parse Strand/App/LiveSessionRunner.swiftDraft because the app-target build and device smoke test still need maintainer/CI verification.