I have a simple winit application that is creating an empty window and running the EventLoop:
event_loop.run(move |event, _, control_flow| {
control_flow.set_wait_until(std::time::Instant::now() + Duration::from_millis(1000));
match event {
Event::WindowEvent{ ref event, window_id, } => {},
Event::MainEventsCleared => {
window.request_redraw()
},
_ => {}
}
});
On MacOS this process uses 100% of 1 core of CPU. If I remove the window.request_redraw call, or when I artificially limit with a thread sleep (regardless of setting wait until to control flow), the CPU usage falls dramatically to about 10%. This suggests that wait/wait until are not working correctly because I expect to only see calls to request_redraw every 1 second if I understood correctly.
Is there any way to limit the event loop run frequency other than thread::sleep/wait/wait until, or I am doing something else wrong?