简体   繁体   中英

webassembly load time is too long

I am working with face detection model which is in .wasm format. I am reading and executing it in JavaScript. Everything works fine. But it takes too much time to complete the WebAssembly.instantiate() method with an array buffer output.

The wasm file is 8.6MB in size and it is taking 3 seconds to finish the execution after loading the file.

Application load time is delaying because of this. Is there any way to reduce the size of the .wasm file or improving the file execution time?

Any help is appreciated.

WebAssembly.instantiate() is officially not a recommended way.

Use the newer WebAssembly.instantiateStreaming() . This will load a wasm file more efficiently. Note that you should use a response object from fetch() than an ArrayBuffer to load wasm file.

Also, 8.6MB is pretty big for a wasm file. So you might still feel it is a bit slow to load. Have you compiled the project using optimization flags?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM