Babylon native on Ubuntu

Tried to get it running with a debugger on my Pixi again, no success, it fails to create context (even when I fall back to OpenGL ES 1). I think it’s an OS issue, because it does the same in emulation (AVD) with Android < 7.0.

Wouldn’t it be better if we created a special thread for Babylon Native testing ?

Because I will gradually go through all the stages of development (as I migrate all my code from browser to Native) and hopefully ‘catch’ all the errors.

I’ve started the migration of the game… unfortunately I think I’m missing something.
Here’s the code in the CreateBoxAsync().then’ :

                    var camera = new BABYLON.UniversalCamera("FreeCamera", new BABYLON.Vector3(20, 20, 20), scene);


                    scene.collisionsEnabled = true;
                    scene.gravity = new BABYLON.Vector3(0, -0.9, 0);
                    camera.checkCollisions = true;
                    camera.applyGravity = true;
                    camera.ellipsoid = new BABYLON.Vector3(1, 1.8, 1);
                    camera.inertia = 0;
                    camera.speed = 0.1;
                    camera.maxZ = 1500;
                    scene.activeCamera(camera);

                    CreateInputHandling(scene);

                    var skybox = new BABYLON.MeshBuilder.CreateSphere("skyBox", {diameter:1200}, scene);
                    skybox.isPickable = false;
                    var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
                    skyboxMaterial.backFaceCulling = false;
                    skyboxMaterial.reflectionTexture = new BABYLON.Texture("http://192.168.0.10/3d/assets/images/TropicalSunnyDay_ny.jpg", scene);
                    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SPHERICAL_MODE;
                    skyboxMaterial.emmisiveColor = new BABYLON.Color3(0.2, 0.2, 0.5);

                    skyboxMaterial.specularColor = new BABYLON.Color3(0.2, 0.2, 0.5 );
	                skyboxMaterial.diffuseColor = new BABYLON.Color3(0.2, 0.2, 0.5 );

                    skybox.material = skyboxMaterial;
                    skybox.infiniteDistance = true;
	                skybox.visibility = 1;
	                skybox.applyFog = false;



	                 var spot = new BABYLON.PointLight("spot", new BABYLON.Vector3(0, 400, -300), scene);

	                 var shadowGenerator = new BABYLON.ShadowGenerator(128, spot);

                      shadowGenerator.filteringQuality = BABYLON.ShadowGenerator.QUALITY_LOW;

                      spot.diffuse = new BABYLON.Color3(1, 1, 1);
                      spot.specular.copyFromFloats( 0.07, 0.07, 0.07);
                      spot.intensity = 5;
        		      spot.infiniteDistance = true;


	            var sunnyMaterial = new BABYLON.TerrainMaterial("terrainMaterial", scene);
                sunnyMaterial.ambientColor = new BABYLON.Color3(0.4, 0.4, 0.4);
                sunnyMaterial.diffuseColor = new BABYLON.Color3(0.4, 0.4, 0.4);
                sunnyMaterial.specularColor = new BABYLON.Color3(0.45, 0.45, 0.45);
	            sunnyMaterial.specularPower = 0.1;
		            sunnyMaterial.mixTexture = new BABYLON.Texture("http://192.168.0.10/3d/assets/images/mixMapSunny.png", scene);

                var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "http://192.168.0.10/3d/assets/images/02.png", 500, 500, 13, 0, 10, scene, false, null);
                ground.material = sunnyMaterial;
                ground.receiveShadows = true;
                ground.position = new BABYLON.Vector3(0, 0, 0);
                ground.isPickable = true;
                ground.checkCollisions = true;

                  if (logfps) {
                      var logFpsLoop = function () {
                          BABYLON.Tools.Log("FPS: " + Math.round(engine.getFps()));
                          window.setTimeout(logFpsLoop, 1000);
                      };

                      window.setTimeout(logFpsLoop, 3000);
                  }

    engine.runRenderLoop(function () {
        scene.render();
    });

All I get is a blank screen, and nothing happening in Debug.

Can you remove the code to create shadows? It’s unsupported for now

I’ve tried everything, it’s the same…

Oh, and I get a lot of these in the event log (Some of them were there with the test with the building that worked) :

