Fix emulator boot reliability: AVD detection order, offline skip, early exit#311
Closed
rmarinho wants to merge 1 commit intofeature/emulator-runnerfrom
Closed
Fix emulator boot reliability: AVD detection order, offline skip, early exit#311rmarinho wants to merge 1 commit intofeature/emulator-runnerfrom
rmarinho wants to merge 1 commit intofeature/emulator-runnerfrom
Conversation
…ly exit Three fixes for emulator boot issues discovered while fixing dotnet/android#10965: 1. Swap AVD name detection order in GetEmulatorAvdNameAsync: use 'getprop ro.boot.qemu.avd_name' first (reliable on modern emulators), fall back to 'emu avd name' (returns empty on emulator 36.4.10+). 2. Skip AVD name queries for offline emulators in ListDevicesAsync: neither getprop nor 'emu avd name' works on offline devices, causing unnecessary delays during the boot polling loop. 3. Add early process exit detection in BootEmulatorAsync: detect non-zero exit codes immediately instead of waiting for the full timeout. Handle macOS fork behavior where the emulator parent exits with code 0 while the real QEMU process continues running. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
Splitting into two separate PRs: one targeting main (AdbRunner fixes) and one targeting feature/emulator-runner (EmulatorRunner fix). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fixes for emulator boot reliability issues discovered while investigating dotnet/android#10965.
Related PR: dotnet/android#10969
Fixes
1. Swap AVD name detection order (
AdbRunner.GetEmulatorAvdNameAsync)adb -s <serial> emu avd namereturns empty output on modern Android emulators (tested with emulator 36.4.10, adb v36). This causes AVD name matching to fail even when the correct emulator is running.Fix: Use
adb shell getprop ro.boot.qemu.avd_namefirst (reliable on all modern emulators, always set by the emulator kernel), fall back toemu avd namefor older emulator versions.2. Skip AVD name queries for offline emulators (
AdbRunner.ListDevicesAsync)ListDevicesAsynccalledGetEmulatorAvdNameAsyncfor ALL emulators including offline ones. Neithergetpropnoremu avd nameworks on offline devices — they fail or timeout. DuringBootEmulatorAsync's polling loop, this causes unnecessary delays on every iteration as the emulator transitions from offline → online.Fix: Only query AVD names for online emulators (
Status == AdbDeviceStatus.Online).3. Early process exit detection (
EmulatorRunner.BootEmulatorAsync)The boot polling loop had no check for
emulatorProcess.HasExited. If the emulator fails immediately (e.g., insufficient disk space, missing AVD, bad config), the full 300s timeout is wasted before reporting failure.On macOS, the emulator binary forks the real QEMU process and the parent exits with code 0 immediately. The previous code would have also failed here since any process exit would trigger timeout.
Fix: Check
HasExitedduring polling. Non-zero exit codes fail fast withLaunchFailed. Exit code 0 (macOS fork) continues polling — the real emulator is running as a separate process.Testing
dotnet runandroid#10969