Re: wasm application works perfectly on mac and desktop chrome but throws error on android chrome

740 views
Skip to first unread message
Message has been deleted

Floh

unread,
May 12, 2021, 5:15:53 AM5/12/21
to emscripten-discuss
Looks to me like that opencv library has been compiled with threading support.


Threading on WASM comes with all sorts of unfortunate caveats. Even if the browser's WASM engine supports threading in general, the feature is locked behind specific HTTP response headers (so apart from requiring a supported browser you also need control over the web server's configuration, e.g. just using one of the popular cloud hosting services may or may not work).

On Wednesday, 12 May 2021 at 09:38:16 UTC+2 joeja...@gmail.com wrote:
Hi, I have a cpp program which uses opencv modules and I have successfully compiled it to webassembly using emscripten. It works very well on chrome in my macbook. However when I tried to load the page through localhost in my phone using android chrome it threw the following error.

Uncaught (in promise) RuntimeError: abort(CompileError: WebAssembly.instantiate(): Compiling function #21 failed: Invalid opcode 0xfe (enable with --experimental-wasm-threads) @+5378). Build with -s ASSERTIONS=1 for more info.

So I tried to figure out what was causing this and understood that it only happens after I have used a static library from opencv to build my wasm app using the following command.

emcc -O3 -o hello.js -s -I/Users/user1/MyDocuments/work/new/emscripten_playground/playground libopencv_core.a hello.cpp -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap"]' -s SINGLE_FILE=1

if I take out the libopencv_core.a and remove the lines that use stuff from that module, the wasm loads without any warnings in the android chrome.
But I need to use those modules.
Please tell me if you got any idea about how to solve this problem.
Also if I enable the experimental webassembly flag in the android chrome it works without any problems. But I don't think I can do that through code so I need to find a way to fix this without the experimental flag. There has to be a way because opencv.js(wasm embedded) that is available from the opencv documentation runs without any errors on the android chrome .

Joe

unread,
May 12, 2021, 5:40:30 AM5/12/21
to emscripte...@googlegroups.com
Hi @Floh. I think you are right. Do you know how I can compile the opencv library files into static ones without the threading support? I was having a lot of trouble doing it using emcmake so I actually got that particular one after a lot of googling in the past and I do not know how it was built back then. So you are probably right in that the way it was compiled would have been with threading support.

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/DgiF0eaVaAI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/92ca6637-80cf-4a74-88b3-19babcfdd06fn%40googlegroups.com.

Joe

unread,
May 12, 2021, 6:33:02 AM5/12/21
to emscripte...@googlegroups.com
Thanks for pointing in the right direction @Floh. Got it to compile properly finally.
Reply all
Reply to author
Forward
0 new messages