-
Notifications
You must be signed in to change notification settings - Fork 931
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
Web: implement WaitUntilStrategy
#3739
Conversation
acee834
to
7004f5b
Compare
7004f5b
to
8f2483d
Compare
@@ -0,0 +1,10 @@ | |||
onmessage = event => { |
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.
Hmm, I'm confused as to why this is in JavaScript? Is it not possible to write the worker in Rust? Or is it because it'd require a cumbersome build.rs
step or similar to first compile the Rust code to WASM, and then embed that WASM into the final application?
(I'm totally fine with this being JS either way, mostly just curious).
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.
Unfortunately its currently impossible to spawn a worker without at least some JS.
Even the current plan of the Shared Everything Threads Proposal requires a polyfill written in JS to make it work.
In any case, until the component model is stable and integrated a lot of functionality currently requires JS anyway, its just that it is something wasm-bindgen
usually takes care of. However spawning workers unfortunately isn't one of those things.
I was briefly considering waiting until I release my web-thread
crate, but realized that it would require a custom JS solution for single-threaded Wasm anyway, so this works for both.
8f2483d
to
309dd54
Compare
This implements an alternative scheduling strategy for
ControlFlow::WaitUntil
on Web to prevent throttling when the tab is not focused by using a worker, which commonly browsers don't throttle regardless of tab focus.I also added another step to the CI to add JS minification, let me know if you want me to remove it.
Fixes #3738.