Skip to content

Android: only one emulator per worker joins Wi-Fi (shared netsim, same snapshot) #1586

Closed

Description

@vitalyiegorov

What happens

When a worker runs more than one Android emulator, only one of them joins Wi-Fi. The others report Wifi is not connected and reach the network only over the emulated mobile data link (eth0).

Seen on a simlock 0.6.0 worker (macOS 15.7.4 arm64, emulator 37.2.13) with four emulators booted:

Emulator cmd wifi status wlan0 IPv4
emulator-5586 connected to "AndroidWifi" 10.0.2.16/24
emulator-5588 not connected none
emulator-5590 not connected none
emulator-5592 not connected none

All four were started from the same AVD and snapshot (qemu-system-aarch64-headless -avd simlock ... -snapshot simlock_boot), and a single netsimd serves every instance on the host.

Why it matters

Which device gets Wi-Fi depends on boot order, so it changes from lease to lease. A test that checks the connection type (for example NetInfo type === 'wifi'), or app logic that only works on Wi-Fi, passes or fails depending on which emulator it was leased. Consumers currently work around it by forcing every device onto mobile data.

Suspected cause (not verified)

Every instance restores the same snapshot, so all of them likely come up with the same Wi-Fi MAC address. They all share one netsim radio, so the instances collide and only one association succeeds. I couldn't read the MAC from the guest without root to confirm this.

Possible fixes

  • Give each emulator its own netsim instance (-netsim-args / netsimd --instance <n>, keyed off the console port), or
  • give each emulator a unique Wi-Fi MAC at launch or after a snapshot restore.

Expected result: every leased emulator has its own working Wi-Fi.

Activity

  1. added
    bug:new
    on Nov 18, 2026
  2. self-assigned this
    on Nov 18, 2026
  3. V3RON commented on Nov 18, 2026

    @V3RON
    Contributor

    Handoff

    Done: reproduction pushed to bug/1586-repro: e2e/slow-android-wifi.test.ts, "two Pixel 9 leases held at once both report Wi-Fi connected with an IPv4 address on wlan0". Not run: only real emulators show it.

    Not done: the failing run, root cause confirmation, fix trial, report.

    Findings: simlock passes nothing per copy for Wi-Fi (src/drivers/android/emulator.ts:257); every copy boots -snapshot simlock_boot (index.ts:632). The emulator sets a unique Wi-Fi MAC at cold boot from a kernel mac_prefix; a snapshot load keeps the seed's. Since 36.5 all instances share one Wi-Fi network, so equal MACs collide. Candidate fixes, untested:

    emulator -help: -wifi-mac-address <mac>  "only applies ... loaded from snapshot using read-only mode"
    -feature -WiFiPacketStream               old per-instance router (developer.android.com, emulator-networking-interconnect)
    -netsim-args "--instance <n>"            one netsimd per emulator
    

    Blocked on: a slow-lane run of e2e/slow-android-wifi.test.ts.

    Written by an agent.

  4. added
    bug:blocked
    and removed
    bug:new
    on Nov 18, 2026
  5. removed their assignment
    on Nov 18, 2026
  6. added a commit that references this issue on Nov 19, 2026
  7. V3RON commented on Nov 19, 2026

    @V3RON
    Contributor

    Reproduction

    e2e/slow-android-wifi.test.ts on bug/1586-repro, "two Pixel 9 leases held at once both reach the Wi-Fi gateway over wlan0". It now pings 10.0.2.2 over wlan0: right after a snapshot load every copy still reports "connected", with the seed's address.

    scripts/slow-e2e.sh e2e/slow-android-wifi.test.ts      # emulator 37.2.13, macOS arm64
    emulator-5588: Wifi is enabled / …  { connected: false, wlan0Ipv4: false, gatewayAnswers: false }
    emulator-5590: Wifi is enabled / …  { connected: false, wlan0Ipv4: false, gatewayAnswers: false }
    

    Root cause

    Defect. A cold boot sets the Wi-Fi MAC from the console port (5654 → 02:16:16:00:00:00); a snapshot load keeps the seed's. Every copy boots -snapshot simlock_boot (src/drivers/android/index.ts:632) with no per-copy Wi-Fi flag (src/drivers/android/emulator.ts:364). So copies share one MAC and IP on the one netsim Wi-Fi network the host's emulators have shared since emulator 36.5, and at most one of them stays associated.

    Simplest fix

    Add -feature -WiFiPacketStream to emulatorLaunchFlags, so each emulator has its own Wi-Fi router, and add it to seedLaunchInputs (index.ts:902), so older seeds go stale and are remade under it. Tried: the reproduction passed (248 s, seed remake included).

    Copies working, 3 booted at once, by hand:

    no change                        4/12
    -feature -WiFiPacketStream      12/12  (seed without the flag: Wi-Fi ~55 s after ready)
      same, seed made with it        6/6   (Wi-Fi within 9 s; ready in 5–6 s, as today)
    

    Alternatives rejected

    • Port-derived -wifi-mac-address (± -read-only): 8/12 and 10/12; copies keep the snapshot's IP.
    • -netsim-args --instance <n>: the emulator can't reach its netsimd; hangs or segfaults.
    • One netsimd per copy via -packet-streamer-endpoint: 12/12, but simlock would run and reap a netsimd per device.

    Risk

    • Emulators on one worker no longer share Wi-Fi with each other; traffic through the host (10.0.2.2, tunnels) is unchanged.
    • Untested on Linux/Windows and other images; a future emulator may drop the feature.
    • Every existing seed is remade once.

    Fast track

    • Defect: yes
    • Fix tried: no — 83 unit tests whose fakes pin the emulator command line need the new flag
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: no — a shared-network fix would keep emulator-to-emulator Wi-Fi

    Written by an agent.

  8. added
    bug:ready
    and removed
    bug:blocked
    on Nov 19, 2026
  9. self-assigned this
    on Nov 19, 2026
  10. V3RON commented on Nov 19, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: #1764 (#1586)
    Decided: #1586 — should saved Android baselines go stale when the Wi-Fi flag is added? → no: only seeds are remade; a copy of a baseline saved before the change joins Wi-Fi about a minute after it is ready (#1764 (comment))

    Written by an agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions