Skip to content

Fix CI: force-kill emulator to prevent 20+ min hang after tests#2805

Merged
pyricau merged 2 commits intomainfrom
fix-emulator-hang
Feb 26, 2026
Merged

Fix CI: force-kill emulator to prevent 20+ min hang after tests#2805
pyricau merged 2 commits intomainfrom
fix-emulator-hang

Conversation

@pyricau
Copy link
Copy Markdown
Member

@pyricau pyricau commented Feb 26, 2026

Problem

On API 26 google_apis, the emulator process does not exit after receiving adb emu kill.
The android-emulator-runner post-step polls in a loop waiting for kill -0 $pid to fail.
The process never dies before the 30-minute job timeout, so the CI runner cancels the job
with The operation was canceled. — roughly 23 minutes after the tests actually finished.

This has happened consistently on API 26 (confirmed in runs for PR #2802 and earlier):

15:29:15 BUILD SUCCESSFUL in 5m 17s
15:29:15 ##[group]Terminate Emulator
15:29:15 adb emu kill → OK: killing emulator, bye bye
15:29:15 INFO | Wait for emulator (pid 2659) 20 seconds to shutdown gracefully before kill
  ...
15:52:05 ##[error]The operation was canceled.

Fix

Add pkill -9 -f "qemu-system" || true at the end of the test script, before the
android-emulator-runner post-step cleanup runs. When the post-step then checks whether
the process is alive, it is already gone and the cleanup exits immediately.

The || true makes it a no-op on API levels where the emulator shuts down cleanly.

On API 26 google_apis, the emulator process does not exit after
receiving adb emu kill. The android-emulator-runner post-step
polls until the process dies, which never happens before the
30-minute job timeout triggers, wasting ~23 minutes of CI time.

Force-kill the qemu-system process at the end of the test script,
before the action's post-step cleanup runs. When the post-step
then checks whether the process has exited, it is already gone
and the cleanup step exits immediately.
@pyricau pyricau marked this pull request as ready for review February 26, 2026 19:02
@pyricau pyricau merged commit 96375aa into main Feb 26, 2026
14 checks passed
@pyricau pyricau deleted the fix-emulator-hang branch February 26, 2026 19:02
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