You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Main Thread - Extension code
Worker 1 - Extension sub piece, which starts Worker 2
Worker 2 - Needs to use the sync api
Worker 2 cannot communicate with the Main Thread because its MessageChannel is only with Worker 1.
For CPython I have this exact situation when trying to run the debugger:
Main thread - Extension code
Worker 1 - Load of python.js
Worker 2 - Reader thread for debugger
Worker 3 - Writer thread for debugger
Worker 2 and 3 cannot send messages to the Main Thread.
Note: Emscripten (by default proxies) all FS (or socket) API calls to its main thread (worker 1 in this case) but that causes deadlock issues because the Atomics.wait in the sync-api block the main worker thread, therefore no other fs API calls can be handled while waiting. Took me a while to figure this out as most of it was working until Worker 3 tried to acquire a lock.
The text was updated successfully, but these errors were encountered:
I believe there's a solution to this, use a BroadcastChannel instead. (supported by node and web browsers).
Essentially every worker uses the BroadcastChannel instead. When sending messages, a target could be set, something like so:
{
"dest": "main",
"src": "worker-<threadid>"
}
Main thread would listen on the same broadcast channel and handle messages with "dest" : "main".
Worker threads would listen on the same broadcast channel and handle messages with "dest": "worker-<threadid>" where the thread id matches their own.
I believe that would let messages to go to and from an arbitrary worker to the main thread.
Suppose you have something like so:
Main Thread - Extension code
Worker 1 - Extension sub piece, which starts Worker 2
Worker 2 - Needs to use the sync api
Worker 2 cannot communicate with the Main Thread because its MessageChannel is only with Worker 1.
For CPython I have this exact situation when trying to run the debugger:
Worker 2 and 3 cannot send messages to the Main Thread.
The text was updated successfully, but these errors were encountered: