Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webxr example gives blank white page in firefox, chromium-browser, and quest3. errors appear in firefox dev console. #4421

Open
mutantbob opened this issue Jan 31, 2025 · 3 comments
Labels

Comments

@mutantbob
Copy link

Describe the Bug

When I try to run the webxr example, I get errors in my xterm and a copy of the error in the browser.

Steps to Reproduce

I have version c35cc93 checked out.
rustup show reports rustc 1.83.0 (90b35a623 2024-11-26)
I upgraded wasm-pack to v0.13.1
npm is 7.24.2
OS is Ubuntu 20.04.6 LTS

I followed the instructions in the README

cd examples/webxr
RUSTFLAGS=--cfg=web_sys_unstable_apis npm run serve

and used firefox to browse to localhost:8080

Expected Behavior

I expected some kind of XR demo to display in the web browser.

Actual Behavior

Instead I the browser showed me an error message which was also present in the xterm running the server:

examples/webxr$ RUSTFLAGS=--cfg=web_sys_unstable_apis npm run serve

> serve
> webpack serve

🧐  Checking for wasm-pack...

✅  wasm-pack is installed at /home/thoth/.cargo/bin/wasm-pack. 

ℹ️  Compiling your crate in development mode...

<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8080/, http://[::1]:8080/
<i> [webpack-dev-server] On Your Network (IPv4): http://172.18.0.1:8080/
<i> [webpack-dev-server] Content not from webpack is served from '/home/thoth/vendor/wasm-bindgen/examples/webxr/public' directory
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
   Compiling unicode-ident v1.0.12
   Compiling proc-macro2 v1.0.86
   Compiling wasm-bindgen-shared v0.2.100 (/home/thoth/vendor/wasm-bindgen/crates/shared)
   Compiling bumpalo v3.16.0
   Compiling log v0.4.22
   Compiling rustversion v1.0.17
   Compiling autocfg v1.3.0
   Compiling wasm-bindgen v0.2.100 (/home/thoth/vendor/wasm-bindgen)
   Compiling cfg-if v1.0.0
   Compiling futures-sink v0.3.30
   Compiling futures-core v0.3.30
   Compiling once_cell v1.19.0
   Compiling pin-project-lite v0.2.14
   Compiling futures-channel v0.3.30
   Compiling futures-io v0.3.30
   Compiling memchr v2.7.4
   Compiling pin-utils v0.1.0
   Compiling futures-task v0.3.30
   Compiling slab v0.4.9
   Compiling quote v1.0.37
   Compiling syn v2.0.87
   Compiling wasm-bindgen-backend v0.2.100 (/home/thoth/vendor/wasm-bindgen/crates/backend)
   Compiling futures-macro v0.3.30
   Compiling wasm-bindgen-macro-support v0.2.100 (/home/thoth/vendor/wasm-bindgen/crates/macro-support)
   Compiling futures-util v0.3.30
   Compiling wasm-bindgen-macro v0.2.100 (/home/thoth/vendor/wasm-bindgen/crates/macro)
   Compiling js-sys v0.3.77 (/home/thoth/vendor/wasm-bindgen/crates/js-sys)
   Compiling futures-executor v0.3.30
   Compiling futures v0.3.30
   Compiling web-sys v0.3.77 (/home/thoth/vendor/wasm-bindgen/crates/web-sys)
   Compiling wasm-bindgen-futures v0.4.50 (/home/thoth/vendor/wasm-bindgen/crates/futures)
   Compiling webxr v0.0.0 (/home/thoth/vendor/wasm-bindgen/examples/webxr)
warning: unexpected `cfg` condition value: `console_error_panic_hook`
 --> examples/webxr/src/utils.rs:8:11
  |
8 |     #[cfg(feature = "console_error_panic_hook")]
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the condition
  |
  = note: no expected values for `feature`
  = help: consider adding `console_error_panic_hook` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: requested on the command line with `-W unexpected-cfgs`

warning: use of deprecated method `web_sys::XrRenderStateInit::base_layer`: Use `set_base_layer()` instead.
   --> examples/webxr/src/lib.rs:106:31
    |
106 |             render_state_init.base_layer(Some(&xr_gl_layer));
    |                               ^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

warning: `webxr` (lib) generated 2 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 16.06s
[INFO]: ⬇️  Installing wasm-bindgen...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: ✨   Done in 16.25s
[INFO]: 📦   Your wasm pkg is ready to publish at /home/thoth/vendor/wasm-bindgen/examples/webxr/pkg.
✅  Your crate has been correctly compiled

assets by path *.js 312 KiB
  asset index.js 279 KiB [emitted] (name: main)
  asset webxr_js.index.js 33.3 KiB [emitted]
