Skip to content

fix(ios): read and press deep trees on physical devices through private AX - #5093

Merged
thymikee merged 11 commits into
callstack:mainfrom
kdy1:fix/ios-physical-private-ax-deep-snapshot
Nov 25, 2026
Merged

thymikee merged 11 commits into
callstack:mainfrom
kdy1:fix/ios-physical-private-ax-deep-snapshot

Conversation

@kdy1

@kdy1 kdy1 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On a physical iOS device, a screen nested deeper than the AX server's per-request depth limit fails every snapshot tier with kAXErrorIllegalArgument. #4089 fixed this for the Simulator bridge only.

  • The private-AX tier (depth ladder and frontier continuations) uses only XCTest's in-process AX client, so it now also runs on iOS physical devices. tvOS, visionOS, watchOS, and macOS keep the XCTest backends.
  • On a device, AXRuntime reports no app to the runner, so ref presses refused with window-origin-unknown. When the probe proves nothing, the sole XCTest screen, read on main once per snapshot, is now the full-screen proof frame. Placed iPad windows stay derived (iOS: deferred private-AX captures lose the origin of placed iPad windows #4399).
  • diff --actions no longer says devices lack private AX.
  • .boundedXCTestProbe is now unreachable. Kept; remove here?

Before / after

iPhone 17 Pro Max, iOS 27.2.1, UIKit fixture with a button under 90 nested views:

base b2d4ec051
snapshot   -> COMMAND_FAILED invalid-viewport (ax-rejected: kAXErrorIllegalArgument)

head 6b70a1b3c
snapshot   -> recovered, backend private-ax, viewport 440x956, deep-button @e92 at depth 90
press @e92 -> Tapped @e92 (220, 157); label reads "Tapped 1"

Validation

  • pnpm check:affected --run --head 85bc04bab: passed, exactCommit: true. Swift runner lanes are CI-owned.
  • At 6b70a1b (later commits: comments, docs): 109 runner unit tests (iOS 27.2 Simulator), macOS, tvOS, visionOS, watchOS, iOS-device runner builds, and device depths 20 and 150 passed.

Risks:

  • No iPad run. Off the phone idiom the gesture route still needs AXRuntime's proof, so deep ref presses are probably refused, not mis-pressed. Landscape iPhone is refused too.
  • A press right after the first deep capture can get runner_busy.

AI assistance and human review

AI was used to prepare these changes. Human-reviewed by @kdy1.

  • Harness: Claude Code (T3 Code)
  • Model: claude-opus-5-5
  • Reasoning Effort: high

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

kdy1 and others added 6 commits November 25, 2026 11:54
…AX tier

On a physical iPad, one deep screen failed every snapshot tier with
kAXErrorIllegalArgument. The AX server limits the depth of each snapshot
request, and XCUIElement.snapshot() and the query sweep both ask for the
whole tree in one request. The runner's private-AX tier already works
around this limit: it steps down a depth ladder and re-roots requests at
the depth-capped frontier nodes. It was compiled for iOS Simulators only.

The tier uses only XCTest's own in-process AX client
(XCUIDevice.accessibilityInterface, requestSnapshotForElement), which is
also present on a device. So the runner now offers it on iOS physical
devices too. tvOS, visionOS, watchOS, and macOS still do not get it: a
new otherApplePlatform environment keeps them on the XCTest backends,
which is what they had when they were mapped to physicalDevice.

Consequences on a physical device: a capture that the tree and query
tiers cannot serve falls through to private AX, and a penalized XCTest
channel defers to private AX instead of a bounded XCTest probe, as on a
runner-read Simulator.

Only iOS runners penalize the channel, and every iOS runner now has
private AX, so no runner reaches the bounded XCTest probe any more. The
probe stays as the policy for a plan without an independent backend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… devices

On a physical device AXRuntime reports no app to the runner process
(`AXElement.primaryApp` and `systemApplication` answer nil), so the
full-screen probe answered Unknown and every private-AX root stayed
`derived`. A deep screen then read through private AX, but every ref
press refused with `window-origin-unknown`. The e2e mobile engine presses
by ref, so its taps on that screen failed.

When the probe proves nothing, take the sole XCTest screen in native
portrait points as the frame the root must equal. No window smaller than
the screen can equal it, so a placed iPad window's local root (callstack#4399)
stays `derived`. Windowed or not-primary evidence never falls back, and a
landscape or unreadable sole screen answers no frame.

The XCTest tree tier shares the frame through `capturedSnapshotViewport`,
so on a physical device a full-screen portrait window now comes from the
root snapshot instead of a live `app.windows` read, as on a Simulator.

The sole-screen gesture route is unchanged: off the phone idiom it still
needs AXRuntime's fills-screen proof, so a ref press on a deep screen of
a physical iPad is still refused, not mis-pressed.

Verified on an iPhone 17 Pro Max (iOS 27.2.1) with a UIKit screen nested
90 and 150 views deep: the private-AX viewport is `reported`, and
`press @ref` reaches the button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f frame

ADR 0004 still said a private-AX root is `reported` only when AXRuntime
reports the app filling the screen, and the next sentence added a case
where AXRuntime reports nothing. The runner README had the same shape.
State one rule instead: the root must equal the full-screen proof frame
at the origin, and the AXRuntime result decides that frame.

The acquisition paragraph also said physical devices "keep their existing
owners" right before saying that iOS physical devices now use the private
AX tier. It now says what stays the same for them: they do not use the
host AX bridge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`XCUIScreen` is main-actor isolated, and its reads are synchronous IPC.
The private-AX tier runs on the command queue, and its viewport fallback
read `XCUIScreen.screens` there whenever the AXRuntime probe proved
nothing, which is every capture on a physical device.

Snapshot preparation already runs on main and hands the off-main capture
the facts it needs in `SnapshotCaptureTarget`. It now also reads the sole
screen there (cached per command in `soleDisplayPortraitSize`), and the
private-AX viewport proves a full-screen root against that size.
`RunnerFullScreenApplicationFrame` takes the size as a block, so the
tree tier, which reads its viewport on main, still reads the screen only
when the probe proves nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…diff --actions

`diff snapshot --actions` refused a non-Simulator target by saying the
target does not have the private accessibility snapshot backend. A
physical iOS runner now has that backend; custom actions are admitted on
Simulators only. Use the wording `snapshot --actions` already uses
("custom actions are unavailable on this <platform>/<kind> target") and
correct the platform-guard test comment that made the same claim.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Snapshot dispatch skips `executePrepared`, the only place that clears
`mainOwned.soleDisplayPortraitSize` at the start of a command. So
snapshot preparation reused the size an earlier snapshot read. After a
display change, such as a second screen or a Display Zoom change, the
private-AX tier could prove a full-screen root against a screen that no
longer holds.

Snapshot preparation now clears the cache and reads the size again, so it
is fresh for each command. The tree tier, which reads its viewport on
main, reuses that read instead of a second uncached `XCUIScreen` read
with a different shape. A request that names a lit panel skips the read:
its plan has no private-AX tier, and on a multi-screen device the read
would only log `APP_SCREEN_UNRESOLVED` on every snapshot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 21 files

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Re-trigger cubic

kdy1 and others added 5 commits November 25, 2026 13:11
The private-AX tier honors an explicit raw depth as asked, with no
accepted-depth memory and no frontier extension, so the ADR must not
promise continuation for that request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RunnerFullScreenProofFrame answers CGRectNull for an unknown probe
when the sole screen cannot be measured or is landscape, so the ADR
states that the origin then stays unknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The decision history named a physical iPad failure that this change
did not reproduce. It now names the deep-screen rejection reproduced
on a physical iPhone at the base commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
effectiveSnapshotCapturePlan reorders only the regular visible plan;
raw and lit-panel plans keep their order, so the comment no longer
says that every penalized plan defers to private AX.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Physical iOS runners now read private AX, so the module comment no
longer says only the simulator has that backend. It says that the
daemon admits --actions on the simulator only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member

Thanks for the work on this, the code at 85bc04b looks good and no blocking problems were found.

These threads no longer apply and can be resolved: raw depth (the ADR now says an explicit raw depth gets that depth only, with no continuation), sole screen proof (the ADR now says an unmeasurable or landscape sole screen gives no proof frame), deferral scope (the deferral is now limited to the regular visible plan), test module doc (it now says --actions is admitted on Simulators only), and decision history device (it now names a physical iPhone).

The live device run is known only from the PR body summary, with no raw debug log or AGENT_DEVICE_RUNNER_PRIVATE_AX_ROOT_VIEWPORT kind=reported runner line attached. That run was at 6b70a1b, and later commits change only comments and docs on the device path.

Not verified here: an iPad run, physical or Simulator; a live placed-window run for the #4399 rule that placed windows stay derived, which is covered by construction and a pure unit test; whether AXRuntime on physical hardware always answers Unknown and never NotPrimaryApp or Windowed (a NotPrimaryApp answer would make presses refuse, which fails closed); and a local run of the Swift runner tests.

All 16 checks pass at this commit. Nothing blocks the merge. As an optional cleanup, the unreachable .boundedXCTestProbe path can be deleted.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 25, 2026
@thymikee
thymikee merged commit 5d6c2f4 into callstack:main Nov 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants