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

Web: queue EventLoopProxy::send_event() to microtask when triggered from outside the event loop #3728

Merged
merged 2 commits into from
Jun 11, 2024

Conversation

daxpedda
Copy link
Member

This also checks if its coming from a thread or not, in which case it doesn't queue it.

I also noticed some legacy code that deferred to ControlFlow::Poll when receiving events instead of waking up the event loop immediately, which I removed, so now events should come in faster regardless of PollStrategy.

Fixes #3715.

@daxpedda daxpedda added this to the Version 0.30.2 milestone Jun 11, 2024
Copy link
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't understand what's happening here, just gonna leave an approving review so that you can merge it since it only touches the web backend.

A few questions though: Why are we not using wasm_bindgen_futures internally ourselves? And why does web_sys not expose queueMicrotask?

@daxpedda
Copy link
Member Author

daxpedda commented Jun 11, 2024

A few questions though: Why are we not using wasm_bindgen_futures internally ourselves?

We are in a few places.
While it is true that wasm_bindgen_futures::spawn_local() actually uses queueMicrotask() internally, it also does way more then just that, which we don't need in this case.

And why does web_sys not expose queueMicrotask?

Just missing, I will make a PR.

@madsmtm
Copy link
Member

madsmtm commented Jun 11, 2024

Just missing, I will make a PR.

Don't sweat it, we do this sort of thing all the time in Winit, just curious.

@daxpedda
Copy link
Member Author

Just missing, I will make a PR.

Don't sweat it, we do this sort of thing all the time in Winit, just curious.

Done in rustwasm/wasm-bindgen#3981.

@daxpedda daxpedda merged commit 9522670 into rust-windowing:master Jun 11, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

EventLoopProxy::send_event executes user events immediately in microtasks
2 participants