Repository navigation
LR-CLOUD-SMARTPREVIEW: opt-in lossless smart previews (#709) - #1400
AlexChambers wants to merge 48 commits into
Conversation
b23d04c to
a2c6fc4
Compare
|
Rebased onto batch 33 (#1431). The conflicts were in
Both have regression tests. The description has the details. |
a2c6fc4 to
cf1c803
Compare
|
Rebased onto main b3d392b, which includes #850. The only conflict was in
#850's quality 97, its Compact @eliets2, one thing I noticed while reconciling, which is also true on main. The encode-version rebuild only reaches photos with a per-file camera look (raws), because the build consults |
|
Heads-up @AlexChambers: I'm building #1492 (Build Smart Previews runs several photos at once) on top of this PR, because it changes the same |
cf1c803 to
5a97a2e
Compare
… downgrade a newer proxy (storytold#1328 review) Review of 52f6b7e8: P2. A pixel next to a strongly coloured clipped highlight (the blue sample at an orange sun's rim, a neon tube's edge) had its interpolated channels rebuilt from its weakest, measured channel, mostly with a neutral colour where the content around was clipped: a dark checkerboard line just inside the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The rebuild may now darken a pixel only to 0.8 of the luminance its reconstruction told by value gives (highlight::CONTINUITY), else it keeps the latter; it may brighten it by as much among strongly coloured content, and further among pale content (a white sky behind twigs, where the value keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D twigs stay dark. Treating only the channels with their own FROM bit as unknown was tried: the mean colour spread around clipped areas went from under 3 % to 8.5 % and X-Trans lifted dark lines, so the other interpolated channel stays unknown with them. P2. Build Smart Previews rebuilt a stale proxy from the session's source, which is the old proxy's when it was decoded while the original was offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded sources and rendered previews made from the old one. On storytold#1400 both are covered by its machinery, which this commit uses instead of its own: jobs read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's invalidation (a marker before the first change, the thumbnail clear at the end of the run, decoded sources following the cache generation, late results refused by generation). The tests below pass on it. P2. A refresh rewrote a proxy whose other version came from a newer build (look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and leaves any proxy with a newer one alone; the folder markers only go up. With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the same way (smart::from_newer_build), staleness for the look includes an older Compact encoding (storytold#850's is_stale), and the look marker keeps its two versions, each never going back. P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains 64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one that is not finite, or whose magnitude times the largest gain (or divided by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read afresh, develop unbalanced. The MAX_GAIN doc no longer claims more. P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes). Tests: coloured suns and tubes keep their brightness at the edges (every method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops unbalanced and finite (1.5e28 at the extreme gains balanced and finite), both failing on 52f6b7e8; proxies with a newer look or source version are never rewritten and the markers stay, failing without this commit. Build Smart Previews refreshes with the old proxy still cached, and a refreshed proxy replaces the session's source, cached render and late results and the reopened library's: these pass through storytold#1400's machinery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on (storytold#1328 review) Review of 6d8a2a67, now stacked on storytold#1400 (issue storytold#709): storytold#1328's own cache invalidation (a per-photo refresh queue, a proxy epoch in the sources' identity, and a rendered-cache clear through the cache object the run started with) is gone. A raw decode refresh replaces a proxy through storytold#1400's run: the marker before the first change, the clear at the end through the invalidation that follows the library's folder, decoded sources following the cache generation, the generation read before the source, late results refused by generation and cache owner. P2. Another library opened during a refresh left the rebuilt photo's old thumbnail on disk for good (the refresh cleared a retired cache). storytold#1400's invalidation clears the folder the library owns: reopened, the thumbnail is the new proxy's (mean 76.6; it was 25.6, the old proxy's). P2. A refresh that finished after a job took its old source but before it read the generation let the job fill the cleared cache with the old proxy's thumbnail. storytold#1400 reads the generation first and drops the job. P2. A clear removed the disk files while holding the generation lock that the app reads every frame (6.7 s for 100,000 files). That clear is storytold#1400's too (its conversions, discards and look refreshes end with it), so the fix is on storytold#1400 (739c2f02, the unlocked clear) and this branch builds on it. P3. Docs: the protection from newer proxies holds for builds with the guard; a build that knows only the look version still rewrites a look 4 / source 1 proxy as look 5 without a source version. Tests: another library opened during a refresh, a refresh between a job's source and its generation, and the process ending in the middle of a source refresh (child process) leave no old thumbnail; a run that refreshes nothing keeps the thumbnails; a Lossless proxy records the raw decode version and is rebuilt as Lossless, keeping unknown header fields but not the old version. The first three fail with storytold#1400's folder clear, generation order or marker taken out (25.6, 25.4 and 25.6 against about 77). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wer build (storytold#1328 review) Review of 0accb271: a format mismatch bypassed the forward-version guard. smart_run ORed Ages::stale with "stored format differs from the one to build", so an ordinary Build Smart Previews (no format asked for) rebuilt a Lossless proxy under the default Compact preference, or a Compact one under a Lossless preference, with this build's older look or decode and stamped its versions: (look + 1, 0), (look - 1, source + 1) and (look + 1, source + 1) all became (5, 1) in the other format. The opening refresh kept them already. A usable proxy is now classified first: one from a newer build (smart::from_newer_build: its look or source version, or a Compact proxy's encode version from storytold#850, above this build's) is kept as it is, in its stored format, whatever format is preferred or asked for, and counted as newerKept in the result; only a current or older one is considered for a format conversion. A deliberate downgrade is not offered (Discard removes the proxy). Ages::stale uses the same check. source_version stays a field the writer owns. Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and storytold#850): LOOK_VERSION is 5 there (storytold#1340), so this build writes look 5 / source 1 (and Compact enc 2), which a build from main at look 5 takes as current; RENDER_CACHE_VERSION goes to 65 (main is at 62). Test: proxies at those three version pairs (and a Compact proxy from a newer encoding) survive the opening refresh and Build Smart Previews for both stored formats under both preferences, and are reported as newerKept (6 of the 12 version-pair cases were rewritten before; the encoding case is rewritten without its check). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto main a4b53b2 (batch 35). Conflicts were in @mattsivak, this was a force-push, in case #1492 needs to rebase onto it. |
|
The FreeBSD failure on 5a97a2e isn't from this PR: both failing tests come from main and this branch doesn't touch them. The settings dialog test's click back to the automatic memory budget didn't apply, which left the process-wide budget at 1 GiB, and the Compare test that ran after it needed more than that. #1463, which contains all of this branch, passed the same job. Details are on #1424, which is fixing that test. |
5a97a2e to
4d97de8
Compare
… downgrade a newer proxy (storytold#1328 review) Review of 52f6b7e8: P2. A pixel next to a strongly coloured clipped highlight (the blue sample at an orange sun's rim, a neon tube's edge) had its interpolated channels rebuilt from its weakest, measured channel, mostly with a neutral colour where the content around was clipped: a dark checkerboard line just inside the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The rebuild may now darken a pixel only to 0.8 of the luminance its reconstruction told by value gives (highlight::CONTINUITY), else it keeps the latter; it may brighten it by as much among strongly coloured content, and further among pale content (a white sky behind twigs, where the value keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D twigs stay dark. Treating only the channels with their own FROM bit as unknown was tried: the mean colour spread around clipped areas went from under 3 % to 8.5 % and X-Trans lifted dark lines, so the other interpolated channel stays unknown with them. P2. Build Smart Previews rebuilt a stale proxy from the session's source, which is the old proxy's when it was decoded while the original was offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded sources and rendered previews made from the old one. On storytold#1400 both are covered by its machinery, which this commit uses instead of its own: jobs read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's invalidation (a marker before the first change, the thumbnail clear at the end of the run, decoded sources following the cache generation, late results refused by generation). The tests below pass on it. P2. A refresh rewrote a proxy whose other version came from a newer build (look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and leaves any proxy with a newer one alone; the folder markers only go up. With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the same way (smart::from_newer_build), staleness for the look includes an older Compact encoding (storytold#850's is_stale), and the look marker keeps its two versions, each never going back. P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains 64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one that is not finite, or whose magnitude times the largest gain (or divided by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read afresh, develop unbalanced. The MAX_GAIN doc no longer claims more. P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes). Tests: coloured suns and tubes keep their brightness at the edges (every method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops unbalanced and finite (1.5e28 at the extreme gains balanced and finite), both failing on 52f6b7e8; proxies with a newer look or source version are never rewritten and the markers stay, failing without this commit. Build Smart Previews refreshes with the old proxy still cached, and a refreshed proxy replaces the session's source, cached render and late results and the reopened library's: these pass through storytold#1400's machinery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on (storytold#1328 review) Review of 6d8a2a67, now stacked on storytold#1400 (issue storytold#709): storytold#1328's own cache invalidation (a per-photo refresh queue, a proxy epoch in the sources' identity, and a rendered-cache clear through the cache object the run started with) is gone. A raw decode refresh replaces a proxy through storytold#1400's run: the marker before the first change, the clear at the end through the invalidation that follows the library's folder, decoded sources following the cache generation, the generation read before the source, late results refused by generation and cache owner. P2. Another library opened during a refresh left the rebuilt photo's old thumbnail on disk for good (the refresh cleared a retired cache). storytold#1400's invalidation clears the folder the library owns: reopened, the thumbnail is the new proxy's (mean 76.6; it was 25.6, the old proxy's). P2. A refresh that finished after a job took its old source but before it read the generation let the job fill the cleared cache with the old proxy's thumbnail. storytold#1400 reads the generation first and drops the job. P2. A clear removed the disk files while holding the generation lock that the app reads every frame (6.7 s for 100,000 files). That clear is storytold#1400's too (its conversions, discards and look refreshes end with it), so the fix is on storytold#1400 (739c2f02, the unlocked clear) and this branch builds on it. P3. Docs: the protection from newer proxies holds for builds with the guard; a build that knows only the look version still rewrites a look 4 / source 1 proxy as look 5 without a source version. Tests: another library opened during a refresh, a refresh between a job's source and its generation, and the process ending in the middle of a source refresh (child process) leave no old thumbnail; a run that refreshes nothing keeps the thumbnails; a Lossless proxy records the raw decode version and is rebuilt as Lossless, keeping unknown header fields but not the old version. The first three fail with storytold#1400's folder clear, generation order or marker taken out (25.6, 25.4 and 25.6 against about 77). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wer build (storytold#1328 review) Review of 0accb271: a format mismatch bypassed the forward-version guard. smart_run ORed Ages::stale with "stored format differs from the one to build", so an ordinary Build Smart Previews (no format asked for) rebuilt a Lossless proxy under the default Compact preference, or a Compact one under a Lossless preference, with this build's older look or decode and stamped its versions: (look + 1, 0), (look - 1, source + 1) and (look + 1, source + 1) all became (5, 1) in the other format. The opening refresh kept them already. A usable proxy is now classified first: one from a newer build (smart::from_newer_build: its look or source version, or a Compact proxy's encode version from storytold#850, above this build's) is kept as it is, in its stored format, whatever format is preferred or asked for, and counted as newerKept in the result; only a current or older one is considered for a format conversion. A deliberate downgrade is not offered (Discard removes the proxy). Ages::stale uses the same check. source_version stays a field the writer owns. Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and storytold#850): LOOK_VERSION is 5 there (storytold#1340), so this build writes look 5 / source 1 (and Compact enc 2), which a build from main at look 5 takes as current; RENDER_CACHE_VERSION goes to 65 (main is at 62). Test: proxies at those three version pairs (and a Compact proxy from a newer encoding) survive the opening refresh and Build Smart Previews for both stored formats under both preferences, and are reported as newerKept (6 of the 12 version-pair cases were rewritten before; the encoding case is rewritten without its check). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto main (af4c5e1, after #1406). The only conflicts were translation catalog ends: main's catalog-import messages are kept with this PR's smart-preview keys. Source patches are unchanged. Scoped build and tests (1808 passed), fmt, Clippy with |
4d97de8 to
3eada64
Compare
…once (storytold#1492) The global SMART_WRITE lock is replaced by a per-proxy lock keyed by file name. smart_run runs its jobs on export_parallelism lanes (the opening look refresh keeps one). The thumbnail marker (Pending) is shared behind a mutex, a marker failure stops every lane, and a panic in one photo fails that photo alone. storytold#1400's interruption tests now wait for the first proxy instead of assuming photos finish in order. cargo xtask ci: everything passes except lightcraft-pipeline visualize::tests::all_masks_overlay_shows_every_visible_mask_at_once, which fails identically on the base (PR storytold#1400 head cf1c803) and on main's FreeBSD CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…b order; tests run several lanes (storytold#1492) - Two lanes creating the same new shard folder no longer fail one photo with "File exists": AlreadyExists is accepted when the folder is there; a missing parent of the shard still fails. - Failures are reported in job order (the selection's order), as the serial build did, not sorted by photo id. - Under cfg(test), library.smartPreviews uses up to 4 lanes, so storytold#1400's end-to-end tests exercise the lanes on small CI runners too. - The cancel test checks a tight bound, done == built, and no leftover temp files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… downgrade a newer proxy (storytold#1328 review) Review of 52f6b7e8: P2. A pixel next to a strongly coloured clipped highlight (the blue sample at an orange sun's rim, a neon tube's edge) had its interpolated channels rebuilt from its weakest, measured channel, mostly with a neutral colour where the content around was clipped: a dark checkerboard line just inside the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The rebuild may now darken a pixel only to 0.8 of the luminance its reconstruction told by value gives (highlight::CONTINUITY), else it keeps the latter; it may brighten it by as much among strongly coloured content, and further among pale content (a white sky behind twigs, where the value keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D twigs stay dark. Treating only the channels with their own FROM bit as unknown was tried: the mean colour spread around clipped areas went from under 3 % to 8.5 % and X-Trans lifted dark lines, so the other interpolated channel stays unknown with them. P2. Build Smart Previews rebuilt a stale proxy from the session's source, which is the old proxy's when it was decoded while the original was offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded sources and rendered previews made from the old one. On storytold#1400 both are covered by its machinery, which this commit uses instead of its own: jobs read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's invalidation (a marker before the first change, the thumbnail clear at the end of the run, decoded sources following the cache generation, late results refused by generation). The tests below pass on it. P2. A refresh rewrote a proxy whose other version came from a newer build (look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and leaves any proxy with a newer one alone; the folder markers only go up. With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the same way (smart::from_newer_build), staleness for the look includes an older Compact encoding (storytold#850's is_stale), and the look marker keeps its two versions, each never going back. P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains 64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one that is not finite, or whose magnitude times the largest gain (or divided by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read afresh, develop unbalanced. The MAX_GAIN doc no longer claims more. P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes). Tests: coloured suns and tubes keep their brightness at the edges (every method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops unbalanced and finite (1.5e28 at the extreme gains balanced and finite), both failing on 52f6b7e8; proxies with a newer look or source version are never rewritten and the markers stay, failing without this commit. Build Smart Previews refreshes with the old proxy still cached, and a refreshed proxy replaces the session's source, cached render and late results and the reopened library's: these pass through storytold#1400's machinery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on (storytold#1328 review) Review of 6d8a2a67, now stacked on storytold#1400 (issue storytold#709): storytold#1328's own cache invalidation (a per-photo refresh queue, a proxy epoch in the sources' identity, and a rendered-cache clear through the cache object the run started with) is gone. A raw decode refresh replaces a proxy through storytold#1400's run: the marker before the first change, the clear at the end through the invalidation that follows the library's folder, decoded sources following the cache generation, the generation read before the source, late results refused by generation and cache owner. P2. Another library opened during a refresh left the rebuilt photo's old thumbnail on disk for good (the refresh cleared a retired cache). storytold#1400's invalidation clears the folder the library owns: reopened, the thumbnail is the new proxy's (mean 76.6; it was 25.6, the old proxy's). P2. A refresh that finished after a job took its old source but before it read the generation let the job fill the cleared cache with the old proxy's thumbnail. storytold#1400 reads the generation first and drops the job. P2. A clear removed the disk files while holding the generation lock that the app reads every frame (6.7 s for 100,000 files). That clear is storytold#1400's too (its conversions, discards and look refreshes end with it), so the fix is on storytold#1400 (739c2f02, the unlocked clear) and this branch builds on it. P3. Docs: the protection from newer proxies holds for builds with the guard; a build that knows only the look version still rewrites a look 4 / source 1 proxy as look 5 without a source version. Tests: another library opened during a refresh, a refresh between a job's source and its generation, and the process ending in the middle of a source refresh (child process) leave no old thumbnail; a run that refreshes nothing keeps the thumbnails; a Lossless proxy records the raw decode version and is rebuilt as Lossless, keeping unknown header fields but not the old version. The first three fail with storytold#1400's folder clear, generation order or marker taken out (25.6, 25.4 and 25.6 against about 77). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wer build (storytold#1328 review) Review of 0accb271: a format mismatch bypassed the forward-version guard. smart_run ORed Ages::stale with "stored format differs from the one to build", so an ordinary Build Smart Previews (no format asked for) rebuilt a Lossless proxy under the default Compact preference, or a Compact one under a Lossless preference, with this build's older look or decode and stamped its versions: (look + 1, 0), (look - 1, source + 1) and (look + 1, source + 1) all became (5, 1) in the other format. The opening refresh kept them already. A usable proxy is now classified first: one from a newer build (smart::from_newer_build: its look or source version, or a Compact proxy's encode version from storytold#850, above this build's) is kept as it is, in its stored format, whatever format is preferred or asked for, and counted as newerKept in the result; only a current or older one is considered for a format conversion. A deliberate downgrade is not offered (Discard removes the proxy). Ages::stale uses the same check. source_version stays a field the writer owns. Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and storytold#850): LOOK_VERSION is 5 there (storytold#1340), so this build writes look 5 / source 1 (and Compact enc 2), which a build from main at look 5 takes as current; RENDER_CACHE_VERSION goes to 65 (main is at 62). Test: proxies at those three version pairs (and a Compact proxy from a newer encoding) survive the opening refresh and Build Smart Previews for both stored formats under both preferences, and are reported as newerKept (6 of the 12 version-pair cases were rewritten before; the encoding case is rewritten without its check). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I kept main's thumbnail migration and deferred writer alongside the preview namespace and unlocked clear; the regression fixtures now use .lcthumb names and distinguish cache metadata from build markers. Main's Move Photos dialog and ID validation remain, and locale conflicts retain only this PR's own keys, with a shorter Georgian title. Rebased onto main |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…atch-edit recipes, panic lints in every crate root) (storytold#709) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # crates/ui-egui/locales/cs-formats.json # crates/ui-egui/locales/cs.json # crates/ui-egui/locales/de-formats.json # crates/ui-egui/locales/de.json # crates/ui-egui/locales/es-formats.json # crates/ui-egui/locales/es.json # crates/ui-egui/locales/fi-formats.json # crates/ui-egui/locales/fr-formats.json # crates/ui-egui/locales/fr.json # crates/ui-egui/locales/id-formats.json # crates/ui-egui/locales/it-formats.json # crates/ui-egui/locales/it.json # crates/ui-egui/locales/ja-formats.json # crates/ui-egui/locales/ja.json # crates/ui-egui/locales/ka-formats.json # crates/ui-egui/locales/pl-formats.json # crates/ui-egui/locales/pl.json # crates/ui-egui/locales/pt-br-formats.json # crates/ui-egui/locales/pt-br.json # crates/ui-egui/locales/ru-formats.json # crates/ui-egui/locales/ru.json # crates/ui-egui/locales/sv-formats.json # crates/ui-egui/locales/uk-formats.json # crates/ui-egui/locales/uk.json # crates/ui-egui/locales/vi-formats.json # crates/ui-egui/locales/zh-hans-formats.json # crates/ui-egui/locales/zh-hans.json # crates/ui-egui/locales/zh-hant-formats.json # crates/ui-egui/locales/zh-hant.json # crates/ui-egui/src/app/frame.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(test) (storytold#709) Main now denies unwrap_used in the engine's crate root (storytold#2170). Clippy's allowance for tests recognised neither cfg(all(test, ...)) nor these module names, so the wasm32 exclusion moves to its own attribute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Refreshed #1400 again on top of Alex's Windows fix ( Merged current main (
No version constants change. Full local |
…hdrawn, DxO Kelvin white balance, Lightroom import masks) (storytold#709) The view render keys in media/session.rs keep both this branch's cache generation and main's decoder key.
…hts/Shadows process V8, catalog journal 13) (storytold#709)
|
Merged current main (1a301fc) into this branch. Main brought jez's #3462 (process V8 Highlights/Shadows base and a faster GPU median) and #2661 (Lens Blur). The only conflict was the parity checklist's summary table, which I regenerated with cargo xtask parity --write. No version number changed: the branch takes main's LOOK_VERSION 13, RENDER_CACHE_VERSION 76 and catalog journal 13. cargo xtask ci passed locally except two tests. tests_light::v1_and_v2_render_as_before_v3 fails the same way on main 1a301fc on this machine. find_similar::stopping_leaves_the_view_alone_and_the_next_search_reads_only_the_rest failed once (10 reads, expected 12), then passed three single runs and a full ui-egui rerun on the same commit. That is the flaky test tracked in #3823 (fix in #3824), and this branch does not touch it. |
…ened-library write guards) (storytold#709) Main gives the thumbnail disk cache a write gate (storytold#3825, issue storytold#3240); this branch attaches the cache in a namespace. The two are combined: - attach_disk_cache_namespace takes the gate and sets it on the new cache, at library open and when the smart preview folder changes (Library::thumbs_gate). - set_disk_cache_bytes keeps this branch's form: it only changes the budget of an attached cache and attaches nothing, so it needs no gate. - DiskCache::clear checks the gate first and every 256 files, as on main, and still leaves the total unknown after a clear, as here. The clear that replaces an exhausted namespace at open gets the gate too. - The new early return for an over-budget brush mask (security batch) fills in this branch's cache_generation and cache_owner. No version constant changes: LOOK 13 and RENDER 76 come from main.
… size after a clear (storytold#709) A clear leaves the disk cache's size unknown here, because a thumbnail written while it removes files outlives it. The test's checks on which files a closed gate keeps are unchanged.
…brary write guards; render cache stays 84, source version 1) The thumbnail cache conflicts are the ones storytold#1400 has with main, resolved the same way: the namespaced cache takes main's write gate at open and at a smart preview folder change, set_disk_cache_bytes attaches nothing, and the brush budget early return fills in the cache identity fields.
…; no file changes here)
…s the unknown size after a clear)
|
I brought this branch up to date with main at fd0b914, which adds the security batch and the opened-library write guards (#3825). Main gives the thumbnail disk cache a write gate, so it leaves a library's folder alone while the path leads somewhere else. This branch attaches that cache in a namespace, so the two met in library.rs, media/cache.rs and preview/src/disk.rs. I combined them. attach_disk_cache_namespace now takes the gate and sets it on the new cache, both when a library opens and when the smart preview folder changes. set_disk_cache_bytes keeps this branch's form, which only changes the budget and attaches nothing, so it needs no gate. DiskCache::clear checks the gate as on main and still leaves the size unknown afterwards, as here. The clear that replaces an exhausted namespace at open gets the gate too. Two smaller follow-ups: the new early return for an over-budget brush mask fills in this branch's cache identity fields, and main's new gate test now expects an unknown size after a clear instead of zero, with its checks on which files the gate keeps unchanged. No version constants change, so LOOK 13 and RENDER 76 come from main. The full cargo xtask ci ran locally on macOS. fmt, clippy, heif, parity, layers, assets, roots, wasm and the doctests passed. The test step passed except tests_light::v1_and_v2_render_as_before_v3, which also fails on main (#3801), and main's gate test, which passes after the follow-up. |
…arity paths after the craft-libs cutover, ArtCraft feature-name guards) (storytold#709)
…; the parity checklist takes main's craft-libs paths)
# Conflicts: # crates/ui-egui/src/menus/menubar/tests.rs
storytold#3861's new test a_proxy_from_the_previous_look_version_is_stale calls smart::is_valid, which this stack (storytold#1400) renamed to is_complete with the same meaning. Use is_complete there so the merge builds.
storytold#3861's new test a_proxy_from_the_previous_look_version_is_stale calls smart::is_valid, which this branch renamed to is_complete with the same meaning. Use is_complete there so the merge builds.
Merge main to resolve the conflict with storytold#3469 (Enter Keywords), which split LightcraftApp::run_typed into run_typed and run_command. The PR author asked for this so the PR can be reviewed and merged (AGENTS.md rule 37). The smart-preview intercept now starts run_command, so it also gets main's selection-change counting.
Brings in storytold#1400's merge of main, which resolves the conflict with storytold#3469 (Enter Keywords) in crates/ui-egui/src/app.rs. The PR author asked for this so the PR can be reviewed and merged (AGENTS.md rule 37).
Fixes #709
Rebased onto main
0da998f2after integration batch 40. This branch inherits main'sLOOK_VERSION9 andRENDER_CACHE_VERSION64.Changes
Adds a per-library Lossless format using the existing pure-Rust float TIFF codec with Deflate. Compact JPEG remains the default. The Settings preference controls future builds; Build Smart Previews can override it for a selection.
Lossless stores the decoded, reduced scene-linear source before tone curves and edits. It preserves finite source floats exactly, including negative values and highlights above 1.0. This improves editing from an offline proxy while retaining the proxy's existing resolution limit. Online originals still take precedence.
Existing LCSP1 JPEG previews keep working. LCSP2 adds bounded parsing, payload length and checksum checks, and a completeness marker. Format conversion rebuilds from available originals and keeps offline proxies unchanged. Unknown header and tone fields, including
white_stat, survive rewrites.Builds verify payload integrity and successful decoding before reusing a proxy. A Compact proxy must also be complete: a JPEG cut short still decodes, with part of the picture made up, so a cut-short Compact proxy is not counted, rendered or kept over a complete copy, and Build Smart Previews repairs it, as on main (issue #106). Migration verifies the destination before removing the source, including after an atomic copy. The structural staleness hint and the full usability check have separate names. Builds, discards and look refreshes invalidate the cache currently attached to the same library, including cache replacement and reopening in another session. Render jobs capture their cache generation before acquiring a source and reject construction if it changes. Returned sources must also belong to the current cache object, because different cache objects can have the same generation. Size accounting includes both formats and layouts. Documentation and the LR-CLOUD-SMARTPREVIEW checklist row are updated.
Folder changes and cancellation
Settings starts folder changes on a worker. The activity stack reports progress and accepts cancellation while files are copied and verified. The old location stays in use until every destination verifies and the library saves the new location. Builds and look refreshes must finish before migration starts; they cannot start during migration. This also resolves the pre-existing move race reproduced below.
Cancellation or a failure during copying, verification or preference saving leaves the entire old folder in use. A source that does not decode, such as a proxy cut short, is not a failure: it stays in the old folder, the rest of the folder moves, and the result names it. Build Smart Previews rebuilds it in the new folder from its original. Copies already written to the new folder can remain, and retries reuse valid destinations. Source cleanup runs on a worker after the location switch and cannot be cancelled. A crash before the switch reopens the complete old folder. A crash during cleanup reopens the complete new folder and may leave redundant old files. Each destination is verified again before its source is removed.
The folder and a thumbnail cache generation are saved in the same atomic preferences write. Reopening uses that generation before reading any disk thumbnail. An exit immediately after the save and failure to spawn cleanup therefore cannot expose thumbnails from a different proxy in the old folder. Cache replacement changes memory state without scanning or deleting files, and old writers use separate disk keys. Old thumbnail files share the existing cache budget and are removed by normal pruning.
Same-volume moves also use copy and verification. Renaming sources early would break the cancellation guarantee. The destination needs space for the copies while the old folder is retained.
Automatic look refresh checks stale candidates. It can skip corruption in current-look proxies without decoding them. Build Smart Previews is the verification and repair action for those files.
Interrupted builds
A build, discard or look refresh clears the thumbnail cache once, after its last photo. Before it writes or removes its first proxy, it creates and syncs an empty marker file in the library's thumbnail folder, and it removes the marker after that clear. A quit or crash in between, for example Quit Anyway during a long Lossless conversion, leaves the marker. The next opening then saves a new thumbnail cache generation before it reads any disk thumbnail, and removes the marker. Thumbnails of the replaced proxies therefore do not come back, also when a retry with the originals offline changes no proxy. Every change records the marker, including a discard: an interrupted discard leaves thumbnails of the removed proxies, which still show the photo until a later first build replaces that picture. Each leftover marker moves the generation on by one, so if an opening cannot save its generation and is interrupted again, the next opening does not reuse it. Opening the library again in the same process while a build runs keeps that build's marker and receives its final clear, through any spelling of the library's path (a symlink,
..or a relative path).A full drive can refuse even an empty file; APFS and HFS+ both do. The run then clears the thumbnail cache at once, which removes every thumbnail of the proxies about to change and frees space, and tries the marker again. If the drive is still full, it continues without the marker and clears the thumbnail cache again after each proxy it replaces (a format conversion or a newer camera look). A build into a smart preview folder on another drive with room therefore works while the library drive is full, and a thumbnail rendered from a proxy before its replacement can survive an exit only between writing that proxy and the clear after it. A first build or a repair skips that clear, which would empty every thumbnail and loaded picture on screen once per proxy. Other failures, such as a read-only thumbnail folder, stop a build with an error before it changes any proxy, without clearing anything. A discard is never stopped: without a marker it still removes the proxies, so a full drive never blocks the discard that frees its space.
Translations
The new interface messages have translations in German, Spanish, French, Japanese, Brazilian Portuguese, Russian, Ukrainian, Simplified Chinese, Traditional Chinese, Czech, Polish, Italian and Georgian, covering thirteen non-English locales. They cover the storage dialog with its Build and Build Anyway buttons, the format choices, warnings, offline-original guidance, activity labels, completion messages, and the Smart Preview Format command in Keyboard Shortcuts. Photo and file counts use explicit whole-number plural forms, including Russian and Ukrainian counts such as 21 and 22. The new strings use each catalog's existing words for smart previews and folders: смарт-просмотры in Russian, смарт-перегляди and тека in Ukrainian, 智慧型預覽 in Traditional Chinese, and, in Portuguese, the catalog's existing mix of "prévias inteligentes" and "pré-visualizações inteligentes". A native speaker should still check the new translations.
The rebase adds only this PR's own message and format keys to the Czech, Polish, Italian and Georgian catalogs introduced on main. Existing keys and translations from main are retained. The new count messages use neutral labels and preserve all placeholders and plural-form fields. The added Italian, Czech, Polish and Georgian text has not had native-speaker review.
Opening the library in an older version
Versions up to 0.7.1 can open a library this PR has used, with limits that
docs/smart-previews.mdnow lists:File > Previews > Discard Preview Cache removes cached thumbnails of every generation. A second copy of the generation outside
prefs.jsonwould cover only the last case, because the older version reads the old thumbnails itself, so this PR documents the limits instead.Storage and fidelity
On the public 61 MP Sony ILCE-7CR sample, the actual binned proxy is 2376 x 1584. Float TIFF used about 39.5 MB versus 0.92 MB for JPEG at the former quality 92. On the ILCA-77M2 sample, it used about 45.4 MB versus 0.52 MB. Compact at quality 97, since PR #850, is about twice those sizes. Before a Lossless build starts, the UI shows the photo count, estimated total size and destination free space. The estimate uses 39.5 MB per photo and states that actual sizes vary. An estimate above free space shows a warning and Build Anyway. The space query runs on a worker. The native UI adds fs4, a Rust filesystem wrapper, for that query.
Compared existing PNG16, TIFF16 with a horizontal predictor, JXL16 lossless, and TIFF32 Deflate. TIFF16 used roughly half the space but quantized the source. The original JXL comparison mixed sRGB-tagged input samples with decoded linear Rec.2020 pixels. Correcting that comparison gives a maximum source error of 1.47e-5 on the A7CR sample; the direct 16-bit integer round trip is exact. There is no codec bug. Float TIFF retains its exact-float advantage. No codec dependency was added.
A real library test disconnected an isolated copy of the public A7CR raw and rendered in fresh processes. Lossless matched the online 1600 x 1067 render pixel for pixel at neutral settings, Exposure -2 with Highlights -100, and Exposure +2. JPEG mean delta E76 at quality 92 was 1.334, 0.773, and 1.506.
The synthetic source-grid render matched exactly after lossless storage at default settings, Exposure -2 with Highlights -100, and Exposure +2. JPEG mean CIE76 delta E at quality 92 was 0.620, 0.391, and 0.416 respectively. A smooth source gradient had 759 repeated adjacent samples after JPEG storage and none after lossless storage.
The float-output codec measurements isolate storage error on the same source grid. The library test also checks the actual offline metadata and render path for that A7CR sample. It does not cover the missing DNG metadata described below. Neither establishes full-resolution raw-render parity or compares against Lightroom.
The cost-confirmation interceptor now handles main's validated target Result, reports malformed ids before checking storage, and honors a singular id with no selection. The new regression covers those cases. The crash-regression fixtures now use main's
.lcthumbextension and distinguish its two persistent cache metadata files from build markers. Crash, stale-pixel and invalidation assertions are retained. The added Georgian lossless-build title is shorter so the existing layout test can check it without elision. Builds and tests were not rerun after this rebase.Validation
Historical implementation commit before this rebase:
cf1c803ac1ee72ac417a55b92421dd6028955575. At that commit, the branch was rebased onto mainb3d392b4, which includes integration batch 33 and PR #850. Rebasing onto batch 33 kept every commit and its message; its conflicts were strings both sides added to the 18 translation catalogs (both kept), history rows and the header ofdocs/parity-checklist.md(one tracker row per id), and two newRenderResultconstructions incrates/engine/src/media.rsthat now carry this branch's cache fields. Rebasing ontob3d392b4reconciledcrates/engine/src/smart.rswith PR #850 (see Coordination) and left every other file of those commits unchanged; a new last commit adds the Lossless test and the documentation for it.Each regression below was written before its fix and failed on the branch commit before it, with only the tests added. The red runs before the last commit were made before the rebase onto batch 33; the hashes below are those commits after the rebase.
35213536). Two photos have Compact proxies. The first photo's thumbnail, rendered from its proxy while the original was offline, is in the disk cache. A subprocess converts both photos to Lossless and exits, without running destructors, while it reads the second original. At that point the first photo's Lossless proxy is durable. On35213536, reopening with the originals offline served the old Compact thumbnail from disk (cache_hit=true), 7,844 pixels different from the Lossless render under the same cache encoding. The test reopens twice, retries the build with the originals offline, and reopens again.c35a7873). The library sits on a 40 MB APFS or HFS+ disk image that is filled until even an empty file is refused. Discard Smart Previews, and a Lossless conversion into a proxy folder on another drive, were both refused with "No space left on device". Now the discard removes the proxies and the conversion converts both, with no thumbnail of the old proxies left. The test runs on macOS and is skipped wherehdiutilcannot attach an image; portable tests inject the same failure into marker creation.c35a7873). Reopening the library throughaside/../librarywhile a build was blocked deleted the build's marker. The test then checks that the finished build's clear reaches the reopened session.c35a7873). A leftover marker is followed by a session whoseprefs.jsonsave fails. That session renders a thumbnail from a Compact proxy and is interrupted during a conversion. The next opening reused that session's namespace and served the old thumbnail, 7,844 pixels different.d214084f). A 1200 x 800 Compact proxy is cut to 50, 75, 90 and 99 %. Info reported a smart preview, the offline render showed a partly wrong picture (800 to 23,421 of 43,776 pixels), and Build reported it as built without repairing it. A move into a folder holding a 90 % copy kept that copy and deleted the complete proxy. Now Info reports none, the offline render refuses it, Build repairs it byte for byte, and the move keeps the complete proxy.d214084f). A discard ends after removing the proxies and before its clear, then a first Lossless build ends while reading its second original. Neither left a marker, so the next opening served the old Compact thumbnail, 7,844 pixels different.d214084f). With marker creation failing for lack of space, the grid writes a thumbnail of the second photo from its old proxy during the run, the build replaces that proxy, and the process ends. The next opening served that thumbnail, 8,369 pixels different.d214084f). A discard goes ahead, but a first build afterward must stop like a conversion; it built both proxies. A conversion refused for a permission error must keep the thumbnail cache; it was cleared.bc559d29). Two Compact proxies, one cut to 90 % with its original offline, so Build cannot repair it. The folder move failed with "smart preview is cut short", naming no file. Now the move commits, the intact proxy moves, and the cut one stays in the old folder and is named in the result.bc559d29). On a thumbnail drive that stays full, a first build of two photos moved the cache generation four times, once per proxy, and each move empties the grid and the loupe. Now it moves twice: the clear that frees space and the final one. A conversion still clears after each proxy it replaces.4d6e1829; found in the review of Full-size demosaic runs before white balance: green/cyan fringes beside clipped specular highlights and on sharp white edges #1328, which is stacked on this branch). Every run that changes a proxy ends with a thumbnail clear, andPreviewCache::clearremoved every disk file while holding the generation lock that the app reads every frame (Renderer::poll): 100,000 cached thumbnails took 6.7 s, all of it with drawing waiting. Now the generation moves on and memory empties under the lock, briefly, and the files are removed after it is released. Until they are gone no disk file is read, so none from before the clear is served, and the clear returns only once they are gone, so a run still removes its marker only after the files. The test fills a cache with 20,000 files: on4d6e1829the new generation could be read only once all were gone; now it is read while files remain, no old thumbnail is served meanwhile, and none is left after.6bc9e680). Thumbnails of the new generation can be written while a clear removes the files, and one written after the clear lists them outlives it. The clear then set the cache's size to zero (0 for 807 bytes on disk in the test), so the budget undercounted until something scanned the folder again. Now the size is unknown after a clear and the next check scans the nearly empty folder; a writer updates it under the same lock as its file replacement, so none can put back a size from before the clear.enc(1) is lower than Compact's encode version (2); read as that version, the proxy was marked stale. Now it is current: Build keeps it without reading the original, and the opening scan of a folder checked before the encode version leaves it untouched.35213536). "Build" and "Smart Preview Format" had no translation in any catalog. A test now covers every smart preview command label and the dialog buttons, and the localized storage dialog test also checks the usual state with enough free space, where the button is Build.Further tests: a reopening in the same process while a build is blocked keeps the build's marker and namespace; a conversion whose thumbnail folder cannot hold a marker for another reason (here a file in its place) stops before it changes a proxy; a thumbnail drive that is full at first is cleared before the first replacement, which makes room for the marker; and one that stays full still converts. Earlier regressions still cover an exit immediately after the durable preferences write of a folder change, failure to start the cleanup thread, preference-save rollback, a folder switch while an old thumbnail read is blocked, late results and writes, cache-budget changes, reopening, cancellation, exits during copying and cleanup, reopening during conversion, concurrent preferences, and active-build exclusion.
After the rebase onto main
b3d392b4, which includes #990, #997 and the 0.7.1on_exitfix, so no temporary patches were needed:cargo fmt --check, Clippy with warnings denied on the engine, preview and UI crates (all targets), the preview crate's tests (19 passed), the engine's smart preview and import tests (167 passed and 7 ignored child processes, including PR #850's tests and the full-volume test on real disk images), the UI's localization tests (30 passed), andcargo xtask parity,layersandwasm(all 28 crates) pass. The wasm32 warnings are in files this PR does not change, plus the missing optional CJK-font warning. Both public reproductions below give the stated results on the final commit. The full workspace suite was not rerun after the rebases, which changed no invalidation code.Before the rebase, on main
76b53778with the #990 and #997 patches applied temporarily:cargo xtask cipassed formatting, workspace Clippy with warnings denied, and the HEIF gates, then stopped at the 11 known engine test failures. The completecargo test --workspace --no-fail-fastrun finished with 3,074 passed, exactly the 12 known failures listed below, and 33 ignored, and parity, layers, assets and wasm passed. The thumbnail clear was validated the same way on the #1328 branch stacked on it: 3,099 passed, the same 12 known failures, 34 ignored.The known workspace failures before the rebase:
sidecar::tests_repair_companions::partial_move_companions_allow_save_and_autowrite_without_weakening_collisionssidecar::tests_repair_companions::queued_stem_retry_preserves_shared_packet_after_batch_rollbacksidecar::tests_repair_companions::rollback_repair_and_shared_copy_keep_known_companionssidecar::tests_repair_provenance::absent_peer_destinations_are_not_owned_and_retirement_records_only_completed_packetssidecar::tests_repair_provenance::changed_separated_sources_are_not_moved_or_retiredsidecar::tests_repair_provenance::failed_redo_and_discarded_or_pruned_history_keep_companion_provenancesidecar::tests_repair_provenance::own_atomic_shared_packet_writes_advance_retained_versions_and_failures_do_notsidecar::tests_repair_provenance::replaced_and_in_place_companions_block_save_autowrite_retry_and_file_historysidecar::tests_repair_saves::autowrite_repairs_partial_rename_before_merging_foreign_xmp_across_library_switchsidecar::tests_repair_saves::unowned_shared_stem_repair_does_not_block_healthy_jpeg_full_sidecar_savetests_dialog_fit::export_dialog_is_unchanged_in_a_tall_windowtests_lightroom_folder::odd_folders_never_fail_the_checkThe same 12 tests also failed on main
701f78ea(0.7.1) in this environment. They are unrelated to smart previews.The tests simulate process exit, not physical power loss. Native-speaker review, physical drive disconnection, and optional model and external-corpus coverage were not performed. CJK font files are unavailable in this checkout, so the localized headless checks do not verify Japanese or Chinese glyph coverage. The public raw fidelity and codec measurements above are from earlier runs of this branch.
Resolved folder-move race
On main, a running preview build captures the old folder. A concurrent folder move can change the active location before that build writes its output. The build then leaves one proxy in the old folder and none in the new folder, while the new folder is active. This PR rejects a folder change while a build or look refresh is active, so the old folder and its completed proxy stay in use.
Save the following as
crates/engine/examples/repro_smart_move.rsand runcargo run -p lightcraft-engine --example repro_smart_move. It creates its own fixture and uses public engine APIs. It works on main using the default Compact format. Remove the temporary example afterward.On main (
76b53778; 0.7.1 does not change this code) it printsaccepted=true, old=1, new=0, current_is_new=true. On the final commit of this PR it printsaccepted=false, old=1, new=0, current_is_new=false.Separate metadata issue
Offline smart previews still lose source metadata needed for some edits. The defect exists on main and affects Compact too. Catalog reconstruction does not restore camera colour metadata, DNG local tone maps or semantic mattes. It is not part of this PR. It is filed as #1534, with a synthetic reproducer and five measured pixel counts.
Coordination
These open branches conflict with this one. The merges were checked with
git merge-treewithout changing this branch, and no rebase onto them is included.enc: 2) in the Compact header and the folder's look marker, and rebuilds a Compact proxy from an older encoding like one from an older camera look. Here that encode version applies to Compact (LCSP1) proxies only: the Lossless (LCSP2) header uses the sameencfield for its own format version, which reading the file checks, andpreserve_headernever copiesencbetween formats. smart previews: store proxies at JPEG quality 97 and version the encoding (#709) #850's rebuild replaces a usable proxy, so it goes through this PR's thumbnail marker and per-replacement clear, like a look refresh. smart previews: store proxies at JPEG quality 97 and version the encoding (#709) #850's tests pass, with one call renamed fromis_validtois_usable(this branch splits that check).crates/engine/src/lib.rs,crates/engine/src/library.rs,crates/engine/src/media.rs,crates/preview/src/disk.rs,crates/preview/src/lib.rs,crates/ui-egui/src/panels/settings.rsanddocs/parity-checklist.md.No code from other contributors' open PRs is included in this branch.
🤖 Generated with Claude Code
Summary by CodeRabbit