RReverser / wasm-bindgen-rayon

An adapter for enabling Rayon-based concurrency on the Web with WebAssembly.
https://docs.rs/wasm-bindgen-rayon
Apache License 2.0
108 stars 8 forks source link

Running in the Main Thread #5

Open mfranzs opened 3 months ago

mfranzs commented 3 months ago

To work around crossOriginIsolation issues coming from the SharedArrayBuffer, I'm trying to run this package in the main thread. I see that support was added for this recently.

However, when I remove the rustflags = '--cfg web_sys_unstable_apis -Ctarget-feature=+atomics,+bulk-memory,+mutable-globals' CLI setting suggested in the README, I get this error:

compile_error!("Did you forget to enable atomics and bulk-memory features as outlined in wasm-bindgen-rayon README?");

Do you know how I can get this running in the main thread, or how I can get rayon itself running in the main thread? For context, my goal is to run burn either in the main thread or in a worker, with crossOriginIsolation off.

Thank you very much!

AlexErrant commented 3 months ago

FYI this proj demos Rayon+Burn running in the main thread. I know this because the entire screen freezes when I run training. Despite being on the main thread, it still (empirically) requires +atomics,+bulk-memory. I guess a natural question is "are you sure you can't enable coop/coep?"

(I'm currently trying to figure out how to move it off the main thread, but I'm running into bundler issues. Bah.)