Skip to content

ci(flutter): boot the cached emulator snapshot with a real readiness check - #452

Open
aojea wants to merge 2 commits into
google:mainfrom
aojea:flutter-e2e-cold-boot
Open

aojea wants to merge 2 commits into
google:mainfrom
aojea:flutter-e2e-cold-boot

Conversation

@aojea

@aojea aojea commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes the recurring e2e-android failures in test_flutter.yaml: 5 of the last 30 runs, all with the same signature and all before mobile_e2e.sh test even started. Keeps the cached AVD snapshot, so the job stays at ~7 minutes.

Why

Every failure looks like this, inside the android-emulator-runner action, right after it restores the cached snapshot:

Successfully loaded snapshot 'default_boot' using 1517 ms
adb -s emulator-5554 shell getprop sys.boot_completed   -> adb: device offline
adb -s emulator-5554 shell getprop sys.boot_completed   -> 1   "Emulator booted."
adb -s emulator-5554 shell input keyevent 82
java.lang.IllegalStateException: android.os.ServiceManager$ServiceNotFoundException: No service published for: input

A restored guest already has sys.boot_completed=1 from the saved state, so the action's boot wait returns two seconds after the load, as soon as adb reconnects, and its unconditional input keyevent 82 races the system services coming back up. The action offers no way to skip or retry that command (launchEmulator in v2.38.0, unchanged on main).

Fix

The action is now used only where it is not racy: creating the AVD and its snapshot on a cache miss. The test step boots the snapshot from a run: step that does what the action did (same sdkmanager installs, same emulator flags, same animation settings), but waits until input keyevent 82 itself succeeds before declaring the emulator ready. That is the exact command that was failing, so the readiness signal cannot be wrong in the same way again. adb emu kill runs in an if: always() step.

The first commit on this branch was a cold-boot fix; the second replaces it to keep the snapshot's ~5 min saving. Squash on merge.

Five of the last thirty e2e-android runs failed before the test script
started, all with the same trace from the emulator-runner action:

  adb shell input keyevent 82
  IllegalStateException: ServiceNotFoundException: No service published for: input

The test step restored the cached AVD snapshot. A restored guest already
has sys.boot_completed=1, so the action's boot wait returns as soon as adb
reconnects, two seconds after the load, and its unconditional keyevent
races the system services coming back up. The action has no option to
skip or retry that command, and upstream main still issues it.

Boot cold with -no-snapshot and drop the snapshot cache: the property
then flips only after the services are published. Costs about a minute
of boot time with KVM.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

The cold boot in the previous commit fixes the race but gives back the
five minutes the cached snapshot saves. Keep the snapshot and stop using
the emulator-runner action for the test step: the action only creates
the AVD on a cache miss. A run step restores the snapshot and treats a
successful `input keyevent 82` as the readiness signal, which is exactly
the command that failed, instead of trusting a sys.boot_completed that a
restored guest reports before its services are back.
@aojea aojea changed the title ci(flutter): cold-boot the e2e emulator instead of restoring a snapshot ci(flutter): boot the cached emulator snapshot with a real readiness check Sep 19, 2026
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