Skip to content

Android leases time out with no reason when the emulator rejects -crash-report-mode (Emulator 36.1.9) #1199

Closed

Description

@saibotma

What happened

With Android Emulator 36.1.9, every Android lease waited about three minutes and then failed:

$ simlock lease --platform android --device "Pixel 9" --detach --ttl 10m --timeout 6m
{"push":"progress","stage":"provisioning","etaMs":1000}
{"push":"progress","stage":"booting","etaMs":70000}
{"error":{"code":"INTERNAL","message":"Timed out waiting for device to boot: dev_0a628b60-efcd-49b2-a23f-aea62103186c"}}

No emulator process ever appeared while the lease waited, and simlock doctor reported no findings.

To find out why, I copied the AVD that Simlock created during a lease and started it myself with the same arguments. The emulator stopped at once:

INFO         | Android emulator version 36.1.9.0 (build_id 13823996) (CL:N/A)
INFO         | Graphics backend: gfxstream
INFO         | Found systemPath /Users/<me>/Library/Android/sdk/system-images/android-36/google_apis_playstore/arm64-v8a/
unknown option: -crash-report-mode
please use -help for a list of valid options

After updating the emulator to 37.2.13 (sdkmanager --install emulator) and restarting the daemon, leases boot normally.

What you expected

Simlock to say that the installed emulator can't be used, for example in the lease error or in simlock doctor, instead of a boot timeout with no reason. A boot that can never succeed shouldn't take the full boot timeout to fail either.

How to reproduce

  1. Install Android Emulator 36.1.9 (the version Android Studio installed here until recently).
  2. simlock daemon start
  3. simlock lease --platform android --device "Pixel 9"

It failed every time (five attempts, through the CLI and through agent-device).

Environment

  • Simlock 0.5.0, Android
  • macOS 26.6.1 (arm64), Xcode 27.2, Android Emulator 36.1.9, platform-tools 36.0.0, cmdline-tools 19.0
  • simlock doctor: {"findings":[]}

Logs and evidence

Daemon log for one attempt:

{"level":"warn","module":"daemon.device-provisioner","message":"new device failed to become ready","fields":{"deviceId":"dev_bee0f4d1-1613-4f06-9331-5bff0692e2a2","step":"boot","error":"BootTimeoutError: Timed out waiting for device to boot: simlock_5692ecb6-ae11-46c0-98ec-f3b9c075d58a"}}
{"level":"error","module":"daemon.server.dispatch","message":"operation","fields":{"operation":"lease.request","role":"agent","durationMs":182578,"code":"INTERNAL","message":"Timed out waiting for device to boot: dev_bee0f4d1-1613-4f06-9331-5bff0692e2a2"}}

emulator -help on 36.1.9 doesn't list -crash-report-mode; on 37.2.13 it does.

