perf(ios): read a simulator snapshot target's identity and foreground once each

Merged
IM
5d ago
+234-19

Summary

Each bridge snapshot of an iOS Simulator app spawned ps -p <pid> -o lstart= three times for one pid and read the AXRuntime primary app four times. The resolver's cache check stays: it keeps a relaunched app on the bridge.

  • The resolver's verified start time replaces the read before the exchange. The read after it compares against that value, so an unchanged start time still proves the tree came from the resolved process.
  • A failed exchange re-reads the identity and fails as stale-target when the process exited or was replaced, so a relaunch is not reported as a bridge refusal.
  • In the bridge, one primary-app read answers ownership and window placement, and the first native request relies on it. Later requests and the post-acquisition check still read.
Before / after (iPhone 17 Pro, iOS 27.2 simulator, Settings)

Per bridge snapshot: ps spawns 3 → 2, primaryApp reads 4 → 2. Daemon-side medians, builds taking turns:

FlowQuietLoaded (4 busy CPU processes)
Repeated snapshot -i63.0 → 58.0 ms119.0 → 95.0 ms
wait stable 300 5000483 → 470.5 ms513.5 → 484 ms

Validation

  • Base 7d392e6214, head 9ba30d821d.
  • Simulator at head: steady snapshots, the first after open --relaunch, and the next all used the bridge; after termination, the snapshot fails as on base.
  • Native bridge fixture counts primary-app reads (53 passed); lifecycle tests cover the single read and the reclassification. 8 mutants each fail a test.
  • Gate passed, including xctest-selection, packaged-runner-swift, package, and provider-integration.