Closed ZhaoXiangXML closed 10 months ago
Is this related to #31? If you're running tests on the main thread, it probably won't work.
Also - just to check - are you building with all the necessary flags as described in the docs?
Is this related to #31? If you're running tests on the main thread, it probably won't work.
They are related. I'm trying to run wasm-bindgen-rayon my rust unit tests and javascript pages, neither of them worked for me. And I've all the necessary build flags (or I would have compile errors).
Anyway, guess I'll have to figure out a way to init a worker thread in rust? Is it even possible?
And I've all the necessary build flags (or I would have compile errors).
Not really, I think without some of the flags you'd simply get runtime errors as that's what wasm32-unknown-unknown target does for unsupported APIs. So it fails at runtime if you try to access filesystem or try to create thread but built without atomic flags and so on.
Anyway, guess I'll have to figure out a way to init a worker thread in rust? Is it even possible?
I think it's something you need to do from JS side, as it needs to be done before your Rust is even instantiated (since Wasm itself has to already run in a worker). But you can try playing with either rayon::spawn
or web_sys::Worker
, there might be a way, just not one I can think of.
https://github.com/rustwasm/wasm-bindgen/issues/2892 needs to be addressed.
Linked issue was resolved, so this should work nowadays. If not, please open an issue on the new repo (https://github.com/RReverser/wasm-bindgen-rayon).
I'm trying to use
wasm-bindgen-rayon
in unit tests bywasm-bindgen-test
, here is an demo project:src/lib.rs
Cargo.toml:
Then I ran the test with:
and I got the following output:
I've add some logs in
wasm-bindgen-rayon
, it appears the callback inwaitForMsgType
was never called.I'd like to know how can I fix this issue. Thank you.