fix(ios-runner): slow synthesized replacement so a value-owning field loses fewer characters
Summary
fill's synthesized replacement typed at XCTest's default 60 characters/second. An app that owns its field's value renders it after the edit that produced it — a controlled React Native TextInput — and that render erases whatever the burst typed while it was in flight, then reads its own erasure back into its model. The field sits stable short of the request: the ada@example -> aexample signature in #2080.
Both routes that type without resolving an XCUIElement are now paced at 12 characters/second, declared once on RunnerSynthesizedTextEntry. This reduces the loss; it does not prevent it. Against a fixture app that acknowledges each edit within 40 ms (20 bursts of ada@example each, iPhone 17 Pro simulator, iOS 26.2):
| pace | field after the burst | bursts with a write-back |
|---|---|---|
| 60 cps (before) | 1 of 11 characters, 20/20 | 20/20, 10 write-backs each |
| 12 cps (this PR) | 11 of 11 in 7/20, 10 of 11 in 13/20 | 13/20, 1 write-back each |
XCTest does not space typingSpeed: characters evenly: at 12 cps a burst averages ~78 ms per gap, but its closest pair was 11–44 ms. So no fixed pace can promise that an app with a 40 ms window keeps up. Every short value was refused with TEXT_INPUT_COMMIT_NOT_OBSERVED (the commit wait main already has). Preventing the loss is #2906 (back-pressure from the field).
Because the pace makes length the burst's wall clock, text that cannot be posted inside one command is refused before the first character: fill answers TEXT_INPUT_SYNTHESIS_BUDGET_EXCEEDED, and the element-less type fallback keeps its application-wide route, which cannot read the field back and so reports the value unverified. The budget is derived from the runner's 30 s main-thread watchdog (mainThreadExecutionTimeout, which bounds the whole command), minus a 2 s focus allowance and the 10 s commit-wait ceiling: 18 s of delivery. Each synthesize call is charged its characters at the pace plus a measured 150 ms call overhead, and a --delay-ms plan pays one call and the delay per character. That admits 214 characters without --delay-ms and 57 at --delay-ms 80. The refusal hint names both.
Follow-ups: #2903 (verified element route), #2906 (back-pressure; owns the "field keeps its value" guarantee).
User-facing note (release notes; CHANGELOG.md is gone on main): on iOS, synthesized text entry types about 83 ms apart instead of 13 ms, so a field whose app writes its own value back loses far fewer characters. The command still refuses a field left short. A fill too long for one runner command (about 214 characters, fewer with --delay-ms) now fails with TEXT_INPUT_SYNTHESIS_BUDGET_EXCEEDED before typing anything.
Refs #2080
Validation
At 80bf831fe4 (pnpm check:affected --run exit 0):
- Pace regression, red/green:
testSynthesizedReplacementPacesAnAppOwnedFieldAtItsAcknowledgeWindowasserts that a burst's characters reach the app at least one acknowledge window (40 ms) apart on average. WithRunnerTextEntryTypingSpeedCharactersPerSecondflipped to 60 it failed on both fills: "11 edits reached the app in 111 ms (closest pair 2 ms)" and 125 ms, and the host policy test failed too. Flipped back to 12: green (bursts 753–801 ms). - Through the daemon CLI, own simulator, Release
AgentDeviceTesterForm tab. The synthesized route only runs while the XCTest channel is penalized, so a temporary, uncommitted build forcedisSnapshotXCTestChannelPenalizedto true.runner.logshowsroute=synthesized-first-responder-replacementfor every fill below:- Before this commit:
fill @e10 <358 chars>failed at 30.2 s withCOMMAND_FAILED"main thread execution timed out". Delivery alone took 30.3 s, so the watchdog abandoned the command mid-burst. The in-process harness behind the earlier 358-character "32.6 s ok" never ran under that watchdog. fill @e10 <215 chars>:TEXT_INPUT_SYNTHESIS_BUDGET_EXCEEDEDin 0.9 s,budgetChars=214.fill @e10 <214 chars>: ok, 20.1 s wall. Focus 491 ms, delivery 18.3 s, commit wait 1.1 s. Thensnapshot -i: ok, 0.24 s.fill @e10 <57 chars> --delay-ms 80: ok, 19.2 s wall. Focus 503 ms, 57 synthesize calls of 213–556 ms each, commit wait 1.1 s. Thensnapshot -i: ok, 0.54 s.
- Before this commit:
- The iOS PR lane (
check:xctest-selection --ios-pr-tests, 66 tests, including both lane tests) plus 7 touched host tests: 73 tests, 0 failures on my simulator.
At a58713b50 (check:xctest-selection: 323 declared methods, iOS PR lane 67, 0 unreachable):
- The over-budget application-wide branch (
TextTyping.swift) had no coverage, and charging the budget per dispatch left it unreachable in practice: an append peels its first character for warmup, so 215 characters arrived as 1 + 214 and both pieces fit.testOverBudgetTypeWithoutResolvableElementTypesApplicationWidefailed onroute=synthesized-first-responderbefore the charge moved to the command's length and delay; it passes after, assertingroute=xctest-application-fallback, no failure,verified == nil(the branch has no element to read), and all 215 characters in the field.--agent-device-text-entry-soft-keyboardgives the fixture field a real input view; without it no keyboard-visible branch is reachable. - 11 tests of the text-entry family (both budget lane tests, the pace lane test, the 4 policy tests, and the 4 neighbouring
typeroutes): 0 failures, 71.6 s; the new test is 14.8 s.format:check,lint,check:xctest-selection,check:gate-manifest,check:packaged-runner-swiftgreen.
Risk: the 2 s focus allowance and the 150 ms call overhead come from one host. A slower host has less watchdog left for the commit wait. The pace's cost on long text is bounded only by the refusal (#2906).