Activity

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

    @V3RON
    Contributor

    Automated triage. I read the code only. I wrote no failing test and pushed no bug/1199-repro branch, because this routine changes no code. A maintainer or the triage-bug flow still needs to add that test.

    Classification: Android bug, a regression in 0.5.0. Labelled platform:android. It stays bug:new. Moving it to bug:ready is a maintainer call.

    Root cause. This is a defect with two parts:

    1. Defect. src/drivers/android/index.ts:2282 always passes -crash-report-mode never to the emulator. That flag came in with 20c3640 (fix(android): start the emulator with -crash-report-mode never #1186), the fix for Android: a stale emulator crash dump makes every boot wait on a crash-report dialog until the lease times out #1183, and shipped in 0.5.0. Simlock never checks whether the installed emulator supports the flag. Per the report, Emulator 36.1.9 rejects it, so the emulator exits at once. src/drivers/android/index.ts:2020 (#emulatorVersion) already reads emulator -version, but nothing uses the result to gate the flag.
    2. Gap. That is why the lease waits the full timeout. The emulator is spawned with stdio: "ignore", and #waitForReadiness (src/drivers/android/index.ts:2126) only polls adb getprop until BootTimeoutError. It never notices that the process has already exited, and it has no stderr to report. simlock doctor has no check for the emulator version either.

    Simplest fix (proposal). Pass -crash-report-mode only when the emulator supports it: a version check, or a one-time emulator -help probe. Also, fail the boot as soon as the spawned emulator exits, with an error that quotes its stderr tail. Deciding on a minimum supported emulator version (a doctor finding) is left to the maintainer.

    Risk

    Duplicates / related: no duplicate found. Related: #1183 (closed, the bug whose fix introduced this flag) and #1186 (that fix).

    Missing info: none needed. It would still help to know the oldest emulator version that accepts -crash-report-mode. The report shows only that 36.1.9 rejects it and 37.2.13 accepts it.

    Written by an agent.

  4. added
    platform:android
    on Nov 3, 2026
  5. V3RON commented on Nov 3, 2026

    @V3RON
    Contributor

    Reproduction

    Confirmed. Gap: the boot wait never watches the emulator process, so an exit at launch costs 180 s and no reason. The expectation is a proposal.

    src/drivers/android/index.test.ts:769, "fails the boot as soon as the emulator exits, naming the emulator's own error line", on bug/1199-repro (d90473c). The fake emulator prints the issue's 36.1.9 lines and exits 1; the clock never moves.

    pnpm exec vitest run --project unit src/drivers/android/index.test.ts -t "naming the emulator's own error line"
    
    AssertionError: still waiting for the boot after the emulator exited: expected undefined to match object { message: StringContaining "unknown option: -crash-report-mode" }
    
    # this host, emulator 36.5.11 (-help runs in 26 ms)
    $ emulator -help | grep crash-report
        -crash-report-mode <option list>   Override crash reporting mode. Available options: disabled, never, always, ask
    

    Root cause

    src/drivers/android/index.ts:2282 passes -crash-report-mode never (#1186) to every emulator; 36.1.9 rejects it. The wait is the gap: #startEmulator (:2270) spawns with stdio: "ignore", and #waitForReadiness (:2126) polls only adb until the timeout, never handle.wait(). Then src/core/device-provisioner.ts:142 replaces any driver reason with "Timed out waiting for device to boot" (#1229).

    Simplest fix

    Ranked:

    1. Spawn with stdio: { file: <root>/<avd>.avd/emulator.log } (0600, truncated each start), race handle.wait() in the boot wait, and on exit throw DriverCrashError("The emulator exited with code <n> before booting: <last lines>"). Covers every launch failure. Needs A lease whose new device fails to boot always says "Timed out waiting for device to boot" with code INTERNAL, whatever the driver's reason #1229, or the requester still reads "Timed out".
    2. Doctor (androidPrerequisites): run emulator -help, report each fixed flag it lacks, remedy sdkmanager --install emulator.
    3. requirements.mdx: name an emulator that accepts the flag (36.5.11 does).

    Alternatives rejected

    Risk

    Side findings

    Written by an agent.

  6. removed their assignment
    on Nov 3, 2026
  7. V3RON commented on Nov 3, 2026

    @V3RON
    Contributor

    Maintainer decision (relayed by an agent): fix as the triage report recommends — items 1 (fail fast on emulator exit with its own log lines), 2 (doctor check from emulator -help for every flag Simlock always passes) and 3 (emulator requirement in requirements.mdx). No flag-only-when-supported fallback, no pinned minimum version.

    Scope also includes #1229's fix, since item 1 is invisible without it: DeviceProvisioner keeps BootTimeoutError (reason boot-timeout) but carries the driver's message instead of replacing it.

    Land before #1205, which rewrites the Android boot.

    Written by an agent.

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

    @V3RON
    Contributor

    Fix spec (maintainer decision, relayed by an agent)

    This supersedes the earlier automated triage's "pass the flag only when supported" proposal.

    Tests

    • src/drivers/android/index.test.ts: fails the boot as soon as the emulator exits, naming the emulator's own error line (triage test on bug/1199-repro, d90473c): no wait for the boot timeout; the error is a DriverCrashError carrying the last lines of the emulator's log.
    • src/drivers/android/index.test.ts: the emulator's output goes to <avd folder>/emulator.log, mode 0600, truncated at each start; adopting a running emulator after a daemon restart and the taken-console-port cases behave as today.
    • src/core/device-provisioner.test.ts: a new device whose driver fails to make it ready gives the requester BootTimeoutError (reason boot-timeout) carrying the driver's message (A lease whose new device fails to boot always says "Timed out waiting for device to boot" with code INTERNAL, whatever the driver's reason #1229; extend "rolls back a registered device…").
    • Android prerequisites test: emulator -help lacking a flag Simlock always passes (e.g. -crash-report-mode) gives a doctor finding naming the flag and the fix sdkmanager --install emulator; an emulator listing every flag gives none.

    Done when

    Written by an agent.

  11. V3RON commented on Nov 3, 2026

    @V3RON
    Contributor

    Decision

    Question: when an existing shut-down device fails to boot (bootShutdown, src/leasing/lease-acquisition-coordinator.ts:1197), does the requester get the driver's message too? The fix spec's Tests name only the new-device path (device-provisioner).

    Taken: yes. That path rejects BootTimeoutError (reason boot-timeout) carrying the driver's message, as the provisioner path does. Done when line 2 ("a boot failure the driver reports with a reason reaches the requester with that reason") covers every boot, and without it a second lease of the same Pixel 9 would still time out with no reason.

    Tests: src/leasing/ coordinator test: a shut-down device whose driver fails to boot gives the requester BootTimeoutError (reason boot-timeout) carrying the driver's message.

    (decided in delivery, pending the maintainer)

    Written by an agent.

  12. V3RON commented on Nov 3, 2026

    @V3RON
    Contributor

    Delivery run

    Merged: #1232 (#1199)
    Parked: none
    Waiting: none
    Decided: #1199 — does a shut-down device's boot failure carry the driver's message? → yes, bootShutdown passes it to BootTimeoutError (pending the maintainer)

    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:readyplatform:android

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions