bevy icon indicating copy to clipboard operation
bevy copied to clipboard

`low_power` example does not work on WASM

Open aevyrie opened this issue 1 year ago • 4 comments

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.

aevyrie avatar Jul 08 '24 01:07 aevyrie

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

mockersf avatar Jul 08 '24 14:07 mockersf

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.

aevyrie avatar Jul 08 '24 16:07 aevyrie

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

mockersf avatar Jul 08 '24 19:07 mockersf

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.

daxpedda avatar Jul 12 '24 16:07 daxpedda