Skip to content

sysmon exits with code 0 and no data when xcuitest is active (iOS ≤ 16); tunneld fallback fails for some devices (iOS 17+) #1682

@selahattinceylan-testinium

Description

What happened?

pymobiledevice3 developer dvt sysmon system fails when xcuitest is already running on the same device. Two different failure modes:

iOS ≤ 16: The command exits with code 0 and writes nothing to stdout. Only stderr shows "Connection was terminated abruptly". Since exit code is 0, there's no way to programmatically detect the failure.

iOS 17+: The command gets InvalidServiceError, falls back to tunneld, but the fallback works for some devices and fails for others — on the same host, same tunneld process. Failing devices get IncompleteReadError: 0 bytes read on a total of 9 expected bytes
during XPC handshake. rsd-info works fine for all devices.

Expected: sysmon should either coexist with xcuitest, or fail with a non-zero exit code. On iOS 17+, tunneld fallback should work consistently for all connected devices.

How can we reproduce this?

# 1. Start xcuitest on device
  pymobiledevice3 developer dvt xcuitest com.facebook.WebDriverAgentRunner.xctrunner --udid <UDID> &
  sleep 5                                                                                                                                                                                                                                                              
   
  # 2. Run sysmon on the same device                                                                                                                                                                                                                                   
  pymobiledevice3 developer dvt sysmon system --udid <UDID>; echo "EXIT_CODE: $?"
                                                                                                                                                                                                                                                                       
  # iOS ≤ 16: exits with code 0, stdout empty, stderr shows "Connection was terminated abruptly"                                                                                                                                                                       
  # iOS 17+: works for some devices, fails with IncompleteReadError for others on the same host

Environment

Host OS: Linux (Docker container)
Python: 3.12
pymobiledevice3: latest (pipx)
Background: pymobiledevice3 remote tunneld running

Tested devices:

  • iPhone9,3 / iOS 15.8.3 → DTX connection terminated (exit code 0)
  • iPhone10,4 / iOS 16.7.10 → DTX connection terminated (exit code 0)
  • iPhone10,6 / iOS 16.7.11 → DTX connection terminated (exit code 0)
  • iPhone17,5 / iOS 18.6.2 → tunneld fallback SUCCESS
  • iPhone15,4 / iOS 18.6.2 → tunneld fallback FAIL (IncompleteReadError)
  • iPhone14,7 / iOS 26.0.1 → tunneld fallback FAIL (IncompleteReadError)

All devices: developer mode enabled, DDI mounted, paired

Relevant log output

# iOS ≤ 16 output:
  $ pymobiledevice3 developer dvt sysmon system --udid <device>; echo "EXIT_CODE: $?"
  INFO DTX reader exiting: connection terminated
  ERROR Connection was terminated abruptly
  EXIT_CODE: 0

  # iOS 17+ failing device output:
  $ pymobiledevice3 developer dvt sysmon system --udid <device>
  WARNING Got an InvalidServiceError. Trying again over tunneld since it is a developer command
  IncompleteReadError: 0 bytes read on a total of 9 expected bytes

  # iOS 17+ working device output (same host, same tunneld):
  $ pymobiledevice3 developer dvt sysmon system --udid <device>
  WARNING Got an InvalidServiceError. Trying again over tunneld since it is a developer command
  ERROR Error in channel on_closed handler for channel 2
  TypeError: Queue does not support shutdown()
  vmFreeCount: 25701
  CPU_TotalLoad: 80.53
  EnabledCPUs: 6
  # ... data returned successfully despite the TypeError

Search

  • I searched for existing open and closed issues before opening this

AI assistance

Claude assisted with formatting and structuring this report. The debugging, device testing, and data collection were done manually.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

  • pymobiledevice3 remote rsd-info works for all iOS 17+ devices — RSD connectivity is fine, the issue is specific to tunneld's per-device tunnel stability.
  • The working iOS 17+ device (iPhone17,5) also shows the TypeError: Queue does not support shutdown() traceback but still returns data. The failing devices crash before reaching that point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions