Revert: Web: don't wait for polling when sending events

This is a breaking change, thus revert it for patch series.
This commit is contained in:
Kirill Chibisov
2024-06-15 16:37:29 +03:00
parent b512ed1e63
commit ecd14688dc
2 changed files with 29 additions and 26 deletions

View File

@@ -40,11 +40,6 @@ changelog entry.
## Unreleased
### Changed
- On Web, let events wake up event loop immediately when using
`ControlFlow::Poll`.
### Fixed
- On Web, fix `EventLoopProxy::send_event()` triggering event loop immediately

View File

@@ -476,9 +476,11 @@ impl Shared {
if local {
// If the loop is not running and triggered locally, queue on next microtick.
if let Ok(RunnerEnum::Running(_)) =
if let Ok(RunnerEnum::Running(ref runner)) =
self.0.runner.try_borrow().as_ref().map(Deref::deref)
{
// If we're currently polling let `send_events` do its job.
if !matches!(runner.state, State::Poll { .. }) {
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_name = queueMicrotask)]
@@ -502,6 +504,7 @@ impl Shared {
return;
}
}
}
self.send_events(iter::repeat(Event::UserEvent(())).take(count.get()))
}
@@ -517,8 +520,13 @@ impl Shared {
// If we can run the event processing right now, or need to queue this and wait for later
let mut process_immediately = true;
match self.0.runner.try_borrow().as_ref().map(Deref::deref) {
// If the runner is attached but not running, we always wake it up.
Ok(RunnerEnum::Running(_)) => (),
Ok(RunnerEnum::Running(ref runner)) => {
// If we're currently polling, queue this and wait for the poll() method to be
// called.
if let State::Poll { .. } = runner.state {
process_immediately = false;
}
},
Ok(RunnerEnum::Pending) => {
// The runner still hasn't been attached: queue this event and wait for it to be
process_immediately = false;