perf(app): only subscribe to window::frames while animating
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 <noreply@anthropic.com>
This commit is contained in:
parent
4fa01b3a1a
commit
0db2d16232
1 changed files with 11 additions and 1 deletions
|
|
@ -605,8 +605,18 @@ impl H7CAD {
|
|||
|
||||
pub fn subscription(&self) -> Subscription<Message> {
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue