From 686077a85fa3f6d7dea8348076786f1fdb7f444b Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 8 Nov 2026 18:32:44 +0100 Subject: [PATCH] Footage cache (#3271): the Project panel's thumbnail key follows the preferences; browser footage budget in the docs The panel worked a thumbnail's key out again only on a new project revision, footage reload or time, but Switches Affect Nested Comps and real-time shadows change what a comp shows without either: the preferences revision is now part of the check. The docs say the browser's Footage Frame Cache is at most 256 MB for frames and channels together. The panel test changes the preference alone; it fails on the old code. --- crates/ui-egui/src/panels/project.rs | 16 +++++++++------- crates/ui-egui/tests/it/ui_large_project.rs | 19 ++++++++++++++++++- docs/footage.md | 4 ++-- docs/preferences.md | 4 ++-- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/panels/project.rs b/crates/ui-egui/src/panels/project.rs index d401b021d..25c5a2ac8 100644 --- a/crates/ui-egui/src/panels/project.rs +++ b/crates/ui-egui/src/panels/project.rs @@ -124,14 +124,16 @@ type PendingThumb = (u128, Arc)>>>>); /// The content key of item `it`'s thumbnail at `t` ([`effectcraft_engine::Session::thumbnail_key`]), /// worked out again only when the project's revision, the footage reloads (Reload Footage or a -/// watched file that changed: the project's revision stays) or the time changed. +/// watched file that changed: the project's revision stays), the preferences (Switches Affect +/// Nested Comps and real-time shadows change what a comp shows) or the time changed. fn thumbnail_key(app: &EffectcraftApp, ctx: &egui::Context, it: &Item, t: effectcraft_engine::time::Tick) -> u128 { let id = egui::Id::unique(("proj-thumb-key", it.id.0)); let rev = app.session.revision; let reloads = app.session.footage_reloads.load(std::sync::atomic::Ordering::Relaxed); + let prefs = app.session.prefs_revision; let now = ctx.input(|i| i.time); - if let Some((r, n, at, k, when)) = ctx.data(|d| d.get_temp::(id)) { - if r == rev && n == reloads && at == t.0 { + if let Some((r, n, pr, at, k, when)) = ctx.data(|d| d.get_temp::(id)) { + if r == rev && n == reloads && pr == prefs && at == t.0 { return k; } // (the key hashes the comp's content: while edits come fast, at most every 0.25 s) @@ -142,13 +144,13 @@ fn thumbnail_key(app: &EffectcraftApp, ctx: &egui::Context, it: &Item, t: effect } // (no key: the revision stands in, as before) let k = app.session.thumbnail_key(it.id, t, THUMB_SIDE).unwrap_or(u128::from(rev) | (1 << 127)); - ctx.data_mut(|d| d.insert_temp::(id, (rev, reloads, t.0, k, now))); + ctx.data_mut(|d| d.insert_temp::(id, (rev, reloads, prefs, t.0, k, now))); k } -/// A thumbnail's content key as last worked out: (project revision, footage reloads, time, key, -/// when, in seconds of UI time). -type ThumbKey = (u64, u64, i64, u128, f64); +/// A thumbnail's content key as last worked out: (project revision, footage reloads, preferences +/// revision, time, key, when, in seconds of UI time). +type ThumbKey = (u64, u64, u64, i64, u128, f64); /// The longest side of a Project panel thumbnail, in pixels. const THUMB_SIDE: u32 = 192; diff --git a/crates/ui-egui/tests/it/ui_large_project.rs b/crates/ui-egui/tests/it/ui_large_project.rs index dc42097ae..8ddaa9687 100644 --- a/crates/ui-egui/tests/it/ui_large_project.rs +++ b/crates/ui-egui/tests/it/ui_large_project.rs @@ -84,7 +84,7 @@ fn a_footage_reload_gives_the_panel_thumbnail_a_new_key() { h.state_mut().session.execute("project.select", json!({"items": [main.0]})).unwrap(); h.state_mut().show_panel(PanelKind::Project); let id = egui::Id::unique(("proj-thumb-key", main.0)); - let shown = |h: &egui_kittest::Harness<'_, EffectcraftApp>| h.ctx.data(|d| d.get_temp::<(u64, u64, i64, u128, f64)>(id)).map(|k| k.3); + let shown = |h: &egui_kittest::Harness<'_, EffectcraftApp>| h.ctx.data(|d| d.get_temp::<(u64, u64, u64, i64, u128, f64)>(id)).map(|k| k.4); let want = |h: &egui_kittest::Harness<'_, EffectcraftApp>| h.state().session.thumbnail_key(main, effectcraft_engine::time::Tick::ZERO, 192); h.run_steps(2); let before = shown(&h); @@ -103,6 +103,23 @@ fn a_footage_reload_gives_the_panel_thumbnail_a_new_key() { } assert_ne!(now, before, "a new key after the reload"); assert_eq!(now, want(&h)); + // A preference that changes what a comp shows (Switches Affect Nested Comps) does too; the + // project's revision stays. + let before = now; + let rev = h.state().session.revision; + let on = h.state().session.prefs.general.switches_affect_nested_comps; + h.state_mut().session.execute("prefs.set", json!({"key": "general.switchesAffectNestedComps", "value": !on})).unwrap(); + assert_eq!(h.state().session.revision, rev); + for _ in 0..100 { + h.step(); + now = shown(&h); + if now != before { + break; + } + std::thread::sleep(std::time::Duration::from_millis(10)); + } + assert_ne!(now, before, "a new key after the preference changed"); + assert_eq!(now, want(&h)); } #[test] diff --git a/docs/footage.md b/docs/footage.md index 31db3e89b..f7bdedf96 100644 --- a/docs/footage.md +++ b/docs/footage.md @@ -126,8 +126,8 @@ decompresses all of its pixels to read them). Once an effect reads an item's cha once for the picture and the effects together, and only the channels the effects pick are read (EXtractoR's channel names, Cryptomatte's layer, the 3D Channel effects' channel popups). The decoded channels are kept for a while, in the Footage Frame Cache together with the -decoded frames (the least recently used frame or channel set goes first; in the browser the -channels take at most 512 MB), a soft bound, as the newest file and files still in use stay +decoded frames (the least recently used frame or channel set goes first; in the browser that +budget is at most 256 MB for frames and channels together), a soft bound, as the newest file and files still in use stay whatever their size. The picture is kept once, converted: its own R, G, B and A planes are not kept beside it, unless an effect names one of them. Several frames asking for the same file at once wait for one decode. Once no enabled effect reads the item any more, its frames diff --git a/docs/preferences.md b/docs/preferences.md index 74d440347..5da1392af 100644 --- a/docs/preferences.md +++ b/docs/preferences.md @@ -82,8 +82,8 @@ Commands (CLI, MCP, control channel): - `memory.layerCacheMb`: Layer Cache (in the browser at most 512 MB, see [web.md](web.md)) - `memory.mediaCacheMb`: Footage Frame Cache (in the browser at most 256 MB). It covers the decoded footage frames and the decoded OpenEXR channels together: one budget, the least - recently used frame or channel set goes first, whichever it is (in the browser the channels - take at most 512 MB of it) + recently used frame or channel set goes first, whichever it is (in the browser 256 MB at most + for both together) - `memory.previewCacheMb`: Preview (RAM) Cache - `threeD.defaultRenderer`: Default 3D Renderer - `labels.N.name` / `labels.N.color`: the 16 label names and colours, used by the Label menu,