perf(ios-runner): settle post-snapshot interactions on a deadline, not a fixed sleep
Summary
Follow-up to #2395. After every XCTest snapshot, the runner set mainOwned.needsPostSnapshotInteractionDelay = true, causing applyInteractionStabilizationIfNeeded() to sleep a flat 0.2 s on the next interaction even when seconds had already passed.
Replace the boolean with a monotonic postSnapshotInteractionReadyUptime: TimeInterval? deadline stamped in beginPostSnapshotInteractionStabilization() when the snapshot finishes, mirroring firstInteractionWindow (#2395, #3532). applyInteractionStabilizationIfNeeded() sleeps only readyUptime - ProcessInfo.processInfo.systemUptime and clears the deadline. The guard (from #72) is a minimum gap after the snapshot, so elapsed time satisfies it: tight loops keep the full 200 ms; agent-paced flows credit elapsed round-trip time instead of paying 200 ms twice.
Before / after (iPhone 17 Pro, iOS 27.2 simulator, Settings)
snapshot -i --actions (XCTest path) then fill (350 ms gap, N=7; 0 ms gap, N=5) and back-to-back press (0 ms gap, N=5):
| Metric (median, min–max) | Base (9d6059c120) | Head (21c99f3250) | Delta |
|---|---|---|---|
fill accept→dispatch (350 ms) | 204.5 ms (202.3–206.2) | 2.6 ms (1.6–10.7) | −201.9 ms |
fill runner type (350 ms) | 2080.3 ms (1999.1–2316.4) | 1869.8 ms (1742.1–1938.4) | −210.5 ms |
fill CLI wall (350 ms) | 2322.6 ms (2230.6–2568.2) | 2043.8 ms (1903.2–2148.3) | −278.8 ms |
fill accept→dispatch (0 ms) | 205.4 ms (202.8–206.6) | 4.1 ms (1.6–53.4) | −201.3 ms |
press landed (0 ms) | 5/5 | 5/5 | — |
Validation
- Tested commit
21c99f3250. - Runner XCTest (
LifecycleCacheTests+SnapshotExecutionTests, iOS 27.2 simulator): 21 tests, 0 failures. - All 5 Apple runner builds (
ios,macos,tvos,visionos,watchos) succeeded. pnpm check:affected --base upstream/main --run --head 21c99f3250(native-dupes,xctest-selection,packaged-runner-swift),pnpm check:quick, andpnpm format:checkpassed.
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.