mrk-its / bevy_webgl2

WebGL2 renderer plugin for Bevy game engine
MIT License
172 stars 46 forks source link

WebAssembly crashing when loading mesh from loaded texture #26

Open chaoticgood1 opened 3 years ago

chaoticgood1 commented 3 years ago

Bevy version

0.4

Operating system & version

Ubuntu 18.04

What you did

Change the build from default bevy to wasm

What you expected to happen

Should be able to load and process the skybox

What actually happened

It is crashing

Additional information Working default bevy commit: Nickan/bevytest@d65065b

Wasm not working commit: Nickan/bevytest@e48d689

Cause of error in bevytest/src/bevy_skybox/image.rs line 126 or 127, commenting either one of them makes the panicking goes away, but won't render anything. Hope this is helpful, thanks.

Error logs

panicked at 'called `Option::unwrap()` on a `None` value', /home/nickan/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_webgl2-0.4.2/src/webgl2_render_pass.rs:228:89

Stack:

Error
    at imports.wbg.__wbg_new_59cb74e423758ede (http://127.0.0.1:4000/target/wasm.js:377:19)
    at console_error_panic_hook::Error::new::hc91ec718933cceed (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[131916]:0x815b1f)
    at console_error_panic_hook::hook_impl::h9ad56955303e5175 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[7982]:0x37a319)
    at console_error_panic_hook::hook::h855ef18b67e7ea42 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[131915]:0x815b19)
    at core::ops::function::Fn::call::hfa8ec601b2d06713 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[131886]:0x815a20)
    at std::panicking::rust_panic_with_hook::ha2032d5112bb8441 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[5147]:0x2ed20b)
    at std::panicking::begin_panic_handler::{{closure}}::hae464eed10d0d166 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[44067]:0x660b88)
    at std::sys_common::backtrace::__rust_end_short_backtrace::hb5a638417526adb2 (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[47112]:0x6839b4)
    at rust_begin_unwind (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[32814]:0x5c9cd1)
    at core::panicking::panic_fmt::h9021786fae10a3ab (http://127.0.0.1:4000/target/wasm_bg.wasm:wasm-function[47114]:0x683a1a)
vicky5124 commented 3 years ago

I am able to reproduce this issue, but very inconsistently. https://gitlab.com/nitsuga5124/bevy-tic-tac-toe this is the source code of the game, and it happens randomly when placing a piece (press a number), and when it happens, the text disappears.

mrk-its commented 3 years ago

I've just ran your code. Please take a look on network tab (dev tools) in your browser - it seems you are loading two new textures 60 times per second :) I'll still try to investigate this, because it looks like good stress test of asset loader, but you definitely should fix texture loading on your side too (it also explains memory leak you were mentioning earlier)

vicky5124 commented 3 years ago

@mrk-its thanks for that one! i just fixed it :P