When compiled with -s PROXY_TO_PTHREAD=1, calls to SDL_Init() fail with the error "screen is not defined".
This is important to me because proxying all socket commands through a local websocket server as described here is the only way I can get any networking to work in my project.
Here's my source file, poc.c:
#include "SDL.h"
int main() {
SDL_Init(SDL_INIT_VIDEO);
SDL_Quit();
}
And here's my commands to compile and run:
emcc poc.c -s USE_SDL=2 -s USE_PTHREADS=1 -s PROXY_POSIX_SOCKETS=1 -s PROXY_TO_PTHREAD=1 -o poc.html
python -m SimpleHTTPServer 5000
Open localhost:5000/poc.html in a browser, open the developer console, and you see this error:
poc.worker.js:175 Uncaught ReferenceError: screen is not defined
at 37846 (http://localhost:2222/poc.js:1908:21)
at _emscripten_asm_const_iii (http://localhost:2222/poc.js:1927:27)
at wasm-function[968]:0x6a84c
at wasm-function[852]:0x603e7
at wasm-function[260]:0x3472
at wasm-function[261]:0x35b0
at wasm-function[258]:0x339a
at wasm-function[259]:0x33a9
at Module._main (http://localhost:2222/poc.js:9838:32)
at ___call_main (http://localhost:2222/poc.js:2312:24)
From jakogut's comments on this site, it appears that the problem is simply that the screen object is not proxied to the new main thread. Relevant lines from video/emscripten/SDL_emscriptenvideo.c:
mode.w = EM_ASM_INT_V({
return screen.width;
});
mode.h = EM_ASM_INT_V({
return screen.height;
});
Indeed, the documentation on PROXY_TO_PTHREAD only says that the canvas object is proxied to the new main thread. How can we get screen proxied as well? I'm happy to contribute code, just need to be pointed in the right direction!
When compiled with
-s PROXY_TO_PTHREAD=1, calls toSDL_Init()fail with the error "screen is not defined".This is important to me because proxying all socket commands through a local websocket server as described here is the only way I can get any networking to work in my project.
Here's my source file, poc.c:
And here's my commands to compile and run:
Open localhost:5000/poc.html in a browser, open the developer console, and you see this error:
From jakogut's comments on this site, it appears that the problem is simply that the screen object is not proxied to the new main thread. Relevant lines from
video/emscripten/SDL_emscriptenvideo.c:Indeed, the documentation on PROXY_TO_PTHREAD only says that the canvas object is proxied to the new main thread. How can we get
screenproxied as well? I'm happy to contribute code, just need to be pointed in the right direction!