-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Remove support for TEXTDECODER=0 #24700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sbc100
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The codesize changes here are because of the removal of the comments in the output (they only effected tests were the unoptimized output tests, that include comments).
kripken
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this, I wonder if we can enable mode 2 when ENVIRONMENT / the browser versions imply that?
Yes, I was thinking that too. Or at least we could default to it. I do wonder about the short-string optimization where we currently opt out of using the |
Oh wow, I didn't remember those. It looks like #16994 can now be closed. I'm not sure about #18034 .. that looks very odd, and is hopefully fixed. |
|
I believe this causes a regression for browsers that are unable to use TextDecoder.decode() on SharedArrayBuffers, because Emscripten is unable to detect that (unless it did a test decode and caught an exception). |
Users that want to ensure that their code works on earlier browser versions could set TEXTDECODER=0 and be sure that they wouldn't hit browser bugs. I am a bit surprised what the benefit was for removing TEXTDECODER=0 support. |
Do such bugs exist? Couldn't such as user just do
Its quite a bit of complexity being removed, and in paritucalar IIRC it also lays the groundwork for followup simplifications, although I don't remember now what they were. |
Yes, there is a very long range of browsers that after adding support for SharedArrayBuffer, didn't yet support TextDecoder on SAB views. E.g. maybe two to three years of Firefoxes at least, probably same duration of Chromes.
The user will have to discover that the bug exists in the old browsers first. And then that would mean that any other uses of TextDecoder site wide code in the same JS context would not get to access TextDecoder either, even on non-Emscripten content. Though maybe it won't become a problem to users. For us at least this won't be an issue, we are eyeing towards WebGPU only browsers for the future. |
I thought TextDecode was simply/officially not supported with SAB, and we have code for dealing with that, don't we? e.g. Are there browsers that do support this and wouldn't need the call to
True, asking users to do Better for us to handle any
|
|
(Like the workaround we already have for the SAB limitation) |
Ohhh. I didn't recall that at all. Then nevermind, nothing to see here. (Performance might be appalling with |
FWIW that's not entirely correct. The spec has allow TextDecoder to work with SABs for a while now, it's just that none of the browsers bother to prioritise and implement it, so we are stuck with the slow clone workaround. I wonder if Emscripten could nudge someone to help it happen at Chrome.
I saw this bug in wasm-bindgen today and thought of this thread: wasm-bindgen/wasm-bindgen#4471 I suspect Emscripten will run into the same issue after decoding 2GB worth of strings, as we also use a shared TextDecoder instance (like everyone else). Might be worth testing and adding a workaround. |
|
Uhh, what a bug. I think it would be best to restore TEXTDECODER=0 then. |
|
I think it's worth adding a workaround anyway, counting how much we've decoded (or catching the error) is not that hard. |
Oh, so one day, once browsers start implementing it we can probe for support for this? Is there some way to track this feature or know when one of the browsers implements it?
|
|
I guess we need to write a test the decoded 3gb of data now. Great. Thanks Safari. |
Yup you can see AllowSharedBufferSource in the spec: https://encoding.spec.whatwg.org/#textdecoder For individual bugs, you'd have to track them down in corresponding browser bug trackers, but e.g. it's already implemented in Node.js: nodejs/node#32203
IIUC, it's also enough to feed same small chunk data in a loop until you reach total 3gb, you don't necessarily need to allocate that much. |
Setting this to zero doesn't provide much value to anyone since that conditional usage
is relatively cheap (compared to the fallback) and the API available in all browsers these days.
We still need the fallback for things like audio worklets and JS shell environments.