From 372c29f2c3e7c2cc6b5c0ad86723cb16fc754a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Sat, 16 May 2026 04:01:43 -0400 Subject: [PATCH] perf(app): stop extending loading poll bursts --- .../ely_app/src/shell/web_surface_cadence.rs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/ely_app/src/shell/web_surface_cadence.rs b/crates/ely_app/src/shell/web_surface_cadence.rs index 9bddfd1..686037b 100644 --- a/crates/ely_app/src/shell/web_surface_cadence.rs +++ b/crates/ely_app/src/shell/web_surface_cadence.rs @@ -39,9 +39,12 @@ impl WebSurfacePollCadence { pub(super) fn note_frame(&mut self, render_state: &str, now: Instant) { let phase = WebSurfaceRenderPhase::from_render_state(render_state); match phase { - WebSurfaceRenderPhase::Created | WebSurfaceRenderPhase::Loading => { + WebSurfaceRenderPhase::Created | WebSurfaceRenderPhase::Loading + if self.last_render_phase != Some(phase) => + { self.boost_until(now + LOAD_BOOST_WINDOW); } + WebSurfaceRenderPhase::Created | WebSurfaceRenderPhase::Loading => {} WebSurfaceRenderPhase::Complete if self.last_render_phase != Some(phase) => { self.boost_until(now + FRAME_SETTLE_WINDOW); } @@ -213,4 +216,19 @@ mod tests { assert!(!cadence.should_poll(start + Duration::from_millis(339))); assert!(cadence.should_poll(start + Duration::from_millis(340))); } + + #[test] + fn repeated_loading_frames_do_not_extend_load_boost_window() { + let start = Instant::now(); + let mut cadence = WebSurfacePollCadence::default(); + + cadence.note_frame("loading", start); + cadence.note_frame("loading", start + Duration::from_millis(200)); + cadence.note_poll_submitted(start + Duration::from_millis(5_010)); + + assert_eq!( + cadence.next_poll_delay(start + Duration::from_millis(5_010)), + IDLE_POLL_INTERVAL + ); + } }