Skip to content

perf(ios): anchor recording gesture clock from runner response stamps#762

Merged
thymikee merged 1 commit into
mainfrom
perf/670-recording-uptime-anchor
Jun 11, 2026
Merged

perf(ios): anchor recording gesture clock from runner response stamps#762
thymikee merged 1 commit into
mainfrom
perf/670-recording-uptime-anchor

Conversation

@thymikee

Copy link
Copy Markdown
Member

Closes #670

What

Starting an iOS simulator recording with touch overlays no longer sends a standalone uptime runner command just to anchor gesture-overlay timing.

  • The Swift runner now stamps currentUptimeMs (the same monotonic clock used for gestureStart/EndUptimeMs telemetry) onto every ok response at the single transport encoding chokepoint, captured just before the HTTP write.
  • The daemon's simulator recording start anchors the gesture clock from the warm snapshot response it already makes: gestureClockOriginUptimeMs = the stamped value, gestureClockOriginAtMs = daemon receipt time. Receipt-time pairing is used instead of request midpoint because the warm request can include cold runner launch (10s+); the late bias is one-way loopback latency (single-digit ms), far below overlay tolerance (tap markers render for ≥450ms).
  • Stamping happens after commandJournal.finish, so journal-stored lifecycleResponseJson stays unstamped — a journal-recovered response never pairs a stale uptime with a late receipt time; the daemon just falls back.

Fallback

If the anchor is missing or unusable (older cached runner build, warm-up failure, non-finite value), the existing standalone uptime + request-midpoint pairing runs unchanged; if that also fails, the existing wall-clock-only degradation remains. The iOS physical-device and macOS recording flows are untouched.

Validation (iPhone 17 Pro Max simulator, iOS 26.2)

Per-request diagnostics (--debug) for record start with touch overlays:

runner sends during record start
main snapshot + uptime
this PR snapshot only

The branch run emits a record_start_gesture_clock_anchor diagnostic confirming the anchor came from the warm response. Recorded a tap with overlays on both main and this branch: the marker appears at the tap moment and fades identically on both (frame-by-frame comparison), so overlay timing is preserved. (Both branches show a pre-existing marker y-position offset, tracked separately.)

  • pnpm typecheck passes; record-trace, record-trace-ios, and recording-timing suites pass (46 tests).
  • pnpm build:xcuitest:ios succeeds; new Swift XCTest cases cover the stamping helper and assert journal responses stay unstamped.

Every ok runner response now carries a transport-stamped currentUptimeMs
captured just before the HTTP write. Simulator recording start anchors
gesture overlay timing from the warm snapshot response it already makes,
skipping the standalone uptime request. The standalone uptime path stays
as fallback for older runner builds, and journal-stored responses remain
unstamped so recovered results never pair a stale uptime with a late
receipt time.

Closes #670
@github-actions

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.2 MB 1.2 MB +99 B
JS gzip 390.4 kB 390.3 kB -61 B
npm tarball 501.7 kB 502.4 kB +684 B
npm unpacked 1.7 MB 1.7 MB +2.7 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.1 ms 28.5 ms +1.4 ms
CLI --help 42.2 ms 44.0 ms +1.8 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/9542.js -422 B -144 B
dist/src/record-trace-recording.js +371 B +88 B
dist/src/cli.js +379 B +85 B
dist/src/8173.js -175 B -70 B

@thymikee thymikee merged commit 8694157 into main Jun 11, 2026
19 checks passed
@thymikee thymikee deleted the perf/670-recording-uptime-anchor branch June 11, 2026 12:23
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-11 12:24 UTC

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.

perf(ios): remove extra recording uptime request by returning a runner timing anchor

1 participant