Skip to content

Use usbmuxd for physical Apple device discovery instead of spawning devicectl/xctrace #1522

Description

@thymikee

Context

#1403 asked whether the usbmux client should grow beyond the runner transport, and set the bar at "a second concrete product use case". Measuring #1517 produced one.

In the final cabled capture from #1517, resolving the target device cost 6672 ms:

resolve_target_device  6672 ms
open_timing             982 ms

Device resolution is an order of magnitude more expensive than anything the transport change saved per command. It shells out to devicectl list devices, xctrace list devices, simctl list devices, plus the Android and web probes, and pays process-spawn cost for each. Earlier uncached resolutions in the same investigation measured 4.5–6.8 s.

usbmuxd answers ListDevices over a unix socket in milliseconds, and it is already the authority on which physical iOS devices are attached — the same authority #1517 now trusts for routing.

Proposal

Use usbmuxd as a fast path for physical Apple device discovery, on the plist protocol the client already speaks (runner-usbmux-protocol.ts, roughly 50 LOC of additions):

  • ListDevices to enumerate attached physical devices without spawning anything
  • optionally Listen to stream attach/detach events, which would let a long-lived daemon keep an accurate device list instead of re-probing

usbmuxd returns the UDID and connection type but not the display name, OS version, or anything about Wi-Fi-only devices, so this is a fast path rather than a replacement: it can confirm which devices are cabled immediately, with the existing tooling filling in metadata or covering Wi-Fi-only devices. The exact split is the main design question here.

Why it is worth doing

Non-goals (unchanged from #1403)

A public port-forward command, reverse forwarding for Metro or React DevTools, lockdownd services (installation proxy, AFC, syslog relay), and extracting a general-purpose usbmux package — that last one was evaluated during #1403 and rejected: one internal call site does not justify a package boundary, and a published client would immediately attract the whole libimobiledevice surface area.

Acceptance

  • Measured before/after on resolve_target_device for a cabled physical device
  • Wi-Fi-only and simulator resolution keep working unchanged
  • No behaviour change when usbmuxd is unavailable — it degrades to today's path

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions