DEV Community

hon6
hon6

Posted on AI-assisted

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 stack

  • CPU: QEMU's virt machine with -accel hvf (Hypervisor.framework). One process per emulator, controlled by the Swift app over QMP; frames come back through IOSurface shared memory with zero copies.
  • Touch: QEMU's virtio-multitouch device, driven directly over QMP input-send-event. No adb in the input path, and real multi-touch: holding W to move while dragging the mouse to aim and pressing a skill key is three fingers on the screen at once.
  • Graphics: GLES 3.2 → Mesa virgl (guest) → virtio-gpu → virglrenderer → ANGLE (Vulkan backend) → KosmicKrisp → Metal.

One hard limit comes from the chip: Apple Silicon has no 32-bit ARM support, so only arm64-v8a apps install. Most current games ship 64-bit builds.

Things that were harder than expected

  • GLES version. ANGLE's Metal backend stops at GLES 3.0. Its Vulkan backend on MoltenVK gives 2.0; on KosmicKrisp it gives 3.1. A few virglrenderer patches later the guest reports GLES 3.2. Geometry shaders stay unavailable because Metal has none.
  • Dark frames. Android window buffers are linear RGBA8 and games using a linear color space write through sRGB views. ANGLE has no texture views, so the sRGB encode was silently skipped. Encoding manually in the fragment shader and in clears fixed it.
  • Stuck at 60 Hz. Android's vsync follows the virtual display's EDID. Writing the host refresh rate into the virtio-gpu EDID unlocked up to 144 fps.
  • Stutter. Reading frames back synchronously on QEMU's main thread (where virgl also lives) caused hitches. A two-stage pipeline (GPU copy + fence, polled every 0.5 ms) cut stutter frames under heavy load from 8.2% to 0.2%.
  • "Network error" in game SDKs. User-mode networking exposed IPv6; apps tried IPv6 first and waited 10 s to time out. Turning IPv6 off fixed logins.
  • Boot time. Implementing EGL_ANDROID_blob_cache to persist compiled shaders brought cold boot from about 27 s down to about 10 s.

On top of the engine

Seven key-mapping types (tap, rapid tap, auto-click, joystick, swipe, camera look, aimed skill), one profile per game that switches automatically, Xbox / PlayStation / Switch Pro controllers with hot-switching, 33 built-in device profiles with matching resolution and DPI, multi-instance, frame interpolation for 30 fps games and MetalFX upscaling.

Measured on an M5 Max: about 9% of one core when idle on the Android home screen, about half a core of engine overhead in a game's main city.

APK PlayStudio needs an Apple Silicon Mac (M1 or later) and macOS 13+. It is currently in Mac App Store review, free for the first 7 days, then a subscription. Site: https://apkplaystudio.betac.cn/en/

Apple, Mac, macOS and Metal are trademarks of Apple Inc. Android is a trademark of Google LLC.

Top comments (0)