Re: [whatwg/encoding] Make decode() and encodeInto() accept SharedArrayBuffer-backed views (#172)

> Also in case of WebGL, all API entry points were retroactively re-specced to allow SharedArrayBuffers and SharedArrayViews in addition to regular typed arrays and views. That would be nice to happen with `decode()` as well, although if so, it should probably happen exactly at the same time as a new function `decodeRange()` was added, so that code can feature test via the presence of `decodeRange()` if the old `decode()` function has been improved or not.

> It's updated now (search for [AllowShared]), thanks all for your input and contributions!

> For UTF-8, I'm _very_ reluctant to add yet another UTF-8 to UTF-16 converter that ...

It is nice that AllowShared was added to TextDecoder spec, however the issue that I posted in the original comment remains, that by changing the existing function, there is no good way to discover whether a browser supports the updated form:
 1. because the existing function was modified without other changes (like `decodeRange()` that was originally recommended), JS code must perform an awkward runtime feature test that allocates a garbage SAB, then tests decode() in it and see if it throws, and if not, then use it.
 2. because it is the same function that is mutated, users and documentation are not easily prompted to understand to update their support tables: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/decode . Knowing when it is safe to migrate is hard.

The change has fixed point 1. out of the three points above, but points 2. and 3. from the original comment (generated garbage and need to manually scan a string in O(n) time to find its null termination point before being able to call .decode()) still persist in Wasm applications.

Would it be possible to revisit to fix the remaining problems 2. and 3. above?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/encoding/issues/172#issuecomment-765888903

Received on Saturday, 23 January 2021 08:30:21 UTC