emscripten-core / emscripten-core/emscripten

Better error messages when loading the wrong Wasm binary?

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

Description

The [Squoosh](https://squoosh.app) spent quite a long time why were were getting the following error:

```
Compress-9e039c93.js:1 Uncaught (in promise) TypeError: Cannot read property 'apply' of undefined
at o.___wasm_call_ctors (features-worker-18f82dab.js:1)
[...]
```

It turns out, we forgot to adjust a path and were using the glue code from one Emscripten module with the Wasm binary from another Emscripten module:

```js
import jxlEncoder, { JXLModule } from 'codecs/jxl/enc/jxl_enc';
import wasmUrl from 'url:codecs/webp/enc/webp_enc.wasm';
```

I wish Emscripten would give me a better error message.

**Implementation idea:** Would it be worth embedding a small data string containing a UID in the Wasm binary to check that the glue code is loading the .wasm file it was designed for?

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.