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
Add [AllowShared] to allow accepting SharedArrayBuffers #353
Conversation
Previous to this commit, any API that accepted any of the buffer source types would also accept a SharedArrayBuffer. This was not the approach we want; instead, we want APIs to explicitly opt-in. Enabled by previous work creating annotated types, this adds the new [AllowShared] extended attribute to allow APIs to opt in to accepting SharedArrayBuffers. While here, this removes an unimplemented check for detached array buffers when converting from ES values to IDL types, fixing #352.
So this is primarily for WebGL at this point right? Do we have some follow-up filed there? |
Yes, although I am told it might expand over time, e.g. for web audio or similar. We don't have a follow-up filed on Web GL, because to my knowledge their specs are developed in private with no public issue tracker or "editor's draft". I am not sure what the procedure will be. Maybe we'll need to maintain a moneypatch somewhere. I'll try to poke tc39/proposal-ecmascript-sharedmem#168 about that issue. |
The WebGL issue tracker is at https://github.com/KhronosGroup/WebGL/issues |
Ah OK yeah, I just found that myself; clearly my info was out of date. |
And https://www.khronos.org/registry/webgl/specs/latest/ links to the editor's drafts of WebGL1 and WebGL2, fwiw. |
This annotates all ArrayBuffer or ArrayBufferView types with [AllowShared], per the proto-specification at https://tc39.github.io/ecmascript_sharedmem/dom_shmem.html#webgl, extended to also modify the Web GL 2.0 entrypoints. This allows the backing data to be a SharedArrayBuffer, instead of only non-shared ArrayBuffers, per whatwg/webidl#353. This also makes some related editorial changes, removing the redundant BufferDataSource typedef in favor of the defined-in-Web IDL BufferSource type, and consolidating two overloads of bufferData (one accepting ArrayBuffer? and the other accepting ArrayBufferView) into a single overload accepting BufferSource?.
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.
LGTM.
A type that is not a [=buffer source type=] must not be | ||
[=extended attributes associated with|associated with=] the [{{AllowShared}}] extended attribute. | ||
|
||
See the rules for converting ECMAScript values to IDL [=buffer source types=] in |
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.
I admit I had to look "entails" up. Maybe instead write:
[…] for the specific requirements that using [{{AllowShared}}] creates.
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.
This is already used for every other extended attribute, so I'd rather be consistent.
Does anyone else want to review before we merge? Ideally speak up within the next day-ish. |
* Support SharedArrayBuffers This annotates all ArrayBuffer or ArrayBufferView types with [AllowShared], per the proto-specification at https://tc39.github.io/ecmascript_sharedmem/dom_shmem.html#webgl, extended to also modify the Web GL 2.0 entrypoints. This allows the backing data to be a SharedArrayBuffer, instead of only non-shared ArrayBuffers, per whatwg/webidl#353. This also makes some related editorial changes, removing the redundant BufferDataSource typedef in favor of the defined-in-Web IDL BufferSource type, and consolidating two overloads of bufferData (one accepting ArrayBuffer? and the other accepting ArrayBufferView) into a single overload accepting BufferSource?. * Also allow SharedArrayBuffer in the -List typdefs
Previous to this commit, any API that accepted any of the buffer source types would also accept a SharedArrayBuffer. This was not the approach we want; instead, we want APIs to explicitly opt-in. Enabled by previous work creating annotated types, this adds the new [AllowShared] extended attribute to allow APIs to opt in to accepting SharedArrayBuffers.
While here, this removes an unimplemented check for detached array buffers when converting from ES values to IDL types, fixing #352.
Preview | Diff