wasm_thread icon indicating copy to clipboard operation
wasm_thread copied to clipboard

Library seems to no longer work

Open Nub opened this issue 9 months ago • 2 comments

It seems as if this library no longer functions. Tested the following in Chrome + Safari.

After integrating into my main application with no success, with the minimal usage of

    thread::spawn(|| {
        info!("HELLO WORLD");
    }).join().expect("HELLO BOOM");

causing the following error

/Users/zachthayer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasm_thread-0.3.0/src/wasm32/mod.rs:349:10:
called `Result::unwrap()` on an `Err` value: JsValue(DataCloneError: Failed to execute 'postMessage' on 'Worker': #<Memory> could not be cloned.
Error: Failed to execute 'postMessage' on 'Worker': #<Memory> could not be cloned.

I then cloned this repo and ran the example test project and get the following

simple.js:306 panicked at src/wasm32/mod.rs:349:10:
called `Result::unwrap()` on an `Err` value: JsValue(DataCloneError: Failed to execute 'postMessage' on 'Worker': SharedArrayBuffer transfer requires self.crossOriginIsolated.
Error: Failed to execute 'postMessage' on 'Worker': SharedArrayBuffer transfer requires self.crossOriginIsolated.
    at http://127.0.0.1:9091/target/simple.js:383:25
    at handleError (http://127.0.0.1:9091/target/simple.js:247:18)
    at imports.wbg.__wbg_postMessage_7380d10e8b8269df (http://127.0.0.1:9091/target/simple.js:382:74)
    at simple-9ac858f1882ee09f.wasm.web_sys::features::gen_Worker::Worker::post_message::hf73b8a56d65d300b (http://127.0.0.1:9091/target/simple_bg.wasm:wasm-function[237]:0xe405)
    at simple-9ac858f1882ee09f.wasm.wasm_thread::wasm32::Builder::spawn_for_context::hc871054e2d60e870 (http://127.0.0.1:9091/target/simple_bg.wasm:wasm-function[53]:0x3143)
    at simple-9ac858f1882ee09f.wasm.wasm_thread::wasm32::spawn::h57a6a2f5660c2a8a (http://127.0.0.1:9091/target/simple_bg.wasm:wasm-function[73]:0x6a9c)
    at simple-9ac858f1882ee09f.wasm.simple::main::h09a0471d30a17e74 

Nub avatar May 08 '24 19:05 Nub

What HTTP server are you using? The error indicates problem with cross origin isolation. The instructions in README use sfz server with --coi option to bypass this protection.

https://web.dev/articles/coop-coep

chemicstry avatar May 12 '24 10:05 chemicstry

It works fine for me, and that error clearly shows that its not crossOriginIsolated.

9SMTM6 avatar Aug 04 '24 21:08 9SMTM6