Android Emulator Launch keeps failing with HV_UNSUPPORTED
rohanp-91 opened this issue · comments
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
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.
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.
@mikhailkoliada I see, makes sense. Is there any alternative to launch emulator on M1 devices?
@mikhailkoliada Also, could you please explain how is it nested virtualisation if I am not running in Rosetta? I am using qemu-darwin-aarch64.
Nevermind, I think it's because we are trying to launch the emulator VM inside the macOS VM.