bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
34.31k stars 3.35k forks source link

`low_power` example does not work on WASM #14214

Open aevyrie opened 2 weeks ago

aevyrie commented 2 weeks ago

Bevy version

0.14

What you did

  1. Run the web example: https://bevyengine.org/examples/window/low-power/
  2. Press space until you get to the third mode, with RequestRedraw being sent

What went wrong

The event loop should run continuously as long as the event is being sent. However, it does not.

Additional information

let _ = event_loop_proxy.send_event(WakeUp); was added to the example, but the docs all refer to RequestRedraw. Replacing the event loop proxy wakeup with RequestRedraw appears to fix the behavior.

The event loop proxy is useful when waking from another thread, but it appears it is not a direct replacement for the bevy event on all platforms.

mockersf commented 2 weeks ago

the issue seems to be that in Wasm, user events don't interrupt when the event loop is waiting

aevyrie commented 2 weeks ago

Retested, and edited my original report, I was wrong about some of the behavior.

Do we just need to update the example? RequestRedraw seems to work as expected.

mockersf commented 2 weeks ago

I updated the example to be more explicit about RequestRedraw and WakeUp in https://github.com/bevyengine/bevy/pull/14224

I'll try to get it working in Wasm too... but later

daxpedda commented 1 week ago

the issue seems to be that in Wasm, user events don't interrupt when the event loop is waiting

Let me know if this is a Winit bug, last time I checked user events should wake up the event loop correctly on Webwith Winit.