-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
SDL2 application will break when using pthreads #6009
Comments
I'm encountering this same issue. USE_SDL and USE_PTHREAD/PROXY_TO_PTHREAD seem to be incompatible. |
Digging into the issue further, the stack trace shows:
Looking at the Emscripten port of SDL2,
So it seems that the |
I've resolved the issues with proxying
Doing a little digging around seems to indicate that the EGL code at |
This may be stuff that has not been proxied yet, yes - @juj can confirm. |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant. |
@kripken No blockers, just have to address the feedback given. I can look at doing that later this week. |
Hi, is there any update for this issue? |
For those coming across this, it looks like emscripten-ports/SDL2#127 is still open. |
So question is... when? 😅 |
I ran into this issue as well and would add +1 for merging emscripten-ports/SDL2#127 which seems to fix it. |
+1 running into this issue. |
+1 , Besides the screensize, mouse locking crashes, and all of the EGL calls proxy to main, which makes using EGL on a thread not really feasible. (Fixable by removing every async property from EGL.js lib) Long story short, emscripten is not ready for production level threading work that needs to be performance critical. |
There is a fix available for using
After that, you should be able to run SDL compiled with Although, I have noticed some issues re: audio locking the main thread if you have |
Is this still an issue since libsdl-org/SDL#5365 has been merged? |
Fixing your link: libsdl-org/SDL#5365 I believe libsdl-org/SDL#6142 is what may have resolved this, which I think incorporated the changes I suggested to the author in my previous comment. |
I have made a SDL2 application using the linker flag "-s USE_SDL=2" which works as expected.
I have made a ASIO application using https://github.com/emscripten-ports/asio which works as expected.
I have made a ASIO/pthread application with works as expected using the linker flags "-s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -s PROXY_TO_PTHREAD=1"
But I can not merge these applications together. It seems as if USE_SDL and USE_PTHREADS/PROXY_TO_PTHREAD works against each other. I known that many older tutorials states that multithreading is not possible, but also knows that a lot of activities has been done to change this.
I get the following error when combining SDL and pthreads:
pthread-main.js onmessage() captured an uncaught exception: ReferenceError: screen is not defined
I can understand that I would make sense that the resources for rendering would only be available for the main thread, but pthread is missing some features/resources for SDL to possible.
Is it by design that USE_SDL and USE_PTHREADS/PROXY_TO_PTHREAD work against each other?
Would it be possible to use SDL from the main thread and still use pthreads for additional work?
The text was updated successfully, but these errors were encountered: