Skip to content

Conversation

@marcprux
Copy link
Contributor

@marcprux marcprux commented Jan 11, 2026

While waiting for the Android emulator to start up, we poll it with adb wait-for-any-device. This seems to crash sometimes (e.g, in this workflow run for apple/swift-configuration#140) with:

USER_INFO    | Emulator is performing a full startup. This may take upto two minutes, or more.
WARNING      | Failed to process .ini file /home/runner/.android/emu-update-last-check.ini for reading.
timeout: the monitored command dumped core
/home/runner/work/swift-configuration/swift-configuration/github-workflows/.github/workflows/scripts/android/android-emulator-tests.sh: line 99:  6236 Aborted                 timeout "${ANDROID_EMULATOR_TIMEOUT}" adb wait-for-any-device
WARNING      | Failed to process .ini file /home/runner/.android/emu-update-last-check.ini for reading.

This PR introduces periodic polling with adb shell getprop sys.boot_completed on the theory that the emulator startup process is conflicting with the adb command.

An example of the output should now look like:

** Waiting for Android emulator startup (5)
* daemon not running; starting now at tcp:5037
* daemon started successfully
adb: device offline
** Waiting for Android emulator startup (10)
** Waiting for Android emulator startup (15)
** Waiting for Android emulator startup (20)
** Waiting for Android emulator startup (25)
** Waiting for Android emulator startup (30)
** Waiting for Android emulator startup (35)
INFO         | Boot completed in 38815 ms
INFO         | Increasing screen off timeout, logcat buffer size to 2M.
** Waiting for Android emulator startup (40)
** Emulator is ready
** Prepare Swift test package

CC: @finagolfin

@marcprux marcprux requested a review from a team as a code owner January 11, 2026 20:46
@marcprux
Copy link
Contributor Author

Oops, this might conflict with the delay introduced in #221. Converting to draft while I inquire…

@marcprux
Copy link
Contributor Author

marcprux commented Jan 13, 2026

The new adb start-server call added in PR #221 is now crashing:

USER_INFO    | Emulator is performing a full startup. This may take upto two minutes, or more.
WARNING      | Failed to process .ini file /home/runner/.android/emu-update-last-check.ini for reading.
/home/runner/work/swift-configuration/swift-configuration/github-workflows/.github/workflows/scripts/android/android-emulator-tests.sh: line 99:  6111 Aborted                 (core dumped) adb start-server

(before it was crashing with adb wait-for-any-device)

Maybe we can introduce a delay before calling any adb operation?

@marcprux
Copy link
Contributor Author

BTW, @justice-adams-apple, why did you add adb start-server? I haven't experienced that it was necessary in the past…

@marcprux
Copy link
Contributor Author

The way that ReactiveCircus/android-emulator-runner deals with this is to continually poll adb -s emulator-${port} shell getprop sys.boot_completed. Maybe that's the way to go…

@finagolfin
Copy link
Member

finagolfin commented Jan 13, 2026

I was wondering how you got away with not doing that, as even that polling has failed in the past, its error rate is just lower...

@marcprux marcprux changed the title Wait briefly before starting to poll the emulator in android-emulator-tests.sh Fix crash in emulator launch in android-emulator-tests.sh Jan 14, 2026
@marcprux
Copy link
Contributor Author

Can someone add this to the "In Progress" for the Swift on Android project board?

@ahoppen ahoppen moved this to In Progress in Swift on Android Jan 14, 2026
@marcprux marcprux marked this pull request as ready for review January 14, 2026 22:42
@marcprux
Copy link
Contributor Author

OK, I think this is ready to go.

@finagolfin and @justice-adams-apple, if you want to test this out prior to it being merged, I think you should be able to test it with:

-    uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
+    uses: swift-android-sdk/github-workflows/.github/workflows/swift_package_test.yml@android-sleep-before-adb

marcprux added a commit to swift-android-sdk/swift-collections that referenced this pull request Jan 14, 2026
@marcprux
Copy link
Contributor Author

if you want to test this out prior to it being merged, I think you should be able to test it with:

Derp, nevermind. I see it isn't allowed:

Error
The reusable workflow swift-android-sdk/github-workflows/.github/workflows/swift_package_test.yml@android-sleep-before-adb is not allowed in apple/swift-configuration because all reusable workflows must be from a repository owned by your enterprise or match one of the patterns…

We'll need to wait for this to be merged before we can really exercise it.

Copy link
Contributor

@justice-adams-apple justice-adams-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marcprux
Copy link
Contributor Author

Can someone merge this please, @swiftlang/github-workflows-contributors ? I don't have permission…

@justice-adams-apple justice-adams-apple merged commit 1ffcd38 into swiftlang:main Jan 15, 2026
108 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Swift on Android Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants