Skip to content

Add Android AAR project for embedding Babylon Native#1682

Open
CedricGuillemet wants to merge 3 commits intoBabylonJS:masterfrom
CedricGuillemet:AndroidAARPackage
Open

Add Android AAR project for embedding Babylon Native#1682
CedricGuillemet wants to merge 3 commits intoBabylonJS:masterfrom
CedricGuillemet:AndroidAARPackage

Conversation

@CedricGuillemet
Copy link
Copy Markdown
Collaborator

@CedricGuillemet CedricGuillemet commented Apr 28, 2026

Adds Install/AndroidAAR/ — a self-contained Gradle project producing a publishable Android AAR (BabylonNative-release.aar) intended to embed Babylon Native inside any Android application with the smallest possible footprint.

Footprint optimizations

  • QuickJS engine, libc++ statically linked
  • arm64-v8a + x86_64 only
  • OpenGL ES 3.0 backend only — no Vulkan / D3D / Metal compiled into bgfx
  • Image loading, shader compiler, NativeInput, XMLHttpRequest, NativeXr plugins disabled
  • Release built with MinSizeRel (-Os), function/data sections, hidden visibility, --gc-sections, --strip-all

Public contract

  • Embedding application drives script loading via BabylonView.loadScript() — nothing is auto-loaded by the AAR.
  • Optional shader cache is read from the embedding application's shadercache.bin asset.

Includes

  • README.md documenting the contract and footprint optimizations
  • build-release.ps1 helper that builds + prints AAR / .so sizes
  • New CI job Android_AAR (build-android-aar.yml) that builds the AAR, prints artifact sizes and uploads the AAR as a workflow artifact

Note

Temporarily pins JsRuntimeHost to the CedricGuillemet/JsRuntimeHost fork until the upstream QuickJS support PR is merged.
Naming is hard. I'm using generic/stupid names like 'Android-AAR'. Please provide your ideas.

Adds Install/AndroidAAR/ - a standalone Gradle project that builds a
publishable AAR (libBabylonNativeJNI.so + BabylonView/Wrapper Java
classes) tuned for the smallest possible footprint:

- QuickJS engine, libc++ statically linked
- Only arm64-v8a / x86_64 ABIs
- OpenGL ES 3.0 only (no Vulkan/D3D/Metal compiled into bgfx)
- Image loading, shader compiler, NativeInput, XMLHttpRequest, NativeXr
  plugins disabled
- Release build uses MinSizeRel (-Os, hidden visibility,
  --gc-sections, --strip-all)

Embedding application is expected to drive script loading via
BabylonView.loadScript() - nothing is auto-loaded by the AAR. Optional
shader cache is read from the embedding application's
'shadercache.bin' asset.

Includes:
- README.md documenting the contract and footprint optimizations
- build-release.ps1 helper that builds and prints AAR/.so sizes
- New CI job Android_AAR (build-android-aar.yml) that builds the AAR,
  prints artifact sizes and uploads the AAR as a workflow artifact

Note: temporarily pins JsRuntimeHost to CedricGuillemet/JsRuntimeHost
fork until the upstream QuickJS support PR is merged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 13:36
CedricGuillemet and others added 2 commits April 29, 2026 10:17
…JsRuntimeHost

- Restore JsRuntimeHost FetchContent declaration without EXCLUDE_FROM_ALL
  (per the comment block above, JsRuntimeHost is intentionally an exception
  because it exposes top-level targets like AppRuntime that are part of
  the Babylon Native contract).

- Rename Install/AndroidAAR -> Install/AndroidQuickJSMinimal and align all
  related identifiers:
    * workflow file: build-android-aar.yml -> build-android-quickjs-minimal.yml
    * CI job:       Android_AAR -> Android_QuickJSMinimal
    * gradle root project: BabylonNativeAAR -> BabylonNativeQuickJSMinimal
    * uploaded artifact: BabylonNative-release-aar -> BabylonNative-QuickJSMinimal-release-aar
    * build staging dir: Build/Android-AAR -> Build/Android-QuickJSMinimal

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The minimal AAR does not link NativeXr, so xrSurfaceChanged() and
isXRActive() are dead surface area. Drop them from:
  - BabylonNativeJNI.cpp (the two stub JNI exports)
  - Wrapper.java (the two native declarations)
  - BabylonView.java (the secondary xrSurfaceView, its callback and
    the isXRActive() check in onDraw)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant