Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for M1 Silicon - HVF error: HV_UNSUPPORTED #350

Open
blumendorf opened this issue Oct 4, 2023 · 6 comments
Open

Support for M1 Silicon - HVF error: HV_UNSUPPORTED #350

blumendorf opened this issue Oct 4, 2023 · 6 comments

Comments

@blumendorf
Copy link

M1 Silicon is now supported by macOs runners on GitHub.

I tried to used android-emulator-runner on a setup using M1 and it does not seem to fire up the emulator.

The relevant error message seems to be this:

HVF error: HV_UNSUPPORTED
qemu-system-aarch64-headless: failed to initialize HVF: Invalid argument

Below is the full output and the gituhub workflow we are using.

Output:

Run reactivecircus/android-emulator-runner@v2
  with:
    api-level: 31
    arch: arm64-v8a
    avd-name: Nexus_5X_API_31
    script: yarn detox test --configuration android.emu.release --headless --record-logs all
    target: default
    cores: [2](XXXXX#step:11:2)
    force-avd-creation: true
    emulator-boot-timeout: 600
    emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
    disable-animations: true
    disable-spellchecker: false
    disable-linux-hw-accel: auto
    enable-hw-keyboard: false
    channel: stable
  env:
    JAVA_HOME: /Users/runner/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.8-101/arm64/Contents/Home
    JAVA_HOME_17_ARM64: /Users/runner/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.8-101/arm64/Contents/Home
    ANDROID_HOME: /Users/runner/Library/Android/sdk
    ANDROID_SDK_ROOT: /Users/runner/Library/Android/sdk
Configure emulator
  API level: [3](XXXXX#step:11:3)1
  target: default
  CPU architecture: arm6[4](XXXXX#step:11:4)-v8a
  Hardware profile: 
  Cores: 2
  RAM size: 
  Heap size: 
  SD card path or size: 
  Disk size: 
  AVD name: Nexus_[5](XXXXX#step:11:5)X_API_31
  force avd creation: true
  Emulator boot timeout: [6](XXXXX#step:11:6)00
  emulator options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim
  disable animations: true
  disable spellchecker: false
  disable Linux hardware acceleration: false
  enable hardware keyboard: false
  Channel: 0 (stable)
  Script:
  yarn detox test --configuration android.emu.release --headless --record-logs all
  Pre emulator launch script:
Install Android SDK
  /bin/sh -c \yes | sdkmanager --licenses > /dev/null
  Installing latest build tools, platform tools, and platform.
  /bin/sh -c \sdkmanager --install 'build-tools;33.0.2' platform-tools > /dev/null
  Installing latest emulator.
  /bin/sh -c \sdkmanager --install emulator --channel=0 > /dev/null
  Installing system images.
  /bin/sh -c \sdkmanager --install 'system-images;android-31;default;arm64-v8a' --channel=0 > /dev/null
Launch Emulator
  Creating AVD.
  /bin/sh -c \echo no | avdmanager create avd --force -n Nexus_5X_API_31 --abi 'default/arm64-v8a' --package 'system-images;android-31;default;arm64-v8a'
  Loading local repository...                                                     
  [=========                              ] 25% Loading local repository...       
  [=========                              ] 25% Fetch remote repository...        
  [=======================================] 100% Fetch remote repository...       
  sh to create a custom hardware profile? [no] [command]/bin/sh -c \printf 'hw.cpu.ncore=2
  ' >> /Users/runner/.android/avd/Nexus_5X_API_31.avd/config.ini
  Starting emulator.
  /bin/sh -c \/Users/runner/Library/Android/sdk/emulator/emulator -avd Nexus_5X_API_31 -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim &
  INFO    | Android emulator version 32.1.15.0 (build_id 10696886) (CL:N/A)
  INFO    | Found systemPath /Users/runner/Library/Android/sdk/system-images/android-31/default/arm64-v8a/
  WARNING | Please update the emulator to one that supports the feature(s): Vulkan
  WARNING | /etc/localtime does not point to zoneinfo-compatible timezone name
  ERROR   | Unable to connect to adb daemon on port: 503[7](XXXXX#step:11:7)
  WARNING | cannot add library /Users/runner/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib: failed
  INFO    | Crashreporting disabled, not reporting crashes.
  INFO    | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
  INFO    | added library /Users/runner/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib
  INFO    | Sending adb public key [QAAAAHksz6k3gigFetxeAZXd9/lPSSLbdH/UxNcGEyNqrUdqEB9+/tOcM2Ye1OJVV0tnqaYlI6OPgljAy2ENFyeAJLw45ylXrH2OoEzDL1osleobLYeaCgkMBW[8](XXXXX#step:11:8)/CnWKe4AAZbGLY3Tv58[9](XXXXX#step:11:9)SsMrqt/37eQhkWdAFjwSrVbThJ2cStQlPO5JKlNuLkvU1FcaxtDlDV4Xu94YMEItEpxDVx1YsXJK7DledoLGf1mGjGtJCjks0hZynps4/Wu5whWtKOzWiqRLJXeaYtq+o/tMMzm0dV+a5/wYxuM7WrRrIuWjy7WhUEhjdyK7KV63goz7x0CVQijDj078K6BuTvgLBo0YGbreieqKrSDob9s2kgylNPax8AxfrKzq8KOK0YkWU7Ugr4djJv1WsCkS1SG8UissgLQedOCnC2GQRsQvk9KRywZElheE4qEDSQDevhrThbQU8ASNrG7K0FHUwEGEpX+CyHF5BRFF6yRHaHAUhzwo1PcQMviKE43oVWK5vFuDwGNs7[10](XXXXX#step:11:10)2AaIMUAXvxOCXwe9XCUul0ciEORK7omLRkz5YOsDUhmpcssrSv8IMWWCEh7ha8KDccjIZjpjLadXYGmJfn3/SGMKhinTngGrsSdTDB6insS52+LoASsVyAEuL/0wFYePnBc5ar7nbLFkVMCayksqmhF+linfDeKE371dFWOC0DCTD/PwEAAQA= runner@unknown]
  HVF error: HV_UNSUPPORTED
  qemu-system-aarch64-headless: failed to initialize HVF: Invalid argument
  INFO    | Wait for emulator (pid 59397) [20](XXXXX#step:11:20) seconds to shutdown gracefully before kill;you can set environment variable ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL(in seconds) to change the default value (20 seconds)
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  * daemon not running; starting now at tcp:50[37](XXXXX#step:11:38)
  * daemon started successfully
  adb: no devices/emulators found
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  The process '/Users/runner/Library/Android/sdk/platform-tools/adb' failed with exit code 1
  /Users/runner/Library/Android/sdk/platform-tools/adb shell getprop sys.boot_completed
  adb: no devices/emulators found
  [this continues ...]

workflow:

[...]
run-e2e-android-m1:
    name: Run Android e2e Tests on M1
    runs-on: macos-latest-xlarge
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18.x
          cache: "yarn"

      - name: Install Dependencies
        run: yarn install

      - name: Expo Prepare Build
        run: yarn prebuild --platform android

      - name: Setup Java
        uses: actions/setup-java@v3
        with:
          cache: gradle
          distribution: temurin
          java-version: 17

      - name: Setup Android SDK (needed for the build)
        uses: android-actions/setup-android@v3

      - name: Cache Build
        id: cache-detox-android-build
        uses: actions/cache@v3
        with:
          path: android/build
          key: ${{ runner.os }}-detox-android-build
          restore-keys: |
            ${{ runner.os }}-detox-android-build

      - name: Detox Build
        run: detox build -c android.emu.release

      - name: Get device name
        id: device
        run: node -e "console.log('AVD_NAME=' + require('./detox.config.js').devices.emulator.device.avdName)" >> $GITHUB_OUTPUT

      - name: Detox Test
        uses: reactivecircus/android-emulator-runner@v2
        with:
          api-level: 31
          arch: arm64-v8a
          avd-name: ${{ steps.device.outputs.AVD_NAME }}
          script: yarn detox test --configuration android.emu.release --headless --record-logs all
@colinrtwhite
Copy link

Running into this as well with the newly released macos-14 Apple Silicon images. I tried applying this fix to the CI image, but it didn't work unfortunately.

@mikehardy
Copy link

@colinrtwhite just a doubt -

Running into this as well with the newly released macos-14 Apple Silicon images. I tried applying this fix to the CI image, but it didn't work unfortunately.

When you tried to apply that fix, did you do the whole thing with command line tools install for Xcode (though likely they were already installed...) and did you make sure to add the entitlement to the aarch64 emulator vs x86_64.

This whole issue seems like an advanced-user hangout, so I'm guessing you did, but just wanted to check - would be curious to see your workflow run log if you could link it

@colinrtwhite
Copy link

@mikehardy I believe so, but it's possible I missed something! Here's the script I wrote to run on CI.

@mikehardy
Copy link

@colinrtwhite that looks perfect. Disappointed it's not working but with a set -e on the top and the script looking the way it does, I think you'd know if the methodology of your test was wrong. Just the test had sad results. Alas. Thanks for sharing, much appreciated. Guess I'll try to pick apart the other semi-related thread where it appears the new public repo runners behind ubuntu-latest have nested-virt enabled if you can jump through the correct hoops to get the runner user /dev/kvm access and install the qemu packages etc...

github-merge-queue bot pushed a commit to slackhq/circuit that referenced this issue Feb 2, 2024
- The recent change to `macos-14` means that we can't use x64 emulator
(as currently set). Ideally we would just use ARM64 emulators, but that
is blocked by
ReactiveCircus/android-emulator-runner#350
though.

- Instead I've refactored the CI setup:
- Moved most things to run `ubuntu-latest`. We can use the new
nested-virt KVM support to make the emulator fast there.
- We still use `macos-14` but only for iOS builds in a separate job.
This is similar to what I do in Tivi.
- Add some hierarchy to the jobs, so that `publish` only happens when
all of the other jobs pass.

- Benchmark tests do not work (by default) on emulators, which is why
they've been failing for a while. We can suppress that error and get
them to run but there's little benefit, so it's better to just disable
them when running on an emulator.
@marcprux
Copy link

marcprux commented Apr 1, 2024

Does anyone have any further insight into this? Not being able to run the Android emulator on macos-14 is going to become more problematic, as the macos-13 image is not getting Xcode updates (15.3 is only available for macos-14).

Looking at actions/runner-images#9460, things don't sound promising. Is there any hope of ever getting the emulator running on macos-14?

nohli added a commit to nohli/firebase_testlab_detector that referenced this issue Jun 5, 2024
lsuski added a commit to cucumber/cucumber-android that referenced this issue Jul 25, 2024
@karlhorky
Copy link

Copying the comment from @peterlazar1993 , looks like it could be interesting for theoretical future GitHub Actions runners on M3 chips with macOS Sequoia:

You cannot run a VM(android emulator) inside a VM on M1, M2 macs.

M3 macs with OSX15 (upcoming), will allow nested virtualisation - forum.parallels.com/threads/macos-15-sequoia-nested-virtualization-for-m3-macs.364397

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

No branches or pull requests

5 participants