fix(ios): preserve simulator app accessibility after runner teardown
Merged
TH
6d ago+757+757+012345678901234567890123456789-28-28-01234567890123456789
Summary
When an XCTest session ends on an iOS simulator (graceful disposal or daemon stop --clean), the simulator is left with ApplicationAccessibilityEnabled=0. Every app launched afterwards then shows an empty accessibility tree to other tools (AXe: one Application node, 0×0) until reboot, and agent-device's own first snapshot after open --relaunch can be sparse. An external benchmark hit this and had to reboot between runs.
- Runner teardown (both paths) writes
ApplicationAccessibilityEnabled=YESafter confirmed termination; lease cleanup reads a new typedsimulatorTargetlease field, and older leases skip the repair. openwrites it before an app or URL launch on an iOS/iPadOS simulator. Failures are diagnostics and do not block launch.- Only that key, only iOS/iPadOS simulators; custom sets stay scoped; physical devices and macOS are excluded.
- Owner cleanup holds the lease lock through termination, repair, and release.
Validation
Tested f870c81fb54930a478a49ee2877590a11f60bb86.
pnpm check:affected --run --head f870c81fb5: passed (exactCommit). Regression suites: base 10 failed / 19 passed, head 29 passed.- Live, fresh iPhone 17 simulator (iOS 26.2), this build with isolated state and lease dirs, AXe 1.8.0, app relaunched with
simctl terminate/launch:
| Case | main | this PR |
|---|---|---|
runner session, daemon stop --clean, relaunch | 1 node, 0×0 | 155 nodes |
same with AGENT_DEVICE_IOS_RUNNER_DETACH=0 + daemon stop | 1 node, 0×0 | 155 nodes |
key forced to NO, open --relaunch, first snapshot -i | 1 node | 30 nodes |
The key stayed 1 when read again 15 s after teardown. The simulator was deleted afterwards.