From 1a463770a33a9b33feff9fac6012805353c1161b Mon Sep 17 00:00:00 2001 From: lisk77 Date: Mon, 17 Nov 2025 22:29:44 +0100 Subject: [PATCH] fix(app): changed mainloop to mitigate no response from application --- crates/comet_app/src/app.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/comet_app/src/app.rs b/crates/comet_app/src/app.rs index 31112b2..083aa48 100755 --- a/crates/comet_app/src/app.rs +++ b/crates/comet_app/src/app.rs @@ -370,15 +370,9 @@ impl App { WindowEvent::CloseRequested {} => elwt.exit(), WindowEvent::Focused(focused) => { window_focused = *focused; - if window_focused && !window_occluded { - window.request_redraw(); - } } WindowEvent::Occluded(occluded) => { window_occluded = *occluded; - if window_focused && !window_occluded { - window.request_redraw(); - } } WindowEvent::Resized(physical_size) => { renderer.resize(*physical_size); @@ -410,7 +404,6 @@ impl App { _ => {} }, Event::AboutToWait => { - elwt.set_control_flow(ControlFlow::Poll); self.delta_time = renderer.update(); if self.dt() != f32::INFINITY { @@ -425,6 +418,14 @@ impl App { if window_focused && !window_occluded { window.request_redraw(); } + + if self.dt().is_finite() { + let next_frame = std::time::Instant::now() + + std::time::Duration::from_secs_f32(self.update_timer); + elwt.set_control_flow(ControlFlow::WaitUntil(next_frame)); + } else { + elwt.set_control_flow(ControlFlow::Wait); + } } _ => {} }