Skip to content

Android: boot snapshot is saved before the cellular data call is up, so every lease starts offline #1631

Closed as not planned

Description

@cchatfield

Summary

On Android, simlock saves the seed's simlock_boot snapshot before the emulated cellular data call is up, and readiness never checks the network. Every lease restored from that snapshot starts with no network. On our host, 13 of 13 google_atd leases had no route when simlock lease returned. They came online 16 to 58 s later.

Related: #1586 (the same idea for Wi-Fi: per-device network state frozen in the shared snapshot).

Environment

  • simlock 0.7.0, emulator 37.2.13, platform-tools 37.0.1, Linux x64 (WSL2), headless.
  • --platform android --device "Pixel 9" --os 36 --image-tag google_atd --mode full, warm pool off.
  • Default slirp networking. No -netdelay, -netspeed or -net-tap.

What happens

  1. dist/drivers/android/seeds.js:491-496 (#bootToSnapshot) starts the seed with -no-snapshot-load, waits for readiness, and calls #saveBootSnapshot at once.
  2. dist/drivers/android/seeds.js:517-520 (#saveBootSnapshot) runs adb emu avd snapshot save simlock_boot.
  3. Readiness is dist/drivers/android/emulator.js:128-171 (waitForReadiness, #bootSettled). It checks sys.boot_completed, init.svc.bootanim and pm path android. It does not check connectivity.
  4. In the seed's boot log, the save came 1.7 s after sys.boot_completed. The SIM had just reported READY, the radio was not in service, and no SETUP_DATA_CALL had been sent.
  5. After a lease restores the snapshot, telephony resumes. Data stays disallowed (SIM_NOT_READY DATA_CONFIG_NOT_READY NO_SUITABLE_DATA_PROFILE NOT_IN_SERVICE DEFAULT_DATA_UNSELECTED) until SIM records and carrier config load. Then SETUP_DATA_CALL is sent, eth0 comes up with 10.0.2.15/24, and ConnectivityService reports validation passed.

Until then, the guest has:

  • eth0 state DOWN, with no address;
  • no oif eth0 rules in ip rule, so lookups fall through to 32000: from all unreachable;
  • dumpsys connectivity: Active default network: none;
  • connect: Network is unreachable for any host, 10.0.2.2 included, and failing DNS.

Tests that start right after the lease see sign-in and CAPTCHA failures and EHOSTUNREACH.

Per-lease measurements

One lease at a time, same seed each time.

lease network at lease return online after host load1
c1 down about 35 s 8
c2 down about 35 s 17
c3 down 30 s 14
c4 down 55 s 14
c5 down 51 s 30
c6 down 16 s 39
c7 down 40 s 44
c8 down 37 s 63
c9 down 24 s 53
c10 down 58 s 49
i1 down 41 s 53
i2 down 51 s 73
i3 down 30 s 48

Down at lease return: 13 of 13. Still down 60 s after lease: 0 of 13. Recovery time does not track host load. c1 and c2 were polled every 10 s, so their times are approximate.

Proposed fix

Either of these would close it:

  1. In #bootToSnapshot, wait for a validated default network before #saveBootSnapshot. For example, poll dumpsys connectivity until the active default network has VALIDATED, with a bound. The snapshot then holds a guest whose data call is already up.
  2. Add the same network check to readiness, so a lease is not granted until its guest is online. This also covers a restored guest that has to redo the data call.

Option 1 removes the delay for every lease. Option 2 is a safety net for images whose network state does not survive a restore.

Workaround

We now wait in our e2e harness after each lease, for up to 120 s, for a validated default network that reaches our backend host.

Activity

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

    @V3RON
    Contributor

    Reproduction

    Gap, not a defect: readiness never promised a network, and nothing waits for one before the save. The test's expectation is a proposal. Branch bug/1631-repro, src/drivers/android/seeds-copies.test.ts, "saves a seed's boot snapshot only once the guest reports a default network". The fake guest reports Active default network: none twice, then 100.

    pnpm exec vitest run --project unit src/drivers/android/seeds-copies.test.ts -t "default network"
    AssertionError: expected 'never read' to be '100'
    

    Confirms the report. The source lines are src/drivers/android/seeds.ts:631-640 and emulator.ts:194-249, not dist/.

    Root cause

    src/drivers/android/seeds.ts:637: #bootToSnapshot calls #saveBootSnapshot as soon as emulator.start returns. start returns once waitForReadiness passes (emulator.ts:194), and that checks only sys.boot_completed, init.svc.bootanim, the AVD path and pm path android (emulator.ts:228-249). So the snapshot every copy resumes holds a guest whose data call is not up yet. The leases are only where the symptom shows.

    Simplest fix

    In #bootToSnapshot, before the save, poll adb -s <serial> shell dumpsys connectivity every 1 s until it matches ^Active default network: \d+. Bound the wait at 120 s, and past the bound save anyway, as today. The test fakes (test-seed-harness.ts, test-emulator-host.ts, two-instances.test.ts) answer the probe with a network.

    pnpm exec vitest run --project unit src/drivers/android/   # 41 files, 739 passed
    pnpm test:changed                                          # 106 files, 1510 passed
    

    Alternatives rejected

    • Wait for VALIDATED: validation needs the host's internet, so an offline host would always wait out the bound.
    • Wait in readiness (option 2): every lease would return 16-58 s later.
    • Fail the make at the bound: a host or image with no data call would lose Android.

    Risk

    • Only the slow lane proves that a restored copy is online when its lease returns. Make that a Done when line.
    • Seeds made before the fix stay offline. Check whether the fix must mark them stale, as the -WiFiPacketStream change did.
    • The dumpsys connectivity lines are not recorded from a real emulator. Record a fixture.

    Fast track

    • Defect: no — a gap: readiness never promised a network
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: no — the readiness wait would change when leases return

    Written by an agent.

  4. removed their assignment
    on Nov 19, 2026
  5. V3RON commented on Nov 19, 2026

    @V3RON
    Contributor

    Folded into #1748 (Android settle of #1732). We won't fix it separately.

    The settle replaces a kind's quick seed with a snapshot saved from an idle copy, and #1748 now requires that copy to have a default network before the save. Measured on this Mac (Android 36 google_apis, emulator 37.2.13):

    • A snapshot saved at ready, as today, has Active default network: none. Restored, it came online about 5–6 s after ready, here through Wi-Fi.
    • A snapshot saved with a default network restored with it 3 of 3 times: Active default network: 100 and a ping to 8.8.8.8 both answered at ready, 2.0 s after launch.
    • The wait can listen rather than poll. adb logcat -T 1 -m 1 -e 'CONNECTED broadcast.*isDefaultNetwork=true' ConnectivityService:D '*:S' exits within about 0.7 s of ConnectivityService picking a default network. -e matches the message only, so the tag goes in the filter spec. A netlink ip -o monitor route | grep -m1 '^default' also fires, but it sees a route, not Android's choice of default network.

    What stays as it is: the first leases of a kind, which copy the quick seed before its settle; a worker that is never quiet; and Android baselines. The triage's repro test is on branch bug/1631-repro.

    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

No one assigned

    Labels

    bug:new

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions