I spent 2 days on compiling my C++ project with enabled pthreads via emscripten to WASM without success.
It compiles fine. I used options -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4.
But when I execute my index.html via "emrun index.html" - it even doesn't reach main function and stuck on pthreads pool preallocation: pthread sent an error! undefined:undefined: undefined
Obviously if I don't specify pthreads pools - it starts my main function but throws the same error when I reach pthread creation in my code.
Unfortunately I didn't find any answers in the google related to this problem. I run this in my browser: https://alex-wasm.appspot.com/threads/index.html And it reports that browser fully supports pthreads in WebAssembly.
Today I found example WASM project which is used pthreads but surprisingly when I start it with emrun I get exactly the same pthreads error in the console.
After this I tried to run it without emrun and got different error:
Uncaught DOMException: Failed to construct 'Worker': Script at 'file:///D:/engine/src/main/Emscripten/wengine.worker.js' cannot be accessed from origin 'null'. at Object.allocateUnusedWorker (file:///D:/engine/src/main/Emscripten/wengine.js:2221:36) at Object.initMainThreadBlock ...
I get the same error in both my project and example project when I run without emrun...
P.S. I need emrun to access my files without deploying the project on the server (for fast debugging).
So can you please give me the hints for this 2 questions:
- Is it possible to run webassembly build with pthreads support using emrun?
- Why it doesn't work even without emrun with this Uncaught DOMException ?