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

How do I run the wasm version in firefox? (Firefox panics: can't sleep, already borrowed: BorrowMutError) #588

Open
iAmInActions opened this issue Aug 6, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@iAmInActions
Copy link

Exactly what the title says. Would like to know how to do that.

@terrarier2111
Copy link
Contributor

The wasm support of this project is incomplete.

@iceiix
Copy link
Owner

iceiix commented Sep 6, 2021

While incomplete, you can run what exists so far with the steps in https://github.com/iceiix/stevenarella/tree/master/www
Issue for tracking progress: #446 🕸️ Web support
There is not much more than support for WebGL rendering, at the moment - shows the title screen, but no gameplay yet

Google Chrome (tested on 93.0.4577.63) provides the best support. It can render an WebGL title screen, allows interaction, and includes animated rendering of the default world (no textures yet):

Screen Shot 2021-09-06 at 4 42 52 PM

Testing on Firefox (used version 91.0.2), it does not get as far as Chrome. It renders the title screen, but soon crashes, due to:

panicked at 'can't sleep', library/std/src/sys/wasm/thread.rs:26:9
panicked at 'already borrowed: BorrowMutError', src/main.rs:485:41
panicked at 'can't sleep', library/std/src/sys/wasm/thread.rs:26:9

Stack:

__wbg_new_59cb74e423758ede/<@webpack:///../pkg/stevenarella_bg.js?:627:15
logError@webpack:///../pkg/stevenarella_bg.js?:490:18
__wbg_new_59cb74e423758ede@webpack:///../pkg/stevenarella_bg.js?:626:48
__wbg_new_59cb74e423758ede@http://localhost:8080/bootstrap.js:74:77
console_error_panic_hook::Error::new::hdee240f43266f5be@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[55783]:0x5759c3
console_error_panic_hook::hook_impl::h3a29498d8900916d@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[4582]:0x3826b1
console_error_panic_hook::hook::h23f8a0a7689e5af5@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[55782]:0x5759bd
core::ops::function::Fn::call::ha0cbe1dd9089443a@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[55440]:0x574e5e
std::panicking::rust_panic_with_hook::h9d91fa0fae16500f@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[3242]:0x33ec9c
std::panicking::begin_panic::{{closure}}::h7f2601f85e24f333@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[24649]:0x4f0da6
std::sys_common::backtrace::__rust_end_short_backtrace::h93a3cae656f3b5f6@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[23072]:0x4df6c1
std::panicking::begin_panic::h355bc40e0ef968c7@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[24647]:0x4f0d46
std::sys::wasm::thread::Thread::sleep::h1797969db77cdfdd@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[40930]:0x54dc9b
std::thread::sleep::hc57a66751b6d0587@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[61143]:0x580b7e
stevenarella::tick_all::hc28e6acdc6a42bff@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[849]:0x237d1e
stevenarella::main2::{{closure}}::h7116ebde1f3549e5@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[1769]:0x2cd11d
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h0b44c2e9832912ea@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[27487]:0x50b73d
__wbg_adapter_37@webpack:///../pkg/stevenarella_bg.js?:524:56
real@webpack:///../pkg/stevenarella_bg.js?:473:20

stevenarella_bg.js:620:17
__wbg_error_4bb6c2a97407129a webpack:///../pkg/stevenarella_bg.js?:620
logError webpack:///../pkg/stevenarella_bg.js?:490
__wbg_error_4bb6c2a97407129a webpack:///../pkg/stevenarella_bg.js?:618
__wbg_error_4bb6c2a97407129a http://localhost:8080/bootstrap.js:71
h2de485a72b4ad478 http://localhost:8080/ceb370e364185983fa9d.module.wasm:4352633
h3a29498d8900916d http://localhost:8080/ceb370e364185983fa9d.module.wasm:3680027
h23f8a0a7689e5af5 http://localhost:8080/ceb370e364185983fa9d.module.wasm:5724605
ha0cbe1dd9089443a http://localhost:8080/ceb370e364185983fa9d.module.wasm:5721694
h9d91fa0fae16500f http://localhost:8080/ceb370e364185983fa9d.module.wasm:3402908
h7f2601f85e24f333 http://localhost:8080/ceb370e364185983fa9d.module.wasm:5180838
h93a3cae656f3b5f6 http://localhost:8080/ceb370e364185983fa9d.module.wasm:5109441
h355bc40e0ef968c7 http://localhost:8080/ceb370e364185983fa9d.module.wasm:5180742
h1797969db77cdfdd http://localhost:8080/ceb370e364185983fa9d.module.wasm:5561499
hc57a66751b6d0587 http://localhost:8080/ceb370e364185983fa9d.module.wasm:5770110
hc28e6acdc6a42bff http://localhost:8080/ceb370e364185983fa9d.module.wasm:2325790
h7116ebde1f3549e5 http://localhost:8080/ceb370e364185983fa9d.module.wasm:2937117
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h0b44c2e9832912ea http://localhost:8080/ceb370e364185983fa9d.module.wasm:5289789
__wbg_adapter_37 webpack:///../pkg/stevenarella_bg.js?:524
real webpack:///../pkg/stevenarella_bg.js?:473
Uncaught RuntimeError: unreachable executed
__wbg_adapter_37 webpack:///../pkg/stevenarella_bg.js?:524
real webpack:///../pkg/stevenarella_bg.js?:473
ceb370e364185983fa9d.module.wasm:5795435:1
panicked at 'already borrowed: BorrowMutError', src/main.rs:485:41

Stack:

__wbg_new_59cb74e423758ede/<@webpack:///../pkg/stevenarella_bg.js?:627:15
logError@webpack:///../pkg/stevenarella_bg.js?:490:18
__wbg_new_59cb74e423758ede@webpack:///../pkg/stevenarella_bg.js?:626:48
__wbg_new_59cb74e423758ede@http://localhost:8080/bootstrap.js:74:77
console_error_panic_hook::Error::new::hdee240f43266f5be@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[55783]:0x5759c3
console_error_panic_hook::hook_impl::h3a29498d8900916d@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[4582]:0x3826b1
console_error_panic_hook::hook::h23f8a0a7689e5af5@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[55782]:0x5759bd
core::ops::function::Fn::call::ha0cbe1dd9089443a@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[55440]:0x574e5e
std::panicking::rust_panic_with_hook::h9d91fa0fae16500f@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[3242]:0x33ec9c
std::panicking::begin_panic_handler::{{closure}}::h2d82b5b2db976f3f@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[5589]:0x3aacdd
std::sys_common::backtrace::__rust_end_short_backtrace::h24539600b7e2452c@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[23071]:0x4df693
rust_begin_unwind@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[15550]:0x47ccff
core::panicking::panic_fmt::h91d2023e5afe1929@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[23073]:0x4df6f8
core::option::expect_none_failed::h203584ddbc785ca2@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[6322]:0x3c37fb
core::result::Result<T,E>::expect::h2ca24a474fd2eede@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[13993]:0x464b50
core::cell::RefCell::borrow_mut::he6911a5097aad4d6@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[12905]:0x452efb
stevenarella::main2::{{closure}}::h581d5e3042f88457@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[2842]:0x32592d
winit::platform_impl::platform::event_loop::EventLoop::run::{{closure}}::hc161a693cdb9186c@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[15593]:0x47d744
<alloc::boxed::Box<F,A> as core::ops::function::FnMut>::call_mut::ha14cf979b84b48da@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[13123]:0x4568e3
winit::platform_impl::platform::event_loop::runner::Runner::handle_single_event::h47c5fdce9f45f06b@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[11377]:0x438b6e
winit::platform_impl::platform::event_loop::runner::Shared::handle_event::he5c79dce29303529@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[1673]:0x2c2377
winit::platform_impl::platform::event_loop::runner::Shared::run_until_cleared::h9ea651a1ed8210f4@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[1241]:0x28966b
winit::platform_impl::platform::event_loop::runner::Shared::send_events::h810f4466b95f867e@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[996]:0x25d5e3
winit::platform_impl::platform::event_loop::runner::Shared::send_event::hbaf03e32943d8ee5@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[16747]:0x48e2e0
winit::platform_impl::platform::event_loop::window_target::WindowTarget::register::{{closure}}::hea7819875c89cf1f@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[11667]:0x43dd06
winit::platform_impl::platform::backend::canvas::pointer_handler::PointerHandler::on_cursor_enter::{{closure}}::h51a252f0f04b9c13@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[20487]:0x4c02fe
winit::platform_impl::platform::backend::canvas::Common::add_event::{{closure}}::hc54a9052cbe993ce@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[15798]:0x4806fc
<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h98c3026c0437fb33@http://localhost:8080/ceb370e364185983fa9d.module.wasm:wasm-function[27173]:0x508c27
__wbg_adapter_52@webpack:///../pkg/stevenarella_bg.js?:554:56
real@webpack:///../pkg/stevenarella_bg.js?:473:20

stevenarella_bg.js:620:17
Uncaught RuntimeError: unreachable executed
__wbg_adapter_52 webpack:///../pkg/stevenarella_bg.js?:554
real webpack:///../pkg/stevenarella_bg.js?:473
ceb370e364185983fa9d.module.wasm:3402952:1


Screen Shot 2021-09-06 at 4 49 59 PM

The "already borrowed: BorrowMutError" error occurs at:

    events_loop.run(move |event, _event_loop, control_flow| {
        #[cfg(target_arch = "wasm32")]
        let winit_window = winit_window.borrow_mut(); // here -- winit_window already borrowed

maybe as a consequence of the "can't sleep" panic? Or maybe as a result of a behavioral difference between Chrome and Firefox implementations. I'll use this issue for getting Firefox compatibility up to par with Chrome (overall web porting progress in #446 🕸️ Web support).

@iceiix iceiix added the bug Something isn't working label Sep 6, 2021
@iceiix iceiix changed the title How do I run the wasm version in firefox? How do I run the wasm version in firefox? (Firefox panics: can't sleep, already borrowed: BorrowMutError) Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants