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

Android Emulator Launch keeps failing with HV_UNSUPPORTED #9472

Closed
2 of 13 tasks
rohanp-91 opened this issue Mar 7, 2024 · 5 comments
Closed
2 of 13 tasks

Android Emulator Launch keeps failing with HV_UNSUPPORTED #9472

rohanp-91 opened this issue Mar 7, 2024 · 5 comments

Comments

@rohanp-91
Copy link

Description

We are trying to launch Android emulator using our test script. I have pasted a snippet of the relevant code below:

# check and download specific SDK - Android 30 (11.0)
 yes | ~/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager --licenses
 echo -e $(date) "$debugTag Update packages "
 ~/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager --update --channel=0 || ~/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager --update --channel=3
 echo -e $(date) "$debugTag List packages "
 ~/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager --list --channel=0 || ~/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager --list --channel=3
 echo -e $(date) "$debugTag Install packages "
 if [[ "`uname -m`" == "arm64" ]]; then
   ~/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager "system-images;android-30;google_apis;arm64-v8a"
 else
   ~/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager "system-images;android-30;google_apis;x86_64"
 fi

 # create and start emulator with specific SDK
 emulator_name='emulator0'
 echo -e $(date) "$debugTag Create AVD $emulator_name "
 if [[ "`uname -m`" == "arm64" ]]; then
   ~/Library/Android/sdk/cmdline-tools/latest/bin/avdmanager create avd -n $emulator_name -k "system-images;android-30;google_apis;arm64-v8a" -d pixel_6 -f
 else
   ~/Library/Android/sdk/cmdline-tools/latest/bin/avdmanager create avd -n $emulator_name -k "system-images;android-30;google_apis;x86_64" -d pixel_6 -f
 fi
 echo -e $(date) "$debugTag Check hardware acceleration "
 ~/Library/Android/sdk/emulator/emulator -accel-check
 echo -e $(date) "$debugTag Boot AVD $emulator_name "

 echo -e $(date) "$debugTag Symlink libvulkan.dylib"
 ln -s ~/Library/Android/sdk/emulator/lib64 ~/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64

 if [[ "`uname -m`" == "arm64" ]]; then
   ~/Library/Android/sdk/emulator/emulator -avd $emulator_name -cores 2 -memory 5120 -accel on -noaudio -no-snapshot -no-boot-anim &
 else
   ~/Library/Android/sdk/emulator/emulator -avd $emulator_name -cores 2 -memory 5120 -accel on -gpu swiftshader_indirect -noaudio -no-snapshot -no-boot-anim &
 fi

This same script works across macos-12 and macos-13 images. However, on macos-13-arm agents, it keeps failing with the following error:

Thu Mar 7 18:56:55 UTC 2024 (DEBUG) Check hardware acceleration 
WARNING | Crash annotation is very large (24017), only 16384 bytes will be recorded, 7633 bytes are lost.
accel:
0
Hypervisor.Framework OS X Version 13.6
accel
INFO    | Storing crashdata in: /tmp/android-runner/emu-crash-34.1.19.db, detection is enabled for process: 6033
Thu Mar 7 18:56:55 UTC 2024 (DEBUG) Boot AVD emulator0 
Thu Mar 7 18:56:55 UTC 2024 (DEBUG) Symlink libvulkan.dylib
Thu Mar 7 18:56:55 UTC 2024 (DEBUG) Wait for AVD boot finished 
WARNING | Crash annotation is very large (24087), only 16384 bytes will be recorded, 7703 bytes are lost.
INFO    | Storing crashdata in: /tmp/android-runner/emu-crash-34.1.19.db, detection is enabled for process: 6041
INFO    | Android emulator version 34.1.19.0 (build_id 11525734) (CL:N/A)
INFO    | Found systemPath /Users/runner/Library/Android/sdk/system-images/android-30/google_apis/arm64-v8a/
WARNING | Crash annotation is very large (24811), only 16384 bytes will be recorded, 8427 bytes are lost.
WARNING | Please update the emulator to one that supports the feature(s): Vulkan
WARNING | FeatureControl is requesting a non existing feature.
**added library /Users/runner/Library/Android/sdk/emulator/qemu/darwin-aarch64/lib64/vulkan/libvulkan.dylib
initialize: Supports id properties, got a vulkan device UUID
HVF error: HV_UNSUPPORTED
qemu-system-aarch64: failed to initialize HVF: Invalid argument
WARNING | QEMU main loop exits abnormally with code 1**

Is there some agent level suppressions that's failing to launch Hypervisor? Since the same script works for macOS-13 (Intel), I don't think there's an issue with the script.

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 20.04
  • Ubuntu 22.04
  • macOS 11
  • macOS 12
  • macOS 13
  • macOS 13 Arm64
  • macOS 14
  • macOS 14 Arm64
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

Image: macos-13-arm64
Version: 20240219.3

https://msasg.visualstudio.com/Bing_Ads/_build/results?buildId=44158865&view=logs&j=1f633cd7-02c6-5eca-e555-d21a3c888056&t=6b46bbb8-3868-5170-56cb-4f4fbbcb5c8f

Is it regression?

No

Expected behavior

Android emulator should launch with Hypervisor.

Actual behavior

Hypervisor creation fails with HV_UNSUPPORTED.

Repro steps

Try to launch emulator.

@mikhailkoliada
Copy link
Contributor

Hello! Apple M1 (which is a base for both OS13 & OS14 arm64 runners) does not support nested virtualisation, that is why android emulator is not supposed to function here, it is expected and nothing could/should be done here.

@rohanp-91
Copy link
Author

@mikhailkoliada I see, makes sense. Is there any alternative to launch emulator on M1 devices?

@rohanp-91
Copy link
Author

@mikhailkoliada Also, could you please explain how is it nested virtualisation if I am not running in Rosetta? I am using qemu-darwin-aarch64.

@rohanp-91
Copy link
Author

Nevermind, I think it's because we are trying to launch the emulator VM inside the macOS VM.

@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
Projects
None yet
Development

No branches or pull requests

3 participants