Compile is disallowed on the main thread, if the buffer size is larger than 4KB
2023/10/12    标签: electron   

electron项目报错:

"Uncaught RangeError: WebAssembly.Compile is disallowed on the main thread, if the buffer size is larger than 4KB. Use WebAssembly.compile, or compile on a worker thread."

原因:electron的渲染进程禁不允许wasm的文件超过4KB。

目前解决方案是渲染进程与主进程通信,frok一个子进程,在子进程里执行wasm相关程序,将结果返回给主进程,主进程再返回渲染进程。