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

Problem using wasm-bindgen-rayon in wasm-bindgen-test #6

Open
yuroitaki opened this issue Apr 13, 2024 · 1 comment
Open

Problem using wasm-bindgen-rayon in wasm-bindgen-test #6

yuroitaki opened this issue Apr 13, 2024 · 1 comment

Comments

@yuroitaki
Copy link

Related to GoogleChromeLabs/wasm-bindgen-rayon#30, I tried to initalise thread pool in my wasm bindgen test with the following:

use wasm_bindgen_futures::{spawn_local, JsFuture};
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;

wasm_bindgen_test_configure!(run_in_browser);

#[wasm_bindgen_test]
async fn test() {
   spawn_local(JsFuture::from(init_thread_pool(8)).map(|_| ()));
   ...
}

and run the test with the following

wasm-pack test --firefox --release

but the webworkers don't seem to have been set up correctly (picture below) and my test just hang halfway — if i disable rayon in my code, the test will work

image
@themighty1
Copy link

Since initThreadPool should be called from within the WebWorker, I'd expect this to work

wasm_bindgen_test_configure!(run_in_dedicated_worker);`

#[wasm_bindgen_test]
async fn test() {
   spawn_local(JsFuture::from(init_thread_pool(8)).map(|_| ()));
   ...
}

But even with the above change, my test hang.
I worked around it by modifying the JS code produces by wasm-bindgen-test:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants