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

Blocking APIs in Workers? #38

Open
ricea opened this issue May 27, 2021 · 1 comment
Open

Blocking APIs in Workers? #38

ricea opened this issue May 27, 2021 · 1 comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@ricea
Copy link
Collaborator

ricea commented May 27, 2021

From a usability perspective, a blocking API is very attractive. However, the impact on interactivity would be unacceptable on the main thread.

An interesting possibility is to provide a blocking API only in workers.

Maybe something like

[Exposed=Worker] static Uint8Array blockingCompress(DOMString format, BufferSource input);

See also #8 for an equivalent non-blocking method and #37 for motivation.

@nicjansma
Copy link

One place where a blocking API could be helpful is for cases of using compression in unload, i.e. beaconing data for analytics usage. RUM libraries like boomerang.js hook into pagehide etc, and we often beacon data at the end of the page session.

However, we don't know of an easy way to utilize the Compression Streams API in this scenario as the async nature means we won't get the compressed bytes for passing to .sendBeacon() in the pagehide handler in time -- the page has unloaded waiting for the callback/await.

I've added an idea to the Beacon API tracker to see if it could compress on its own w3c/beacon#72, but it could also possibly be solved with a sync API here. Though having the sendBeacon() API allow for this may be more ideal, as it it could handle the compression off-thread and off the critical path of the page unloading.

@annevk annevk added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

3 participants