wasmer icon indicating copy to clipboard operation
wasmer copied to clipboard

Unable to load large wasm modules when loading through wasi

Open HarukaMa opened this issue 3 years ago • 1 comments

I'm using wasmer-js for a wasi environment to run a pretty large wasm module with some parts of openssl. However I'm unable to load the module through wasi.instantiate().

wasmer 2.0.0 | rustc 1.60.0-nightly (4e8fb743c 2022-02-03) | x86_64

Steps to reproduce

Currently I'm not able to provide a sample code, but trying to load a large enough wasm module on Chromium-based browser should trigger this.

Expected behavior

The module should load.

Actual behavior

There is a cryptic error in console:

Uncaught (in promise) Error: Failed to instantiate WASI: RuntimeError: `

Additional context

I've tried to modify the wasmer code to trace the error and found the error is from here:

https://github.com/wasmerio/wasmer/blob/2b396e0fad8118755184109ac5af770c937d66c0/lib/api/src/js/module.rs#L247-L251

The actual error caught here is:

RangeError: WebAssembly.Instance is disallowed on the main thread, if the buffer size is larger than 4KB. Use WebAssembly.instantiate.

I was not able to use any kind of block_on as std::thread::park panics in wasm.

Although I'm using wasmer-js, the actual code is in the wasmer repo so I reported the issue here.

HarukaMa avatar Feb 15 '22 11:02 HarukaMa