Instantiate WebAssembly modules asynchronously
Michael-F-Bryan opened this issue · comments
In #311, @sigmaSd noticed that the Wasi.instantiate()
method is synchronous, which implies wasmer
is synchronously calling the new WebAssembly.Instance()
constructor.
Ideally, we would use something promise-based like WebAssembly.instantiateStreaming()
so we don't block the main event loop.
This may require some reworking of the wasmer::js
module's internals. Probably around here where we instantiate modules.
Hey @Michael-F-Bryan, we can actually skip using Instance::new
all together and actually do the instantiate streaming directly via the wasm-bindgen JS API in this codebase (we already support providing directly an instance to the WASI API):
https://github.com/wasmerio/wasmer-js/blob/main/tests/index.spec.js#L85-L90
This should be resolved with the @wasmer/sdk
rewrite. We no longer instantiate WebAssembly modules from the main thread.