Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

[WIP] SDL2 PROXY_TO_PTHREAD Fixes #77

Closed

Conversation

jakogut
Copy link
Contributor

@jakogut jakogut commented Mar 7, 2019

This pull request fixes undefined references and proxying issues when using SDL2 with PROXY_TO_PTHREAD=1.

Requires emscripten-core/emscripten#8254

This was tested with tests/sdl2_gl_frames_swap.c and PROXY_TO_PTHREAD=1.

This still requires creating a WebGL context and making it current as documented here:
emscripten-core/emscripten#7684 (comment)

Fixes: emscripten-core/emscripten#6009

@jakogut
Copy link
Contributor Author

jakogut commented Mar 7, 2019

@juj I'm open to feedback about a better way to do this.

@conversy
Copy link

conversy commented Mar 9, 2019

I understood that this PR would enable the use of SDL with threads, is this correct? If so, I'm very interested into it. I'm not sure I have the skills to test it though.

@jakogut
Copy link
Contributor Author

jakogut commented Mar 9, 2019

@conversy It enables SDL2 applications to be run with the option PROXY_TO_PTHREAD=1, which runs the main function in a separate thread.

@jakogut
Copy link
Contributor Author

jakogut commented Mar 15, 2019

@conversy I don't know if this is what you're actually wanting, but I'm now working on SDL2 threads support through an unrelated turn of events. I've made an issue here: emscripten-core/emscripten#8300

@conversy
Copy link

My application says: "screen is not defined" when run in a browser. I understood that it was because I also use threads with SDL. Is this PR supposed to fix it?
I gave it a try (em 1.38.29, cloning SDL port, applying the PR, compiling with EMCC_LOCAL_PORTS) to no avail...

@kripken
Copy link
Member

kripken commented Mar 27, 2019

Curious to hear @Daft-Freak's thoughts here. My general feeling is that we can fix this another way, by replacing say Emscripten_SetWindowTitle with a new emscripten C API function emscripten_set_window_title, and we'd handle proxying of that in emscripten itself. That would be less work here, more work shared in emscripten, unless I'm missing something?

@Daft-Freak
Copy link
Member

A lot of this could be done with new emscripten API. emscripten_set_window_title and emscripten_get_screen_size would likely be useful API additions anyway, maybe something like emscripten_set_element_style(selector, property, value) could be added for setting the cursor.

That would leave the framebuffer and creating cursors, which uses a canvas to convert some pixel data into a data-url, maybe there's some way we could do this that would also work on a worker?

@Daft-Freak
Copy link
Member

Small comment on the PR itself: we usually just prefix commits with emscripten:

@fallenoak
Copy link

I just gave this PR a spin and it works well for my use case. What are the next steps? Implementing functions like emscripten_set_window_title in the main emscripten code base and updating this PR to make use of them?

@kripken
Copy link
Member

kripken commented Apr 9, 2019

@fallenoak yes, exactly, that's the right order. I don't think anyone's working on that yet, so if you or anyone else wants to, that would be great!

@jakogut
Copy link
Contributor Author

jakogut commented Aug 27, 2019

Do we only want APIs for emscripten_set_window_title and emscripten_get_screen_size, or others as well?

@jakogut
Copy link
Contributor Author

jakogut commented Aug 27, 2019

@kripken @Daft-Freak I've updated this PR, and started a PR in Emscripten for some of these API changes. emscripten-core/emscripten#9336

@jakogut jakogut force-pushed the sdl2-proxy-pthread-fixes branch 2 times, most recently from 5bdbd8a to 54b6e2c Compare August 27, 2019 21:42
@jakogut jakogut closed this Dec 3, 2019
Daft-Freak added a commit that referenced this pull request Apr 13, 2020
kripken pushed a commit to emscripten-core/emscripten that referenced this pull request Aug 3, 2020
This PR implements various C APIs for SDL2 to work with PROXY_TO_PTHREAD=1 as discussed here: emscripten-ports/SDL2#77

* create C API for setting window title

* create C API for getting window title

* tests: test_html5: test emscripten_{get,set}window_title

* create C API for getting screen size

* tests: test_html5: test emscripten_get_screen_size
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SDL2 application will break when using pthreads
6 participants