emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.35k stars 3.25k forks source link

Refused to execute script from 'http://localhost/undefined' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled #22117

Open andynewman10 opened 1 week ago

andynewman10 commented 1 week ago

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)

Case 2)

Note that OpenCV will always work fine when WASM threads are disabled (--threads option not used).

sbc100 commented 1 week ago

Has this ever worked in the past? i.e. is this a regression?

andynewman10 commented 1 week ago

Good question. What is puzzling me is why is this working from the main page, and not from a web worker.

sbc100 commented 1 week ago

Thats a good question too, but I think in the general case starting the program from within a worker is something we do test, so there could be something odd going on here with opencv. Since this is not a known regression (i.e it wasn't known to work in the past) I'm temped to suggest you file an upstream bug with opencv to ask them about it, since its hard to know if this is something they expect to work.

andynewman10 commented 1 week ago

OpenCV issue opened here:

https://github.com/opencv/opencv/issues/25790