TextDecoderWrapper doesn't always work

38 views
Skip to first unread message

Dan C

unread,
Jul 5, 2021, 9:21:17 PM7/5/21
to emscripten-discuss
Hi everyone,

In TextDecoderWrapper.decode, we currently have a checking whether the input buffer is an SharedArrayBuffer. After heap size is increased from INITIAL_MEMORY, "data.buffer instanceof SharedArrayBuffer" can evaluate to false when data is a view of the SharedArrayBuffer of the heap. I suspect this is because the new SharedArrayBuffer was created in a different thread.

Thanks,
Dan

Alon Zakai

unread,
Jul 7, 2021, 12:32:55 PM7/7/21
to emscripte...@googlegroups.com
Very strange. In that case, what is the type of data.buffer?

The main SharedArrayBuffer is always created in the main thread during startup. Later growth does not create a new SAB in another thread, it just grows it, and it updates the views in each thread using updateGlobalBufferAndViews. Regardless, the buffer of those views must always be an SAB - if somehow it is just an AB, that would be a serious browser bug (which is possible, of course).

--
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/c78e913e-7a0b-4fe3-9573-6e0300c5c2afn%40googlegroups.com.

Dan C

unread,
Jul 7, 2021, 3:57:12 PM7/7/21
to emscripten-discuss
The type of data.buffer is still SharedArrayBuffer, but "data.buffer instanceof SharedArrayBuffer" is false. Browser is Chrome 91.

P.S. I can't reproduce the issue today after update Chrome to 91.0.4472.124 in Windows.

Reply all
Reply to author
Forward
0 new messages