perf(apple): carry the readied simulator through open and drop the redundant post-boot waits

Merged
TH
14d ago
+246-75

Summary

open on a shut-down iOS Simulator waited for boot twice and listed devices once too often.

  • ensureAppleReady returns the readied device (booted: true), but open and prepareAppleRunner discarded it. The runner's ensure_booted then ran a second simctl bootstatus -b (1.4-1.75 s).
  • After a successful bootstatus -b (exit 0 only once boot completes), readiness ran another simctl list devices -j (~1.4 s). That listing is gone; deadline and cancellation checks remain.
  • The Apple lifecycle keeps the readied device per request and rebuilds its interactor binding after successful preparation. Open, runner prewarm, prepare ios-runner and now close (with ensureReady) all receive booted: true. Failed or cancelled preparation keeps the original binding.

8 files, 4 production.

Validation

  • Tested commit 991ae15516, rebased on aa1b08ca4d: pnpm check:affected --run passed (321 files, 2247 tests).
  • Reverting the two production files (lifecycle.ts, readiness/runtime.ts) to main fails 8 of the new or updated tests. The runner-session stale-bundles test and the failed-preparation test pass on main too.
  • Live A/B on one iPhone 17 Pro / iOS 26.2 sim, alternating main and branch (shutdown, open com.apple.Preferences, click 'label="General"'), at ce1e4a1e36. Round 1 excluded (unrelated runner rebuild); 4 paired rounds:
    • runner test-without-building starts 2.96 s sooner after bootstatus (all rounds: -2.5 to -3.4 s);
    • simctl launch starts 1.42 s sooner;
    • median open→first-click -1.6 s, spread +0.2 to -5.0 s (XCTest attach time absorbs part of the gain).