Skip to content
Open
5 changes: 5 additions & 0 deletions contributors/people.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,8 @@ display_name = "Brian Wang"

[people.Terra854]
display_name = "Terra854"

[people.SamLovick]
real_name = "Sam Lovick"
display_name = "Sam Lovick"
sync_github_name = false
9 changes: 8 additions & 1 deletion crates/engine/src/prep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ pub struct PrepState {
/// A build that couldn't start: the view (its signature), and when it may try again (not on
/// every tick while the cause lasts; CodeRabbit on #3080).
pub retry_at: Option<(u64, web_time::Instant)>,
/// The long edge (px) the frontend builds standard previews at (its Build Standard-Sized
/// Previews size; 0: [`crate::cmd::previews::standard_edge`]). The background build uses it
/// too, so a later build asked for skips what it made instead of rendering it again (#3947).
pub edge: usize,
/// Tests: the next starts to fail, as a build thread that can't be spawned does.
#[cfg(test)]
pub(crate) fail_starts: usize,
Expand Down Expand Up @@ -420,7 +424,10 @@ impl Session {
if ids.is_empty() {
return;
}
let p = json!({"ids": ids, "background": true, "from": at.0, "backward": backward});
let mut p = json!({"ids": ids, "background": true, "from": at.0, "backward": backward});
if let Some(o) = p.as_object_mut().filter(|_| self.prep.edge > 0) {
o.insert("edge".into(), json!(self.prep.edge));
}
// (tests: a start made to fail, as a build thread that can't be spawned fails)
#[cfg(test)]
let fail = self.prep.fail_starts.checked_sub(1).map(|left| self.prep.fail_starts = left).is_some();
Expand Down
24 changes: 24 additions & 0 deletions crates/engine/src/tests/preview_prep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,30 @@ fn the_background_preparation_starts_when_culling_and_can_be_stopped() {
let _ = std::fs::remove_dir_all(root);
}

/// #3947: the background build makes standard previews at the size the frontend's Build
/// Standard-Sized Previews asks for, so that build skips them instead of rendering every one again.
#[test]
fn the_background_build_makes_previews_at_the_frontends_standard_size() {
let (mut s, root, ids) = library("prep-edge", 3);
s.prep.edge = 300;
let mode = crate::prep::Mode::Library;
for id in &ids {
s.prep_tick(mode, Some(*id), false);
}
let b = s.preview_build.clone().expect("culling: the view is prepared");
assert!(b.background);
assert!(wait_finished(&b), "built");
assert_eq!(b.failed.load(Ordering::Relaxed), 0);
for id in &ids {
let p = s.catalog.photo(*id).unwrap().clone();
let (w, h) = s.media.rendered.disk().expect("a disk cache").dims(s.view_key(&p, true)).expect("on disk");
assert_eq!(w.max(h), 300, "built at the frontend's standard size");
}
let r = s.execute("library.buildPreviews", &json!({"ids": ids_json(&ids), "edge": 300, "wait": true})).unwrap();
assert_eq!(r["skipped"], 3, "the build asked for skips what the background made {r}");
let _ = std::fs::remove_dir_all(root);
}

/// While editing, the whole view's build follows the Library row (its switch and "which photos");
/// the Editing row's scope is only for the photos kept ready ahead.
#[test]
Expand Down
2 changes: 2 additions & 0 deletions crates/ui-egui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ impl LightcraftApp {
let loupe = self.ui.fullscreen || self.ui.view == state::ViewMode::Detail;
let at = if loupe { self.session.active() } else { None };
let backward = self.look_ahead.backward();
// the background build makes previews at Build Standard-Sized Previews' size (#3947)
self.session.prep.edge = self.ui.settings.standard_build_edge(self.session.loupe_edge) as usize;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2. Refresh preparation when the requested preview size changes. The setting updates prep.edge, but the completed or running build is still keyed by the same view. Prepare a folder at 1600, switch to 3840, and stay in the folder: the next manual request can still rerender the old previews. Include the requested size in the build identity while preserving explicit Stop. Extend the same-size reuse regression with a size change in the same view.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 430443a: the started build is now remembered with the size it builds at, so a new size in the same view stops a running build and prepares the view again at that size. A stop from its row is still remembered by view alone, so it holds whatever size comes next. the_background_build_makes_previews_at_the_frontends_standard_size now changes 300 to 500 in the same view (fails without the fix), then checks that a stop holds through another size change.

self.session.prep_tick(mode, at, backward);
if self.session.preview_build.as_ref().is_some_and(|b| b.running()) {
ctx.request_repaint_after(std::time::Duration::from_millis(500));
Expand Down
13 changes: 5 additions & 8 deletions crates/ui-egui/src/menus/menubar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,12 @@ fn live_label(app: &LightcraftApp, id: &str, label: &str) -> String {
}

/// The parameterized submenus.
/// The params of Build Standard-Sized Previews: automatic builds as big as the loupe on this screen shows photos
/// (the engine's standard size, once a loupe has been drawn); before that, in a fresh session, the standard
/// 2560 px, not the engine's 2048 px minimum, so a typical fit view needn't render again; a chosen limit is used as is.
/// The params of Build Standard-Sized Previews: automatic builds at the standard 2560 px (not the engine's
/// 2048 px minimum, so a typical fit view needn't render again), or as big as the loupe on this screen shows
/// photos when that is more; a chosen limit is used as is. The background preparation builds at the same size
/// ([`crate::state::AppSettings::standard_build_edge`]), so this build skips what it made (#3947).
pub(crate) fn standard_build_params(settings: &crate::state::AppSettings, loupe_edge: usize) -> Value {
match settings.preview_limit {
0 if loupe_edge == 0 => json!({"size": "standard", "edge": settings.standard_preview_edge()}),
0 => json!({"size": "standard"}),
edge => json!({"size": "standard", "edge": edge}),
}
json!({"size": "standard", "edge": settings.standard_build_edge(loupe_edge)})
}

pub(crate) fn expanded(app: &LightcraftApp, name: &str) -> Option<Vec<MenuNode>> {
Expand Down
12 changes: 12 additions & 0 deletions crates/ui-egui/src/state/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,18 @@ impl AppSettings {
pub fn standard_preview_edge(&self) -> u32 {
if self.preview_limit == 0 { STANDARD_PREVIEW_EDGE } else { self.preview_limit }
}

/// The long edge standard previews are built at, by Build Standard-Sized Previews and by the
/// background preparation alike: a chosen limit as is; on Automatic the standard size, or the
/// loupe's size on this screen (`loupe_edge`, 0: no loupe drawn yet) when that is bigger. The
/// same in every session, so a build skips the previews an earlier one made (#3947).
pub fn standard_build_edge(&self, loupe_edge: usize) -> u32 {
if self.preview_limit != 0 {
return self.preview_limit;
}
let loupe = u32::try_from(loupe_edge.min(8192)).unwrap_or(8192);
STANDARD_PREVIEW_EDGE.max(loupe)
}
}

/// How the Keywording box lays out the selection's keywords.
Expand Down
14 changes: 14 additions & 0 deletions crates/ui-egui/src/tests/lifecycle_037.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2354,6 +2354,20 @@ fn background_preparation_advances_while_the_window_is_hidden() {
let _ = ctx.run_logic(&visible, |ctx| app.logic(ctx));
assert_eq!(app.prep_ticks, 3, "a shown pass advances it once");
}

/// #3947: the background preparation builds previews at Build Standard-Sized Previews' size (a
/// chosen limit, else the standard 2560 px), so that build skips them instead of rendering them again.
#[test]
fn background_preparation_builds_at_the_standard_build_size() {
let mut app = app();
let ctx = egui::Context::default();
let hidden = viewport_raw(egui::vec2(800.0, 600.0), false);
let _ = ctx.run_logic(&hidden, |ctx| app.logic(ctx));
assert_eq!(app.session.prep.edge, crate::state::STANDARD_PREVIEW_EDGE as usize);
app.ui.settings.preview_limit = 1600;
let _ = ctx.run_logic(&hidden, |ctx| app.logic(ctx));
assert_eq!(app.session.prep.edge, 1600, "a chosen limit");
}
/// CodeRabbit on #3077/#3080: a background build that couldn't start asks for a frame at its retry
/// time, so the retry happens with no input and no other timed frame.
#[test]
Expand Down
11 changes: 7 additions & 4 deletions crates/ui-egui/src/tests/preview_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1643,15 +1643,18 @@ mod in_the_loupe {
}
}

// Build Standard-Sized Previews on Automatic: the loupe's size once one was drawn (the engine's standard), the
// standard 2560 px in a fresh session, not the engine's 2048 px minimum a fit view would render again over
// (CodeRabbit on #3077); a chosen limit as is
// Build Standard-Sized Previews on Automatic: the standard 2560 px, not the engine's 2048 px minimum a fit
// view would render again over (CodeRabbit on #3077), or the loupe's size when bigger; a chosen limit as is.
// The same with or without a loupe drawn, so a fresh session's build skips the previews an earlier
// session's background preparation made (#3947)
#[test]
fn standard_build_keeps_the_standard_size_before_a_loupe_was_drawn() {
use crate::menubar::standard_build_params;
use serde_json::json;
assert_eq!(standard_build_params(&with_limit(0), 0), json!({"size": "standard", "edge": STANDARD_PREVIEW_EDGE}));
assert_eq!(standard_build_params(&with_limit(0), 2400), json!({"size": "standard"}));
assert_eq!(standard_build_params(&with_limit(0), 2400), json!({"size": "standard", "edge": STANDARD_PREVIEW_EDGE}));
assert_eq!(standard_build_params(&with_limit(0), 3000), json!({"size": "standard", "edge": 3000}));
assert_eq!(standard_build_params(&with_limit(0), 50_000), json!({"size": "standard", "edge": 8192}));
assert_eq!(standard_build_params(&with_limit(3840), 0), json!({"size": "standard", "edge": 3840}));
assert_eq!(standard_build_params(&with_limit(3840), 2400), json!({"size": "standard", "edge": 3840}));
}
2 changes: 1 addition & 1 deletion docs/parity-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ From `08-lightroom-classic-extras.md` (Classic-only features) and part 2 of `06-
| LRC-LIB-VISUALSEARCH | Find similar photos | P2 | ✅ | `cmd:library.findSimilar`, `crates/pipeline/src/cull.rs` (`signature`), `crates/engine/src/cmd/similar.rs`, `crates/ui-egui/src/find_similar.rs` | photo menu / Photo ▸ Find Similar Photos: look-alike photos (composition and tones), most similar first, as a filter (`only`); the app reads the photos on a worker thread under an activity row with ✕ |
| LRC-LIB-MISSING | Missing files & relink | P1 | ✅ | `cmd:library.missing`, `cmd:photo.relink`, `cmd:library.findMissing`, `cmd:file.findMissing`, `cmd:photo.locate`, `crates/engine/src/cmd/missing.rs` (`checked_path`), `crates/ui-egui/src/missing_sweep.rs`, `crates/ui-egui/src/panels/left.rs` (`locate_missing_item`) | File → Find Missing Photos… (anywhere in a folder: same name, size and content hash; renamed files by size + content hash; same name and size alone only when unambiguous — look-alikes are skipped and reported; searched on a worker thread, one undo step), photo menu → Locate Missing File…; a folder or disk row's Locate Missing Files… chooses its new location and scopes the same recursive background finder to that folder and its subfolders. Unreadable files show "!" in the grid and a reason in the loupe; undo never moves files. Missing Photos in the sidebar (counted on a worker thread; the view, the Info panel, the grid's context menu and thumbnails read file availability from a cache a worker thread fills, so an offline NAS never stalls a frame); it covers library photos only — Local browse records are never checked, for the count, the view, `library.missing` and Find Missing alike; `library.missing` from the control channel or `mcp --connect` checks the files on a worker thread (a "Missing Photos" row in the activity stack, ✕ stops it) and answers when it ends, so a large library on a network share never stalls the window; the same request meanwhile shares the running check |
| LRC-LIB-CONVERT | Convert to DNG | P2 | ✅ | `cmd:photo.convertToDng`, `crates/engine/src/cmd/convert.rs` | Photo ▸ Convert to DNG: lossless DNG next to the raw with the settings embedded, photo (and its virtual copies) relinked; originals kept; undoable; the DNG is decoded and compared with the raw data, written to a temp file, synced, read back and only then given a free name (never replacing a file) — a failed write leaves no DNG and the photo on its raw (issue #106) |
| LRC-LIB-PREVIEWS | Build / discard previews | P1 | ✅ | `cmd:library.buildPreviews`, `cmd:library.previewProgress`, `cmd:library.cancelPreviews`, `cmd:library.clearPreviews`, `crates/engine/src/cmd/previews.rs`, `crates/preview/src/lib.rs`, `crates/engine/src/tests/preview_prep.rs` | File ▸ Previews: build standard-sized (as big as the loupe shows photos on this screen, at least 2048 px, or the Settings → Performance size) or 1:1 previews of the selected photos (more than one) or every photo in view, in the background (a row in the activity stack, ✕ to stop), discard the cache; disk thumbnail + view cache. The loupe shows a built preview that is big enough as the photo (fitted down, no render); a build skips photos whose previews are there and writes each to disk before it counts it; the disk cache's automatic size makes room for every photo of the library (about 1.5 MB a photo, no ceiling: a low drive is told once per session, see LR-PREF-LOCALSTORAGE), and memory for previews follows the memory budget |
| LRC-LIB-PREVIEWS | Build / discard previews | P1 | ✅ | `cmd:library.buildPreviews`, `cmd:library.previewProgress`, `cmd:library.cancelPreviews`, `cmd:library.clearPreviews`, `crates/engine/src/cmd/previews.rs`, `crates/preview/src/lib.rs`, `crates/engine/src/tests/preview_prep.rs` | File ▸ Previews: build standard-sized (as big as the loupe shows photos on this screen, at least 2560 px, or the Settings → Performance size; background preparation builds at the same size, so this build skips what it made, issue #3947) or 1:1 previews of the selected photos (more than one) or every photo in view, in the background (a row in the activity stack, ✕ to stop), discard the cache; disk thumbnail + view cache. The loupe shows a built preview that is big enough as the photo (fitted down, no render); a build skips photos whose previews are there and writes each to disk before it counts it; the disk cache's automatic size makes room for every photo of the library (about 1.5 MB a photo, no ceiling: a low drive is told once per session, see LR-PREF-LOCALSTORAGE), and memory for previews follows the memory budget |
| LRC-PERF-PREP | Prepare photos in the background (beyond Lightroom) | P1 | 🟡 | `cmd:prefs.backgroundPrep`, `cmd:prefs.setBackgroundPrep`, `crates/engine/src/prep.rs`, `crates/ui-egui/src/dialogs/settings/performance.rs` | Settings ▸ Performance ▸ Prepare photos in the background, per mode (Culling, Library, Editing), app-wide or for one library: previews of every photo in view built in the spare time once the user steps through photos (yields to the photo on screen, nearest photos first in the direction of travel, one cancellable row), photos ahead rendered for the loupe (0 = off), eye focus strips ahead, which photos (every / picks, rated and labelled / only the one on screen); editing keeps the next photos decoded. Not yet: face detection, AI masks and AI Denoise as background jobs of these settings (they keep their own switches) |
| LRC-LIB-SLIDESHOW-IMPROMPTU | Impromptu slideshow | P2 | ✅ | `cmd:view.slideshow` | see LR-VIEW-SLIDESHOW |
| LRC-DEV-SNAPSHOTS | Named snapshots | P1 | ✅ | `cmd:version.create`, `cmd:version.restore` | = versions |
Expand Down
5 changes: 5 additions & 0 deletions docs/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
the other exports do, and writes the file atomically. It used to write the presets over whatever file it was given,
and a failed write (a full disk) could leave a cut-off file where an earlier export was.

### Previews are built once
- Background preparation now builds previews at the same size as File ▸ Previews ▸ Build Standard-Sized Previews
(the Settings → Performance size, else at least 2560 px), so that build skips them instead of rendering every one
again (issue #3947).

### Film grain that looks like film (process V7)
- Grain now comes from a simulated emulsion of crystal layers (after Aurélien Pierre's model): dense, soft and cloudy
rather than dots on top of the photo. It fades out towards black and white as on a print, so shadows keep their depth
Expand Down