Pthread: not working on webworker.js #17561
Replies: 2 comments 1 reply
-
Are you sure you are not running into https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread? You need to return to event loop before you threads will start... or you can use PTHREAD_POOL_SIZE as a workaround. |
Beta Was this translation helpful? Give feedback.
-
The compile command is as follow: The multi_thread.c is the same as the first post of this issue. The browser infomation: Chrome 104.0.5112.81 64bit , run with (--enable-features=SharedArrayBuffer) If run multi_thread,js on main brower thread (test_script.html ) , it will work fine to create thread // test_script.html
// script.js // work.js
But if start multi_thread.js on a webwork(work.js), it doesn't work. it can't create and execute the thread. // test_scripte.html
// script.js // work.js
|
Beta Was this translation helpful? Give feedback.
-
I had read the follow reference about running pthread on webwork.js :
https://groups.google.com/g/emscripten-discuss/c/EO1q0lDKi6Y/m/LyB2Hro1CgAJ
#11914
#12102
My emsdk is newest for now (3.1.18), so it should had fixed the issue 12102.
but i still cann't get pthread be create on main runtime thread. ( it can be create on main browser thread)
// follow are the source code of html/js
//test_script.html
// script.js
const worker = new Worker("worker.js");
// worker.js
//multi_thread.c
main_browser.png show on html environment, to call pthread_create, it work fine
but main_runtime_thread.png show on web worker environment, to call pthread_create, it will failed.
Could anyone help me to finger out what cause this issue?
Beta Was this translation helpful? Give feedback.
All reactions