Question about a test : gl_in_pthread.cpp

62 views
Skip to first unread message

Mehdi Sabwat

unread,
Aug 26, 2019, 12:52:45 PM8/26/19
to emscripten-discuss
Hi,

The test with these command options fails in Chromium (page hanging after first pthread_create).

em++ gl.cpp -o test.html -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1 -s PTHREAD_POOL_SIZE=2 -s -s OFFSCREEN_FRAMEBUFFER=1 -lGL -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 --emrun

I tried this instead and it seems to work better, is this the new way to do `-s OFFSCREENCANVAS_SUPPORT=1` ? Should this be applied to all gl/pthread tests?

Alon Zakai

unread,
Aug 26, 2019, 7:02:34 PM8/26/19
to emscripte...@googlegroups.com
I just refactored that test a little in


The flags used in the test now in test_browser.py should only be actually necessary ones.

You do need either OffscreenCanvas support, or OFFSCREEN_FRAMEBUFFER. OffscreenCanvas is a browser API, which works in at least Chrome, while OFFSCREEN_FRAMEBUFFER compiles in some code to proxy GL commands to the main thread, so it's like a polyfill for OffscreenCanvas.

Note that you currently need to set OFFSCREENCANVAS_SUPPORT even if using FRAMEBUFFER. I'm not sure why that is, but I think it's why your command didn't work. If that's not it, is an error shown in the dev console perhaps?


--
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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/06462979-cf0b-4bd8-912d-1957f5d6b1ad%40googlegroups.com.

Mehdi Sabwat

unread,
Aug 27, 2019, 7:56:49 AM8/27/19
to emscripten-discuss
Thank you for the details, the PR is not about the test I sent thought.

To answer your question, in Chromium the test makes the page hang. I cannot get anything on the console unfortunately.

If I add -s PROXY_TO_PTHREAD=1 (without OFFSCREEN_FRAMEBUFFER as stated in the test) I get :
pthread_create: failed to transfer control of canvas "canvas" to OffscreenCanvas! Error: ReferenceError: document is not defined

for gl_in_pthread.cpp:

- if I don't use -s PROXY_TO_PTHREAD=1, the page hangs
- if I don't use -s OFFSCREEN_FRAMEBUFFER=1 I get the error above

On Tuesday, August 27, 2019 at 1:02:34 AM UTC+2, Alon Zakai wrote:
I just refactored that test a little in


The flags used in the test now in test_browser.py should only be actually necessary ones.

You do need either OffscreenCanvas support, or OFFSCREEN_FRAMEBUFFER. OffscreenCanvas is a browser API, which works in at least Chrome, while OFFSCREEN_FRAMEBUFFER compiles in some code to proxy GL commands to the main thread, so it's like a polyfill for OffscreenCanvas.

Note that you currently need to set OFFSCREENCANVAS_SUPPORT even if using FRAMEBUFFER. I'm not sure why that is, but I think it's why your command didn't work. If that's not it, is an error shown in the dev console perhaps?


On Mon, Aug 26, 2019 at 9:52 AM Mehdi Sabwat <mehdi...@gmail.com> wrote:
Hi,

The test with these command options fails in Chromium (page hanging after first pthread_create).

em++ gl.cpp -o test.html -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1 -s PTHREAD_POOL_SIZE=2 -s -s OFFSCREEN_FRAMEBUFFER=1 -lGL -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 --emrun

I tried this instead and it seems to work better, is this the new way to do `-s OFFSCREENCANVAS_SUPPORT=1` ? Should this be applied to all gl/pthread tests?

--
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 emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Aug 27, 2019, 4:28:32 PM8/27/19
to emscripte...@googlegroups.com
Oh sorry, looks like I confused test_webgl_offscreen_canvas_in_pthread with test_webgl_offscreen_canvas_in_proxied_pthread...

Running your command on that test does work for me, on Chrome 76. Which version did you test on?

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/f58a7e32-fe5a-41eb-bf3e-a694354d785c%40googlegroups.com.

