Skip to content

Latest commit

 

History

History
110 lines (78 loc) · 25.9 KB

device-support.md

File metadata and controls

110 lines (78 loc) · 25.9 KB

Physical device support

How AXe drives a connected iPhone or iPad, what it supports and where it stops. Wire formats are in device-protocols.md; usage is in the physical device reference.

Rules

  • Devices use the same commands, options and error codes as simulators. --udid decides the target: AXe looks the UDID up in the simulator set first, then in CoreDevice's device list, and targetNotFound names both.
  • AXe never pairs a device, enables Developer Mode, mounts a developer disk image or unlocks the device. doctor detects each of these and prints the fix.
  • AXe uses the connection that Xcode's CoreDevice manages. It does not create its own tunnel.
  • Anything a device cannot do fails with unsupportedOnDevice before any work.
  • Protocol code is written from device-protocols.md and AXe's own captures, never ported from GPL code (pymobiledevice3).
  • devicectl output is read only through its JSON file output, accepting both the current properties shape and the older connectionProperties/deviceProperties shape.

How a command reaches a device

  1. CoreDevice (devicectl device info details) gives the tunnel address and the pairing, Developer Mode, connection, disk image and lock state. An idle network tunnel is reconnected by this call; list-devices reports it as unchecked rather than blocked.
  2. AXe finds the device's service directory (RSD) port on that tunnel (the port axe device-port saved for the current tunnel, then nettop; see device-protocols.md), connects, and checks the device's UniqueDeviceID against the hardware UDID before opening any service. When nettop finds nothing, the error prints a line to paste in Terminal that finds the port with netstat and saves it.
  3. A per-device broker process holds the RSD session, the HID connection and the accessibility channel across commands, so a warm command opens no connection. A broker from a different AXe build is refused (deviceBrokerMismatch) until it exits on its idle timeout.
  4. For a device on Wi-Fi the broker keeps CoreDevice's tunnel open while it lives. CoreDevice closes that tunnel about ten seconds after the last CoreDevice client finishes, whatever AXe is still sending through it; every request then goes unanswered until something asks CoreDevice for the device again. A devicectl device notification observe that waits for a notification nobody posts counts as a client, so the broker runs one and starts the next when it ends. It sends nothing to the screen and does not keep the device awake. A device on a cable keeps its tunnel, and none is run for it. Xcode's Device Hub also holds the tunnel, which is why this did not show while it was open.
  5. A command reads the device's readiness and lock state from CoreDevice when it starts: two devicectl runs, about 0.5 s together. It skips them when the broker sent input to the device in the last 25 seconds, because that input went through a working connection to an unlocked device and restarted its auto-lock timer. A failed operation or button lock ends that, so the next command reads again. A batch checks the lock state before input that follows a quiet gap of 25 seconds or more, and refuses input after its own button lock step. CoreDevice reports a device without a passcode as unlocked, even on the lock screen.
  6. A read of the accessibility tree is a new request to the device each time. The device answers in about 1 s plus 44 ms per element, in two parts; the identifiers come in the second. A read may take 20 seconds, which is about 330 elements; beyond that it fails with treeUnavailable. tap --id, --label or --value taps from one read. Only a target that appeared while --wait-timeout was polling is read a second time, and the tap is refused with targetChanged if it moved. A read that gets no answer is made again inside its time limit: when the two halves of a tree disagree because the screen changed between them, when a read's first subscription has heard nothing after 6 seconds, and when a display report, which is a new connection each time, has no answer after 2 seconds. AXE_DEVICE_TRACE=<file>, set when the broker starts, makes it append one line a step with the step's time.
Capability Service
Screenshots, screenshot streams and recordings com.apple.coredevice.screencaptureservice
Display size and orientation com.apple.coredevice.deviceinfo (displayinfo)
Touch, keyboard and buttons com.apple.coredevice.hid.indigo
rotate com.apple.coredevice.devicecontrol
Accessibility trees, point lookups, semantic press, slider values com.apple.accessibility.axAuditDaemon.remoteAXService (DTX)
Native H.264 (stream-video --format h264, record-video) com.apple.coredevice.displayservice
settings xcrun devicectl

Supported and refused

