Hi everyone,
I have been working successfully with Emscripten over the past few weeks porting a fairly heavy C++ GLES2 3D terrain-rendering engine and small glut-based application layer. It uses pthreads. Everything runs incredibly well in Chrome! I have always seen the JS console throw the warning: "Blocking on the main thread is very dangerous." To correct this blocking-on-main issue and to be able to add websockets support to the application, I have added the -s PROXY_TO_PTHREAD=1 flag to my build. With this, the application crashes with a pthread error when it first encounters a glGetString call. I have tried using the -s OFFSCREEN_FRAMEBUFFER=1 flag and things get further, but then crash on a glTexImage2D call.
To emulate the problem in a simpler context, I went back to my first simple GLES2 test, standard es2gears.c, which I successfully built using:
emcc -s WASM=1 -g es2gears.c -o demo.html
Similarly with it, when I add the -s PROXY_TO_PTHREAD=1 and -s USE_PTHREADS=1 flags, it crashes the same way when it encounters a glEnable call, throwing the same kind of error:
"pthread sent an error! ... Uncaught TypeError: Cannot read property 'enable' of undefined at _glEnable"
So, I think the es2gears.c build is a good test case of the issue I'm seeing.
Any suggestions to fix this? Is WebGL not able to run in a thread under main? Thank you for any insights!