Mehdi Sabwat

unread,
Aug 28, 2019, 8:10:37 AM8/28/19
to emscripten-discuss
Yes my command works but it's not the one that actually shows in test_browser.py. And yes, I have Chromium 76.

should it be changed?

I wanted to know if the command that passes the test seems correct?


On Tuesday, August 27, 2019 at 10:28:32 PM UTC+2, Alon Zakai wrote:
Oh sorry, looks like I confused test_webgl_offscreen_canvas_in_pthread with test_webgl_offscreen_canvas_in_proxied_pthread...

Running your command on that test does work for me, on Chrome 76. Which version did you test on?

On Tue, Aug 27, 2019 at 4:56 AM Mehdi Sabwat <mehdi...@gmail.com> wrote:
Thank you for the details, the PR is not about the test I sent thought.

To answer your question, in Chromium the test makes the page hang. I cannot get anything on the console unfortunately.

If I add -s PROXY_TO_PTHREAD=1 (without OFFSCREEN_FRAMEBUFFER as stated in the test) I get :
pthread_create: failed to transfer control of canvas "canvas" to OffscreenCanvas! Error: ReferenceError: document is not defined

for gl_in_pthread.cpp:

- if I don't use -s PROXY_TO_PTHREAD=1, the page hangs
- if I don't use -s OFFSCREEN_FRAMEBUFFER=1 I get the error above

On Tuesday, August 27, 2019 at 1:02:34 AM UTC+2, Alon Zakai wrote:
I just refactored that test a little in


The flags used in the test now in test_browser.py should only be actually necessary ones.

You do need either OffscreenCanvas support, or OFFSCREEN_FRAMEBUFFER. OffscreenCanvas is a browser API, which works in at least Chrome, while OFFSCREEN_FRAMEBUFFER compiles in some code to proxy GL commands to the main thread, so it's like a polyfill for OffscreenCanvas.

Note that you currently need to set OFFSCREENCANVAS_SUPPORT even if using FRAMEBUFFER. I'm not sure why that is, but I think it's why your command didn't work. If that's not it, is an error shown in the dev console perhaps?


On Mon, Aug 26, 2019 at 9:52 AM Mehdi Sabwat <mehdi...@gmail.com> wrote:
Hi,

The test with these command options fails in Chromium (page hanging after first pthread_create).

em++ gl.cpp -o test.html -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1 -s PTHREAD_POOL_SIZE=2 -s -s OFFSCREEN_FRAMEBUFFER=1 -lGL -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 --emrun

I tried this instead and it seems to work better, is this the new way to do `-s OFFSCREENCANVAS_SUPPORT=1` ? Should this be applied to all gl/pthread tests?

--
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 emscripten-discuss+unsub...@googlegroups.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 emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
Aug 28, 2019, 2:35:59 PM8/28/19
to emscripte...@googlegroups.com
Thanks, I see now - the test is indeed marked as disabled in chrome, due to https://crbug.com/961765 which is why the failure wasn't noticed on CI.

That test does pass with offscreen framebuffer + PROXY_TO_PTHREAD, as you said. That avoids using the native OffscreenCanvas support in the browser of canvas proxying, and does the proxying manually. In general that is less optimal, so it's not recommended.

But here proxying the OffscreenCanvas hits a bug, related to adding PROXY_TO_PTHREAD to that test (as you did, and which works around the sync issue that the test is disabled because of), I filed https://github.com/emscripten-core/emscripten/issues/9344

In general: OffscreenCanvas is the future in this area. But offscreen framebuffer can help in the meantime in browsers that don't support it yet.

- Alon


To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.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 emscripten-disc...@googlegroups.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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/94e98298-fe60-4b39-844d-22b8ba306764%40googlegroups.com.

Mehdi Sabwat

unread,
Aug 28, 2019, 5:00:04 PM8/28/19
to emscripte...@googlegroups.com
Thanks Alon for the super clear explanation! Cheers

Reply all
Reply to author
Forward
0 new messages