Supported: list-devices, doctor, screenshot, describe-ui (including --point), displays, tap by coordinates or --id/--label/--value with polling, tap --semantic-press on a native checkbox, swipe, drag, draw, gesture presets (with --inside-id or --inside-label) and coordinate gestures, touch --down --up, type, key, key-sequence, key-combo, slider, button home|lock|siri, batch (which can hold a contact across steps and releases it on exit), rotate, split-view on an iPhone Duo, stream-video (mjpeg, raw, ffmpeg, bgra, h264), record-video (the device's own stream, or from screenshots with --fps, --quality or --scale), settings apart from the status bar, and agent mode (--agent) on every command that has it.

Refused with unsupportedOnDevice: --input-mode selected and the screen options, shutdown, hinge, clipboard, button side-button and apple-pay, describe-ui --agent --web, and a standalone touch without both --down and --up. settings status-bar fails with settingUnsupported.

What a device's tree is

A device's accessibility service gives the list of an app's accessibility elements and nothing else. The views that hold them are not in it: the Playground's controls page is 20 elements, all children of the application, where the simulator's tree of the same page has 316 with the scroll views and groups among them. Three things follow.

  • An ID or label that belongs to a container, such as a scroll view's, names nothing on a device. gesture <preset> --inside-id and --inside-label take an accessibility element there, or an app by its label, whose area is what its elements cover.
  • A device lists what is on screen. An element scrolled out of view is not in the tree until it is scrolled back.
  • The tree cannot say which of two overlapping elements is on top. A tap by ID, label or value whose point lies in two branches' frames asks the device what is at the point, one live lookup of about 50 ms, and taps only when that is the element or part of it.

Agent mode

--agent works with a hardware UDID on describe-ui, tap, type, swipe, drag, key, key-combo, key-sequence, slider, touch, gesture double-tap, gesture pinch and batch. The agent controller is the simulator's: it plans each action as one native request and judges the reply, and a device executor answers the same requests, so a capture, a ref and a refusal mean the same on both. The device broker keeps the capture's table between commands, as a simulator's input helper does, for the 60 seconds a snapshot lives.

Every input follows one rule: read the screen again, require the capture's fingerprint and the chosen control on that read, ask the device what is at the first touch point, and only then send. Nothing is sent after a failed check and nothing is sent twice.

What differs from a simulator, each measured on an iPhone Duo (iOS 27.3):

  • The device numbers its elements afresh in every read, so a ref names an element by its type, identifier and label, which stay the same when the screen scrolls or a keyboard comes up. A control with no elements inside it is named as well by the text in its own row: text that overlaps it by half its height, or failing that the text directly above it. A list's Delete buttons therefore keep their rows' names, and after the list scrolls by one row the old ref is not found where its button was. Controls that are still identical after that are told apart by their frames, and their names take in every piece of text the app shows, so such a ref ends when any text on the screen changes: cards that scroll into each other's places end the old refs. The rule is about what the screen shows, not what iOS knows. A control that is the only one of its name on screen, with no text in its row or directly above it, keeps its name when another like it takes its place. And a control beside text that its own action changes (a slider beside its value, a stepper beside its count) has a new name afterwards: the action itself still finds it, by its type, identifier, label and frame, and the capture the action returns has its new ref.
  • With no scroll views in the tree, a capture has one scroll area per app: the rectangle its elements cover. swipe --ref and drag --ref on it move whatever scrolls under its middle, as a finger there would.
  • The first touch point is checked by one live lookup in place of the simulator's hit test: another process there (an alert, another app), or an element of the same app that is neither the target, inside it nor around it, refuses the action with targetCovered. One exception is made, because a flat tree lists a button's own title beside it: a piece of text wholly inside the target whose words are the target's label, or part of it, counts as the target's. A picture inside a control, text that says something else, and two controls of one size at one place are refused.
  • Keys are sent in parts. The field must be the chosen one with the keyboard's focus before the first key. The field is asked again before the next part after a key that can move focus (Return, Tab, a shortcut), after a wait, and every --focus-check-interval keys (16 unless set); a field that has lost focus stops the rest with fieldNotFocused. A part ends only where no key is held, with one exception: Shift held across more letters than the interval is let go for the check and pressed again. Another modifier held across many keys (a shortcut) is not interrupted, so the interval does not apply inside it. Each check is a whole new read of the screen, which is why typing costs a read per part: a lookup on the subscription a command already has can answer from before its keys.
  • slider drags the knob with one held finger and reads the slider's value from the device after each move, as the simulator does for a slider without native geometry. What is at the slider's middle is asked after every move; something else there, or no answer while the finger is down, ends the drag. It lands within 0.5 % of the range, or within 1.5 points of finger travel where that is more. A slider's value follows the finger several touch events late: on the Duo, after a drag of 100 to 230 points, the value read with the finger still down was 3 to 9 % short of where the lift then left it, and neither holding still for two seconds nor sending the end point again changed that, because a touch that has not moved is no event. So the finger closes on each stopping point in seven smaller and smaller moves either side of it before the value is read. With that a value lands in one touch: 8 to 10 seconds on the Duo, about 15 on an iPad Pro, where every read is a whole one. The value comes from a live lookup where that is current (an iPhone Duo on iOS 27.3) and from a whole read where it is not (an iPad Pro on iPadOS 27.2 went on answering a lookup with the value from before the drag); the value after the finger lifts is always from a whole read.
  • A read is the device's own work: from the request to the tree it took 1.3 to 1.5 seconds on the Duo (iOS 27.3) and 2.3 to 2.5 on an iPad Pro (iPadOS 27.2.1), in two parts, of which the second holds the tree. An action reads twice, once to check the screen before its input and once for the capture it returns, so on the iPad a capture takes 2.6 s, a ref tap about 5.4 s and type --focus 11 to 13 s (release build, 3 December 2026; each is the command alone, after the one before it).
  • An action's check before its input is always a fresh read. Using the read that ended the action before was tried on 3 December and taken out: a device does not push every change (an iPad Pro pushed nothing when the Playground showed a hidden button), each live confirmation that would stand in for the read left a case open, and the device pushed after nearly every command anyway, so a kept read stood once in a 21-action sweep.
  • Readiness (pairing, Developer Mode, the lock) is read with two devicectl runs, 0.75 to 0.9 s, by a command that follows no input in the last 25 seconds. When the broker's connection already works, that read runs beside the command's own read; no input goes and no answer is returned before it has passed, so a locked device is refused as before.
  • In split view every read also asks SpringBoard where the two apps are, and reads the half iOS does not send when the read wants it. Until 3 December 2026 that was 16 round trips of about 70 ms (1.1 s) a read for the left half's app and 36 (2.6 s) for the right half's. Three changes cut it. With two apps on screen the left one is the app iOS pushes and SpringBoard lists first, so one lookup confirms its place instead of the seven that found it (the long way still runs when that lookup fails). The divider's and the scene card's identifier and frame come in one request each instead of two. And the other app is read a level at a time: each whole-element read the device answers asks at once for all its children's, which go together and come back in the order they went. Their answers name no element, so that order is all that ties each to its request; on an iPhone Duo (iOS 27.3), 42 reads of five screens done both ways in the same read gave the same tree every time, with up to 21 requests in flight answered in 0.1 s. AXE_LIVE_BATCH=off, set when the broker starts, reads one element at a time again, and compare reads both ways and traces whether they matched. Reading the right half's app went from 0.8–1.6 s to 0.18–0.30 s, and a left-half agent capture from 3.0 s to 2.4 s.
  • Hosted web pages are not read: --web is refused.

Orientation

The digitizer takes points normalized to the device-portrait frame: the display's current mode size, with its axes swapped when the native orientation is rot90 or rot270, divided by the UI scale. The interface rotation is (currentOrientation + nativeOrientation) mod 360; on an iPhone (native rot0) that is currentOrientation alone. On panels whose native orientation is not rot0, such as the iPad Pro's rot270, every touch, point lookup and screenshot video first compares the device's reported orientation with the display and returns displayOrientationMismatch without input when they disagree and a read of the screen cannot settle it, because an iPad can keep reporting its previous display orientation after a software rotation. The read settles it by the shape of a screen-sized app frame: the device orientation wins when the app has its shape and not the display's, and the display wins the other way round, which is what an app that does not take the device orientation would show. A window that does not fill the screen, or two reports of the same shape (the two landscapes), settle nothing. The settlement holds for one command while the display report stays the same; a command that needs it and has not read the tree pays one read, about 2.5 s on an iPad. On 3 December 2026 an iPad Pro on a keyboard case stayed in landscapeLeft with its display reporting upside-down portrait after the rotation checks; with the settlement, coordinate taps there landed exactly where they were aimed. A screenshot is turned by the device itself, so in that state it still comes out sideways. rotate needs Orientation Lock off (otherwise rotationLocked) and succeeds only when the display reaches the orientation the device reports; it returns rotationUnconfirmed once the display has stood still for 2.5 seconds without reaching it, for example when an iPhone is asked to turn upside down.

iPhone Duo

A Duo reports two built-in displays. primary stays on the outer one whichever is lit; active marks the one in use. AXe reads the display report before every touch, tree read, screenshot and video start, takes the active display and names it in the request: the digitizer target is its displayId, the screenshot's displayUniqueID is its uniqueId, and the native stream asks for its displayId. A device with one built-in display is still sent target 0 and no display ID.

Measured on an iPhone Duo on iOS 27.3, open, with v2.2.0, which named no display: the screenshot was the outer display, black; a touch sent with the inner display's geometry and target 0 did nothing on the inner screen; the native stream, asked for the outer display, sent no frames. With the active display named, the screenshot is the inner screen (2853 × 2007 in landscape), the same touch lands, and the native stream carries the inner screen.

  • When the report has neither or both displays active, as a Duo simulator's has while it folds, commands fail with screenChanged. A display snapshot taken before a fold does not equal one taken after it, and a held contact, a tap from an earlier tree read and a recording all compare the two and stop with screenChanged. On the device, a recording of the inner screen stopped that way when the Duo was closed, and the next screenshot, tree read and tap --label used the outer screen. A recording that stops this way is not saved.
  • The inner display reports a mode size of 2007 × 2853 and a native size of 1878 × 2670. Screenshots, accessibility frames and the digitizer use the mode size: 669 × 951 points.
  • The accessibility tree's application frame is 669 × 951 in landscape as well; element frames are in the interface orientation.
  • Split view puts two apps side by side on the inner screen, in landscape only and always split down the middle. The device's tree holds the app in the left pane, whichever pane was touched last or has the keyboard, and each app reports frames relative to its own pane, so the right pane's are 482 points too far left. A read on the inner screen therefore starts with a point lookup on the dividing line, three round trips of 30 to 80 ms each, and stops there unless it finds SpringBoard's splitview-handle. In split view SpringBoard names the applications on screen, and gives a card for one application's scene when an app has its attention; the card's frame is that pane, and it supplies the gap between a pane and the handle (4 pixels when there is no card). AXe reads each other application element by element, decides each one's pane by looking a few of its elements up in both panes, moves its frames by the pane's origin and lists the applications left first. An application is listed only when one of its first elements answers at its moved position with its own process, which keeps out an app that has just left the screen; when none can be placed the pushed tree is returned as it came. describe-ui, describe-ui --point, tap --id, --label and --value, tap --semantic-press and slider work in either pane. A semantic press on a control in the pushed tree is made from that tree, read twice around the press; one in the other pane is found in the whole screen's read and pressed where a live lookup finds it. Agent mode keeps to one app, the left pane's unless --expected-pid names the other. The device pushes the left pane's tree whichever app the agent wants; the right pane's app is read element by element, one round trip each, only when it is the agent's, and is otherwise listed by name. A half that shows the home screen is named in capture.splitView with home and SpringBoard's process, and its icons are not read: capturing it by that process is refused with unsupportedOnDevice. The second app costs about one round trip an element: Settings and Claude, 25 elements between them, took 3.7 s, and Claude beside a web page of 70 elements took 5.3 to 7.5 s, where the left app alone took 2.3 s.
  • split-view reads the same handle. Its value is Pinned or Not Pinned and its custom actions arrange the halves: Full Screen <app> and Dismiss <app> for each app, left first, Swap Positions, Pin Apps or Unpin Apps, and Switch Left and Switch Right, which open an app switcher inside that half. swap, full, home, pin and unpin perform them: an action request for an element the pushed tree does not hold, admitted for that one command on a fresh tree. left and right are a touch stroke, the home gesture carried to one side, since there is no handle until the screen is split. With the home screen in one half iOS lists the handle's actions and ignores them, so swap, full and home are strokes then too. Each took 2 to 7 s on the device, most of it reading the handle before and after. The translator on the Mac keeps the first list of custom actions it read for an element, so AXe clears that before each read; without it the handle went on listing Pin Apps after it was pinned.
  • A stroke from an edge needs the edge named in each touch, or iOS takes it as a touch on the app. The digitizer numbers the panel's own edges, whichever way the interface is turned: left 1, bottom 3, right 4, and 0 for the top, which is also "no edge". In landscape with the camera on the right the bottom of the interface is the panel's right edge, value 4: the bottom-edge preset there went home on the device on 2 December 2026. The other places the panel's right edge can be (the right-edge preset in portrait, the left-edge one upside down) are filled in from that and not measured.
  • The device's tree carries a link's address as an NSURL, which the Mac's decoder for these replies refuses, so a screen with a web link in it failed with "invalid accessibility tree archive" (Claude showing links, X showing a web page). AXe replaces each with its address as text before decoding.
  • A recording of the inner screen from screenshots (record-video --fps) reached 1.2 to 2.3 fps at full size (2852 × 2006). record-video alone reached 56 fps: the native H.264 stream, 1408 × 2016 in the panel's native orientation, saved with a transform that plays it upright at 2016 × 1408.
  • hinge stays simulator-only. displays shows the screen in use, outer or inner; the display report's other screen is not read.

iPad windows

On an iPad an app is a window that can be anywhere on screen, and it reports its frames from its own window's corner with the window's size as its application frame. This was measured on the iPad simulator (iPadOS 27.3); no physical iPad has been read this way yet. SpringBoard's scene card for the app, the same attribute the iPhone Duo's split view uses, has the window's rectangle on screen. On a device the read hit-tests the status bar to reach SpringBoard, asks for the card, takes it for the pushed app's when it has the window's size, moves the tree by the card's origin and keeps the move only when one of the app's controls answers a hit test at its new place. Anything that does not fit, or any failed request, returns the pushed tree unchanged, so a device that behaves differently reads as it did before. Other windows on screen are not added on a device, and axe split-view is refused on a physical iPad: its window menus have been driven on the simulator only.

Native recording

record-video starts the same display stream as stream-video --format h264 and writes its pictures into an MP4 as they arrive, without decoding or encoding them. The movie starts at the first keyframe that carries its parameter sets; each picture is stored with the time it arrived, and pictures between keyframes are marked as such. The stream keeps the panel's native orientation, so the movie carries a rotation that plays it upright for the interface orientation at the start. Measured on an iPhone Duo's inner screen in landscape: 393 pictures in 6.95 s, 56 a second, in a 177 KB file, against 16 pictures at 2.3 a second from screenshots. The file is finished and in place as soon as recording stops; the command then waits for the device to end the stream, 19.6 s in that run. --fps, --quality or --scale choose the screenshot recording, which those options belong to; a stream that cannot start says so. Rotating or folding the device during a native recording is not handled: the stream follows the display it started on.

Known limitations

  • The device sends one native display stream at a time. Native H.264 and Xcode Device Hub's screen view replace each other's stream, and AXe then exits with deviceStreamReplaced. Screenshots, screenshot streams, recording, reads and input work alongside Device Hub.
  • Native H.264 frames keep the panel's native orientation. AXe passes them through and states on stderr how many degrees clockwise to rotate them. Stopping waits for the session to disappear, which can take about 20 seconds.
  • Status bar overrides are simulator-only.
  • Devices with native rot90 or rot180 panels follow the orientation rule but are untested.
  • The lock button needs --allow-lock, and a person must unlock the device again.
  • If a modal alert blocks the accessibility tree, close it on the device and read again.
  • type sends up to 256 UTF-8 bytes per command with the US key layout; focus the field on the device first.

Device test suite

DEVELOPER_DIR=/absolute/path/to/Xcode.app/Contents/Developer make e2e-devices

The suite is opt-in and exits 1 before building when no physical iPhone or iPad is paired. It installs the Playground on each device and reads every result back from the device; see Playground testing for the checks, environment variables and what it does not cover. Unit tests in Tests/PhysicalDeviceFixtureTests.swift cover both CoreDevice JSON shapes, readiness states, the RemoteXPC codec and the orientation rule without hardware.