emscripten-core / emscripten-core/emscripten
Refused to execute script from 'http://localhost/undefined' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled
- 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.57 (1df9c1977b49926c1efca672c31414da45c0c7bb)
clang version 19.0.0git (https:/github.com/llvm/llvm-project ccdebbae4d77d3efc236af92c22941de5d437e01)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/fred/emsdk/upstream/bin
```
(also tried with latest)
**Repro**
The problem occurs when using OpenCV.js compiled with emscripten (3.1.57, or latest)
```
$ git clone https://github.com/opencv/opencv.git
$ git checkout 4.10.0
```
Now build opencv.js:
```
$ emcmake python3 ./opencv/platforms/js/build_js.py build_wasmthreads --build_wasm --threads
```
See opencv.js under build_wasmthreads/bin.
Now try it out:
Make sure SharedArrayBuffer is enabled regardless of cross-origin header status ; for this, I use `--enable-features=SharedArrayBuffer` on Chrome.
Case 1)
- load opencv.js in a web page using a script tag
- `await cv;`. This line of code will succeed
Case 2)
- load opencv.js in a web worker using importScripts()
- `await cv;`. This line of code will fail with the error described in the title of this issue.
Note that OpenCV will always work fine when WASM threads are disabled (--threads option not used).
Contributor guide
Assessment
This issue has not been assessed yet.