From 0db2d1623298141e3cd025ce138aa1b9a2d4b194 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Tue, 19 May 2026 13:42:03 +0300 Subject: [PATCH] perf(app): only subscribe to window::frames while animating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit H7CAD was subscribing to window::frames() unconditionally, so iced kept firing Message::Tick at the display refresh rate even when nothing on screen was changing. That re-ran update() and the view-tree builder ~60 times a second and showed up as 2-3% idle CPU on Windows. Gate the subscription on `self.opening.is_some()` (the only thing that actually needs per-frame redraws today — the file-open progress indicator). Camera-change detection moves with the events that drive it since user input already wakes iced. Closes #18 Co-Authored-By: Claude Opus 4.7 --- src/app/view.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/view.rs b/src/app/view.rs index 03ec41471..93d066c7c 100644 --- a/src/app/view.rs +++ b/src/app/view.rs @@ -605,8 +605,18 @@ impl H7CAD { pub fn subscription(&self) -> Subscription { use iced::event; + // Only request per-frame ticks while something on screen is animating + // (currently just the open-progress indicator). Without this gate the + // app burned 2-3% CPU continuously redrawing an unchanged view. + // See #18. + let needs_frames = self.opening.is_some(); + let frames = if needs_frames { + window::frames().map(Message::Tick) + } else { + Subscription::none() + }; iced::Subscription::batch([ - window::frames().map(Message::Tick), + frames, event::listen_with(|ev, status, win_id| { use iced::event::Status; match ev {