emscripten-core / emscripten-core/emscripten
Undefined wasmBinaryFile when compiled with SPLIT_MODULE and pthread
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
I am trying to introduce multithreading to my codebase where I already use `SPLIT_MODULE` flag with `wasm-split` tool. I am using `PROXY_TO_PTHREAD` flag to call my main function in a pthread. When [createWasm](https://github.com/emscripten-core/emscripten/blob/main/src/preamble.js#L717) is called, it instantiates wasm module in a pthread, which calls `getWasmImports`([here](https://github.com/emscripten-core/emscripten/blob/main/src/preamble.js#L869)). When building with `SPLIT_MODULE`, `getWasmImports` is defined in terms of [splitModuleProxyHandler](https://github.com/emscripten-core/emscripten/blob/main/src/preamble.js#L710), which uses `wasmBinaryFile`([here](https://github.com/emscripten-core/emscripten/blob/main/src/preamble.js#L521)). But `wasmBinaryFile` is undefined at this time, hence getting the issue.
I saw that `wasmBinaryFile` is used as is, if already defined ([here](https://github.com/emscripten-core/emscripten/blob/main/src/preamble.js#L879)), so I have added
```js
self.wasmBinaryFile = self.findWasmBinary();
```
in my postjs and things worked. I am wondering if it is expected for someone to define `wasmBinaryFile` this way if integrating both `SPLIT_MODULE` and pthread together. If yes, this should be documented.
Contributor guide
Assessment
This issue has not been assessed yet.