Add [AllowImmutable] extended attribute for immutable array buffers and views
What problem are you trying to solve?
https://github.com/tc39/proposal-immutable-arraybuffer will likely need a new [AllowImmutable] extended attribute, similar to #982 for resizable array buffers.
What solutions exist today?
No response
How would you solve it?
No response
Anything else?
See also https://github.com/tc39/proposal-immutable-arraybuffer/issues/43.
Proposed structured clone changes: https://github.com/whatwg/html/pull/11033.
One thing that would be good to think about as I don't think we did this quite right with [AllowResizable] is where we would want to see this used. Because now we have resizable buffers in JavaScript, but nowhere to use them in the web platform. From a web developer perspective that is not exactly great.
For instance, we have a fair number of APIs that essentially copy the buffer input so ideally they should all adopt this out of the gate. No real reason for TextDecoder to still reject these the moment the JS engine supports them.
I think the default should be to accept immutable buffers. Even for APIs which write to their argument (which are rare - TextEncoder encodeInto comes to mind, but little else) they'll just throw when they actually try to write. [Edit: actually no, since they manipulate things internally, some algorithms would need to be updated I'm sure.]
It would be nice for APIs which do a copy to be updated not to do that, but this is an unobservable optimization which engines could do anyway, so it's not strictly necessary.
Maybe instead there should be a [ForbidImmutable] attribute for the those rare cases?