android-emulator-runner icon indicating copy to clipboard operation
android-emulator-runner copied to clipboard

Running emulator with cache on multiple jobs causes the jobs to hang.

Open syedahmedjamil opened this issue 2 years ago • 3 comments

I want to run the emulator with cache on two jobs in parallel but the jobs seems to just hang at the end when its time to terminate the emulator. Instead the step keeps running and workflow doesn't ends.

Note: If I remove the step "AVD cache" and "create AVD and generate snapshot for caching" from both jobs then it works fine.

Why does it hang with cache ?

my-workflow.yml file

name: My Workflow

on:
  pull_request:
    branches: [ "dev" ]

jobs:
  job1:
    runs-on: macos-latest
    strategy:
      matrix:
        api-level: [29]
    steps:
      - name: checkout
        uses: actions/checkout@v3

      - name: Gradle cache
        uses: gradle/gradle-build-action@v2
        
      - name: AVD cache
        uses: actions/cache@v3
        id: avd-cache
        with:
          path: |
            ~/.android/avd/*
            ~/.android/adb*
          key: avd-${{ matrix.api-level }}

      - name: create AVD and generate snapshot for caching
        if: steps.avd-cache.outputs.cache-hit != 'true'
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ matrix.api-level }}
          force-avd-creation: false
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: false
          script: echo "Generated AVD snapshot for caching."

      - name: run tests
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ matrix.api-level }}
          force-avd-creation: false
          emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: true
          script: echo "Done"

  job2:
    runs-on: macos-latest
    strategy:
      matrix:
        api-level: [29]
    steps:
      - name: checkout
        uses: actions/checkout@v3

      - name: Gradle cache
        uses: gradle/gradle-build-action@v2
        
      - name: AVD cache
        uses: actions/cache@v3
        id: avd-cache
        with:
          path: |
            ~/.android/avd/*
            ~/.android/adb*
          key: avd-${{ matrix.api-level }}

      - name: create AVD and generate snapshot for caching
        if: steps.avd-cache.outputs.cache-hit != 'true'
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ matrix.api-level }}
          force-avd-creation: false
          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: false
          script: echo "Generated AVD snapshot for caching."

      - name: run tests
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: ${{ matrix.api-level }}
          force-avd-creation: false
          emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
          disable-animations: true
          script: echo "Done"

job1 state image

job2 state image

syedahmedjamil avatar Dec 26 '23 09:12 syedahmedjamil

I'm experiencing the same problem

fillobotto avatar Dec 31 '23 07:12 fillobotto

Same issue here. CI gets stuck if AVD is cached: https://github.com/Purdue-CS307-tsundoku/tsundoku/actions/runs/8320789292/job/22766040436 I had to manually cancel the workflow run.

ericswpark avatar Mar 18 '24 03:03 ericswpark

I am facing this error too in https://github.com/kiwix/kiwix-android/pull/3806 when the job the completed then it stuck on terminating the emulator.

  1. https://github.com/kiwix/kiwix-android/actions/runs/8844204274/job/24286763179?pr=3806
  2. https://github.com/kiwix/kiwix-android/actions/runs/8844204274/job/24285666360?pr=3806

MohitMaliFtechiz avatar Apr 26 '24 08:04 MohitMaliFtechiz