Open andynewman10 opened 5 months ago
Has this ever worked in the past? i.e. is this a regression?
Good question. What is puzzling me is why is this working from the main page, and not from a web worker.
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.
OpenCV issue opened here:
I'm having the same exact issue with a program that does not use OpenCV, it just uses std::thread
, so I don't think this is OpenCV's fault.
I am serving the program on GitHub pages using https://github.com/gzuidhof/coi-serviceworker
This is the source code: https://github.com/vittorioromeo/SFML/blob/wip_emcc/examples/island/Island.cpp
This is the live demo: https://vittorioromeo.github.io/VRSFML_HTML5_Examples/island.html
Note: I only get this error with -sSINGLE_FILE=1
, removing the flag fixes it.
Please include the following in your bug report:
Version of emscripten/emsdk:
(also tried with latest)
Repro
The problem occurs when using OpenCV.js compiled with emscripten (3.1.57, or latest)
Now build opencv.js:
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)
await cv;
. This line of code will succeedCase 2)
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).