Use WebAssembly.instantiateStreaming instead of WebAssembly.compileStreaming

Unfortunately there are performance issues with WebAssembly.compileStreaming on iOS. On iOS devices, there is a limited amount of faster memory. Because of this, the engine doesn’t know which kind of memory to compile for until instantiate is called.

If I understand correctly, for the JSC engine compileStreaming will just do a memcopy of the .wasm. It’s only when instantiate is called that the Memory object is created. Then the engine knows whether it will be using the fast memory, or just a normal malloc’d Memory that needs bounds checks. At this point, it can generate the code appropriately.

Because of this, we plan to recommend that all bundlers use instantiateStreaming instead. Does this cause any issues for webpack?

Author: Fantashit

1 thought on “Use WebAssembly.instantiateStreaming instead of WebAssembly.compileStreaming

  1. This is fixed. We now use instantiateStreaming when possible. Falling back to compileStreaming + async instantiate for WASM-to-WASM dependency chains.

    Falling back non-streaming variants when streaming is not supported by the browser.

Comments are closed.