Babylon native on Ubuntu

Hello, is there any way to install Babylon native in Android Studio with Ubuntu ?
I have all the package requirements installed but I’m not sure where to add them.

Thank you very much.

Once Android Studio + NDK, ninja and CMake are installed, clone the BabylonNative repo with subrepos and follow the instructions on the readme :


Then in AndroidStudio, open the project folder Apps/Playground/Android
Let me know if you have troubles getting the playground to run.

Sorry for not specifying I’m targeting Android, not native Ubuntu…

I’m not totally awake yet :smiley:
GitHub - BabylonJS/BabylonNative: Build cross-platform native applications with the power of the Babylon.js JavaScript framework
Requirements and procedure are the same (npm install)
Also, check this page if you have troubles setting the emulator : BabylonNative/AndroidSimulator.md at master · BabylonJS/BabylonNative · GitHub

After a long long day (Of tinkering with Android Studio), I got it to build, I’ve noticed that after i updated gradle I had to add the following lines in the build.gradle

packagingOptions {
    pickFirst 'lib/armeabi-v7a/libjsc.so'
    pickFirst 'lib/arm64-v8a/libjsc.so'
    pickFirst 'lib/x86/libjsc.so'
    pickFirst 'lib/x86_64/libjsc.so'
}

Unfortunately it doesn’t work on my Alcatel PIXI 4, I will try and test it on a wider range of devices.

Android Studio is still causing me headaches lol, It gets stuck at “Waiting for all target devices…” even tho the Emulator is up and running.

by default, the JavaScript engine is V8. Do you know why you have to add those lines in Gradle?
Can you copy/paste here the logcat errors you get when running on Alcatel PIXI4?

I had to switch from V8 because I ran into some configuration errors. I will try to recreate the environment that caused the error and will get back with an answer.
The lines were added because I was getting an error More than one file was found with OS independent path ‘lib/x86/libjsc.so’.

The reason i couldn’t run V8 was this

Cannot find source file:

source/env_V8.cc

i’ve checked and the files don’t have capital ‘V’ but a ‘v’ I’ll try to do a quick fix and come back.

I managed to ‘trick’ it to run v8 … It builds…

Logcat :

11-12 19:11:54.582 15814-15814/com.android.babylonnative.playground E/MultiWindowProxy: getServiceInstance failed!
11-12 19:11:54.910 15814-15879/com.android.babylonnative.playground A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 15879 (tive.playground)

That’s not enough to get a diagnostic :slight_smile:
Can you have a callstack when debugging the attached app?

Here’s a little bit more data more data… :slightly_smiling_face:

.PlaygroundActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 21904 on device ‘tcl-4034d-75ZP9PVCQS9HQC9D’.
Capturing and displaying logcat messages from application. This behavior can be disabled in the “Logcat output” section of the “Debugger” settings page.
E/MultiWindowProxy: getServiceInstance failed!
D/: /home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/bgfx.cpp (3449): BGFX Init…
D/: /home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/bgfx.cpp (3456): BGFX Version 1.108.7318 (commit: 22df26ab70acb3f36018796fbe952751fa91a9f8)
D/: /home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/bgfx.cpp (1838): BGFX Multithreaded renderer is disabled.
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/bgfx.cpp (1842): BGFX Running in single-threaded mode
D/: /home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/glcontext_egl.cpp (191): BGFX EGL info:
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/glcontext_egl.cpp (193): BGFX APIs: OpenGL_ES
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/glcontext_egl.cpp (196): BGFX Vendor: Android
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/glcontext_egl.cpp (199): BGFX Version: 1.4 Android META-EGL
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/glcontext_egl.cpp (202): BGFX Supported EGL extensions:
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_get_all_proc_addresses
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_ANDROID_presentation_time
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_swap_buffers_with_damage
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_image
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_image_base
D/: /home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_image_pixmap
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_gl_texture_2D_image
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_gl_texture_cubemap_image
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_gl_renderbuffer_image
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_fence_sync
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_create_context
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_EXT_create_context_robustness
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_ANDROID_image_native_buffer
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_ANDROID_recordable
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_KHR_partial_update
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (1136): BGFX EGL_EXT_buffer_age
D/: /home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/glcontext_egl.cpp (320): BGFX Failed to create EGL context with EGL_CONTEXT_FLAGS_KHR (00000001).
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/glcontext_egl.cpp (320): BGFX Failed to create EGL context with EGL_CONTEXT_FLAGS_KHR (00000000).
/home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/glcontext_egl.cpp (323): BGFX 0x00000002: Failed to create context.
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 21927 (tive.playground)

Also the quick fix to get v8 running on Ubuntu 18

napi/CMakeLists.txt

17 : set(SUPPORTED_JAVASCRIPT_ENGINES "Chakra" "v8" "JavaScriptCore" "JSI")

app/CMakeLists.txt
30 : set(NAPI_JAVASCRIPT_ENGINE "v8" CACHE STRING "JavaScript engine for N-API.")

I also had to rename core/AppRuntime/Source/AppRuntimeV8.cpp -> AppRuntimev8.cpp

Hope this is helpful.

Got it up and running in the emulator with the following AVD (This was the minimum that worked for me) :

Pixel 2 XL API 25
Android 7.1.1
Graphics : Hardware - GLES 2.0
Multi-Core CPU 1
RAM 1024 (2048 for decent performance and less glteximage2d error 0x501)

The rest of the settings were standard. I also had to set from the emulator (More -> Settings -> Advanced -> Renderer maximum (up to OpenGL ES 3.1)

Update : Cesium man is working :slight_smile: … I have a quick question, does the Android version support .babylon files ?

1 Like

It should, yes! Let me know if you have issues.

Is there a way to keep in touch with the development team ?

In the future weeks I’ll migrate my game to Android and I can provide a lot of valuable information and even minor bug fixes.
Also I think have the opportunity to test my game (and the engine implicitly) on multiple mobile phones.

That excellent new @gtudorache !!!
This forum is an excellent place to submit your questions. There will always be someone here to answer. If you find a bug/crash, we will create an issue here : Issues · BabylonJS/BabylonNative · GitHub
You can also ping me directly :slight_smile:

I’ve been having trouble loading .babylon files, glTF works well.

Got two crashes with .babylon format :
Fatal signal 5 (SIGTRAP), code 128 - On o remote file
A/libc: Fatal signal 6 (SIGABRT), code -6 - On a file accessed via app:/// protocol

I will come back with more information tomorrow…

1 Like

Here’s the error I get from opening a remote .babylon file

2020-11-14 04:13:36.746 6264-6318/com.android.babylonnative.playground E/emuglGLESv2_enc: device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glRenderbufferStorage:2339 GL error 0x500
2020-11-14 04:13:48.346 6264-6318/com.android.babylonnative.playground A/libc: Fatal signal 5 (SIGTRAP), code 128 in tid 6318 (tive.playground)

I’ve attached a debugger …

it goes like this :slightly_smiling_face:

Babylon::NativeEngine::CreateFrameBuffer
bgfx::createFrameBuffer
bgfx::createTexture2D

It fails with “Invalid texture size (width 0, height 0)”

As I see it, it creates 0x0 framebuffer and tries to use it as a texture.

Quick fix for the bugs I’ve encountered :slight_smile: , the model loads correctly :

NativeEngine.cpp

1049 : if (width <= 0) width = 1;
1050 : if (height <= 0) height = 1;

1284 : if (width <= 0) width = 1;
1285 : if (height <= 0) height = 1;