alepez / lavagna

A collaborative blackboard, ideal for simple sketches during online meetings
https://github.com/alepez/lavagna
Apache License 2.0
149 stars 10 forks source link

Current version of Lavagna is incompatible with Firefox #24

Closed patowen closed 10 months ago

patowen commented 10 months ago

Describe the bug When building Lavagna on Windows with the build-web script, the resulting site works on Chrome but not Firefox.

When loading on Firefox, the following errors appear in the console:

panicked at C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_render-0.12.1\src\lib.rs:281:34:
Failed to create wgpu surface: CreateSurfaceError

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f@http://localhost:8000/lavagna-659AF1E8.js:637:21
console_error_panic_hook::hook::h0b8b8f77f589b45d@http://localhost:8000/lavagna-659AF1E8_bg.wasm:wasm-function[3213]:0x5be826
std::panicking::rust_panic_with_hook::h942f811a58b85774@http://localhost:8000/lavagna-659AF1E8_bg.wasm:wasm-function[8131]:0x7704b0
std::panicking::begin_panic_handler::{{closure}}::h4c2f48d094714b0d@http://localhost:8000/lavagna-659AF1E8_bg.wasm:wasm-function[10777]:0x7f2544
std::sys_common::backtrace::__rust_end_short_backtrace::hc8d5a39cc9b075f2@http://localhost:8000/lavagna-659AF1E8_bg.wasm:wasm-function[29855]:0x8ed10f
rust_begin_unwind@http://localhost:8000/lavagna-659AF1E8_bg.wasm:wasm-function[16122]:0x88bafc
core::panicking::panic_fmt::hc65415ef6e3fc9ba@http://localhost:8000/lavagna-659AF1E8_bg.wasm:wasm-function[16779]:0x896878
core::result::unwrap_failed::h6c35e11f284b3661@http://localhost:8000/lavagna-659AF1E8_bg.wasm:wasm-function[11792]:0x81b5bd
bevy_tasks::single_threaded_task_pool::TaskPool::spawn::{{closure}}::h0943b9c2944fea0d@http://localhost:8000/lavagna-659AF1E8_bg.wasm:wasm-function[498]:0x20a3ae
wasm_bindgen_futures::queue::Queue::new::{{closure}}::h333bf9e7658a70da@http://localhost:8000/lavagna-659AF1E8_bg.wasm:wasm-function[5191]:0x6a03a2
wasm_bindgen::convert::closures::invoke1_mut::h0083c9fbfc8fc3e3@http://localhost:8000/lavagna-659AF1E8_bg.wasm:wasm-function[18602]:0x8ad44f
__wbg_adapter_35@http://localhost:8000/lavagna-659AF1E8.js:221:10
real@http://localhost:8000/lavagna-659AF1E8.js:202:20

lavagna-659AF1E8.js:653:21
    __wbg_error_f851667af71bcfc6 http://localhost:8000/lavagna-659AF1E8.js:653
    h0b8b8f77f589b45d http://localhost:8000/lavagna-659AF1E8_bg.wasm:6023345
    h942f811a58b85774 http://localhost:8000/lavagna-659AF1E8_bg.wasm:7799984
    h4c2f48d094714b0d http://localhost:8000/lavagna-659AF1E8_bg.wasm:8332612
    hc8d5a39cc9b075f2 http://localhost:8000/lavagna-659AF1E8_bg.wasm:9359631
    rust_begin_unwind http://localhost:8000/lavagna-659AF1E8_bg.wasm:8960764
    hc65415ef6e3fc9ba http://localhost:8000/lavagna-659AF1E8_bg.wasm:9005176
    h6c35e11f284b3661 http://localhost:8000/lavagna-659AF1E8_bg.wasm:8500669
    h0943b9c2944fea0d http://localhost:8000/lavagna-659AF1E8_bg.wasm:2139054
    h333bf9e7658a70da http://localhost:8000/lavagna-659AF1E8_bg.wasm:6947746
    h0083c9fbfc8fc3e3 http://localhost:8000/lavagna-659AF1E8_bg.wasm:9098319
    __wbg_adapter_35 http://localhost:8000/lavagna-659AF1E8.js:221
    real http://localhost:8000/lavagna-659AF1E8.js:202

Uncaught RuntimeError: unreachable executed
    __wbg_adapter_35 http://localhost:8000/lavagna-659AF1E8.js:221
    real http://localhost:8000/lavagna-659AF1E8.js:202
lavagna-659AF1E8_bg.wasm:9361362:1
    rust_panic http://localhost:8000/lavagna-659AF1E8_bg.wasm:9361362
    h942f811a58b85774 http://localhost:8000/lavagna-659AF1E8_bg.wasm:7800028
    h4c2f48d094714b0d http://localhost:8000/lavagna-659AF1E8_bg.wasm:8332612
    hc8d5a39cc9b075f2 http://localhost:8000/lavagna-659AF1E8_bg.wasm:9359631
    rust_begin_unwind http://localhost:8000/lavagna-659AF1E8_bg.wasm:8960764
    hc65415ef6e3fc9ba http://localhost:8000/lavagna-659AF1E8_bg.wasm:9005176
    h6c35e11f284b3661 http://localhost:8000/lavagna-659AF1E8_bg.wasm:8500669
    h0943b9c2944fea0d http://localhost:8000/lavagna-659AF1E8_bg.wasm:2139054
    h333bf9e7658a70da http://localhost:8000/lavagna-659AF1E8_bg.wasm:6947746
    h0083c9fbfc8fc3e3 http://localhost:8000/lavagna-659AF1E8_bg.wasm:9098319
    __wbg_adapter_35 http://localhost:8000/lavagna-659AF1E8.js:221
    real http://localhost:8000/lavagna-659AF1E8.js:202

See "Additional context" for what I believe to be the root cause and fix (which worked on my computer).

To Reproduce Steps to reproduce the behavior:

  1. Check out the main branch
  2. With git bash, run tools/build-web (On my computer, it needed to be modified with export rustflags="--cfg=web_sys_unstable_apis" to be able to build)
  3. Run python -m http.server in the www directory (defaults to port 8000)
  4. Load http://localhost:8000 on Firefox
  5. Open the console and see the error.

Expected behavior I expect Lavagna to open on Firefox it does on Chrome.

Desktop

Additional context My wasm-bindgen version is 0.2.89.

I believe the root cause is that the web build is defaulting to WebGPU and not WebGL2. I was able to fix this by adding the webgl2 feature to bevy. Due to my unfamiliarity with Bevy, this fix was not easy to find, as the console did not mention WebGPU, and there were no mentions of WebGPU or WebGL2 in the codebase, making me originally doubt that this was the root case.

Adding the webgl2 feature had the added benefit of removing the requirement to add export rustflags="--cfg=web_sys_unstable_apis" to the build script.

@@ -24,6 +24,7 @@ features = [
   "bevy_winit",
   "x11",
   "png",
+  "webgl2",
 ]

 [dependencies]
alepez commented 10 months ago

Hi! Thanks for your useful report. Unfortunately tools/build-web was not checked by the CI, so I missed it was broken. I need the web_sys_unstable_apis flag to be enabled, even in Linux.

It used to work with Firefox, but I guess bevy has changed the backend from WebGL2 to WebGPU.

alepez commented 10 months ago

Fixed by 77b412c.

Thanks @patowen

patowen commented 10 months ago

Thanks for the fix!

Yeah, it seems like Bevy switched. It still uses WebGL2 as a default, but the only reason it's a default is because webgl2 is a default feature, but default features aren't used in this repo.