emscripten-core / emscripten-core/emscripten

[Threads] Module overrides are not available in worker.js

Open
#22,423 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Please include the following in your bug report:

**Version of emscripten/emsdk:**
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.56 (cf90417346b78455089e64eb909d71d091ecc055)
clang version 19.0.0git (https:/github.com/llvm/llvm-project 34ba90745fa55777436a2429a51a3799c83c6d4c)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: ~/emsdk/upstream/bin

I am currently trying to port my single threaded wasm to multi-threaded one. Our wasm is currently using SPLIT_MODULE integration and we have overriden `Module.loadSplitModule` function. We load our wasm like below:

```js
Module.loadSplitModule = () => {
// overriden
};
importScripts("wasm.js");
```

This override was working flawlessly in single-threaded mode. But with multithreading, if any worker needs to load the deferred module, it is not going through our `loadSplitModule` override but with the default one causing our app to crash. This makes me curious about other overrides on the `Module` object that we have. Perhaps they are also not passing through in any worker that is being created. One way to solve this can be doing all the Module overrides in `pre.js` but that doesn't seem feasible for us as the overrides use other parts of the main app js as well. How to solve this issue in a generic way?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.