Skip to content

Conversation

Copy link

Copilot AI commented Dec 19, 2025

Summary

The Android emulator CI job was failing due to device detection timeouts with the reactivecircus/android-emulator-runner@v2 action. Replaced with manual emulator startup providing explicit control over device initialization and boot verification.

Changes

Install Android dependencies

  • Install emulator and system images via sdkmanager
  • Move cmdline-tools to proper SDK structure ($ANDROID_HOME/cmdline-tools/latest)
  • Add path validation before operations

Replace GitHub Action with manual steps

  • Create AVD explicitly (cached between runs)
  • Start emulator with optimized flags: -no-snapshot-load, -no-boot-anim, -gpu swiftshader_indirect
  • Two-phase boot detection:
    1. Wait for device visibility in adb devices
    2. Poll sys.boot_completed property until 1
  • Add diagnostic step listing connected devices
  • Extract device ID to EMULATOR_DEVICE_ID environment variable

Wait loop

for i in {1..90}; do
  if ! adb devices | grep -q "$EMULATOR_DEVICE_ID"; then
    sleep 10
    continue
  fi
  boot_completed=$(adb -s $EMULATOR_DEVICE_ID shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')
  [[ "$boot_completed" == "1" ]] && break
  sleep 10
done

Test plan

YAML syntax validated. Changes follow standard Android emulator CI patterns. Will be validated by CI run.

Original prompt

Problem Description

The CI job for the Android emulator in the pull workflow is currently failing. The logs show multiple attempts to use adb to communicate with the emulator (device emulator-5554), but these fail because the device is not detected, resulting in the error device 'emulator-5554' not found. The script eventually times out while waiting for the emulator to boot.

Root Cause

  • The emulator for the specified AVD fails to start properly, or the job script does not wait long enough for the emulator to complete its boot sequence.
  • The AVD configuration might be missing or improperly set up.
  • Debugging steps like checking available devices (adb devices) and logging emulator output were not included, making it harder to identify the specific issue.

Proposed Solution

  1. Update the workflow configuration to ensure that the emulator starts correctly by explicitly invoking the emulator with appropriate flags.
  2. Add a wait loop to verify the emulator boot completion before running any tests or adb commands.
  3. Include diagnostic commands to capture emulator and adb state for debugging purposes.

Code Changes

Modify .github/workflows/pull.yml

Insert the following steps into the appropriate section for starting the Android emulator:

- name: Start Emulator
  run: |
    $ANDROID_HOME/emulator/emulator -avd test_avd -no-snapshot-load -no-window -gpu swiftshader_indirect -no-boot-anim &
    adb start-server
    for i in {1..90}; do
        boot_completed=$(adb -s emulator-5554 shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')
        if [[ "$boot_completed" == "1" ]]; then
            echo "Emulator booted."
            break
        fi
        echo "Waiting for emulator to boot..."
        sleep 2
    done

- name: Check Devices
  run: adb devices

Improvements

  • The -no-snapshot-load and -no-boot-anim flags optimize emulator startup.
  • The waiting loop ensures the emulator is fully booted before proceeding.
  • Diagnostic steps make it easier to debug potential issues in the future.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 19, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16350

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 3 New Failures, 1 Unrelated Failure

As of commit f14088a with merge base 09bdad7 (image):

NEW FAILURES - The following jobs have failed:

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla
Copy link

meta-cla bot commented Dec 19, 2025

Hi @Copilot!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

…startup

Co-authored-by: kirklandsign <107070759+kirklandsign@users.noreply.github.com>
@github-actions
Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Copilot AI and others added 2 commits December 20, 2025 00:02
… env var

Co-authored-by: kirklandsign <107070759+kirklandsign@users.noreply.github.com>
Co-authored-by: kirklandsign <107070759+kirklandsign@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing CI job for Android emulator in pull workflow Fix Android emulator CI by replacing action with manual startup Dec 20, 2025
Copilot AI requested a review from kirklandsign December 20, 2025 00:05
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants