Skip to content

fix(wda): listen on the phone's loopback only - #180

Merged
Derrors merged 1 commit into
mainfrom
fix/wda-loopback-only
Nov 24, 2026
Merged

Derrors merged 1 commit into
mainfrom
fix/wda-loopback-only

Conversation

@Derrors

@Derrors Derrors commented Nov 24, 2026

Copy link
Copy Markdown
Owner

What and why

WDA was launched in the background with an empty environment (Tunnel::launch_in_background), and without USE_IP it listens on every interface of the phone. With the phone on Wi-Fi, anyone on the network could drive it through port 8100 (plain HTTP, no authentication) and watch it on 9100 (MJPEG). This is independent of the planned Wi-Fi control (docs/dev/wifi.md §4.2) and is fixed on its own.

  • WDA is launched with USE_IP=127.0.0.1 (ictl_wda::runner::WDA_BIND_IP / launch_env()), in the background and by the debug XCTest runner. usbmuxd's connections arrive on the phone's loopback, so the daemon, wda-bridge and the viewer still reach it.
  • A background WDA launched by an older version is not attached to again but launched anew once: state.json gains loopback_wdas (serde default, omitted when empty), and Persisted::adoptable_for only returns a WDA recorded there. Older versions keep reading detached_wdas; a WDA they launch gets a new pid, so it isn't adopted by this version either. The event log says why it is relaunched.
  • Docs: CHANGELOG (both), regression case test: strengthen device regressions, tab grouping, and compare validation #168, architecture, D3 addendum, docs/dev/wifi.md.

Tests

1. Unit tests

  • New: the_launch_environment_is_a_dictionary_of_strings (ictl-device), only_a_loopback_only_background_wda_is_attached_to_again (ictl-daemon); existing each_device_keeps_its_background_wda, an_older_versions_background_wda_is_still_known still pass
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings and cargo test --workspace --all-features --locked pass locally
  • No existing test removed, ignored or loosened
  • #[ignore] tests of the changed area run by hand: none apply

2. Real-device regression

iPhone 18 Pro Max (iPhone19,7, iOS 27.2.1) on USB, macOS host, forced onto WDA with ICTL_IOS_BACKEND=wda (iOS 27 drives natively by default and doesn't use WDA). WDA on the phone reports build 16.15.2.

Step Before (0.2.9, no USE_IP) After (this branch)
curl http://<phone Wi-Fi IP>:8100/status from the host over the network 200 connection failed (curl exit 7); phone still answers ping
curl http://<phone Wi-Fi IP>:9100/ 200 connection failed (curl exit 7)
WDA /status over usbmuxd (wda-bridge) ready ready
MJPEG on 9100 over usbmuxd (same request as the viewer) — HTTP/1.0 200 OK, 3 JPEG frames in 8 s
Background WDA from the old build at upgrade — not adopted, relaunched (pid 43375 → 43379), event log line shown, loopback_wdas recorded
Tools over WDA — auto-unlock, press_button home, tap_element 设置, list_elements, WDA screenshot all work
Back to native (setting removed, main build) — the recorded background WDA ended, records cleared, native ready

Caveat: the network probe ran from the host itself against the phone's Wi-Fi address (not from a second machine on the LAN); the route went through the host's network, not usbmuxd.

3. Regression cases (docs/dev/regression-cases.md)

🤖 Generated with Claude Code

WDA was launched in the background with an empty environment, and without
USE_IP it listens on every interface of the phone: with the phone on Wi-Fi,
anyone on the network could drive it through port 8100 (no authentication)
and watch it on 9100. Launch it (and the debug XCTest runner) with
USE_IP=127.0.0.1; usbmuxd's connections arrive on the phone's loopback.

A background WDA an older version launched is no longer attached to but
launched again once: state.json records loopback-only ones (loopback_wdas).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Derrors
Derrors merged commit 40ffb1d into main Nov 24, 2026
7 checks passed
@Derrors
Derrors deleted the fix/wda-loopback-only branch November 24, 2026 08:26
@Derrors Derrors mentioned this pull request Nov 24, 2026
12 tasks done
Derrors added a commit that referenced this pull request Nov 24, 2026
Version 0.2.14 in Cargo.toml and Cargo.lock (this workspace's crates only),
and the changelogs' 0.2.14 section with #180 and #182.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant