Running ARM64 Android games on Apple Silicon without instruction translation
Apple Silicon and phone chips share the same instruction set, ARM64. That means a Mac can boot an ARM64 Android system under hardware virtualization and run game code as is, with no x86-to-ARM translation layer in between. APK PlayStudio is an Android game emulator built on that idea, coming soon to the Mac App Store. Here is how the stack fits together and what turned out to be hard. The basic…
Apple Silicon Macs and phone chips share the same ARM64 instruction set, allowing a Mac to run an ARM64 Android system under hardware virtualization without the need for an x86-to-ARM translation layer. APK PlayStudio, an Android game emulator designed for Macs, is set to launch in the Mac App Store. The core components of the system include QEMU's virt machine with the Hypervisor.framework, which runs one process per emulator and communicates via QMP. Frames are transmitted through IOSurface shared memory with zero copies.
Touch input is handled by QEMU's virtio-multitouch device, which is controlled directly over QMP input-send-event without relying on adb. Real multi-touch functionality is achieved through the QMP input path, allowing users to interact with the game using various fingers on the screen. Graphics are processed using GLES 3.2, Mesa virgl, virtio-gpu, virglrenderer, ANGLE with Vulkan backend, and KosmicKrisp, ultimately resulting in Metal rendering.
The main limitation stems from Apple Silicon's lack of 32-bit ARM support, meaning only arm64-v8a apps can be installed. Most games ship with 64-bit builds.
Some challenges arose during development that required creative solutions. For instance, ANGLE's Metal backend only supports up to GLES 3.0, while KosmicKrisp provides 3.1. To overcome this, virglrenderer patches were implemented, which increased the reported GLES version to 3.2. However, geometry shaders remained unavailable due to the absence of Metal support. Another issue was the encoding of sRGB color space, which was skipped by ANGLE and had to be manually added in the fragment shader and clear functions.
Performance issues also surfaced, such as a maximum frame rate of 60 Hz and stuttering when reading frames back synchronously on QEMU's main thread. To address these problems, a two-stage pipeline was introduced, consisting of GPU copy and a fence, which was polled every 0.5 ms. This modification significantly reduced stutter frames from 8.2% to 0.2% during heavy loads. Additionally, network errors were encountered in game SDKs due to user-mode networking exposing IPv6. Turning IPv6 off resolved login issues.
Boot times were improved by implementing EGL_ANDROID_blob_cache, which persisted compiled shaders and reduced cold boot time from around 27 seconds to approximately 10 seconds. The engine overhead in a game's main city was around half a core of a single core when idle on the Android home screen. APK PlayStudio supports seven key-mapping types, one profile per game that automatically switches, Xbox/PlayStation/Switch Pro controllers with hot-switching, 33 built-in device profiles with matching resolution and DPI, multi-instance functionality, frame interpolation for 30 fps games, and MetalFX upscaling.
The software requires an Apple Silicon Mac (M1 or later) running macOS 13+. It is currently in Mac App Store review and is free for the first seven days before transitioning to a subscription model. Apple, Mac, macOS, and Metal are trademarks of Apple Inc., while Android is a trademark of Google LLC.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.