asset b644a7bf9ea0210ebe36.module.wasm 1.52 KiB [emitted] [immutable]
asset index.html 222 bytes [emitted]
runtime modules 31.5 KiB 15 modules
modules by path ./node_modules/ 185 KiB
  modules by path ./node_modules/webpack-dev-server/client/ 81.9 KiB 17 modules
  modules by path ./node_modules/webpack/hot/*.js 5.17 KiB 4 modules
  modules by path ./node_modules/html-entities/lib/*.js 78.9 KiB 4 modules
  ./node_modules/ansi-html-community/index.js 4.16 KiB [built] [code generated]
  ./node_modules/events/events.js 14.5 KiB [built] [code generated]
modules by path ./pkg/ 17 KiB (javascript) 261 KiB (webassembly)
  ./pkg/index.js 167 bytes [built] [code generated]
  ./pkg/index_bg.wasm 40 bytes (javascript) 261 KiB (webassembly) [built] [code generated] [1 error]
  ./pkg/index_bg.js 16.8 KiB [built] [code generated]
modules by path ./*.js 325 bytes
  ./index.js 175 bytes [built] [code generated]
  ./webxr.js 150 bytes [built] [code generated]

ERROR in ./pkg/index_bg.wasm
Module parse failed: Internal failure: parseVec could not cast the value
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: Internal failure: parseVec could not cast the value
    at parseVec (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:343:15)
    at parseTypeSection (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:375:22)
    at parseSection (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1379:23)
    at Object.decode (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1740:25)
    at decode (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/@webassemblyjs/wasm-parser/lib/index.js:253:21)
    at WebAssemblyParser.parse (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/webpack/lib/wasm-async/AsyncWebAssemblyParser.js:61:19)
    at /home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/webpack/lib/NormalModule.js:1299:19
    at processResult (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/webpack/lib/NormalModule.js:933:11)
    at /home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/webpack/lib/NormalModule.js:1026:5
    at /home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/loader-runner/lib/LoaderRunner.js:407:3
 @ ./pkg/index.js 1:0-40 4:15-19 5:0-21
 @ ./webxr.js 1:0-30 3:16-26
 @ ./index.js 3:0-20

webpack 5.94.0 compiled with 1 error in 16766 ms
assets by status 35 KiB [cached] 3 assets
assets by status 280 KiB [emitted]
  asset index.js 279 KiB [emitted] (name: main)
  asset main.829c767a5a9b119d9444.hot-update.js 843 bytes [emitted] [immutable] [hmr] (name: main)
  asset main.829c767a5a9b119d9444.hot-update.json 28 bytes [emitted] [immutable] [hmr]
Entrypoint main 280 KiB = index.js 279 KiB main.829c767a5a9b119d9444.hot-update.js 843 bytes
cached modules 185 KiB [cached] 29 modules
runtime modules 31.5 KiB 15 modules
modules by layer 17 KiB (javascript) 261 KiB (webassembly)
  ./pkg/index.js 167 bytes [built]
  ./pkg/index_bg.wasm 40 bytes (javascript) 261 KiB (webassembly) [built] [1 error]
  ./pkg/index_bg.js 16.8 KiB [built]

ERROR in ./pkg/index_bg.wasm
Module parse failed: Internal failure: parseVec could not cast the value
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: Internal failure: parseVec could not cast the value
    at parseVec (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:343:15)
    at parseTypeSection (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:375:22)
    at parseSection (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1379:23)
    at Object.decode (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1740:25)
    at decode (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/@webassemblyjs/wasm-parser/lib/index.js:253:21)
    at WebAssemblyParser.parse (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/webpack/lib/wasm-async/AsyncWebAssemblyParser.js:61:19)
    at /home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/webpack/lib/NormalModule.js:1299:19
    at processResult (/home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/webpack/lib/NormalModule.js:933:11)
    at /home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/webpack/lib/NormalModule.js:1026:5
    at /home/thoth/vendor/wasm-bindgen/examples/webxr/node_modules/loader-runner/lib/LoaderRunner.js:407:3
 @ ./pkg/index.js 1:0-40 4:15-19 5:0-21
 @ ./webxr.js 1:0-30 3:16-26
 @ ./index.js 3:0-20

webpack 5.94.0 compiled with 1 error in 27 ms

Additional Context

_

@mutantbob mutantbob added the bug label Jan 31, 2025
@mutantbob
Copy link
Author

I deleted the node_modules subdirectory and reran. This time I get no error. Unfortunately, I get a blank white page instead of a webxr demo.

examples/webxr$ RUSTFLAGS=--cfg=web_sys_unstable_apis npm run serve

> serve
> webpack serve

🧐  Checking for wasm-pack...

✅  wasm-pack is installed at /home/thoth/.cargo/bin/wasm-pack. 

ℹ️  Compiling your crate in development mode...

<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8080/, http://[::1]:8080/
<i> [webpack-dev-server] On Your Network (IPv4): http://172.18.0.1:8080/
<i> [webpack-dev-server] Content not from webpack is served from '/home/thoth/vendor/wasm-bindgen/examples/webxr/public' directory
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
   Compiling unicode-ident v1.0.12
   Compiling proc-macro2 v1.0.86
   Compiling wasm-bindgen-shared v0.2.100 (/home/thoth/vendor/wasm-bindgen/crates/shared)
   Compiling bumpalo v3.16.0
   Compiling log v0.4.22
   Compiling rustversion v1.0.17
   Compiling autocfg v1.3.0
   Compiling wasm-bindgen v0.2.100 (/home/thoth/vendor/wasm-bindgen)
   Compiling cfg-if v1.0.0
   Compiling once_cell v1.19.0
   Compiling futures-sink v0.3.30
   Compiling futures-core v0.3.30
   Compiling futures-io v0.3.30
   Compiling pin-project-lite v0.2.14
   Compiling pin-utils v0.1.0
   Compiling futures-channel v0.3.30
   Compiling memchr v2.7.4
   Compiling futures-task v0.3.30
   Compiling slab v0.4.9
   Compiling quote v1.0.37
   Compiling syn v2.0.87
   Compiling wasm-bindgen-backend v0.2.100 (/home/thoth/vendor/wasm-bindgen/crates/backend)
   Compiling futures-macro v0.3.30
   Compiling wasm-bindgen-macro-support v0.2.100 (/home/thoth/vendor/wasm-bindgen/crates/macro-support)
   Compiling futures-util v0.3.30
   Compiling wasm-bindgen-macro v0.2.100 (/home/thoth/vendor/wasm-bindgen/crates/macro)
   Compiling js-sys v0.3.77 (/home/thoth/vendor/wasm-bindgen/crates/js-sys)
   Compiling futures-executor v0.3.30
   Compiling futures v0.3.30
   Compiling web-sys v0.3.77 (/home/thoth/vendor/wasm-bindgen/crates/web-sys)
   Compiling wasm-bindgen-futures v0.4.50 (/home/thoth/vendor/wasm-bindgen/crates/futures)
   Compiling webxr v0.0.0 (/home/thoth/vendor/wasm-bindgen/examples/webxr)
warning: unexpected `cfg` condition value: `console_error_panic_hook`
 --> examples/webxr/src/utils.rs:8:11
  |
8 |     #[cfg(feature = "console_error_panic_hook")]
  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the condition
  |
  = note: no expected values for `feature`
  = help: consider adding `console_error_panic_hook` as a feature in `Cargo.toml`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: requested on the command line with `-W unexpected-cfgs`

warning: use of deprecated method `web_sys::XrRenderStateInit::base_layer`: Use `set_base_layer()` instead.
   --> examples/webxr/src/lib.rs:106:31
    |
106 |             render_state_init.base_layer(Some(&xr_gl_layer));
    |                               ^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

warning: `webxr` (lib) generated 2 warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 16.07s
[INFO]: ⬇️  Installing wasm-bindgen...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: ✨   Done in 16.26s
[INFO]: 📦   Your wasm pkg is ready to publish at /home/thoth/vendor/wasm-bindgen/examples/webxr/pkg.
✅  Your crate has been correctly compiled

assets by path *.js 319 KiB
  asset index.js 282 KiB [emitted] (name: main)
  asset webxr_js.index.js 37 KiB [emitted]
asset 2b66e52d1fca1d175571.module.wasm 261 KiB [emitted] [immutable]
asset index.html 222 bytes [emitted]
runtime modules 33.4 KiB 16 modules
modules by path ./node_modules/ 185 KiB
  modules by path ./node_modules/webpack-dev-server/client/ 81.9 KiB 17 modules
  modules by path ./node_modules/webpack/hot/*.js 5.17 KiB 4 modules
  modules by path ./node_modules/html-entities/lib/*.js 78.9 KiB 4 modules
  ./node_modules/ansi-html-community/index.js 4.16 KiB [built] [code generated]
  ./node_modules/events/events.js 14.5 KiB [built] [code generated]
modules by path ./pkg/ 17.4 KiB (javascript) 261 KiB (webassembly)
  ./pkg/index.js 167 bytes [built] [code generated]
  ./pkg/index_bg.wasm 470 bytes (javascript) 261 KiB (webassembly) [built] [code generated]
  ./pkg/index_bg.js 16.8 KiB [built] [code generated]
modules by path ./*.js 325 bytes
  ./index.js 175 bytes [built] [code generated]
  ./webxr.js 150 bytes [built] [code generated]
webpack 5.97.1 compiled successfully in 17308 ms
assets by status 298 KiB [cached] 3 assets
assets by status 283 KiB [emitted]
  asset index.js 282 KiB [emitted] (name: main)
  asset main.aea674bc5868eb1df867.hot-update.js 843 bytes [emitted] [immutable] [hmr] (name: main)
  asset main.aea674bc5868eb1df867.hot-update.json 28 bytes [emitted] [immutable] [hmr]
Entrypoint main 282 KiB = index.js 282 KiB main.aea674bc5868eb1df867.hot-update.js 843 bytes
cached modules 185 KiB [cached] 29 modules
runtime modules 33.4 KiB 16 modules
modules by layer 17.4 KiB (javascript) 261 KiB (webassembly)
  ./pkg/index.js 167 bytes [built]
  ./pkg/index_bg.wasm 470 bytes (javascript) 261 KiB (webassembly) [built]
  ./pkg/index_bg.js 16.8 KiB [built]
webpack 5.97.1 compiled successfully in 71 ms

This is the same behavior as when I visit https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/ (which is referenced by the README.md)

@mutantbob
Copy link
Author

I checked the firefox console and found this:

wasm-bindgen: imported JS function that was not marked as `catch` threw an error: arg0 is undefined

Stack:
__wbg_isSessionSupported_a3520761af8f50d1/<@webpack:///./pkg/index_bg.js?:409:17
logError@webpack:///./pkg/index_bg.js?:71:18
__wbg_isSessionSupported_a3520761af8f50d1@webpack:///./pkg/index_bg.js?:408:63
webxr.wasm.__wbg_isSessionSupported_a3520761af8f50d1 externref shim@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/a2fc1fe0a9158550fb67.module.wasm:wasm-function[972]:0x29c91
webxr.wasm.web_sys::features::gen_XrSystem::XrSystem::is_session_supported::h58bcb2997259bb06@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/a2fc1fe0a9158550fb67.module.wasm:wasm-function[316]:0x1dbf5
webxr.wasm.webxr::XrApp::init::hbe6dca2a9a8fe4b2@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/a2fc1fe0a9158550fb67.module.wasm:wasm-function[87]:0xd74c
webxr.wasm.xrapp_init@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/a2fc1fe0a9158550fb67.module.wasm:wasm-function[294]:0x1cd8f
webxr.wasm.xrapp_init externref shim@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/a2fc1fe0a9158550fb67.module.wasm:wasm-function[1012]:0x2a038
init@webpack:///./pkg/index_bg.js?:332:26
@webpack:///./webxr.js?:9:7
async*__webpack_require__.a@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:102:17
@webpack:///./webxr.js?:1:21
./webxr.js@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/webxr_js.index.js:18:1
__webpack_require__@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:42:41
promise callback*@webpack:///./index.js?:3:51
./index.js@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:18:1
__webpack_require__@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:42:41
@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:376:56
@https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:378:12
[index_bg.js:80:17](webpack:///pkg/index_bg.js?)
Error importing web assembly: TypeError: arg0 is undefined
    __wbg_isSessionSupported_a3520761af8f50d1 webpack:///./pkg/index_bg.js?:409
    logError webpack:///./pkg/index_bg.js?:71
    __wbg_isSessionSupported_a3520761af8f50d1 webpack:///./pkg/index_bg.js?:408
    init webpack:///./pkg/index_bg.js?:332
    <anonymous> webpack:///./webxr.js?:9
    a https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:102
    <anonymous> webpack:///./webxr.js?:1
    js https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/webxr_js.index.js:18
    __webpack_require__ https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:42
    promise callback* webpack:///./index.js?:3
    js https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:18
    __webpack_require__ https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:42
    <anonymous> https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:376
    <anonymous> https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/index.js:378

@mutantbob
Copy link
Author

I tried the https://rustwasm.github.io/wasm-bindgen/exbuild/webxr/ in chromium-browser and I get a blank white page. The dev console does not show any errors.

I tried it in a Quest 3 headset's browser and got a blank white page with no "Enter VR" option.

@mutantbob mutantbob changed the title webxr example explodes with Internal failure: parseVec could not cast the value webxr example gives blank white page in firefox, chromium-browser, and quest3. errors appear in firefox dev console. Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant