-
Notifications
You must be signed in to change notification settings - Fork 158
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
"get a copy of the bytes held by the buffer source" should not fail for detached buffers #151
Comments
Note that I think this may be a more general issue, in that the ES spec requires throwing in many cases when operating on detached stuff, but in practice UAs don't do that... Worth checking with @jswalden at least; I recall him doing some work on that stuff. |
Yeah, I raised that two years ago when I last did research into this: https://esdiscuss.org/topic/arraybuffer-neutering. @bterlson is TC39 still hoping implementers will throw more for ArrayBuffer and friends? When are we going to throw in the towel? |
In any event, IDL doesn't have to follow suit and can just return the empty byte sequence if IsDetached returns true solving at least part of the problem. |
I think we hope everyone will align and throw more often, but I admit that I haven't looked into this area for at least a year so things may have changed. There should be test262 collateral for all this (right, @tcare / @leobalter / @jugglinmike?) so I think it's just a matter of priorities. Hopefully the web doesn't depend on non-throwing behavior? (Seems likely given that detached buffers aren't very common, I suppose) |
test262 does include tests for this (thanks @leobalter) but I'm still concerned about web compatibility. I haven't figured out how to instrument TypedArrays to measure whether detached TypedArrays are ever accessed without decreasing TypedArray performance (we set the length to 0 and bounds checks handle accesses, so we don't need a separate detached check), so I'm not sure how to get the information from telemetry. Does anyone else have an idea for how to get solid data on this question? |
As far as I can tell there's no way for a %TypedArray%'s [[ViewedArrayBuffer]] internal slot to be undefined. I'm pretty sure this has to be the case as implementations assume this algorithm to never throw (the detached issue is tracked separately by #151).
Instead treat them the same as the empty byte sequence as implementations have been doing since forever. This also performs the IsDetachedBuffer abstract operation on the correct object. Fixes #151.
As far as I can tell there's no way for a %TypedArray%'s [[ViewedArrayBuffer]] internal slot to be undefined. I'm pretty sure this has to be the case as implementations assume this algorithm to never throw (the detached issue is tracked separately by #151).
Instead treat them the same as the empty byte sequence as implementations have been doing since forever. This also performs the IsDetachedBuffer abstract operation on the correct object. Fixes #151.
Currently it seems that IDL throws for detached buffers. However, as far as I can tell implementations do not follow this and simply end up with the empty byte sequence whenever they encounter a detached buffer.
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4414 is my demo for this (note the lack of exceptions/rejections).
(Note that there's also still an ask to clean up this aspect of IDL and make it much easier to work with: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28798 .)
The text was updated successfully, but these errors were encountered: