-
Notifications
You must be signed in to change notification settings - Fork 22.8k
Mention certain ArrayBuffers have controlled detachment #40457
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
Preview URLs
(comment last updated: 2025-07-21 13:20:57) |
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.
Thanks @Josh-Cena; makes sense, but I've got a question, and a suggestion for clarity.
### Exceptions | ||
|
||
- `TypeError` {{domxref("DOMException")}} | ||
- : Thrown if an attempt is made to detach the {{jsxref("ArrayBuffer")}} in any way other than via {{domxref("GPUBuffer.unmap()")}}. |
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.
Ah, so you've removed this from here because this isn't an exception of getMappedRange()
itself?
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.
Yes exactly
@@ -33,7 +33,7 @@ A new {{jsxref("ArrayBuffer")}} object. Its contents are initialized to the cont | |||
- {{jsxref("RangeError")}} | |||
- : Thrown if this `ArrayBuffer` is resizable and `newByteLength` is greater than the {{jsxref("ArrayBuffer/maxByteLength", "maxByteLength")}} of this `ArrayBuffer`. | |||
- {{jsxref("TypeError")}} | |||
- : Thrown if this `ArrayBuffer` is already detached. | |||
- : Thrown if this `ArrayBuffer` is already detached, or if it can only be detached by designated operations. Currently, only certain web APIs are capable of creating such tracked `ArrayBuffer` objects, such as {{domxref("GPUBuffer.getMappedRange()")}} and [`WebAssembly.Memory.buffer`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Memory/buffer). |
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.
Sounds a bit confusing, and unclear as to how this relates to the method page it appears on. Maybe something like:
- : Thrown if this `ArrayBuffer` is already detached, or if it can only be detached by designated operations. Currently, only certain web APIs are capable of creating such tracked `ArrayBuffer` objects, such as {{domxref("GPUBuffer.getMappedRange()")}} and [`WebAssembly.Memory.buffer`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Memory/buffer). | |
- : Thrown if this `ArrayBuffer` is already detached, or if it can't be detached using `transfer()` and can only be detached by designated operations. Currently, only certain methods are capable of detaching tracked `ArrayBuffer` objects, such as those produced by {{domxref("GPUBuffer.getMappedRange()")}} and [`WebAssembly.Memory.buffer`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Memory/buffer). |
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.
- : Thrown if this `ArrayBuffer` is already detached, or if it can only be detached by designated operations. Currently, only certain web APIs are capable of creating such tracked `ArrayBuffer` objects, such as {{domxref("GPUBuffer.getMappedRange()")}} and [`WebAssembly.Memory.buffer`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Memory/buffer). | |
- : Thrown if this `ArrayBuffer` is already detached, or if it can only be detached by designated operations. Currently, only certain web APIs are capable of creating such `ArrayBuffer` objects with designated detaching methods, such as {{domxref("GPUBuffer.getMappedRange()")}} and [`WebAssembly.Memory.buffer`](/en-US/docs/WebAssembly/Reference/JavaScript_interface/Memory/buffer). |
The idea is that you can't create such buffers in userland, and if you have a random array buffer in hand, very likely you don't have to worry about it.
files/en-us/web/javascript/reference/global_objects/arraybuffer/transfertofixedlength/index.md
Outdated
Show resolved
Hide resolved
…r/transfer/index.md
…r/transfertofixedlength/index.md
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.
OK, I get it now; thanks @Josh-Cena! I think this works, so approving. I've included a couple of minor language nitpicks for you to consider before merging.
files/en-us/web/javascript/reference/global_objects/arraybuffer/transfer/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/javascript/reference/global_objects/arraybuffer/transfertofixedlength/index.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>
Thanks for the review! |
Fix #39021.
The main change is made to the JS docs, but I'm updating
GPUBuffer.getMappedRange
as well, because this is not an exception of this method itself.