I've been following the wasm_bindgen guides to create wasm from rust. Those work fine and I have some code that can be loaded in my main app.
That loading works sometimes, but frequently not, with my main program's initialization hanging. A race condition?
We are loading the wasm directly into a webworker. So, whereas as normally wasm has to be loaded asynchronously, that requirement does not hold within web-workers. Forcing synchronous loading is what I would like to do to see whether this creates more consistent behavior, whatever the performance consequences
Here's my setup
- compile rust with
wasm-pack build(or withwasm-pack build --target web) - copy the
./pkg/*output into my main codebase - in the main code
// pkg contains the assets from the wasm_bindgen example
import {greet} from "./pkg";
console.log("****after import")
function ffi_greet(connector, args) {
console.log("*****GREET*********", args)
return greet(args[0])
}
In my webpack.config.js I have:
experiments: {
asyncWebAssembly: true,
}
The code does look synchronous, but I presume that webpack is loading wasm asynchronously. My question is how can I force synchronous wasm loading (in a webworker)