DerKarlos / OSMeta

OSM "Metaverse"
Other
15 stars 2 forks source link

WASM Exception debugging ? #34

Open DerKarlos opened 7 months ago

DerKarlos commented 7 months ago

cargo run --target wasm32-unknown-unknown builds and runs a local server and shows a link for a browser. The build terminal shows the console outputs of the browser windows. (So they must be send form the WASM application to the server) Als Error outputs get visible, including the call stack.

Do we have a way to find the source code position?

The error below happened with Chrome. Chrome works fine, if no other browser is running. (There may be a message because the app is low responding) With also a Safari running, Chrome was slow and the tab crashed/rebooted. The error below points in the Bevy code Asset-Manager.

ERROR app: panicked at /Users/karlos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-hal-0.17.2/src/gles/device.rs:705:52: called Result::unwrap() on an Err value: "Unable to create texture object"

Stack:

Error at imports.wbg.wbg_new_abda76e883ba8a5f (http://127.0.0.1:1334/api/wasm.js:378:13) at wbg_new_abda76e883ba8a5f externref shim (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[50004]:0x18c7682) at console_error_panic_hook::hook::hb6546f05454fa493 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[11727]:0x11949bd) at core::ops::function::Fn::call::h59ad5c64e6309751 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[68312]:0x191c846) at std::panicking::rust_panic_with_hook::hc20eadded6bfe687 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[24562]:0x163b0c0) at std::panicking::begin_panic_handler::{{closure}}::h82415fe35b0e2001 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[28888]:0x17103c1) at std::sys_common::backtrace::__rust_end_short_backtrace::h71f504d46a203d88 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[67511]:0x191abed) at rust_begin_unwind (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[36557]:0x1814fb3) at core::panicking::panic_fmt::h7a368385936888dc (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[40827]:0x186d7a5) at core::result::unwrap_failed::hbe79a418fab461ff (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[32370]:0x1796d3e)

ERROR app: panicked at /Users/karlos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/platform_impl/web/event_loop/runner.rs:462:69: already borrowed: BorrowMutError

Stack:

Error at imports.wbg.wbg_new_abda76e883ba8a5f (http://127.0.0.1:1334/api/wasm.js:378:13) at wbg_new_abda76e883ba8a5f externref shim (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[50004]:0x18c7682) at console_error_panic_hook::hook::hb6546f05454fa493 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[11727]:0x11949bd) at core::ops::function::Fn::call::h59ad5c64e6309751 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[68312]:0x191c846) at std::panicking::rust_panic_with_hook::hc20eadded6bfe687 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[24562]:0x163b0c0) at std::panicking::begin_panic_handler::{{closure}}::h82415fe35b0e2001 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[28888]:0x17103c1) at std::sys_common::backtrace::__rust_end_short_backtrace::h71f504d46a203d88 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[67511]:0x191abed) at rust_begin_unwind (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[36557]:0x1814fb3) at core::panicking::panic_fmt::h7a368385936888dc (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[40827]:0x186d7a5) at core::cell::panic_already_borrowed::h0e569ffcf22f6e1e (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[39108]:0x184f15e)

oli-obk commented 7 months ago

This is deep in the engine, only processing values we gave the engine, not in our code. So there's not much we can debug, except add more debugging messages or use the browser's builtin debugger (not sure how to open and use it in chrome, but firefox has it under Ctrl + alt + i or Ctrl + shift + i)

DerKarlos commented 7 months ago

So an error in our app code should be clear? As Rust is save, we never may see one. But to test it, may be we can generate an error somehow.

oli-obk commented 7 months ago

I've had a situation before where I saw an issue in our code in the backtrace. Any panic will cause this. Panicking is safe, too, so this can happen on any index operation, unwrap, ...