-
-
Notifications
You must be signed in to change notification settings - Fork 55.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
built OpenCV.js fails to load wasm in node.js #19243
Comments
Thanks! I can confirm that using emscripten I can close this issue (as my main problem is solved), however I think these points still stand (so feel free to close the issue or keep it open):
For the tests.js, I really don't understand why it works on the OpenCV build server. Digging through qunit/qunit-node source code, I didn't really see anything that would guarantee correct loading (which is also why it always fails for me); so I guess the CI server is getting a lucky race condition every time 🤷 (which is also weird). |
Lets keep this open. |
I am having this issue with chrome mobile and firefox and many other browsers. It seems like some work with optimisations and threads requested a still experimental feature in browsers and in node. When I force compiling a file using opencv wasm without threads in Emscripten (USE_PTHREADS=0), compilation fails because opencv wasm requested threads (and sharedarraybuffer) when it was compiled. There should be an option to compile without it. |
Also trying to build opencv.js with
|
i'm on 4.3.0 2021.4.21: what opt should use? |
I think the key point is how to install build tool emscripten.
// test command
May this can help you. |
Is this related to wasi? |
System information (version)
Detailed description
Expected behavior:
test_async.js
(see further).test_async.js
Note that running the
tests.html
via browser works correctly, the failures are specific to running via node.js.Actual behavior:
node tests.js
fails to even fail properly and instead just reports0 failed, 0 passed
node test_async.js
fails to load wasm due to needing experimental wasm threads & shared memoryRuntimeError: abort(RuntimeError: abort(CompileError: WebAssembly.instantiate(): Compiling function #73 failed: Invalid opcode (enable with --experimental-wasm-threads) @+39429)
RuntimeError: abort(RuntimeError: abort(CompileError: WebAssembly.instantiate(): Compiling function #73 failed: Atomic opcodes used without shared memory @+39428)
node tests.js
fails most tests (34 failed, 10 passed), due to improper loadingnode test_async.js
works as expected (and generally using the pre-built library works as expected when loaded properly)**
Running
node tests.js
simply outputs:If I modify
tests.js
and only allow a single file (e.g.tests: [ 'test_mat.js']
) I instead get the following error:This is presumably due to the tests not loading the library correctly.
**
Running
node test_async.js
(code see further) produces the following error:Node 8/Node 10 -- generic decoding error:
Node 14 -- invalid threads opcode
Rerunning with
--experimental-wasm-threads
produces invalid shared memory opcode insteadSteps to reproduce
--build_wasm
or not also doesn't seem to matter (it always produces wasm)--build_test
and--build_flags '-s ASSERTIONS=1'
tests.js
to run only for a single file (tests: [ 'test_mat.js' ]
) & run testsnode test_async.js
Issue submission checklist
answers.opencv.org, Stack Overflow, etc and have not found solution
The text was updated successfully, but these errors were encountered: