-
-
Notifications
You must be signed in to change notification settings - Fork 673
Closed
Labels
Description
Hi Everyone,
When instantiating any real-world module (>4KB) using the loader the following error comes up (at the very least in chrome):
RangeError: WebAssembly.Instance is disallowed on the main thread, if the buffer size is larger than 4KB. Use WebAssembly.instantiate.
This is the code segment that causes the issue (lib/loader/index.js):
/** Instantiates an AssemblyScript module using the specified imports. */
function instantiate(module, imports) {
return postInstantiate(
preInstantiate(imports || (imports = {})),
new WebAssembly.Instance(module, imports)
);
}
If i monkey patch it like below it becomes usable (albeit async)
/** Instantiates an AssemblyScript module using the specified imports. */
async function instantiate(module, imports) {
return postInstantiate(
preInstantiate(imports || (imports = {})),
await WebAssembly.instantiate(module, imports)
);
}
I would assume that this issue will be faced by others..
I see two easy ways to fix it:
- my patch above
- export
postInstantiate(..)
andpreInstantiate(..)
hooks so users can build costum instantiation flows.
What do you guys think?