mosra / magnum-examples

Examples for the Magnum C++11 graphics engine
https://magnum.graphics/
The Unlicense
282 stars 95 forks source link

WebXR Fails to Load #102

Open TylerSeppala opened 2 years ago

TylerSeppala commented 2 years ago

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.

Squareys commented 2 years ago

Hi @TylerSeppala !

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

Which emscripten version are you using?

TylerSeppala commented 2 years ago

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

TylerSeppala commented 2 years ago

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 commented 2 years ago

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)

Squareys commented 2 years ago

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?

TylerSeppala commented 2 years ago

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