Oh, the code uses GLUT to initialize the GL context. Unfortunately OFFSCREEN_FRAMEBUFFER (and OFFSCREENCANVAS_SUPPORT) features are only available for contexts created with HTML5 API and SDL2, but won't work for contexts created with GLUT, GLEW, GLFW, EGL or SDL 1.
ti 2. kesäk. 2020 klo 18.13 Greg Baxes ([email protected]) kirjoitti: > > Hi jj, > > Thanks for your reply, very helpful in that building with -s > OFFSCREEN_FRAMEBUFFER=1 allows WebGL to be available from pthreads. > > However, when I build with -s OFFSCREEN_FRAMEBUFFER=1, it throws > "emscripten_async_queue_call_on_thread" errors from pthread at runtime. This > occurs in both my terrain renderer builds as well as the simple es2gears.c > example. As a simple test case, I have attached es2gears.c. It builds and > runs nicely in chrome if I build it with: > > emcc -s WASM=1 -s USE_PTHREADS=1 -g es2gears.c -o demo.html > > However, it crashes at runtime with the > "emscripten_async_queue_call_on_thread" errors from pthreads if I build it > with: > > emcc -s WASM=1 -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1 -s > OFFSCREEN_FRAMEBUFFER=1 -g es2gears.c -o demo.html > > Can you advise what I'm missing to get es2gears.c running with WebGL and > pthreads? Thank you. > > > On Tuesday, June 2, 2020 at 1:46:35 AM UTC-6, jj wrote: >> >> WebGL API is only available in main browser thread by default. >> >> If you build with -s OFFSCREEN_FRAMEBUFFER=1, then WebGL will be >> available from pthreads via the Emscripten WebGL runtime proxying all >> the GL calls to the main thread. >> >> If you build with -s OFFSCREENCANVAS_SUPPORT=1, then WebGL will be >> available from pthreads via the OffscreenCanvas web api. Check >> https://caniuse.com/#feat=offscreencanvas for availability. >> >> Browsers are really bad at printing JS errors: the error "Cannot read >> property 'enable' of undefined" should read something like "GLctx is >> undefined in GLctx.enable(x) at function _glEnable". That is, there is >> no active GL context in the current thread where the GL call was >> attempted. >> >> ti 2. kesäk. 2020 klo 0.34 Greg Baxes ([email protected]) kirjoitti: >> > >> > 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! >> > >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "emscripten-discuss" group. >> > To unsubscribe from this group and stop receiving emails from it, send an >> > email to [email protected]. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msgid/emscripten-discuss/b7bf634d-aaf2-4acd-988c-13058fdda1e5%40googlegroups.com. > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/6239f4c9-6ab3-4ea8-8eab-b4d1cef15205%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CA%2B6sJ-1v2ZpvgNAuP77HFNmCTuVwNp3HkCyjm2Z0RrL5y47-qQ%40mail.gmail.com.
