Skip to content

SDL2 application will break when using pthreads #6009

@aliasdevelopment

Description

@aliasdevelopment

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions