Skip to content
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

SharedArrayBuffer's Atomics.waitAsync() primitive is in need of cancellation support in order to not obstruct GC #29

Open
juj opened this issue Jan 18, 2021 · 1 comment
Assignees

Comments

@juj
Copy link

juj commented Jan 18, 2021

Implementing Atomics.waitAsync based multithreading primitives to Emscripten WebAssembly code libraries, it was realized in WebAssembly/threads#176 that the ability to perform memory deinitialization after having issued a Atomics.waitAsync is severely impaired without a mechanism to cancel a waitAsync operation.

In that thread it was suggested that maybe a future machinery to enable cancelling a Promise might help the issue and let garbage collection to happen properly, without requiring sites to wrap all their multithreaded WebAssembly content inside iframes for GC to work.

Would Promise cancellation mechanism be suitable for fixing the current Atomics.waitAsync GC problem? Are there any rough eta estimates for Promise cancellation support to arrive in browsers? (2021? or later? or too early to tell?)

@rbuckton rbuckton self-assigned this Jan 19, 2021
@rbuckton
Copy link
Collaborator

The cancellation of async operations already exists in browsers (AbortController/AbortSignal), but that implementation depends on browser-specific APIs (i.e., EventTarget) that don't exist in ECMA-262. An alternative I've proposed is #22, defining a symbol-based cancellation protocol that could be recognized in ECMA-262 and implemented on top of AbortController/AbortSignal, or in user-land code.

I plan to bring cancellation (in this protocol form) back before committee later this year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants