Fix empty accessibility hierarchy on iOS 26+ simulators#312
Fix empty accessibility hierarchy on iOS 26+ simulators#312dpearson2699 wants to merge 1 commit intogetsentry:mainfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e963be0. Configure here.
) On iOS 26+ fresh simulators, AccessibilityEnabled and ApplicationAccessibilityEnabled default to 0, which prevents accessibility hierarchy queries from returning any elements. Enable both flags via xcrun simctl spawn defaults write after boot_sim and build_run_sim boot the simulator. The check is idempotent (reads first, writes only if needed) and failures are logged but never propagated to avoid blocking boot.
commit: |
|
Thanks for the work on this, @dpearson2699. Before merging we ran a controlled test of the underlying premise on three freshly-created iOS 26.4 / iPhone 17 simulators (scripts in What we observedT+0 anchored at "
Two trials of B0 produced permanent failure of Why we think this happens
The most plausible mechanism for the regression: Test E confirms the breakage is specifically a race against Likely interpretation of the original observation in #290When you ran Closing this PRI'm closing this rather than merging because the change makes things worse for any agent that calls a UI-automation tool quickly after a fresh boot — exactly the case this PR was meant to help. Please don't take that as dismissal: this is a real bug and your reproduction in #290 is genuine. The methodology just turned out to point at a different cause than the fix targets. If you can reproduce a case where:
then the flag write would be doing something we couldn't measure, and we'd reopen the discussion. The scripts at Either way, thanks again for the contribution and for the detailed reproduction in #290. Sorry to close after a rebase — the empirical finding only emerged when we tried to verify it. |

Summary
On iOS 26+ fresh simulators,
AccessibilityEnabledandApplicationAccessibilityEnableddefault to0, which causessnapshot_uito return an empty accessibility hierarchy with no children.This PR proactively enables both accessibility flags at simulator boot time via
xcrun simctl spawn <udid> defaults write, sosnapshot_uiworks correctly on first use.Changes
src/utils/simulator-accessibility.ts— NewensureSimulatorAccessibility()utility that reads the currentAccessibilityEnabledvalue and writes both flags if disabled. Failures are logged but never propagated (accessibility setup should not block boot).src/mcp/tools/simulator/boot_sim.ts— CallsensureSimulatorAccessibility()after successful boot.src/mcp/tools/simulator/build_run_sim.ts— CallsensureSimulatorAccessibility()after the boot-if-needed section, covering the implicit boot path.src/utils/__tests__/simulator-accessibility.test.ts— 6 unit tests covering enable, skip-if-already-enabled, error handling, and command verification.src/mcp/tools/simulator/__tests__/boot_sim.test.ts— Updated command verification test to account for accessibility calls after boot.Design decisions
snapshot_uitime — avoids the overhead of detecting an empty hierarchy, retrying, and adding response notes.warnlevel, never thrown.Fixes #290