From d795b9a25eb14a33fa10c1059cd0360981489abb Mon Sep 17 00:00:00 2001 From: OorjitSethi <90506135+OorjitSethi@users.noreply.github.com> Date: Sun, 11 Oct 2026 18:26:55 -0500 Subject: [PATCH] PERF-01: isolate editor snapshot and transcript redraw optimizations Split from #728 on current main. Full validation is recorded in the draft PR; the trim and mask-modifier failures reproduce on unchanged main. Co-Authored-By: Codex --- crates/ui-egui/src/lib.rs | 2 + crates/ui-egui/src/panels/effect_controls.rs | 5 +- crates/ui-egui/src/panels/misc.rs | 5 +- crates/ui-egui/src/panels/mixer.rs | 14 ++- crates/ui-egui/src/panels/mod.rs | 2 + crates/ui-egui/src/panels/text.rs | 14 ++- crates/ui-egui/src/panels/timeline.rs | 23 ++-- crates/ui-egui/src/panels/transcript_cache.rs | 106 ++++++++++++++++++ crates/ui-egui/tests/transcript_ui.rs | 42 +++++++ docs/performance.md | 21 ++++ 10 files changed, 212 insertions(+), 22 deletions(-) create mode 100644 crates/ui-egui/src/panels/transcript_cache.rs diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 2e3a7beb..421a6329 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -344,6 +344,7 @@ pub struct FilmcraftApp { pub shortcut_editor: panels::shortcuts_dialog::EditorState, pub toast: Option<(String, f64)>, pub tl: panels::timeline::TlState, + pub(crate) transcript_cache: panels::transcript_cache::TranscriptCache, /// Commands from outside the UI (native menu bar), invoked on the UI thread. pub command_inbox: Option>, /// A V key press (or a Ctrl+V paste) reached the app and its release hasn't yet. @@ -568,6 +569,7 @@ impl FilmcraftApp { toast: None, graphics_notice: None, tl: Default::default(), + transcript_cache: Default::default(), command_inbox: None, v_down: false, stale_clipboard_media: None, diff --git a/crates/ui-egui/src/panels/effect_controls.rs b/crates/ui-egui/src/panels/effect_controls.rs index d453e8e2..972b1004 100644 --- a/crates/ui-egui/src/panels/effect_controls.rs +++ b/crates/ui-egui/src/panels/effect_controls.rs @@ -99,7 +99,10 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) { crate::dock::placeholder(ui, rect, &t, tl!("(no clip selected)")); return; }; - let Some(seq) = app.session.active_sequence().cloned() else { + // Keep the immutable project snapshot alive while UI commands mutate the session. + // Cloning a sequence here copies every clip and effect on every redraw. + let project = app.session.project.clone(); + let Some(seq) = app.session.state.active_sequence.and_then(|id| project.sequence(id)) else { crate::dock::placeholder(ui, rect, &t, tl!("(no sequences)")); return; }; diff --git a/crates/ui-egui/src/panels/misc.rs b/crates/ui-egui/src/panels/misc.rs index 63e494b8..01a2aee2 100644 --- a/crates/ui-egui/src/panels/misc.rs +++ b/crates/ui-egui/src/panels/misc.rs @@ -61,7 +61,10 @@ pub const MARKER_FILTER: [filmcraft_project::Label; 7] = { /// `markers.filter.