Run Android ARM64 VR APKs on Apple Vision Pro

Run Android ARM64 VR APKs on Apple Vision Pro

在 Apple Vision Pro 上运行 Android ARM64 VR APK

Klepton Running Android ARM64 VR APKs on Apple Vision Pro, no JIT required! Architecture klepton-ld translates Android .so libraries into loadable Apple .dylib and .framework libraries, which then link into the Klepton runtime. Klepton currently focuses on Java-thin applications only (no ART, no JVM). For graphics, GLES 3.2 is translated to a vendored ANGLE GLES 3.0 (with its Metal backend), and Vulkan is translated to MoltenVK.

Klepton 可以在 Apple Vision Pro 上运行 Android ARM64 VR APK,且无需 JIT(即时编译)!其架构通过 klepton-ld 将 Android 的 .so 库转换为可加载的 Apple .dylib.framework 库,然后链接到 Klepton 运行时中。目前 Klepton 仅专注于“瘦 Java”应用(不包含 ART 或 JVM)。在图形方面,GLES 3.2 被转换为供应商提供的 ANGLE GLES 3.0(使用 Metal 后端),而 Vulkan 则被转换为 MoltenVK。

┌─────────────────────────────────────────────────────────────────┐ │ GUEST (translated Mach-O, instruction bytes mostly unmodified) │ │ libil2cpp · libunity · libunityopus · libmain · burst · … │ └─────────────────────────────────────────────────────────────────┘ ↕ imports resolved to Klepton runtime in klepton-ld ┌─────────────────────────────────────────────────────────────────┐ │ libklepton_bionic libc/libm/libdl/pthread/liblog → libSystem │ │ libklepton_ndk ALooper · ANativeWindow · ASensor · AAsset │ │ libklepton_jni synthetic JavaVM / JNIEnv │ │ libklepton_ovrp ovrp_* reimplementation │ │ … │ └─────────────────────────────────────────────────────────────────┘ ↕ Frontend platform (mains) and OS-specifics ┌─────────────────────────────────────────────────────────────────┐ │ MoltenVK (Vulkan → Metal) ANGLE (GLES 3.0) │ │ Compositor Services · ARKit · GameController · AVAudioEngine │ └─────────────────────────────────────────────────────────────────┘

(架构图:客体层(转换后的 Mach-O,指令字节基本未修改)↔ klepton-ld 解析导入至 Klepton 运行时 ↔ Klepton 运行时层(Bionic/NDK/JNI/OVR 重新实现)↔ 前端平台与操作系统特定层(MoltenVK/ANGLE/ARKit 等))

While both Android and macOS reserve x18, some (a lot of) older Android applications still use x18, and macOS zeros x18 on context switches. All usage of x18 is patched by klepton-ld so that per-library TLS slots are used instead. Klepton also has the ability to load and patch .so files at runtime with mmap, but this is only really useful on macOS where JIT is actually allowed. It’s likely that some applications will require JIT if they happen to utilize scripting runtimes that expect it (LuaJIT, V8, whatever else).

虽然 Android 和 macOS 都保留了 x18 寄存器,但许多较旧的 Android 应用仍在使用它,而 macOS 在上下文切换时会将 x18 清零。klepton-ld 会修补所有对 x18 的使用,改为使用每个库独立的 TLS(线程本地存储)槽位。Klepton 还具备在运行时通过 mmap 加载和修补 .so 文件的能力,但这仅在允许 JIT 的 macOS 上才真正有用。如果某些应用使用了依赖 JIT 的脚本运行时(如 LuaJIT、V8 等),它们很可能仍需要 JIT 支持。

Building See BUILDING.md for the full guide. The short version: brew install pkg-config sdl3 apktool # host dependencies apktool d -f -o beatsaber beatsaber.apk # you supply the APK; see BUILDING.md make check # full regression sweep

构建 完整指南请参阅 BUILDING.md。简要步骤如下: brew install pkg-config sdl3 apktool # 安装主机依赖 apktool d -f -o beatsaber beatsaber.apk # 提供 APK 文件;详见 BUILDING.md make check # 执行完整回归测试

Quick run scripts: ./build_run_viewer.sh # build and run macOS Beat Saber frontend ./build_run_vpro.sh # build and run Vision Pro Beat Saber frontend ./build_run_slink.sh —shell —view # macOS Steam VR Link frontend (WIP)

快速运行脚本: ./build_run_viewer.sh # 构建并运行 macOS 版 Beat Saber 前端 ./build_run_vpro.sh # 构建并运行 Vision Pro 版 Beat Saber 前端 ./build_run_slink.sh —shell —view # macOS 版 Steam VR Link 前端(开发中)

Status Beat Saber is working on macOS and visionOS with minor graphical issues, Steam VR Link and improving generalizability/build tooling is still WIP.

状态 Beat Saber 已可在 macOS 和 visionOS 上运行,仅存在少量图形问题;Steam VR Link 以及通用性/构建工具的改进工作仍在进行中。