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

Support multi-threaded Wasm #3236

Merged
merged 1 commit into from
Aug 11, 2023
Merged

Support multi-threaded Wasm #3236

merged 1 commit into from
Aug 11, 2023

Conversation

emilk
Copy link
Owner

@emilk emilk commented Aug 11, 2023

Replace atomic_refcell with parking_lot on wasm32.

parking_lot has had problems running on wasm32 before (#1401) but it works these days.
If we have problems again we can always switch to std::sync::Mutex.

Closes #3102

Replace `atomic_refcell` with `parking_lot` on wasm32.

`parking_lot` has had problems running on wasm32 before
(#1401)
but it works these days.
If we have problems again we can always switch to `std::sync::Mutex`.

Closes #3102
@emilk emilk added web Related to running Egui on the web egui labels Aug 11, 2023
@emilk emilk merged commit dd5285c into master Aug 11, 2023
35 of 36 checks passed
@emilk emilk deleted the emilk/use-parking_lot-on-web branch August 11, 2023 13:08
@juancampa
Copy link
Contributor

juancampa commented Nov 7, 2023

@emilk I just got a panic with parking_lot in wasm (Electron). It happened when calling animate_bool_with_time. I haven't investigated what to do yet but I figured I post it here in case you or someone else knows how to fix it or work around it.

Screenshot 2023-11-07 at 3 13 56 PM

Update: text version of callstack:

gaze.js:1069 panicked at 'Parking not supported on this platform', /Users/juan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.7/src/thread_parker/wasm.rs:26:9

Stack:

Error
    at imports.wbg.__wbg_new_e7fbaa407e13d590 (https://file+.vscode-resource.vscode-cdn.net/Users/juan/git/membrane-vscode/vscode-extension/static/gaze/gaze.js:1075:21)
    at eframe::web::panic_handler::PanicSummary::new::hdfdd14a6fe521f74 (wasm://wasm/01ad0952:wasm-function[4306]:0x36ba7e)
    at eframe::web::panic_handler::PanicHandler::install::{{closure}}::h88d3643bc21aec77 (wasm://wasm/01ad0952:wasm-function[2064]:0x2a346e)
    at std::panicking::rust_panic_with_hook::h7d9d49945f5b5498 (wasm://wasm/01ad0952:wasm-function[4253]:0x368e65)
    at std::panicking::begin_panic::{{closure}}::h5a799e48bb920b1c (wasm://wasm/01ad0952:wasm-function[5985]:0x39e0e4)
    at std::sys_common::backtrace::__rust_end_short_backtrace::hc40c0445c905d574 (wasm://wasm/01ad0952:wasm-function[7137]:0x3a40bc)
    at std::panicking::begin_panic::h4b0cd84d8ff65ef6 (wasm://wasm/01ad0952:wasm-function[6042]:0x39ea5f)
    at <parking_lot_core::thread_parker::imp::ThreadParker as parking_lot_core::thread_parker::ThreadParkerT>::prepare_park::hb42c842297d9d702 (wasm://wasm/01ad0952:wasm-function[6741]:0x3a2dbf)
    at parking_lot::raw_rwlock::RawRwLock::lock_exclusive_slow::hef2a6792406c1d36 (wasm://wasm/01ad0952:wasm-function[972]:0x1c0d58)
    at egui::context::Context::animate_bool_with_time::h8218597c319b3b91 (wasm://wasm/01ad0952:wasm-function[3091]:0x318217)
    ```

@juancampa
Copy link
Contributor

Nevermind!

This panic happened when the code was about to deadlock. Maybe this is how deadlock detection manifests in WASM right now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui web Related to running Egui on the web
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On wasm32, egui::mutex::Mutex<T> requires T: Sync to be Sync
2 participants