800: Schedule event waits after redraw events are cleared r=kvark a=kvark

As @adamnemecek pointed out, our examples were busy waiting.
I investigated a bit and figured that our `WaitScheduled` was always interrupted by `RedrawEventsCleared`. So scheduling the wait in it works. Tested on Linux and macOS. CPU time of the cube example drops from 100% to single-digit.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot]
2021-03-18 03:00:21 +00:00
committed by GitHub
2 changed files with 2 additions and 2 deletions

View File

@@ -221,7 +221,7 @@ fn start<E: Example>(
ControlFlow::Poll
};
match event {
event::Event::MainEventsCleared => {
event::Event::RedrawEventsCleared => {
#[cfg(not(target_arch = "wasm32"))]
{
// Clamp to some max framerate to avoid busy-looping too much

View File

@@ -80,7 +80,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
// the resources are properly cleaned up.
let _ = (&instance, &adapter, &shader, &pipeline_layout);
*control_flow = ControlFlow::Poll;
*control_flow = ControlFlow::Wait;
match event {
Event::WindowEvent {
event: WindowEvent::Resized(size),