emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.76k stars 3.3k forks source link

add asyncify into gl_in_pthread.cpp #12572

Open spoon-vertiv opened 4 years ago

spoon-vertiv commented 4 years ago

So the gl_in_pthread.cpp never worked for me. it would always SNAP instantly to red instead of fade to red. It was only recently when I examined gl_in_proxy_pthread.cpp did I realize why. calls like this

while(emscripten_get_now() - now < 16) /no-op/;

were basically blocking the opengl updates from occuring? at least i think that's the reason. In order to fix this example for me you would only need to add the asyncify reference similar to the gl_in_proxy_pthread.cpp example... so

replace on line 55 double now = emscripten_get_now(); while(emscripten_get_now() - now < 16) /no-op/;

with this.

if ASYNCIFY

emscripten_sleep(16);

else

double now = emscripten_get_now();
while(emscripten_get_now() - now < 16) /*no-op*/;

endif

and of course add the appropriate asyncify options to the test_browser.py . -s ASYNCIFY -DASYNCIFY somewhere....

This would fix the example for me and maybe help others?

kripken commented 4 years ago

Thanks @spoon-vertiv , good point.

Looks like it's run like this in the test suite:

self.btest('gl_in_pthread.cpp', expected='1', args=args + ['-s', 'USE_PTHREADS=1', '-s', 'PTHREAD_POOL_SIZE=2', '-s', 'OFFSCREENCANVAS_SUPPORT=1', '-lGL'])

So it is using OFFSCREENCANVAS_SUPPORT which maybe helps? If it does, we should add a comment in the source maybe. If it doesn't, then I agree it needs something like ASYNCIFY, and we should add a comment for that. A PR would would be great.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.