Repository navigation
iOS checks the date before a press, a native timer and a page notice, and retells a refused correction - #1
janicduplessis wants to merge 1 commit into
Conversation
… and retells a refused correction Upstream's followOffset (1353a1d) tells the date when it slipped by a second, before each advance and frame and on the system's clock, zone, wake and activation notices. It now also runs before a press, a native task timer and a page notice, so the first event after a sleep reads the real date, and a setTime the runner refuses (busy or held) leaves the date untold, to be told again at the next check.
75dbcac to
c72c3f4
Compare
|
I rebased this onto Upstream's expo/exact@1353a1de9 already does the core of this PR.
The three commits are squashed into one, and the description is updated to match. On macOS, Upstream covers the wake case through |
…e is told again The session's clock stops while the system sleeps and the date does not, so after a wake the date at the clock's zero is behind. `followOffset` checked it only before frames, clock advances and system notices: a press, a native task timer or a page notice that came first read the date from before the sleep. Each now checks first: `applyInput`, which every person's input goes through (press, edit, key, pointer), `deliverNativeTimer`, `tellPage`, and `tellPageSoon`, which queues the date ahead of the page's facts. `dateMoved` recorded the date as told before `setTime` reached the runner, so a batch the runner refused (busy, or held over a restart's reset) left the session believing it was told, and the date was not sent again until it moved by another second. A refused tell is now forgotten, and the next check tells it. The approach follows Janic Duplessis's fork (appandflow#1), which checked before a press alone. A new SessionClockTimerTests case presses right after `ExactSession.machineDate` moves ahead and holds the runtime over a check; both parts fail without this change. Fixes #668 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Description
On Apple hosts the date an app reads is
time.epochAtZero + performanceNow(), andperformanceNow()comes fromCACurrentMediaTime(), which stops while the device sleeps. Upstream's expo/exact@1353a1de9 fixes most of this.followOffsetnow retells the date when it slipped by a second or more, before each advance and frame, and on the system's clock-change, zone-change, wake and did-become-active notices.This PR covers two gaps that remain on top of that:
followOffsetalso runs before a press, a native task timer and a page notice. So a press, or a timer that fires before any frame or notice, reads the real date instead of the one from before the sleep.setTime. If the runner refuses that batch (busy or held), the correction is lost until the date moves again. Here, a refusedsetTimeclears the told epoch and the held offset, so the next check tells it again.Test plan
bun host/apple/build.mjs --test --only SessionClockTimerTests,HeadlessSessionTests,NativeTaskTimersTests,PageFactsMacTests,PageFactsSoonMacTests,PressFeedbackMacTests: 6 classes, 0 failed.SessionClockTimerTestsincludes upstream's sleep test, which movesExactSession.machineDateahead.CACurrentMediaTime.