magnum-examples icon indicating copy to clipboard operation
magnum-examples copied to clipboard

WebXR Fails to Load

Open TylerSeppala opened this issue 3 years ago • 6 comments

Hi,

I just did a build of Platform::EmscriptenApplication and it works just fine with the default "myApplication" project and the triangle example, displaying them correctly in the browser. However, I run into an issue when I attempt to build the WebXR example.

The project compiles just fine without any errors, and when I run it on a local server, it displays the expected page in the browser, even showing the correct scene in the small window. But when I try to enter the scene in VR, I just get an infinite loading screen, and the console outputs this error:

Uncaught (in promise) ReferenceError: dynCall is not defined at onSessionStart (magnum-webxr.js:6534) at onSessionStarted (magnum-webxr.js:6597)

onSessionStart @ magnum-webxr.js:6534 onSessionStarted @ magnum-webxr.js:6597 Promise.then (async) Module.webxr_request_session_func @ magnum-webxr.js:6620 _webxr_request_session @ magnum-webxr.js:6638 $func216 @ magnum-webxr.wasm:0x6812 $func308 @ magnum-webxr.wasm:0x9c50 mouseEventHandlerFunc @ magnum-webxr.js:4677 jsEventHandler @ magnum-webxr.js:4499

I also get a similar error when I exit the session. I'm attempting to view this using port forwarding on a Quest 2, and the CMake commands I'm using are:

mkdir build-emscripten && cd build-emscripten cmake ..
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten-wasm.cmake"
-DCMAKE_PREFIX_PATH="/home/tseppala/.emsdk/upstream/emscripten/system"
-DCMAKE_INSTALL_PREFIX=/mnt/h/CodeTests/MagServer cmake --build . cmake --build . --target install

Did I forget to include something in my build? Is this a problem with my Emscripten installation? Or am I just typing the wrong commands?

Any help would be greatly appreciated.

TylerSeppala avatar Jan 19 '22 07:01 TylerSeppala

Hi @TylerSeppala !

I saw the email first and replied there, but here's a summary for anyone who comes across this issue:

  • library_webxr.js is from emscripten-webxr, which has received some updates, but nothing directly relating to the dynCall() error you have here. You might find useful cmake flags there and using that repository as a subproject allows you to link to it like a static library.
  • Port forwarding should not be related here, that works fine with emscripten-webxr.

Which emscripten version are you using?

Squareys avatar Jan 19 '22 08:01 Squareys

Alright, good to know. I'm using emscripten 3.1.1

TylerSeppala avatar Jan 19 '22 17:01 TylerSeppala

New developments:

I just decided to go all the way back to emscripten v1.39.4 because that was the version around the time this code was written... and it kind of works. I can now enter VR and see everything just fine, but it seems that shading isn't working properly. The sides of the cubes that are supposed to have any amount of shadow are completely black.

So it seems the problem is definitely surrounding the emscripten version. Maybe I just need to find the right version?

TylerSeppala avatar Jan 19 '22 19:01 TylerSeppala

This is the new error I'm getting... mean anything to anyone?

Uncaught TypeError: Cannot read properties of null (reading 'transform') at _webxr_get_input_pose (magnum-webxr.js:6621) at magnum-webxr.wasm:0x4032 at magnum-webxr.wasm:0x72fd at magnum-webxr.wasm:0x3874 at magnum-webxr.wasm:0x4afef at Module.dynCall_viiii (magnum-webxr.js:7156) at dynCall (magnum-webxr.js:538) at XRSession.onFrame (magnum-webxr.js:6698)

TylerSeppala avatar Jan 19 '22 19:01 TylerSeppala

Whew, so much trouble, I wonder how this is working so well for us 🤔 We're on 2.0.23 at the moment. With a bit of luck that might the version that works for you, too?

Squareys avatar Jan 20 '22 07:01 Squareys

Thanks, I'll definitely try that in the morning!

TylerSeppala avatar Jan 20 '22 07:01 TylerSeppala