Tuesday, December 3, 2019

Emulator 29.2.11 and AMD Hypervisor 1.2 to Stable

Emulator 29.2.11 and AMD Hypervisor 1.2 are now available in all channels. Major changes:
  • Via AMD Hypervisor, we added support for running the emulator on AMD CPUs on Windows:
    • With CPU acceleration
    • Without requiring Hyper-V
    • With speed on par with HAXM
    • Without requiring Windows 10
    • Note that currently, this requires manual install steps, but we plan to remove the need for manual install in a future Studio version.
  • The Windows build, instead of being cross-compiled on Linux via MinGW, is now built natively with Visual Studio and Windows SDK.
  • Many other fixes and improvements to the emulator itself.
  • Since the last stable version, we've launched the Container Scripts, which makes it easier to run the emulator in a CI environment via Docker.
In the following sections, we present the AMD Hypervisor and list all other notable changes relative to the previous stable version.

AMD Hypervisor for Windows users on AMD CPUs

Currently, Windows Hypervisor Platform (WHPX) is required to run the emulator on AMD CPUs on Windows. However, there are compatibility and performance issues. To address this, since emulator 29.2.3, we've added a new hypervisor backend + driver, based on KVM, that allows you to run the emulator on Windows with AMD CPUs with compatibility and performance that should be on par with HAXM.

This is meant for AMD users on Windows who want a faster AVD experience on par with HAXM, or cannot run with Hyper-V / WHPX enabled (e.g., running other virtual machine engines such as VMware/VirtualBox or not running Windows 10; however, note that we are still committed to WHPX / Hyper-V for the use cases where that is optimal, such as interop with Docker on Windows).

The implementation is developed by our team and based on Linux KVM. The code has been open sourced and is available on GitHub here: https://github.com/google/android-emulator-hypervisor-driver-for-amd-processors

AMD Hypervisor for Windows users on AMD CPUs - Install Instructions

Follow the instructions below to enable the AMD Hypervisor for faster Android Emulator on AMD CPUs on Windows. Note that in a future Studio 4.0 release, these instructions will be automatically run as part of the SDK Manager update and become obsolete.

First, make sure your AMD CPU supports virtualization and BIOS has NOT disabled it. As BIOS options are different among vendors, please refer to your system manufacturer's manual.

Next, make sure Hyper-V and Windows Hypervisor Platform are disabled. All Windows features enabling Hyper-V either explicitly or silently must be turned off. See the screenshots below for a few examples:




Then, launch SDK Manager via Android Studio and you should see “Android Emulator Hypervisor Driver for AMD Processors”. Check and click “Apply”. The SDK Manager will download the installer package and unpack it to <Your Android SDK Path>\extras\google\Android_Emulator_Hypervisor_Driver.




Open a Windows command console with administrator privilege, go to <Your Android SDK Path>\extras\google\Android_Emulator_Hypervisor_Driver, and run the following command silent_install.bat. Make sure you see the desired output from the installer: STATE: 4 RUNNING




If something goes wrong, please reach us or file a bug. Make sure to submit your CPU model, OS version info, and installer output.

AMD Hypervisor for Windows users on AMD CPUs - Known Issues
Emulator 29.2.11 changes relative to previous stable version

Snapshots
  • Fixed an issue when running the Windows emulator on AMD CPUs (with either Windows Hypervisor Platform or the AMD Hypervisor) where when resuming from a snapshot from the AVD Manager in Studio, the emulator would show up as offline.
  • Snapshots now should work again with users who are running on Windows Hypervisor Platform.
  • Quickboot snapshots now work again for ARM system images.
  • Snapshots (incl. Quickboot) can now be taken in -no-window mode and resumed with a window, and vice versa.
  • Windows: Fixed issue where VCPU shutdown request would occur if loading snapshots while the emulator is running.
UI / Input
  • Removed some spammy log prints.
  • Fold/unfold button now works more reliably.
  • Linux: Fixed Alt key not working on non-QWERTY layouts.
  • Fixed issue where virtual scene camera WASDQE controls did not work with non-QWERTY layouts.
  • Keycode forwarding: We now maintain a mapping of host keyboard type to Android keyboard type, and only forward host keycodes when both the host and Android keyboard type can be determined and correctly mapped (An upcoming suitable system image is still required).
  • Ctrl-Shift-M can now be used to bring up the Multi Display UI.
  • Fixed issues with emulator window size not updating.
  • Tweaked button sizes, colors, font size of titles, and positions of icons.
  • Fixed issue where usage metrics were not sent.
Headless build
  • The binary emulator-headless is now retired. Headless builds of the engine are now launched via emulator -no-window, thus unifying the previously separate (but similar) paths.
  • 32-bit ARM headless build (qemu-system-armel-headless) is now included with the distribution.
  • Fixed issue around crash service not being able to start in -no-window mode.
Console interface
  • Added interface to screenshot to a particular PNG file instead of one with an autogenerated filename. Usage:
    • adb emu screenrecord screenshot customFileName.png
  • Added a command line option to start a screen recording along with the emulator launch:
    • Format: -record-session <filename>,<delay-until-start>,<duration>
    • Example: -record-session tmp.webm,5,10
  • Added telnet console interface to query whether the emulator is running headless or not, via adb emu avd windowtype.
Graphics
  • (Requires future system image update)
    • Fixed issue where Unity Vulkan examples would not work out of the box.
    • Improved performance of glMapBufferRange and glUnmapBuffer
    • Greatly improved performance when OpenGL ES draw calls are issued at a high rate.
    • Added new AVD config.ini property, hw.lcd.vsync (default 60), which, given an upcoming suitable system image build, will allow the guest's VSYNC rate to be controlled by the AVD configuration. This can be useful for testing apps on high frame rate (HFR) displays.
      • Note that in order to be able to see the visual effect of higher VSYNC rates, a monitor with refresh rate greater than or equal to the setting is required.
  • Fixed potential deadlocks related to gralloc buffer destruction.
  • Fixed issue on API 22 system images where if using the swiftshader_indirect renderer, black frames would result on video playback.
  • Vulkan driver changes
    • ASTC LDR compressed textures are now supported via emulation if not supported on the host GPU (textureCompressionASTC_LDR).
    • Removed support for 1D compressed textures (this is not a use case that is commonly considered).
General Fixes / Improvements
  • Fixed a division by 0 crash in some areas of the UI code.
  • libfontconfig is now bundled with the Linux emulator.
  • Stopped doing some adb commands right on emulator startup as it seems to corrupt state and cause hangs (instead, delaying them until after boot complete).
  • Updated crash reporting libraries.
  • Fixed issue where LD_PRELOAD was clobbered by the Linux emulator.
  • Fixed various possible crashes on exit.
  • Fixed potential issues with ADB APK installer / file pusher UI code not running on the UI thread.
  • Wear AVDs now default to using the AC charger.
  • For API < 16, we now force host side rendering (either with host GPU or Swiftshader). This should resolve issues with black screens on these images.
  • Fixed issue when emulator would get stuck closing if a gRPC endpoint was created.
  • Whenever the emulator has a fatal abort message, we now print in the console in addition to generating the crash report dialog. This should make such events more visible.
  • Fixed freezes related to the battery page.
  • Speculative fix landed for a potential hang that has to do with ADB. If you notice the emulator taking a long time to respond on a cold boot, try force killing the ADB process.