Skip to content

Conversation

@CedricGuillemet
Copy link
Contributor

@CedricGuillemet CedricGuillemet commented Jun 6, 2025

WIP

Goal

Deliver 1 single self contained package with sources (no fetch, no secondary download) for all platform, for all RN versions.
Deprecated existing (Playground, tests, build script) in favor of a single RNTA Playground and simpler tooling.

Building the new NPM

  • Gather all sources (BabylonNative and dependencies) needed by Android/iOS/Windows builds
  • Remove unncessary dependencies (bgfx examples) and generate glue CMake files
  • Bundle previous iosAndroid and Windows Packages into a single NPM along gathered sources

Testing

  • Build RNTA for iOS, Android and Windows
  • Publish an artifact so it can be tested locally

PR Changes

  • Removed old system
  • Renamed BRNPlayground -> Playground
  • Moved react-native-iosandroid and react-native-windows content into Modules/@babylonjs/react-native folder
  • Added buildBabylonNativeSourceTree gulp export to gather BN sources
  • Update Android Gradle to use fetched content and build BabylonNative instead of using static libraries

TODO

  • Android Build
  • Windows Build
  • iOS Build
  • NPM Test publish job
  • Build .ts
  • Publish testable artifacts
  • Remove bgfx example/3rdparty folders
  • Permissions
  • Env var to disable XR and/or Camera plugins (BABYLON_NATIVE_PLUGIN_NATIVECAMERA=0, BABYLON_NATIVE_PLUGIN_NATIVEXR=0)
  • Webp
    - [ ] Script to change RN version for RNTA Left to users to get a working node environment
  • Documentation/Readme
  • Missing CI scripts (publish)
  • Test Playground Android
  • Test Playground iOS
  • Test Playground Windows
  • Test Package Android
  • Test Package iOS
  • Test Package Windows
  • Link error with react-native :
ld.lld: error: undefined symbol: facebook::react::CallInvokerHolder::getCallInvoker() >>> referenced by BabylonNativeInterop.cpp:39 (/Users/cedricguillemet/dev/BRNAnd/Apps/Playground/node_modules/@babylonjs/react-native/android/src/main/cpp/BabylonNativeInterop.cpp:39) >>> CMakeFiles/BabylonNative.dir/src/main/cpp/BabylonNativeInterop.cpp.o:(Java_com_babylonreactnative_BabylonNativeInterop_00024BabylonNative_initialize) 

issue with RN 0.78. fixed with RN 0.80. not tested with previous versions. To fix (if it happens) on user side.

Notes:

  • Android debug build asserts in spirv shader compilation. It works fine in release.
  • Android XR not tested because of missing ARCore dependency. I guess it should be part of the app and not the package. To confirm!
  • ios XR working correctly

Pros/Cons of sources in package

Pros

  • smaller disk footprint. no need to clear up space : https://github.com/BabylonJS/BabylonReactNative/tree/master/.github/workflows/macos_freespace
  • 1 single NPM package for all platforms and RN versions instead of 21
  • smaller NPMs (Windows is 700Mb per RN version)
  • put breakpoints anywhere
  • simpler builds (Android is handled by CMake, no need for Windows build scripts)
  • support for ABI breaking changes
  • unity build not needed anymore (windows binary size issue not relevant)
  • gulp script is reduced in scope
  • more precise control on components used (no more BASE_KIT package)
  • same podspec for dev and NPM
  • faster PR build/publish: ~15min Vs 1h
  • asserts firing!

Cons

  • need to build BN source with same toolchain flags as BRN (but same for prebuilt static libraries)
  • slower build for users (?). need testing for that
  • Xcode builds need CMake

Sizes

Binary packages

TS : 23Kb
Windows: 102Mb (700Mb Unzipped)
iOS-Android: 21Mb (65Mb Unzipped)

Source package

13Mb (74Mb Unzipped)

@CedricGuillemet
Copy link
Contributor Author

@ryantrem Now using cmake-runtime. Its use will appear in the log : Using CMake version 3.31.0 from /Users/runner/work/BabylonReactNative/BabylonReactNative/Modules/@babylonjs/react-native/node_modules/cmake-runtime/bin/cmake

@ryantrem ryantrem self-requested a review July 16, 2025 18:59
CedricGuillemet added a commit to BabylonJS/BabylonNative that referenced this pull request Jul 17, 2025
related to BabylonJS/BabylonReactNative#665 Some dependencies are fetched only for the platform being built. `BABYLON_NATIVE_BUILD_SOURCETREE` variable has been added to allow fetching independently of active platform. --------- Co-authored-by: Drew Fillebrown <andy@docEdub.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants