diff --git a/host/apple/Sources/ExactKit/NativeTaskTimers.swift b/host/apple/Sources/ExactKit/NativeTaskTimers.swift index 0e2a11289..0077fd369 100644 --- a/host/apple/Sources/ExactKit/NativeTaskTimers.swift +++ b/host/apple/Sources/ExactKit/NativeTaskTimers.swift @@ -114,6 +114,7 @@ extension ExactSession { func deliverNativeTimer() { guard state != .destroyed, clock == nil, !ExactEnv.agentFreezes, !applying, !ownerInFlight, let timer = taskTimers.take() else { return } + followOffset() if ExactSession.asyncFills { advanceInFlight = true let captured = generation diff --git a/host/apple/Sources/ExactKit/PageFacts.swift b/host/apple/Sources/ExactKit/PageFacts.swift index 540db1653..047d4e476 100644 --- a/host/apple/Sources/ExactKit/PageFacts.swift +++ b/host/apple/Sources/ExactKit/PageFacts.swift @@ -397,6 +397,7 @@ extension ExactSession { /// notification, in the same turn. func tellPage() { guard booted, state != .destroyed else { return } + if clock == nil { followOffset() } #if canImport(UIKit) // Out of the foreground, a press hands nothing on (PressHandoffIOS). if view?.window?.windowScene?.activationState != .foregroundActive { presenter.supersedePress() } diff --git a/host/apple/Sources/ExactKit/Session.swift b/host/apple/Sources/ExactKit/Session.swift index aa30e8858..d688fed1b 100644 --- a/host/apple/Sources/ExactKit/Session.swift +++ b/host/apple/Sources/ExactKit/Session.swift @@ -762,7 +762,10 @@ public final class ExactSession { apply(batch) } presenter.onClose = { [unowned self] id in apply(runtime.dialogClose(id, now: now())) } - presenter.onPress = { [unowned self] id in applyInput(runtime.press(id, held: presenter.pressHeld, at: presenter.pressPoint, now: now())) } + presenter.onPress = { [unowned self] id in + if clock == nil { followOffset() } + applyInput(runtime.press(id, held: presenter.pressHeld, at: presenter.pressPoint, now: now())) + } // A text field's `input` and `change` carry the selection the edit // left, its `select` the one the person or a script made (x2apps // codeedit #2, `FieldSelections`). diff --git a/host/apple/Sources/ExactKit/SessionTime.swift b/host/apple/Sources/ExactKit/SessionTime.swift index dc42ae621..b55f74bc1 100644 --- a/host/apple/Sources/ExactKit/SessionTime.swift +++ b/host/apple/Sources/ExactKit/SessionTime.swift @@ -28,11 +28,14 @@ extension ExactSession { /// runner's own threshold). The date moves when the clock is set, and /// through a sleep, since the session's clock (`CACurrentMediaTime`, /// `mach_absolute_time`) stops while the system sleeps and the date does - /// not. Runs before each advance and frame; `dateChanged` runs it on a - /// system notice. + /// not. Runs before each advance, frame, press, native timer and page + /// notice, and again after a refused `setTime`; `dateChanged` runs it on + /// a system notice. func followOffset() { guard let date = dateMoved() else { return } - apply(runtime.setTime(epochAtZero: date.epoch, utcOffset: date.offset)) + let batch = runtime.setTime(epochAtZero: date.epoch, utcOffset: date.offset) + apply(batch) + if batch.busy || batch.held { (toldEpoch, offsetHeld) = (nil, nil) } } /// `followOffset`'s date, nil when neither moved. `offsetHeld` is the /// zone the offset was read in and when to read it again: until then, in