11:38 Emulator: sPrepareTexImage2D:3452 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x502

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3452 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x502

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:440 error 0x501

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLcommon/TextureUtils.cpp:doCompressedTexImage2D:521 error 0x500

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3452 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x502

11:38 Emulator: sPrepareTexImage2D:3452 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x502

11:38 Emulator: sPrepareTexImage2D:3452 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x502

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

11:38 Emulator: sPrepareTexImage2D:3440 failed validation

11:38 Emulator: /mnt/tmpfs/src/android/emu-30-release/external/qemu/android/android-emugl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp:glTexImage2D:3489 error 0x501

It’s like 'CreateBoxAsync().then(function () { ’ line doesn’t execute, because I don’t even get the framerate and no exceptions.

ok, let me check that on my linux box

Paused the debugger, it just gets stuck at nSyncAndDrawFrame. I’ve tried to strip the code to just the skybox, light and camera… And it’s still the same.

Ok, ‘reporting’ again :slight_smile: after adding some extra debugging :slight_smile: :

  • Got the camera, light and skybox working by removing ‘scene.activeCamera(camera);’
  • The BABYLON.TerrainMaterial isn’t implemented yet.
  • The other “Emulator: …” errors disappeared after an Android Studio update to version 4.1.1
  • BABYLON.Mesh.CreateGroundFromHeightMap fails with three errors (apparently the features are not implemented yet) :

D/: /home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (5405): BGFX Texture2D 2: RGB8 (requested: RGB8), layers 1, 3648x2736x0.
E/libEGL: called unimplemented OpenGL ES API

D/: /home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (5871): BGFX Vertex Shader consts 12
E/libEGL: called unimplemented OpenGL ES API

D/: /home/gabriel/Documents/3dnative/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/renderer_gl.cpp (5405): BGFX Texture2D 1: RGB8 (requested: RGB8), layers 1, 2048x2048x0.
E/libEGL: called unimplemented OpenGL ES API

called unimplemented OpenGL ES API

It’s your GPU driver that doesn’t implement those functions. Not Babylon Native.

BTW, ca you upload your assets to github so I check how it goes with the same resources ?

It’s your GPU driver that doesn’t implement those functions. Not Babylon Native.

Weird, in the browser version it works well. Hopefully the phone that I ordered will come soon, so I can properly test it.

BTW, ca you upload your assets to github so I check how it goes with the same resources ?

I will upload them tomorrow… I’m just recovering Ubuntu from a bad driver install (I thought the drivers were the fault too :slight_smile:)

1 Like

I’m doing Linux tests. I’ve had the same issue as yourself with the V8 case. I’m doing a PR now.
I didn’t get any troubles with the pickFirst packaging option. defaults worked for me.
And built .apk works on my device (Oppo Reno2)

New updates fresh upgrade to Ubuntu 20.04, Android Studio from snap … After updating NDK the build fails at JavaWrappers.cpp (@132) :slightly_frowning_face:

Quick fix : Changed the scope of std::string message; :slight_smile:

129: std::string message;
130: const char* Throwable::what() const noexcept
131: {
132:    message = GetMessage();
133:    return message.c_str();        //herez
134: }

It now starts, same problem with shaders…

can you please copy/paste the error you got for the message issue?
I didn’t get any compile error. Ubuntu 20.04, Android studio 4.1.1 downloaded from the website and latest ndk.

…/Documents/3dnative/BabylonNative/Dependencies/AndroidExtensions/Source/JavaWrappers.cpp:134:16: error: address of stack memory associated with local variable ‘message’ returned [-Werror,-Wreturn-stack-address]

Original code :

const char* Throwable::what() const noexcept
{
    std::string message;
    message = GetMessage();
    return message.c_str();
}

I know my solution isn’t a proper patch… It’s just a quick fix because I’m frustrated, my whole day seemed to go backwards :slightly_frowning_face:

It looks like master has been updated with changes regarding that string

Please try with the latest master version or the branch linked above that contains my changes to v8 file names

I’ve created a repository and sent you an invite :smiley:

It contains the current assets and quickfixes (just one for now, after updating BabylonNative only one error remained)

Unfortunately I still can’t get the terrain to work in AVD :frowning:, waiting for a test phone to arrive.

sounds good. let me know when you phone arrives and how it goes with it.