From 34d03051f51cb9e1834ded12c7efe81f0a8c71c6 Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Fri, 16 Oct 2026 10:20:26 +0200 Subject: [PATCH] fix: stalled jobs, editor cancellation stops and GoPro DNG decoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Owner review 1, phase 1 (docs/requests/2026-10-15-owner-review-1.md). Thumbnail and proxy jobs over several sequences counted sequences while they checkpointed inside one: the rate decayed until the time left overflowed TimeSpan, the job failed while publishing progress and again while saving it, and stayed Running. The throughput is now seeded by the first window with progress, the time left is bounded (JobEta), saving progress never throws, image passes count frames, and job speeds use the right unit (bytes for verify and import). The debugger stops in WicDecoderProvider.cs when presets changed were cancelled preview decodes leaving synchronous thread-pool delegates; the editor's sources, LatestRunner and the render node's proxy task now keep them in their own tasks, and a cancellation is never an unreadable frame. GoPro DNGs converted by Adobe software were classified GPR and read only through their 8-bit preview, and Windows' preview-only DNG decoder was reported as a native decode. A DNG is GPR only when its raw image is VC-5, WIC decodes RAW only through the Raw Image Extension and never DNG, analyses and previews take an adequate embedded preview by choice while renders develop natively, and frames already indexed as GPR are reclassified by the next light analysis. Also records the owner's request (docs/requests), the BRIEF amendments (§8.1, §8.2, new §24), DECISIONS, CHANGELOG, STATUS and ARCHITECTURE. Co-Authored-By: Claude Opus 5.5 --- docs/ARCHITECTURE.md | 6 +- docs/BRIEF.md | 20 ++- docs/CHANGELOG.md | 11 ++ docs/DECISIONS.md | 5 + docs/STATUS.md | 1 + docs/requests/2026-10-15-owner-review-1.md | 67 ++++++++ docs/requests/README.md | 12 ++ i18n/ar/Jobs.ar.resx | 1 + i18n/bg/Jobs.bg.resx | 1 + i18n/cs/Jobs.cs.resx | 1 + i18n/da/Jobs.da.resx | 1 + i18n/de/Jobs.de.resx | 1 + i18n/el/Jobs.el.resx | 1 + i18n/en/Jobs.resx | 1 + i18n/es/Jobs.es.resx | 1 + i18n/et/Jobs.et.resx | 1 + i18n/fi/Jobs.fi.resx | 1 + i18n/fr/Jobs.fr.resx | 1 + i18n/he/Jobs.he.resx | 1 + i18n/hi/Jobs.hi.resx | 1 + i18n/hr/Jobs.hr.resx | 1 + i18n/hu/Jobs.hu.resx | 1 + i18n/id/Jobs.id.resx | 1 + i18n/it/Jobs.it.resx | 1 + i18n/ja/Jobs.ja.resx | 1 + i18n/ko/Jobs.ko.resx | 1 + i18n/lt/Jobs.lt.resx | 1 + i18n/lv/Jobs.lv.resx | 1 + i18n/ms/Jobs.ms.resx | 1 + i18n/nb/Jobs.nb.resx | 1 + i18n/nl/Jobs.nl.resx | 1 + i18n/pl/Jobs.pl.resx | 1 + i18n/pt-BR/Jobs.pt-BR.resx | 1 + i18n/pt-PT/Jobs.pt-PT.resx | 1 + i18n/ro/Jobs.ro.resx | 1 + i18n/ru/Jobs.ru.resx | 1 + i18n/sk/Jobs.sk.resx | 1 + i18n/sl/Jobs.sl.resx | 1 + i18n/sv/Jobs.sv.resx | 1 + i18n/th/Jobs.th.resx | 1 + i18n/tr/Jobs.tr.resx | 1 + i18n/uk/Jobs.uk.resx | 1 + i18n/vi/Jobs.vi.resx | 1 + i18n/zh-Hans/Jobs.zh-Hans.resx | 1 + i18n/zh-Hant/Jobs.zh-Hant.resx | 1 + src/Titano.App/Editor/LatestRunner.cs | 4 +- src/Titano.App/Editor/LocalSequenceSource.cs | 21 ++- src/Titano.App/Editor/RemoteSequenceSource.cs | 5 +- src/Titano.App/Jobs/JobText.cs | 17 +- .../Wic/WicDecoderProvider.cs | 30 +++- src/Titano.Core/Archiving/SequenceFrames.cs | 3 + src/Titano.Core/Codecs/Dng/DngReader.cs | 13 ++ .../Decoders/ManagedDecoderProvider.cs | 3 + src/Titano.Core/Imaging/Decoding.cs | 19 ++- src/Titano.Core/Metadata/ImageSignature.cs | 4 +- src/Titano.Data/Archiving/FrameTiers.cs | 19 ++- .../Archiving/Jobs/ImageJobHandler.cs | 23 ++- src/Titano.Data/Jobs/JobEngine.cs | 34 +++- src/Titano.Data/Jobs/JobHandler.cs | 42 ++--- src/Titano.Data/Jobs/JobThroughput.cs | 58 +++++++ src/Titano.Data/Jobs/JobWire.cs | 2 +- .../Processing/AnalysisFollowUp.cs | 10 +- .../Processing/RenderNodeClient.cs | 7 +- .../Processing/SequenceFrameSource.cs | 7 +- .../Repositories/FrameRepository.cs | 35 +++-- src/Titano.Data/Repositories/JobRepository.cs | 3 +- src/Titano.Server/Jobs/RenderNodeService.cs | 10 +- .../Editor/ProjectStoreTests.cs | 38 +++++ .../Editor/SchedulingTests.cs | 19 +++ .../Jobs/JobListModelTests.cs | 7 +- .../Decoding/ManagedDecoderProviderTests.cs | 51 ++++++ tests/Titano.Core.Tests/Raw/SyntheticRaw.cs | 28 +++- .../Archiving/PartialRowWriterTests.cs | 2 +- .../Jobs/JobThroughputTests.cs | 147 ++++++++++++++++++ .../Processing/AnalysisJobTests.cs | 54 +++++++ .../Repositories/CatalogRepositoryTests.cs | 2 +- .../Titano.Server.Tests/Api/SequenceTests.cs | 2 +- 77 files changed, 785 insertions(+), 94 deletions(-) create mode 100644 docs/requests/2026-10-15-owner-review-1.md create mode 100644 docs/requests/README.md create mode 100644 src/Titano.Data/Jobs/JobThroughput.cs create mode 100644 tests/Titano.Data.Tests/Jobs/JobThroughputTests.cs diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 56855f1e..8525ddb3 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -29,7 +29,7 @@ Dependencies point one way: `Core` ← `Core.Windows`, `Data`, `Protocol` ← `S | Folder / namespace | Content | |---|---| -| `Imaging` (+ `Decoders`, `Geometry`, `Thumbnails`) | `ImageBuffer` (planar float, linear light), `IImageDecoderProvider`, `DecoderFactory` (decode tiers: native → embedded preview; `ImageDecoder.Probe` names a file's tier without decoding it), `ManagedDecoderProvider`, `FrameWindow` (read-ahead, memory budget, float32 spill), resampler, thumbnail cache | +| `Imaging` (+ `Decoders`, `Geometry`, `Thumbnails`) | `ImageBuffer` (planar float, linear light), `IImageDecoderProvider`, `DecoderFactory` (decode tiers: native → embedded preview; `ImageDecoder.Probe` names a file's tier without decoding it; `DecodeRequest.PreferPreview` takes an adequate RAW preview by choice for analyses and previews, `DecodedImage.ByChoice`), `ManagedDecoderProvider`, `FrameWindow` (read-ahead, memory budget, float32 spill), resampler, thumbnail cache | | `Metadata` (+ `Tiff`, `Jpeg`, `Bmff`, `Raf`, `Riff`, `Png`, `Xmp`, `MakerNotes`) | Signature sniffing, Exif/GPS/XMP/MakerNotes, ISO-BMFF (HEIF, CR3), `MetadataReader`, `MetadataBuilder` (all fallback chains), `ExifWriter` | | `Codecs` (`Jpeg`, `Png`, `Tiff`, `Dng`, `Raw`, `Gif`, `Apng`, `Ico`) | Pure managed codecs; native RAW development (DNG, CR2, NEF, ARW, PEF, RAF) | | `Analysis` (+ `Deep`) | Luminance statistics, deflicker, regions, holy grail, white balance, colour temperature, light analysis, streaming deep analysis with checkpoints | @@ -55,7 +55,7 @@ Dependencies point one way: `Core` ← `Core.Windows`, `Data`, `Protocol` ← `S | `Sqlite`, `Postgres` | SQLite P/Invoke binding (winsqlite3 / libsqlite3), in-house PostgreSQL wire protocol v3 client with pool and LISTEN | | `Migrations/{sqlite,postgres}/NNNN_name.sql` | Embedded, applied in one transaction at open (`MigrationRunner`) | | `Repositories` | `TitanoDatabase` facade: archives, sequences, frames, tags, renders, jobs, cards, users, tokens, uploads, render nodes, settings, audit; `DatabaseBackups` (daily `VACUUM INTO` copies of an SQLite index kept ×3, restore staged for the next start and carried out before the index opens, so it also recovers one that no longer opens) | -| `Jobs` | `JobEngine` (its number of workers can change while it runs), `IJobHandler`, `IJobHandlerProvider`, `JobContext` (progress, checkpoints, follow-up jobs) | +| `Jobs` | `JobEngine` (its number of workers can change while it runs), `IJobHandler`, `IJobHandlerProvider`, `JobContext` (progress, checkpoints, follow-up jobs), `JobThroughput`/`JobEta` (rate and bounded time left) | | `Archiving` | `ArchiveService` (create/adopt/open, archive settings written to `archive.json` then the index), `ArchiveIndexer` (scan, rebuild), `ArchiveIngest` (uploads and imports), `ImportService`, `ArchiveVerifier`, `ArchiveImages`, `FrameTiers` (decode tier, `PreviewOnly`/`Undecodable` flags and preview size of frames, written to sidecar and index by the light analysis, deep analysis, renders and image passes), `GprCompanions` (the JPEG of each GoPro GPR, found in the index when an import kept it in another sequence), `ArchiveMaintenance`, `MassRenamer`, `SequenceTrash` (delete into the archive's hidden trash with a dry run, restore; the folder moves back when the index step fails), job handlers | | `Processing` | `ProcessingService`, `SequenceAnalyser`, `DeepReports` (a saved deep report while it still describes the frames), `SequenceRender`, `ProjectStore`, `ProjectBundles` (a `.titano` file for a sequence, and the sequence a file names), `RenderNodeClient`, job handlers | | `Sync` | `SyncService` (sync table of one server: compare, link by content, settle conflicts, enqueue transfers), `SyncRules` (status, settings merge and differences, no I/O), `SyncPositions` (the settings' frame positions translated by photo to the frames of the copy they go to), `SyncLinkStore` (`sync_links`, `sync_state`), `SyncTransfers` and `SyncJobHandler` (resumable, hash-verified uploads and downloads as jobs; downloads commit through the archive ingest), `SyncAgent` (background comparison, server events, backoff, offline proxies), `ProxyCache` and `RemoteSequence` (server sequences opened with proxies), `ISyncRemote` (the server calls; `TitanoSyncRemote` over `TitanoClient`) | @@ -152,7 +152,7 @@ run as server jobs whose progress comes from the events. | To add | Implement / register | |---|---| -| An image format or decoder | `IImageDecoderProvider` (managed in `Core/Imaging/Decoders` or `Codecs`, WIC in `Core.Windows`); chained by `DecoderFactory` | +| An image format or decoder | `IImageDecoderProvider` (managed in `Core/Imaging/Decoders` or `Codecs`, WIC in `Core.Windows`: a RAW only through the Raw Image Extension, checked per file); chained by `DecoderFactory` | | A video encoder | `IVideoEncoderProvider` (`Core/Video/Managed`, `Core.Windows/MediaFoundation`); list it in the host's `ProcessingOptions.Encoders` | | A background operation | a `JobKind`, an `IJobHandler` (in `Data/Archiving/Jobs` or `Data/Processing/Jobs`) returned by the service's `CreateJobHandlers`; the job engine, Jobs screen, admin and API pick it up | | A server feature | a static `XxxEndpoints.Map(api)` in `Server/Api` with `.Requires(Permissions…)`, called from `ServerHost.ConfigurePipeline`; DTOs in `Titano.Protocol` with the JSON context | diff --git a/docs/BRIEF.md b/docs/BRIEF.md index 6a5f2d75..a8d2136f 100644 --- a/docs/BRIEF.md +++ b/docs/BRIEF.md @@ -437,13 +437,13 @@ preview of the first three names. | JPEG | jpg jpeg jpe jfif | APP1 Exif/XMP, MPF | WIC or managed | managed (baseline + progressive) | | PNG | png | eXIf, iTXt XMP | WIC or managed | managed | | TIFF | tif tiff | IFDs | WIC or managed | managed (strips/tiles; none/PackBits/LZW/Deflate/JPEG) | -| DNG (smartphones: Apple ProRAW, Android, Samsung; DJI; Insta360; Leica; Pentax; Ricoh) | dng | IFDs, MakerNote | WIC (if Raw ext.) or managed full decode | managed full decode | +| DNG (smartphones: Apple ProRAW, Android, Samsung; DJI; Insta360; Leica; Pentax; Ricoh; GoPro files converted by Adobe software) | dng | IFDs, MakerNote | managed full decode (amended 2026-10-16, R4) | managed full decode | | Canon | cr2 cr3 | cr2: TIFF; cr3: ISO-BMFF `CMT1..4` | WIC (Raw ext.) → managed CR2 (P1) → embedded preview | managed CR2 (P1) → embedded full-size JPEG (CR3 track 1) | | Nikon | nef nrw | TIFF | WIC → managed NEF (P1) → preview | managed NEF (P1) → preview | | Sony | arw srf sr2 | TIFF | WIC → managed ARW (P1) → preview | idem | | Fujifilm | raf | RAF header + TIFF | WIC → managed RAF uncompressed (P1) → preview | idem | | Olympus/OM, Panasonic, Pentax, Samsung, Hasselblad, Phase One, Leica | orf rw2 raw pef srw 3fr fff iiq rwl | TIFF-like | WIC → managed (P1/P2) → preview | preview (P1: managed decoders as feasible) | -| GoPro | gpr (DNG+VC-5) + jpg sidecar | IFDs | preview/sidecar JPEG; VC-5 out of scope | sidecar JPEG | +| GoPro | gpr (DNG+VC-5; a DNG is GPR only when its raw image is VC-5, amended 2026-10-16, R4) + jpg sidecar | IFDs | preview/sidecar JPEG; VC-5 out of scope | sidecar JPEG | | HEIF/HEIC/AVIF (iPhone, Samsung, DJI) | heic heif hif avif | ISO-BMFF `Exif` item | WIC (HEIF + HEVC/AV1 extensions) | metadata only; pixels via client-made proxies | | WebP | webp | RIFF `EXIF` chunk | WIC (WebP ext.) | metadata only (P2: managed VP8L) | | JPEG XL, JPEG XR, BMP, GIF (single frame) | jxl jxr bmp gif | minimal | WIC if a codec exists | not supported | @@ -465,6 +465,12 @@ which tier will be used on this machine. 3. **Unavailable** → frame flagged `Undecodable`; excluded from render; listed in the sequence warnings. +The tier is what the frame can give. Analyses, thumbnails, proxies and the editor's preview +take an embedded preview that is large enough when a RAW has one, by choice and without +changing the frame's tier; renders always decode natively. WIC counts as a native RAW +decoder only when the decoder it chose for the file is the Raw Image Extension (Windows' +in-box DNG decoder reads only the preview). (Amended 2026-10-16, R4.) + The in-house DNG pipeline (server and client): CFA/linear DNG, `Compression` 1/7 (lossless JPEG SOF3)/8 (Deflate)/34892 (lossy JPEG), `LinearizationTable`, `BlackLevel` (+ repeat dims, delta), `WhiteLevel`, `AsShotNeutral`/`AsShotWhiteXY`, `ColorMatrix1/2` + @@ -1300,6 +1306,16 @@ Unraid template validated. --- +## 24. Amendments + +The product owner's change requests amend this brief in place; each amended paragraph says +"(amended , R)". The request files in `docs/requests/` keep the owner's words, the +questions asked and the answers; DECISIONS rows give the reasons. + +| Date | Request | Sections | What changed | +|---|---|---|---| +| 2026-10-16 | Owner review 1, R4 | §8.1, §8.2 | DNG decodes through the managed decoder (WIC only through the Raw Image Extension, never DNG); a GoPro DNG is GPR only when VC-5; analyses and previews take an adequate embedded preview by choice, renders decode natively. | + ## Appendix A — `CLAUDE.md` content (create verbatim in Phase 0, keep updated) ```markdown diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 82df35db..48418fe0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -168,6 +168,17 @@ commits follow Conventional Commits (release notes are generated from them by `T returns frames, frames version and settings of one frames version. ### Fixed +- Owner review 1 (2026-10-16, `docs/requests/2026-10-15-owner-review-1.md`): + - thumbnail and proxy jobs over several sequences failed after 10–20 minutes with "TimeSpan overflowed" and then + stayed Running; their progress now counts frames, a stalled job shows no time left, and a job's end is always + recorded (R10); + - the Jobs screen showed the speed of hash verification and card import, which count bytes, in fps; + - choosing presets quickly in the editor made the VS Code debugger stop in `WicDecoderProvider.cs`: a cancelled + preview decode left its background task (R4); + - GoPro DNGs converted by Lightroom or DNG Converter were treated as GPR and read only through their 8-bit embedded + preview, and DNGs Windows' preview-only DNG decoder read were reported as decoded natively. Videos now develop them + natively at 16 bits, analyses and the editor preview use the embedded preview when it is large enough, and the + archive's existing frames are reclassified by the next light analysis (R4). - Opening the repository in VS Code with C# Dev Kit before the first build listed MSB3073 for Titano, the Uploader and Setup: design-time builds no longer generate the program icons, and log WPF's MC1000 about projects not built yet as a message. diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 8e5c669c..05836d0b 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -397,3 +397,8 @@ One line per decision: date · decision · alternative · reason. | 2026-10-13 | A deep pass counts as current only when its report describes the frames as this host reads them under the lock, proxies included (`SequenceAnalyser.Describes`), besides an unchanged frames version. Otherwise it replaces only a saved report that does not describe them either (`ReadReport` of the frames as they are). Refines 2026-10-12 'A deep analysis saves `analysis.json` under the sequence lock…'. | Compare frames versions only | A proxy arriving moves no frames version but makes an unreadable verdict on that frame's original stale. A pass that started before it overwrote the report a later pass made from the proxies, then dropped the deep status. | | 2026-10-15 | VS Code debugs the Windows programs with the C# extension's `coreclr` debugger (`.vscode/launch.json`): Titano, the Uploader, the server, the `--capture` runs of Titano, the Uploader and Setup, `Titano.Tools` and the test programs (these two ask for their arguments). Each launch configuration builds in Debug first (`.vscode/tasks.json`; *Tests* builds the solution) and starts the program's `.exe`. The server's session keeps its data and archive in `out/debug/server` (`TITANO_DATA_PATH`, `TITANO_ARCHIVE_PATH`) and its default ports; Titano and the Uploader use their usual data folder. The build tasks use no reused MSBuild nodes and keep MSB3026 a warning. | C# Dev Kit's `dotnet` launch type with `launchSettings.json`; start `dotnet .dll`; the server's default folders; ports of its own for the server; a portable copy (`portable.txt`) for the desktop programs; reused MSBuild nodes; MSB3026 as an error | The `coreclr` debugger needs only the C# extension. Started as a `.dll`, the process is `dotnet.exe`, which the programs read as their own path (`Environment.ProcessPath`): Setup's payload and the stub of its capture's sample installer, the Run keys and tray icons. A console run creates `%ProgramData%\Titano Server` owned by the developer, which the service then refuses (the console-run data folder rows), and `C:\TitanoArchive` at the drive root. On the default ports the clients reach the debug server as they reach an installed one; the README says to stop the Docker stack or an installed server first. A portable copy would run other code than an installed one (data beside the program, the portable update download). MSB3026 reports a copy that a retry then completes (a file held for a moment by an antivirus or another build): as an error it stopped F5 although the build succeeded, while a copy that never succeeds still fails (MSB3027). Reused MSBuild nodes keep the drive letter's case of the build that started them, while VS Code passes it in lower case: restores mixed both cases, rewrote `project.assets.json` at every build and made C# Dev Kit reload the projects, so no F5 build was a no-op (7 to 14 s for Titano instead of about 5 s). | | 2026-10-15 | Design-time builds (`DesignTimeBuild=true`: C# Dev Kit, Visual Studio) skip the `TitanoGenerateIcons` target (`Directory.Build.targets`) and log WPF's MC1000 as a message (`Directory.Build.props`). Refines 2026-10-02 'Program icons (ICO) are generated at build time…'. | Build `Titano.Tools` from the design-time build; no warnings as errors in design-time builds; leave it | A design-time build builds no project references, so on a fresh clone `make-icon` ran a `Titano.Tools.dll` that did not exist yet: VS Code listed MSB3073 for Titano, the Uploader and Setup when the folder opened. A design-time build compiles nothing, so it needs no icon. Past that target, the markup compile of their XAML cannot load `Titano.Ui.dll` before the first build: MC1000, which the design-time build makes a warning and warnings as errors made an error again (21 of them). Without warnings as errors they would still be listed, as warnings. Real builds still fail on MC1000. | +| 2026-10-16 | Job throughput: the first two-second window that saw progress seeds the moving average, and below 1e-6 items/s the rate reads unknown; a time left is null when it is not finite, negative or above 365 days, and every stored or reported time left goes through `JobEta`. Saving progress never throws (a failure is logged and the job goes on) and a progress subscriber never fails a job, so a job's final state is always written. Thumbnail and proxy jobs count frames across their targets. Refines 2026-10-02 'Job throughput is a moving average…'. (Owner review 1, R10.) | Clamp the time left only when it is stored; keep counting sequences | The owner's Proxies job over 17 sequences counted sequences while it checkpointed every 10 s inside one of 14,082 frames: each window without progress multiplied the rate by 0.7, the time left passed `TimeSpan`'s limit after 18 minutes and threw in `PublishProgress`, then again in `PersistAsync`, so the job stayed Running for 4 hours until the owner cancelled it. A node-supplied rate and the stored seconds had the same unbounded conversion. | +| 2026-10-16 | The editor's background decodes (`LocalSequenceSource`, `RemoteSequenceSource`), `LatestRunner` and the render node's proxy task keep a superseded decode's `OperationCanceledException` inside their own delegate: the local source catches it in the pool delegate and throws it again after the await, so a cancellation is never reported as an unreadable frame. (Owner review 1, R4.) | `justMyCode: false` in launch.json; providers that return null on cancellation | The owner's "error in WicDecoderProvider.cs when I select some presets" was the cancellation of a preview decode a newer click replaced: it left a synchronous `Task.Run` delegate into the thread pool, where the debugger with Just My Code stops as "not handled by user code"; at runtime it was swallowed and nothing was logged. Throwing on cancellation stays the provider contract. | +| 2026-10-16 | WIC decodes a camera RAW only when the decoder it chose is the Raw Image Extension (CLSID read per file), never a DNG, and never for a request that prefers the embedded preview. Refines 2026-10-02 'Camera RAW is "native" via WIC only when the Raw Image Extension package is installed.' (Owner review 1, R4.) | Trust `CodecInventory` per format; force the Raw Image Extension by CLSID for DNG | With the extension installed, WIC still picks Windows' in-box "DNG Decoder" for every DNG with a JPEG preview; it reads only that 8-bit preview, which the provider labelled native (a smaller preview was a silent downscale). The Raw Image Extension develops DNG to 8 bits and fails on Lightroom's lossy LinearRaw DNGs; the managed decoder develops all of the owner's files at 16 bits. | +| 2026-10-16 | A DNG is GPR only when its raw image is VC-5 (Compression 9) or its extension is .gpr; Make=GoPro alone no longer counts. Frames stored as GPR whose file is not a .gpr are probed again by the next light analysis, which the scan follow-up queues for their sequences, and the format the probe finds replaces the stored one in the sidecar and in `frames.format`. (Owner review 1, R4.) | A migration that rewrites every sidecar; leave existing frames as indexed | The owner's 84,400 GoPro DNGs were converted by Lightroom or DNG Converter (lossy LinearRaw, lossless CFA), which the managed DNG decoder develops, but every one was indexed GPR and preview-only. A light analysis reads only metadata and already probes tiers under the sequence lease. | +| 2026-10-16 | Decode policy, the owner's choice: analyses, thumbnails, proxies and the editor's preview set `DecodeRequest.PreferPreview`, so a RAW gives an embedded preview whose long edge reaches the requested size when it has one and is developed otherwise; renders never set it and develop natively at 16 bits. Such a result is `DecodedImage.ByChoice` and is never recorded as the frame's tier. (Owner review 1, R4.) | Native development everywhere; the preview everywhere | Developing one of the owner's 12 MP DNGs takes 0.8–2.6 s against about 0.1 s for its preview: an analysis of the 84,400 frames would take about 18 hours instead of about 2. Exposure measured on a preview is tone-mapped by the converter, so deflicker corrections computed on it only approximate those of the native pixels the render corrects; the owner chose speed for analysis and quality for videos. | diff --git a/docs/STATUS.md b/docs/STATUS.md index 17c862e7..18aedcd1 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -13,6 +13,7 @@ Phase plan: docs/BRIEF.md §22. Windows behaviour is verified on CI (`windows-la | 6 Engine, encoding, editor | Done: render pipeline, MP4/AVI/GIF/APNG/image sequences, Media Foundation H.264/HEVC/AV1 with managed fallbacks; the sequence editor (Frames, Exposure, Camera, Motion and Export tabs, preview tools, section charts, curve editor, undo/redo, batch export) for local and server sequences. Gate: self-test suite green; the in-house inspector validates the containers the tests write; the encoder in use is logged. Playback: MediaPlayer opens the Media Foundation output and a source reader decodes its first frame (Windows tests). The pixel diff of every `--capture` screen against `tests/visual/baselines` (`screenshots diff`, BRIEF §20.2) is wired into CI but not armed: no baseline is committed yet, so the step compares nothing and only warns until the first baselines are accepted from `ci-screenshots` (Next steps). | | 7 Server, sync, uploader | Done: server (API, auth, uploads, jobs, render nodes, events, admin panel with light and dark themes, Windows service), Uploader, client sync (sync table, conflicts with *Save both*, proxies kept offline, metered pause), server sequences edited with proxies and rendered where the originals are, this PC as a render node. Gate covered in-process: a sequence uploaded from one PC downloads identically on another, interrupted uploads and downloads resume, server events update a PC, renders run on a node and on the server's managed fallback, jobs resume after a restart, sign-ins and administrative actions are audited. The run with two real PCs and the Uploader against the Docker server is part of the release test. | | 8 Release readiness | Release pipeline end to end (installers, portable and server zips, SHA256SUMS, release notes, optional signing, multi-arch GHCR image, public releases repository content), update check with verified download, scrubbed diagnostics bundles (desktop and server), performance gates, 38 cultures (`en`, `it` and 36 machine translations with glossaries and independent reviews), RTL pass (`ar`, `he`: mirrored windows, left-to-right islands for media, charts, numbers and paths; any right-to-left culture added later follows), accessibility pass (names, live regions, keyboard paths for charts and the curve editor). CI installs the packed installers silently on a clean `windows-latest` runner, runs the installed programs, upgrades in place and uninstalls (files, Add/Remove Programs, shortcuts, file type, user data kept, exit codes). Pending: a tagged pre-release published from CI, the interactive install on a real PC, Unraid template validation on a real server. | +| 8.1 Owner review 1 | In progress (request, answers and plan: `docs/requests/2026-10-15-owner-review-1.md`). Phase 1 done: stalled thumbnail and proxy jobs no longer fail and stay Running (frame-counted progress, bounded time left, final state always written); the editor's cancelled decodes stay in their tasks (no debugger stops in `WicDecoderProvider.cs`); WIC decodes RAW only through the Raw Image Extension and never DNG; GoPro DNGs converted by Adobe software are DNGs, developed natively for videos, read through their embedded preview for analyses and previews, and reclassified in existing archives by the next light analysis. Next: phase 2, jobs one at a time with photo parallelism and a priority queue. | | 9 Monetization | Not started: requires explicit approval (§22). | ## Verification (2026-10-12) diff --git a/docs/requests/2026-10-15-owner-review-1.md b/docs/requests/2026-10-15-owner-review-1.md new file mode 100644 index 00000000..d51dfdcc --- /dev/null +++ b/docs/requests/2026-10-15-owner-review-1.md @@ -0,0 +1,67 @@ +# Owner review 1 (2026-10-15) + +## Owner's text (verbatim, Italian) + +> Ok, ottimo! Lo hai creato in modo fantastico. Ci sono un po' di cose da controllare: +> - la barra laterale allargala e dai la possibilità di comprimerla lasciando solo le icone +> - cambia modo di eseguire le attività, ovvero DEVONO essere eseguita una volta e il parallelismo decide quante foto +> elaborare nello stesso momento +> - Rivedi il menu di esportazione, così occupa troppo e si capiscono bene i dettagli delle esportazioni +> - C'è un errore quando seleziono alcuni preseti in @src/Titano.Core.Windows/Wic/WicDecoderProvider.cs +> - Dai la possibilità di aggiustare la maschera di ritaglio spostandola sull'immagine in modo da fare un ritaglio +> visuale in base alle proporzioni scelte +> - Aggiungi filtri semplici come specchio, capovolgimento, rotazione, ecc ecc +> - Cambia "Sequenza" in "Modifica", posso selezionare solo una sequenza alla volta da modificare e deve essere +> strutturata come un "percorso" da seguire dall'analisi approfondita della sequenza al suo completamento +> +> Fai domande se qualcosa non è chiaro e aggiorna tutta la documentazione in modo che utenti e IA future siano in +> grado di ricostruire il percorso delle modifiche. +> Esegui test approfonditi. All'avvio ci sono già dei time lapse importati. Aggiungi opzioni di esportazione e una +> libreria separata per i video finali. +> +> Modifiche da fare sia lato docker sia lato desktop. + +## Interpretation + +| Id | Request | Working interpretation | +|---|---|---| +| R1 | Sidebar | Desktop rail wider and collapsible to icons; the server admin panel's sidebar too. | +| R2 | Jobs | One job runs at a time; Parallelism = photos the running job processes at once. Desktop and server. | +| R3 | Export menu | The Export tab and the header's Render menu take too much space and do not make the export details clear (the "non" is missing in the text): compact and clearer. | +| R4 | WicDecoderProvider error | Reproduced: an `OperationCanceledException` from a superseded preview decode leaves a synchronous thread-pool delegate, so the debugger stops in `WicDecoderProvider.cs` (Just My Code). Found while reproducing: WIC decodes the owner's DNGs with Windows' preview-only DNG decoder and labels the 8-bit preview native, and every GoPro DNG is classified GPR, so the archive records them preview-only. | +| R5 | Visual crop | Move and resize the crop mask on the preview, locked to the chosen proportions. | +| R6 | Simple filters | Mirror, flip, 90° rotations, free straighten, colour filters. | +| R7 | Edit path | "Sequence" becomes "Edit" ("Modifica"); one sequence at a time; a guided path from the deep analysis to the finished video. | +| R8 | Export options | Advanced encoding, fades and hold, reverse and boomerang, single frame. | +| R9 | Videos library | One library of the finished videos, desktop and server. | +| R10 | Found in the owner's log | A multi-sequence Proxies job failed with `OverflowException` in `JobContext.Rate()` and stayed Running for 4 hours. | + +## Questions and answers + +| Question | Answer | +|---|---| +| How must jobs run? | One at a time; Parallelism = photos at once inside it. | +| How guided is the Edit path? | Guided steps, freely navigable (Previous/Next, every step clickable). | +| Which simple filters? | Mirror and flip, 90° rotations, straighten (free angle), colour filters. | +| Where does the videos library live? | Desktop + server, one library. | +| Crop proportions vs the export preset's? | The chosen proportions win; the preset adapts its resolution (4K at 9:16 = 2160×3840). | +| Which export options? | Advanced encoding (rate control, keyframes, B-frames, profile, standard resolutions); fades and hold last frame; reverse, boomerang and loop; single frame. | +| Where are the videos' files? | One list; files stay in each sequence's `exports/` and can be copied (hash-verified) to a separate videos folder (Docker: a `/videos` volume). Delete = trash, never erased. | +| How to decode the GoPro DNGs? | Full quality (Titano's native 16-bit decoding) for videos; the embedded preview for analysis and the editor preview. | +| A long background job runs and the user starts another job? | By default the new job is queued; pausing the running job lets the next one start. Settings get a priority queue by job kind: when on, a job of a higher kind pauses the running one without asking, and the paused job resumes by itself afterwards. | +| Rail width? | 200 px (web panel 256 px), collapse with ≡ or Ctrl+B, collapsed icons name their section in the tooltip. | +| How is the sequence chosen in Edit? | A picker inside Edit (searchable single choice) plus "Change sequence" in the header; the other ways to open stay. | +| Commits? | One commit per verified phase. | + +## Delivery plan + +| Phase | Content | State | Commit | +|---|---|---|---| +| 1 | Bugs: R10 job throughput/ETA and stuck jobs; R4 cancellation boundary, WIC decoder truth, GoPro DNG classification, decode policy (preview for analysis, native for renders) | done 2026-10-16: BRIEF §8.1, §8.2, §24; five DECISIONS rows dated 2026-10-16; all test suites, i18n check, format, package guard and xaml-lint green | phase 1 commit | +| 2 | R2 jobs one at a time, Parallelism = photos at once, priority queue with automatic pause/resume (desktop + server) | todo | | +| 3 | R1 rail and admin sidebar; R7 Edit section, picker, guided path | todo | | +| 4 | R5 visual crop, proportions win; R6 transforms, straighten, colour filters | todo | | +| 5 | R3 export panel and Render menu; R8 export options; R9 videos library (desktop, server API, admin page, copy folder, trash) | todo | | +| 6 | Docker/Unraid/deploy docs, BRIEF §24 amendments, full verification | todo | | + +Each phase updates BRIEF (amended paragraphs), DECISIONS, CHANGELOG, STATUS and this file before its commit. diff --git a/docs/requests/README.md b/docs/requests/README.md new file mode 100644 index 00000000..590be8db --- /dev/null +++ b/docs/requests/README.md @@ -0,0 +1,12 @@ +# Owner change requests + +One file per request from the product owner, named `-.md`. Each file keeps: + +1. the owner's text, verbatim; +2. the working interpretation, numbered (R1, R2, …); +3. the questions asked and the owner's answers; +4. the delivery plan, phase by phase, with each phase's state, commit, BRIEF/DESIGN sections amended and DECISIONS rows. + +A request amends the BRIEF: the amended paragraphs say so, and BRIEF §24 lists every amendment with the request that +made it. DECISIONS rows written for a request cite it (`R4`, `owner review 1`). Read the request file first to rebuild +why a part of Titano is the way it is. diff --git a/i18n/ar/Jobs.ar.resx b/i18n/ar/Jobs.ar.resx index 710ea761..9a318d19 100644 --- a/i18n/ar/Jobs.ar.resx +++ b/i18n/ar/Jobs.ar.resx @@ -59,6 +59,7 @@ إعدادات التصيير {0} · {1} البحث في الهدف أو النوع + {0}/ث {0} fps {0}/ث ملغاة diff --git a/i18n/bg/Jobs.bg.resx b/i18n/bg/Jobs.bg.resx index 738205ac..9592c3a4 100644 --- a/i18n/bg/Jobs.bg.resx +++ b/i18n/bg/Jobs.bg.resx @@ -57,6 +57,7 @@ Настройки на рендерирането {0} · {1} Търсене по обект или тип + {0}/с {0} fps {0}/с отменена diff --git a/i18n/cs/Jobs.cs.resx b/i18n/cs/Jobs.cs.resx index ec9705d3..99df717c 100644 --- a/i18n/cs/Jobs.cs.resx +++ b/i18n/cs/Jobs.cs.resx @@ -58,6 +58,7 @@ Nastavení renderování {0} · {1} Hledat cíl nebo typ + {0}/s {0} fps {0}/s zrušeno diff --git a/i18n/da/Jobs.da.resx b/i18n/da/Jobs.da.resx index dc6507a3..1360e10c 100644 --- a/i18n/da/Jobs.da.resx +++ b/i18n/da/Jobs.da.resx @@ -57,6 +57,7 @@ Renderingsindstillinger {0} · {1} Søg i mål eller type + {0}/s {0} fps {0}/s annulleret diff --git a/i18n/de/Jobs.de.resx b/i18n/de/Jobs.de.resx index c68ec619..718819cd 100644 --- a/i18n/de/Jobs.de.resx +++ b/i18n/de/Jobs.de.resx @@ -57,6 +57,7 @@ Rendereinstellungen {0} · {1} Ziel oder Art suchen + {0}/s {0} fps {0}/s abgebrochen diff --git a/i18n/el/Jobs.el.resx b/i18n/el/Jobs.el.resx index 76d3a5f8..fcf3a9c1 100644 --- a/i18n/el/Jobs.el.resx +++ b/i18n/el/Jobs.el.resx @@ -57,6 +57,7 @@ Ρυθμίσεις απόδοσης {0} · {1} Αναζήτηση στόχου ή είδους + {0}/s {0} fps {0}/s ακυρώθηκε diff --git a/i18n/en/Jobs.resx b/i18n/en/Jobs.resx index 1bd5a967..53edb502 100644 --- a/i18n/en/Jobs.resx +++ b/i18n/en/Jobs.resx @@ -60,6 +60,7 @@ Search target or kind {0} fps {0}/s + {0}/s{0} = bytes, e.g. "57 MB" cancelled done failed diff --git a/i18n/es/Jobs.es.resx b/i18n/es/Jobs.es.resx index cc84c6cb..62d39822 100644 --- a/i18n/es/Jobs.es.resx +++ b/i18n/es/Jobs.es.resx @@ -57,6 +57,7 @@ Configuración de renderizado {0} · {1} Buscar elemento o tipo + {0}/s {0} fps {0}/s cancelada diff --git a/i18n/et/Jobs.et.resx b/i18n/et/Jobs.et.resx index 59c0ecc9..58d39411 100644 --- a/i18n/et/Jobs.et.resx +++ b/i18n/et/Jobs.et.resx @@ -57,6 +57,7 @@ Renderdussätted {0} · {1} Otsi objekti või liiki + {0}/s {0} fps {0}/s tühistatud diff --git a/i18n/fi/Jobs.fi.resx b/i18n/fi/Jobs.fi.resx index da9c7b2b..6217b882 100644 --- a/i18n/fi/Jobs.fi.resx +++ b/i18n/fi/Jobs.fi.resx @@ -57,6 +57,7 @@ Renderöintiasetukset {0} · {1} Hae kohdetta tai tyyppiä + {0}/s {0} fps {0}/s peruttu diff --git a/i18n/fr/Jobs.fr.resx b/i18n/fr/Jobs.fr.resx index 6a010ea8..cb905959 100644 --- a/i18n/fr/Jobs.fr.resx +++ b/i18n/fr/Jobs.fr.resx @@ -57,6 +57,7 @@ Paramètres de rendu {0} · {1} Rechercher une cible ou un type + {0}/s {0} fps {0}/s annulée diff --git a/i18n/he/Jobs.he.resx b/i18n/he/Jobs.he.resx index 346054c0..a4928eb0 100644 --- a/i18n/he/Jobs.he.resx +++ b/i18n/he/Jobs.he.resx @@ -58,6 +58,7 @@ הגדרות רינדור {0} · {1} חיפוש לפי יעד או סוג + {0} לשנייה {0} fps {0} לשנייה בוטלה diff --git a/i18n/hi/Jobs.hi.resx b/i18n/hi/Jobs.hi.resx index 30574266..fde774b8 100644 --- a/i18n/hi/Jobs.hi.resx +++ b/i18n/hi/Jobs.hi.resx @@ -57,6 +57,7 @@ रेंडरिंग सेटिंग्स {0} · {1} लक्ष्य या प्रकार खोजें + {0}/सेकंड {0} fps {0}/सेकंड रद्द diff --git a/i18n/hr/Jobs.hr.resx b/i18n/hr/Jobs.hr.resx index 9b51b797..595e5be9 100644 --- a/i18n/hr/Jobs.hr.resx +++ b/i18n/hr/Jobs.hr.resx @@ -58,6 +58,7 @@ Postavke renderiranja {0} · {1} Pretraži cilj ili vrstu + {0}/s {0} fps {0}/s otkazano diff --git a/i18n/hu/Jobs.hu.resx b/i18n/hu/Jobs.hu.resx index cbef3629..dbedbc4c 100644 --- a/i18n/hu/Jobs.hu.resx +++ b/i18n/hu/Jobs.hu.resx @@ -57,6 +57,7 @@ Renderelési beállítások {0} · {1} Keresés cél vagy típus szerint + {0}/s {0} fps {0}/s megszakítva diff --git a/i18n/id/Jobs.id.resx b/i18n/id/Jobs.id.resx index 918d3c0c..53865b97 100644 --- a/i18n/id/Jobs.id.resx +++ b/i18n/id/Jobs.id.resx @@ -57,6 +57,7 @@ Pengaturan render {0} · {1} Cari target atau jenis + {0}/dtk {0} fps {0}/dtk dibatalkan diff --git a/i18n/it/Jobs.it.resx b/i18n/it/Jobs.it.resx index 4524e528..81cb1311 100644 --- a/i18n/it/Jobs.it.resx +++ b/i18n/it/Jobs.it.resx @@ -60,6 +60,7 @@ Cerca oggetto o tipo {0} fps {0}/s + {0}/s annullata conclusa non riuscita diff --git a/i18n/ja/Jobs.ja.resx b/i18n/ja/Jobs.ja.resx index b1a9852c..1465cbd2 100644 --- a/i18n/ja/Jobs.ja.resx +++ b/i18n/ja/Jobs.ja.resx @@ -57,6 +57,7 @@ レンダリング設定 {0} · {1} 対象または種類を検索 + {0}/秒 {0} fps {0}/秒 キャンセル済み diff --git a/i18n/ko/Jobs.ko.resx b/i18n/ko/Jobs.ko.resx index e60e26be..72405f43 100644 --- a/i18n/ko/Jobs.ko.resx +++ b/i18n/ko/Jobs.ko.resx @@ -57,6 +57,7 @@ 렌더링 설정 {0} · {1} 대상 또는 종류 검색 + {0}/초 {0} fps {0}/초 취소됨 diff --git a/i18n/lt/Jobs.lt.resx b/i18n/lt/Jobs.lt.resx index 2badf203..beeeeb3c 100644 --- a/i18n/lt/Jobs.lt.resx +++ b/i18n/lt/Jobs.lt.resx @@ -58,6 +58,7 @@ Atvaizdavimo parametrai {0} · {1} Ieškoti objekto ar tipo + {0}/s {0} fps {0}/s atšaukta diff --git a/i18n/lv/Jobs.lv.resx b/i18n/lv/Jobs.lv.resx index 3bf3711a..fe200c2f 100644 --- a/i18n/lv/Jobs.lv.resx +++ b/i18n/lv/Jobs.lv.resx @@ -58,6 +58,7 @@ Renderēšanas iestatījumi {0} · {1} Meklēt mērķi vai veidu + {0}/s {0} fps {0}/s atcelts diff --git a/i18n/ms/Jobs.ms.resx b/i18n/ms/Jobs.ms.resx index 5f4091be..46a6b577 100644 --- a/i18n/ms/Jobs.ms.resx +++ b/i18n/ms/Jobs.ms.resx @@ -57,6 +57,7 @@ Tetapan render {0} · {1} Cari sasaran atau jenis + {0}/s {0} fps {0}/s dibatalkan diff --git a/i18n/nb/Jobs.nb.resx b/i18n/nb/Jobs.nb.resx index a9273bda..9fe3d393 100644 --- a/i18n/nb/Jobs.nb.resx +++ b/i18n/nb/Jobs.nb.resx @@ -57,6 +57,7 @@ Renderingsinnstillinger {0} · {1} Søk etter mål eller type + {0}/s {0} fps {0}/s avbrutt diff --git a/i18n/nl/Jobs.nl.resx b/i18n/nl/Jobs.nl.resx index 7a18e80e..f80ab89c 100644 --- a/i18n/nl/Jobs.nl.resx +++ b/i18n/nl/Jobs.nl.resx @@ -57,6 +57,7 @@ Renderinstellingen {0} · {1} Zoek doel of type + {0}/s {0} fps {0}/s geannuleerd diff --git a/i18n/pl/Jobs.pl.resx b/i18n/pl/Jobs.pl.resx index 0ff359bc..35931be9 100644 --- a/i18n/pl/Jobs.pl.resx +++ b/i18n/pl/Jobs.pl.resx @@ -59,6 +59,7 @@ Ustawienia renderowania {0} · {1} Szukaj celu lub rodzaju + {0}/s {0} fps {0}/s anulowane diff --git a/i18n/pt-BR/Jobs.pt-BR.resx b/i18n/pt-BR/Jobs.pt-BR.resx index 14c2ea01..6e92e3b4 100644 --- a/i18n/pt-BR/Jobs.pt-BR.resx +++ b/i18n/pt-BR/Jobs.pt-BR.resx @@ -57,6 +57,7 @@ Configurações de renderização {0} · {1} Pesquisar alvo ou tipo + {0}/s {0} fps {0}/s cancelada diff --git a/i18n/pt-PT/Jobs.pt-PT.resx b/i18n/pt-PT/Jobs.pt-PT.resx index 2ff609c8..c76fe0cd 100644 --- a/i18n/pt-PT/Jobs.pt-PT.resx +++ b/i18n/pt-PT/Jobs.pt-PT.resx @@ -57,6 +57,7 @@ Definições de renderização {0} · {1} Pesquisar alvo ou tipo + {0}/s {0} fps {0}/s cancelada diff --git a/i18n/ro/Jobs.ro.resx b/i18n/ro/Jobs.ro.resx index a32497fd..4e8ae006 100644 --- a/i18n/ro/Jobs.ro.resx +++ b/i18n/ro/Jobs.ro.resx @@ -58,6 +58,7 @@ Setări de randare {0} · {1} Căutați ținta sau tipul + {0}/s {0} fps {0}/s anulată diff --git a/i18n/ru/Jobs.ru.resx b/i18n/ru/Jobs.ru.resx index 6fea53a7..529b7736 100644 --- a/i18n/ru/Jobs.ru.resx +++ b/i18n/ru/Jobs.ru.resx @@ -59,6 +59,7 @@ Параметры рендеринга {0} · {1} Поиск по объекту или типу + {0}/с {0} fps {0}/с отменено diff --git a/i18n/sk/Jobs.sk.resx b/i18n/sk/Jobs.sk.resx index a3225914..ee748634 100644 --- a/i18n/sk/Jobs.sk.resx +++ b/i18n/sk/Jobs.sk.resx @@ -58,6 +58,7 @@ Nastavenia renderovania {0} · {1} Hľadať cieľ alebo druh + {0}/s {0} fps {0}/s zrušené diff --git a/i18n/sl/Jobs.sl.resx b/i18n/sl/Jobs.sl.resx index 515138d9..85e2e266 100644 --- a/i18n/sl/Jobs.sl.resx +++ b/i18n/sl/Jobs.sl.resx @@ -58,6 +58,7 @@ Nastavitve upodabljanja {0} · {1} Išči predmet ali vrsto + {0}/s {0} fps {0}/s preklicano diff --git a/i18n/sv/Jobs.sv.resx b/i18n/sv/Jobs.sv.resx index c87b857c..df0acd00 100644 --- a/i18n/sv/Jobs.sv.resx +++ b/i18n/sv/Jobs.sv.resx @@ -57,6 +57,7 @@ Renderingsinställningar {0} · {1} Sök mål eller typ + {0}/s {0} fps {0}/s avbruten diff --git a/i18n/th/Jobs.th.resx b/i18n/th/Jobs.th.resx index 979b2154..5e5c24d6 100644 --- a/i18n/th/Jobs.th.resx +++ b/i18n/th/Jobs.th.resx @@ -57,6 +57,7 @@ การตั้งค่าการเรนเดอร์ {0} · {1} ค้นหาเป้าหมายหรือประเภท + {0}/วินาที {0} fps {0}/วินาที ยกเลิกแล้ว diff --git a/i18n/tr/Jobs.tr.resx b/i18n/tr/Jobs.tr.resx index 3b20f611..b208b158 100644 --- a/i18n/tr/Jobs.tr.resx +++ b/i18n/tr/Jobs.tr.resx @@ -57,6 +57,7 @@ İşleme ayarları {0} · {1} Hedef veya tür ara + {0}/sn {0} fps {0}/sn iptal edildi diff --git a/i18n/uk/Jobs.uk.resx b/i18n/uk/Jobs.uk.resx index 2acd026e..235f2182 100644 --- a/i18n/uk/Jobs.uk.resx +++ b/i18n/uk/Jobs.uk.resx @@ -59,6 +59,7 @@ Налаштування рендерингу {0} · {1} Пошук за об’єктом або типом + {0}/с {0} fps {0}/с скасовано diff --git a/i18n/vi/Jobs.vi.resx b/i18n/vi/Jobs.vi.resx index 4592ce25..96c37e6c 100644 --- a/i18n/vi/Jobs.vi.resx +++ b/i18n/vi/Jobs.vi.resx @@ -57,6 +57,7 @@ Cài đặt kết xuất {0} · {1} Tìm đối tượng hoặc loại + {0}/s {0} fps {0}/s đã hủy diff --git a/i18n/zh-Hans/Jobs.zh-Hans.resx b/i18n/zh-Hans/Jobs.zh-Hans.resx index 19ee5b0d..73635738 100644 --- a/i18n/zh-Hans/Jobs.zh-Hans.resx +++ b/i18n/zh-Hans/Jobs.zh-Hans.resx @@ -57,6 +57,7 @@ 渲染设置 {0} · {1} 搜索目标或类型 + {0}/秒 {0} fps {0}/秒 已取消 diff --git a/i18n/zh-Hant/Jobs.zh-Hant.resx b/i18n/zh-Hant/Jobs.zh-Hant.resx index f29e2402..4715a544 100644 --- a/i18n/zh-Hant/Jobs.zh-Hant.resx +++ b/i18n/zh-Hant/Jobs.zh-Hant.resx @@ -57,6 +57,7 @@ 算圖設定 {0} · {1} 搜尋目標或類型 + {0}/秒 {0} fps {0}/秒 已取消 diff --git a/src/Titano.App/Editor/LatestRunner.cs b/src/Titano.App/Editor/LatestRunner.cs index 32376b43..c3ce4eb4 100644 --- a/src/Titano.App/Editor/LatestRunner.cs +++ b/src/Titano.App/Editor/LatestRunner.cs @@ -36,7 +36,9 @@ public sealed class LatestRunner(TimeSpan delay) : IDisposable try { if (wait > TimeSpan.Zero) await Task.Delay(wait, token).ConfigureAwait(false); - await Task.Run(() => work(token), token).ConfigureAwait(false); + // An async delegate: a work item that throws on cancellation before returning its task (synchronous work) is + // caught here, in user code, instead of in the thread pool, where a debugger with Just My Code stops (R4). + await Task.Run(async () => await work(token).ConfigureAwait(false), token).ConfigureAwait(false); } catch (OperationCanceledException) when (token.IsCancellationRequested) { diff --git a/src/Titano.App/Editor/LocalSequenceSource.cs b/src/Titano.App/Editor/LocalSequenceSource.cs index 300491ee..bc013aca 100644 --- a/src/Titano.App/Editor/LocalSequenceSource.cs +++ b/src/Titano.App/Editor/LocalSequenceSource.cs @@ -118,20 +118,35 @@ public sealed class LocalSequenceSource : ISequenceSource if ((uint)index >= (uint)_files.Length || _files[index] is not { } file) return null; var companions = _companions; var companion = (uint)index < (uint)companions.Length ? companions[index] : null; - return await Task.Run(() => + var pixels = await Task.Run(() => { try { - // Thumbnails take an embedded preview when it is large enough (no RAW development for a filmstrip cell). - var request = new DecodeRequest(file, maxLongEdge, purpose, ForcePreview: purpose == DecodePurpose.Thumbnail, Companion: companion); + // Thumbnails take an embedded preview when it is large enough (no RAW development for a filmstrip cell); the + // preview and its corrections take an adequate embedded preview of a RAW too, developing only without one (R4). + var request = new DecodeRequest(file, maxLongEdge, purpose, ForcePreview: purpose == DecodePurpose.Thumbnail, Companion: companion, + PreferPreview: true); return _decoder.Decode(request, cancellationToken)?.Pixels; } + catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) + { + // Superseded by a newer edit: end here, so the cancellation never crosses into the thread pool (a debugger + // with Just My Code stops there, R4); it is reported below. + return null; + } catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { Log.Warning("editor", $"Frame {file} could not be read", ex); return null; } }, cancellationToken); + // A cancelled decode is a cancellation for the caller, never an unreadable frame. + if (cancellationToken.IsCancellationRequested) + { + pixels?.Dispose(); + cancellationToken.ThrowIfCancellationRequested(); + } + return pixels; } public Task SaveProjectAsync(ProjectSettings project, ProjectSettings basis, CancellationToken cancellationToken) diff --git a/src/Titano.App/Editor/RemoteSequenceSource.cs b/src/Titano.App/Editor/RemoteSequenceSource.cs index 1a4bddf8..03dca423 100644 --- a/src/Titano.App/Editor/RemoteSequenceSource.cs +++ b/src/Titano.App/Editor/RemoteSequenceSource.cs @@ -140,7 +140,8 @@ public sealed class RemoteSequenceSource : ISequenceSource public async ValueTask DecodeAsync(int index, int maxLongEdge, DecodePurpose purpose, CancellationToken cancellationToken) { if ((uint)index >= (uint)_remote.Frames.Count) return null; - return await Task.Run(() => _pixels.LoadAsync(index, maxLongEdge, cancellationToken).AsTask(), cancellationToken); + // The loader decodes synchronously: an async delegate keeps a superseded decode's cancellation in user code (R4). + return await Task.Run(async () => await _pixels.LoadAsync(index, maxLongEdge, cancellationToken).ConfigureAwait(false), cancellationToken); } public async Task SaveProjectAsync(ProjectSettings project, ProjectSettings basis, CancellationToken cancellationToken) @@ -283,7 +284,7 @@ public sealed class RemoteSequenceSource : ISequenceSource ProgressDone = progress.Done, ProgressTotal = progress.Total, ItemsPerSecond = progress.ItemsPerSecond, - Eta = progress.EtaSeconds is { } eta ? TimeSpan.FromSeconds(eta) : null, + Eta = JobEta.FromSeconds(progress.EtaSeconds), }); break; case JobStateEvent state when !_foreign.ContainsKey(state.JobId): diff --git a/src/Titano.App/Jobs/JobText.cs b/src/Titano.App/Jobs/JobText.cs index 28f259ef..839d261b 100644 --- a/src/Titano.App/Jobs/JobText.cs +++ b/src/Titano.App/Jobs/JobText.cs @@ -12,13 +12,18 @@ public static class JobText /// True for jobs whose items are frames, so their speed reads in fps. public static bool CountsFrames(JobKind kind) => - kind is JobKind.Render or JobKind.Proxies or JobKind.Thumbs or JobKind.LightAnalyse or JobKind.DeepAnalyse or JobKind.Verify; + kind is JobKind.Render or JobKind.Proxies or JobKind.Thumbs or JobKind.DeepAnalyse; - /// "11.3 fps" for frame jobs, "41/s" otherwise; empty when unknown. - public static string Speed(JobKind kind, double? perSecond) => - perSecond is > 0 and var rate - ? Loc.L(CountsFrames(kind) ? "Jobs.Speed.Fps" : "Jobs.Speed.PerSecond", Formatting.Rate(rate)) - : string.Empty; + /// True for jobs whose progress counts bytes (hash verification, card import). + public static bool CountsBytes(JobKind kind) => kind is JobKind.Verify or JobKind.Import; + + /// "11.3 fps" for frame jobs, "57 MB/s" for byte jobs, "41/s" otherwise; empty when unknown. + public static string Speed(JobKind kind, double? perSecond) => perSecond switch + { + > 0 and var rate when CountsBytes(kind) => Loc.L("Jobs.Speed.Bytes", Formatting.Bytes((long)rate)), + > 0 and var rate => Loc.L(CountsFrames(kind) ? "Jobs.Speed.Fps" : "Jobs.Speed.PerSecond", Formatting.Rate(rate)), + _ => string.Empty, + }; /// "1,240 / 3,600"; empty while the total is unknown. public static string Counter(long done, long total) => diff --git a/src/Titano.Core.Windows/Wic/WicDecoderProvider.cs b/src/Titano.Core.Windows/Wic/WicDecoderProvider.cs index 03301674..896307ff 100644 --- a/src/Titano.Core.Windows/Wic/WicDecoderProvider.cs +++ b/src/Titano.Core.Windows/Wic/WicDecoderProvider.cs @@ -18,6 +18,13 @@ namespace Titano.Core.Windows.Wic; /// Sources whose native format is floating or fixed point (scRGB: JPEG XR, HDR) are requested as 128bppRGBAFloat /// and copied unchanged, keeping highlights above 1. Alpha is discarded. The Exif orientation is applied while /// de-interleaving (). +/// +/// WIC picks the decoder itself, and for a camera RAW only the Raw Image Extension develops the sensor data: Windows' +/// in-box DNG decoder reads only the embedded JPEG preview, and the TIFF decoder would read a TIFF-based RAW's thumbnail. +/// So a RAW decodes here only when the decoder WIC chose is the Raw Image Extension (checked per file by CLSID), DNG never +/// (the managed decoder develops it at 16 bits, the Raw Image Extension at 8), and a request that prefers the embedded +/// preview is left to the managed decoder, which reads it without developing anything (R4, owner review 1). +/// /// public sealed class WicDecoderProvider : IImageDecoderProvider { @@ -44,7 +51,7 @@ public sealed class WicDecoderProvider : IImageDecoderProvider /// Detects the codecs again (after a Store extension was installed); decodes that start afterwards use them. public CodecInventory Refresh() => _inventory = CodecInventory.Detect(refresh: true); - public DecodeTier? TierFor(ImageFileFormat format) => Inventory.IsNative(format) ? DecodeTier.Native : null; + public DecodeTier? TierFor(ImageFileFormat format) => format != ImageFileFormat.Dng && Inventory.IsNative(format) ? DecodeTier.Native : null; /// /// Decodes the first frame. Returns null when WIC cannot natively decode this format here, when the request @@ -54,7 +61,8 @@ public sealed class WicDecoderProvider : IImageDecoderProvider public DecodedImage? Decode(DecodeRequest request, CancellationToken cancellationToken = default) { ArgumentNullException.ThrowIfNull(request); - if (request.ForcePreview || TierFor(ImageFormatInfo.FromPath(request.Path).Format) is null) return null; + var format = ImageFormatInfo.FromPath(request.Path); + if (request.ForcePreview || (request.PreferPreview && format.IsRaw) || TierFor(format.Format) is null) return null; cancellationToken.ThrowIfCancellationRequested(); Win32Com.EnsureInitialized(); @@ -69,6 +77,7 @@ public sealed class WicDecoderProvider : IImageDecoderProvider var hr = factory.CreateDecoderFromStream(stream, 0, WicDecodeOptions.MetadataCacheOnDemand, out decoder); if (hr == WINCODEC_ERR_COMPONENTNOTFOUND) return null; Marshal.ThrowExceptionForHR(hr); + if (format.IsRaw && DecoderClsid(decoder!) != WicGuids.RawDecoder) return null; frame = decoder!.GetFrame(0); frame.GetSize(out var width, out var height); var orientation = request.ApplyOrientation ? ReadOrientation(frame) : 1; @@ -103,6 +112,23 @@ public sealed class WicDecoderProvider : IImageDecoderProvider } } + /// CLSID of the decoder WIC chose for the stream, or when it does not say. + private static Guid DecoderClsid(IWICBitmapDecoder decoder) + { + if (decoder.GetDecoderInfo(out var pointer) < 0 || pointer == 0) return Guid.Empty; + object? info = null; + try + { + info = Marshal.GetObjectForIUnknown(pointer); + return info is IWICBitmapDecoderInfo decoderInfo ? decoderInfo.GetCLSID() : Guid.Empty; + } + finally + { + Marshal.Release(pointer); + Win32Com.Release(info); + } + } + /// Size after fitting the long edge into (never upscales; 0 = native). internal static (uint Width, uint Height) TargetSize(uint width, uint height, int maxLongEdge) { diff --git a/src/Titano.Core/Archiving/SequenceFrames.cs b/src/Titano.Core/Archiving/SequenceFrames.cs index 11dbf2c7..98d5da31 100644 --- a/src/Titano.Core/Archiving/SequenceFrames.cs +++ b/src/Titano.Core/Archiving/SequenceFrames.cs @@ -59,8 +59,11 @@ public static class SequenceFrames /// tier is kept and is left as it was. /// Whether the host takes the frame's pixels from its proxy (an original it cannot decode, whose /// proxy is there): see . + /// A probe reads the file's signature again: the format it found replaces a stored one that is out of date + /// (GoPro DNGs converted by Adobe software were stored as GPR before owner review 1). public static SidecarFrame WithTier(SidecarFrame frame, FileTier tier, bool damaged = true, bool proxied = false) { + if (tier.Format != ImageFileFormat.Unknown && tier.Format != frame.Format) frame = frame with { Format = tier.Format }; var flags = frame.Flags & ~(FrameFlags.PreviewOnly | FrameFlags.Undecodable); if (tier.Tier == DecodeTier.EmbeddedPreview) flags |= proxied ? FrameFlags.None : FrameFlags.PreviewOnly; else if (tier.Tier == DecodeTier.Unavailable) flags |= damaged ? FrameFlags.Undecodable : frame.Flags & FrameFlags.Undecodable; diff --git a/src/Titano.Core/Codecs/Dng/DngReader.cs b/src/Titano.Core/Codecs/Dng/DngReader.cs index a56db315..d309c2e2 100644 --- a/src/Titano.Core/Codecs/Dng/DngReader.cs +++ b/src/Titano.Core/Codecs/Dng/DngReader.cs @@ -97,6 +97,19 @@ internal static class DngReader if (total * 8 < samples) throw new InvalidDataException("DNG: image data too short for the raster"); } + /// + /// True when the full-resolution raw image of the DNG reads is VC-5 compressed (Compression 9, + /// GoPro's GPR), which no managed decoder handles; false for every other DNG, a GoPro one converted by Adobe software + /// (lossless JPEG or lossy LinearRaw) included, and when no raw image is found. + /// + internal static bool IsVc5(TiffReader r) + { + var chain = r.ReadChain(); + return chain.Count > 0 && FindRawIfd(r, chain) is { } raw && r.GetUInt(raw, TiffTags.Compression) == Vc5Compression; + } + + private const uint Vc5Compression = 9; + /// First IFD with NewSubfileType 0 and a CFA/LinearRaw photometric: IFD0, its SubIFDs (two levels), the chain. private static Ifd? FindRawIfd(TiffReader r, IReadOnlyList chain) { diff --git a/src/Titano.Core/Imaging/Decoders/ManagedDecoderProvider.cs b/src/Titano.Core/Imaging/Decoders/ManagedDecoderProvider.cs index 568ccf8f..4db6e976 100644 --- a/src/Titano.Core/Imaging/Decoders/ManagedDecoderProvider.cs +++ b/src/Titano.Core/Imaging/Decoders/ManagedDecoderProvider.cs @@ -166,6 +166,9 @@ public sealed class ManagedDecoderProvider : IImageDecoderProvider private static DecodedImage? Raw(Stream stream, ImageFileFormat format, DecodeRequest request, CancellationToken cancellationToken) { + if (request.PreferPreview && !request.ForcePreview && request.MaxLongEdge > 0 && RawDecoder.Formats.Contains(format) + && Preview(stream, request, adequateOnly: true, cancellationToken) is { } quick) + return quick.AsChoice(); if (!request.ForcePreview && RawDecoder.Formats.Contains(format)) { try diff --git a/src/Titano.Core/Imaging/Decoding.cs b/src/Titano.Core/Imaging/Decoding.cs index 108831ae..f00a7428 100644 --- a/src/Titano.Core/Imaging/Decoding.cs +++ b/src/Titano.Core/Imaging/Decoding.cs @@ -32,6 +32,10 @@ public enum DecodePurpose /// Use the embedded preview even when native decode is possible (fast paths). /// The JPEG a GoPro wrote with this GPR when it is kept elsewhere than beside it (an import puts /// it in a sequence of its own); null looks beside the file. Other formats ignore it. +/// For a RAW file: use an embedded preview whose long edge reaches +/// when there is one, and decode natively otherwise. Analyses, thumbnails, proxies and the editor's preview ask for it +/// (fast); renders never do. The result is marked , so it never makes the frame +/// preview-only (R4, owner review 1). public sealed record DecodeRequest( string Path, int MaxLongEdge = 0, @@ -39,14 +43,22 @@ public sealed record DecodeRequest( bool ApplyOrientation = true, bool AllowPreview = true, bool ForcePreview = false, - string? Companion = null); + string? Companion = null, + bool PreferPreview = false); /// Decoded pixels plus how they were produced. Dispose to return the buffer to the pool. -public sealed class DecodedImage(ImageBuffer pixels, DecodeTier tier, string decoder, int sourceWidth, int sourceHeight) : IDisposable +public sealed class DecodedImage(ImageBuffer pixels, DecodeTier tier, string decoder, int sourceWidth, int sourceHeight, bool byChoice = false) : IDisposable { public ImageBuffer Pixels { get; } = pixels; public DecodeTier Tier { get; } = tier; + /// + /// The pixels come from an embedded preview the request preferred () although + /// the file may decode natively: says how these pixels were made, not what the frame can give, so it + /// is not recorded as the frame's tier. + /// + public bool ByChoice { get; } = byChoice; + /// Short provider/decoder name for logs ("wic", "managed-jpeg", "managed-dng"). public string Decoder { get; } = decoder; @@ -56,6 +68,9 @@ public sealed class DecodedImage(ImageBuffer pixels, DecodeTier tier, string dec public int SourceHeight { get; } = sourceHeight; public void Dispose() => Pixels.Dispose(); + + /// The same pixels marked (the returned image owns them; do not dispose this one). + internal DecodedImage AsChoice() => new(Pixels, Tier, Decoder, SourceWidth, SourceHeight, byChoice: true); } /// Tier a provider would use for one specific file, with the reason when it is not native. diff --git a/src/Titano.Core/Metadata/ImageSignature.cs b/src/Titano.Core/Metadata/ImageSignature.cs index 1b5becc2..724d4f52 100644 --- a/src/Titano.Core/Metadata/ImageSignature.cs +++ b/src/Titano.Core/Metadata/ImageSignature.cs @@ -119,8 +119,10 @@ public static class ImageSignature var reader = TiffReader.Open(stream); var ifd0 = reader?.ReadIfd(reader.FirstIfdOffset); var make = reader is not null && ifd0 is not null ? IfdValue.String(reader, ifd0, TiffTags.Make) : null; + // A GoPro DNG is GPR only when its raw image is VC-5: one converted by Adobe software (Lightroom, DNG Converter) is + // an ordinary DNG the managed DNG decoder develops (R4, owner review 1). if (ifd0?.Has(TiffTags.DngVersion) == true) - return extension == ImageFileFormat.Gpr || make?.StartsWith("GoPro", StringComparison.OrdinalIgnoreCase) == true ? ImageFileFormat.Gpr : ImageFileFormat.Dng; + return extension == ImageFileFormat.Gpr || Codecs.Dng.DngReader.IsVc5(reader!) ? ImageFileFormat.Gpr : ImageFileFormat.Dng; if (extension == ImageFileFormat.Tiff) return ImageFileFormat.Tiff; var byMake = ByMake(make, extension); if (byMake != ImageFileFormat.Unknown) return byMake; diff --git a/src/Titano.Data/Archiving/FrameTiers.cs b/src/Titano.Data/Archiving/FrameTiers.cs index 62745106..5c5ea8c4 100644 --- a/src/Titano.Data/Archiving/FrameTiers.cs +++ b/src/Titano.Data/Archiving/FrameTiers.cs @@ -22,7 +22,9 @@ internal sealed class FrameTiers(TitanoDatabase db, SequenceWriter writer, Archi /// The tier of every frame of whose tier is not known yet, that decodes only through a /// preview whose size is not known (the output cap needs it), or that is a GPR whose JPEG in another sequence /// (; an upload may index it after the GPR was probed) is larger than its stored preview, - /// probed with the host's decoders without decoding pixels; missing and unreadable files are left for later. + /// or that is stored as GPR without the .gpr extension (indexed before GoPro DNGs converted by Adobe software counted as + /// DNG; R4, owner review 1), probed with the host's decoders without decoding pixels; missing and unreadable files are + /// left for later. /// public async Task> ProbeUnknownAsync(Archive archive, SequencePaths folder, SequenceManifest manifest, CancellationToken cancellationToken) @@ -30,7 +32,7 @@ internal sealed class FrameTiers(TitanoDatabase db, SequenceWriter writer, Archi var tiers = new Dictionary(); var present = manifest.Frames.Where(f => (f.Flags & FrameFlags.Missing) == 0).ToList(); var companions = await GprCompanions.FindWithSizesAsync(db, archive, present, cancellationToken).ConfigureAwait(false); - var unknown = present.Where(f => f.Tier == 0 || (f.Tier == DecodeTier.EmbeddedPreview && f.PreviewW is null) + var unknown = present.Where(f => f.Tier == 0 || (f.Tier == DecodeTier.EmbeddedPreview && f.PreviewW is null) || IsStaleGpr(f) || (companions.TryGetValue(f.Id, out var jpeg) && int.Max(f.PreviewW ?? 0, f.PreviewH ?? 0) < int.Max(jpeg.Width, jpeg.Height))); foreach (var frame in unknown) @@ -97,7 +99,8 @@ internal sealed class FrameTiers(TitanoDatabase db, SequenceWriter writer, Archi if (tier is not null) updated = SequenceFrames.WithTier(frame, tier, DecodesNatively(frame.Format), proxied == true); else if (proxied is { } own) updated = SequenceFrames.WithProxy(frame, own); else continue; - if (updated.Tier == frame.Tier && updated.Flags == frame.Flags && updated.PreviewW == frame.PreviewW && updated.PreviewH == frame.PreviewH) + if (updated.Tier == frame.Tier && updated.Flags == frame.Flags && updated.PreviewW == frame.PreviewW && updated.PreviewH == frame.PreviewH + && updated.Format == frame.Format) continue; gained |= (updated.Flags & ~frame.Flags & FrameFlags.Undecodable) != 0; frames[i] = updated; @@ -118,7 +121,7 @@ internal sealed class FrameTiers(TitanoDatabase db, SequenceWriter writer, Archi // for these frames while this waits for the row, and PostgreSQL would abort one of them. await tx.Sequences.RecordTiersAsync(sequence.Id, gained ? SequenceStatus.HasWarnings : SequenceStatus.None, frames.Count(f => (f.Flags & FrameFlags.PreviewOnly) != 0), cancellationToken).ConfigureAwait(false); - await tx.Frames.UpdateTiersAsync(changed.ConvertAll(f => new FrameTierFields(f.Id, f.Flags, f.PreviewW ?? 0, f.PreviewH ?? 0)), cancellationToken) + await tx.Frames.UpdateTiersAsync(changed.ConvertAll(f => new FrameTierFields(f.Id, f.Flags, f.PreviewW ?? 0, f.PreviewH ?? 0, f.Format)), cancellationToken) .ConfigureAwait(false); await tx.CommitAsync(cancellationToken).ConfigureAwait(false); } @@ -127,6 +130,14 @@ internal sealed class FrameTiers(TitanoDatabase db, SequenceWriter writer, Archi } } + /// + /// A frame stored as GPR whose file is not a .gpr: before owner review 1 every DNG with Make=GoPro counted as GPR, so + /// Adobe-converted GoPro DNGs were recorded preview-only; probing reads its signature again ( + /// then stores the format found). + /// + internal static bool IsStaleGpr(SidecarFrame frame) => + frame.Format == ImageFileFormat.Gpr && !frame.File.EndsWith(".gpr", StringComparison.OrdinalIgnoreCase); + /// /// Whether this host decodes natively, so a file of it that yields no pixels is damaged /// rather than beyond this host (JPEG always: the managed JPEG decoder is part of every host). diff --git a/src/Titano.Data/Archiving/Jobs/ImageJobHandler.cs b/src/Titano.Data/Archiving/Jobs/ImageJobHandler.cs index 32538a60..3b1672cd 100644 --- a/src/Titano.Data/Archiving/Jobs/ImageJobHandler.cs +++ b/src/Titano.Data/Archiving/Jobs/ImageJobHandler.cs @@ -6,8 +6,9 @@ using Titano.Data.Jobs; namespace Titano.Data.Archiving.Jobs; /// -/// and over the target sequences. Progress counts -/// sequences; checkpoint: sequence:frame. +/// and over the target sequences. Progress counts frames +/// across all targets, so the speed and time left follow the photos even inside a long sequence; checkpoint: +/// sequence:frame. /// internal sealed class ImageJobHandler(TitanoDatabase db, ArchiveImages images, JobKind kind) : IJobHandler { @@ -18,18 +19,29 @@ internal sealed class ImageJobHandler(TitanoDatabase db, ArchiveImages images, J var force = ArchiveJobJson.Read(context.Job, ArchiveJobJson.Default.ImageJobParameters, new ImageJobParameters(false)).Force; var (first, firstFrame) = Parse(context.Checkpoint); var targets = context.Job.TargetIds; + var sequences = new Sequence?[targets.Count]; + long total = 0; + for (var s = 0; s < targets.Count; s++) + { + sequences[s] = await db.Sequences.GetAsync(targets[s], context.Cancellation).ConfigureAwait(false); + total += sequences[s]?.FrameCount ?? 0; + } + long before = 0; + for (var s = 0; s < Math.Min(first, targets.Count); s++) before += sequences[s]?.FrameCount ?? 0; for (var s = first; s < targets.Count; s++) { context.Cancellation.ThrowIfCancellationRequested(); - if (await db.Sequences.GetAsync(targets[s], context.Cancellation).ConfigureAwait(false) is not { } sequence + if (sequences[s] is not { } sequence || await db.Archives.GetAsync(sequence.ArchiveId, context.Cancellation).ConfigureAwait(false) is not { } archive) { context.Log(Loc.L("Archive.Log.SequenceMissing", targets[s])); + before += sequences[s]?.FrameCount ?? 0; continue; } var index = s; + var offset = before; ValueTask Checkpoint(int nextFrame, int frames) => - context.CheckpointAsync(string.Create(CultureInfo.InvariantCulture, $"{index}:{nextFrame}"), index, targets.Count); + context.CheckpointAsync(string.Create(CultureInfo.InvariantCulture, $"{index}:{nextFrame}"), Math.Min(total, offset + nextFrame), total); var start = s == first ? firstFrame : 0; var result = kind == JobKind.Thumbs ? await images.BuildThumbnailsAsync(archive, sequence, force, start, Checkpoint, context.Cancellation).ConfigureAwait(false) @@ -37,7 +49,8 @@ internal sealed class ImageJobHandler(TitanoDatabase db, ArchiveImages images, J context.Log(kind == JobKind.Thumbs ? Loc.L("Archive.Log.ImagesDone", sequence.DisplayTitle, result.Built, result.Reused, result.Undecodable) : Loc.L("Archive.Log.ProxiesDone", sequence.DisplayTitle, result.Built, result.Reused, result.Undecodable, result.Waiting)); - await context.CheckpointAsync(string.Create(CultureInfo.InvariantCulture, $"{s + 1}:0"), s + 1, targets.Count).ConfigureAwait(false); + before += sequence.FrameCount; + await context.CheckpointAsync(string.Create(CultureInfo.InvariantCulture, $"{s + 1}:0"), Math.Min(total, before), total).ConfigureAwait(false); } } diff --git a/src/Titano.Data/Jobs/JobEngine.cs b/src/Titano.Data/Jobs/JobEngine.cs index 09a84eb0..c365e436 100644 --- a/src/Titano.Data/Jobs/JobEngine.cs +++ b/src/Titano.Data/Jobs/JobEngine.cs @@ -23,6 +23,9 @@ public sealed record JobEngineOptions /// Finished jobs older than this are purged (BRIEF §14.6: 90 days). public TimeSpan HistoryRetention { get; init; } = TimeSpan.FromDays(90); + + /// Clock of the throughput windows and the checkpoint interval (tests pass their own). + public TimeProvider Time { get; init; } = TimeProvider.System; } /// @@ -182,17 +185,29 @@ public sealed class JobEngine : IAsyncDisposable _shutdown.Dispose(); } + /// Broadcasts live progress. A subscriber that throws never fails the job it watches (logged once per job). internal void PublishProgress(JobContext context) { - var (rate, eta) = context.Rate(); - Progress?.Invoke(new JobProgressInfo(context.Job.Id, context.Job.Kind, context.Job.TargetLabel, context.Done, context.Total, rate, eta, context.Message)); - } - - internal async Task PersistAsync(JobContext context) - { - var (rate, eta) = context.Rate(); try { + var (rate, eta) = context.Rate(); + Progress?.Invoke(new JobProgressInfo(context.Job.Id, context.Job.Kind, context.Job.TargetLabel, context.Done, context.Total, rate, eta, context.Message)); + } + catch (Exception ex) + { + if (context.FirstProgressFailure()) Log.Warning("jobs", $"Progress of {context.Job.Kind} job {context.Job.Id} not published", ex); + } + } + + /// + /// Saves progress, checkpoint and log tail; false when the job no longer runs here (cancelled or paused elsewhere). + /// Saving is best effort and never throws: a failure is logged and the job goes on, so its final state is always written. + /// + internal async Task PersistAsync(JobContext context) + { + try + { + var (rate, eta) = context.Rate(); return await _db.Jobs.UpdateProgressAsync(context.Job.Id, context.Done, context.Total, rate, eta, context.Checkpoint, context.LogTail, CancellationToken.None) .ConfigureAwait(false); } @@ -201,6 +216,11 @@ public sealed class JobEngine : IAsyncDisposable Log.Warning("jobs", "Progress not saved (transient database error)", ex); return true; } + catch (Exception ex) + { + Log.Warning("jobs", $"Progress of {context.Job.Kind} job {context.Job.Id} not saved", ex); + return true; + } } /// True when this engine claims jobs of (it has a handler and the kind is not filtered out). diff --git a/src/Titano.Data/Jobs/JobHandler.cs b/src/Titano.Data/Jobs/JobHandler.cs index f78f9246..293cc7bc 100644 --- a/src/Titano.Data/Jobs/JobHandler.cs +++ b/src/Titano.Data/Jobs/JobHandler.cs @@ -1,4 +1,3 @@ -using System.Diagnostics; using System.Text; using Titano.Core.Model; @@ -39,23 +38,26 @@ public sealed class JobContext { private const int LogTailLines = 40; private readonly JobEngine _engine; - private readonly Stopwatch _clock = Stopwatch.StartNew(); + private readonly TimeProvider _time; + private readonly long _started; private readonly Queue _log = new(); private readonly Lock _gate = new(); - private long _lastPersistTicks; - private long _rateDone; - private double _rateSeconds; - private double? _rate; + private readonly JobThroughput _throughput; + private long _lastPersist; + private int _progressFailures; internal JobContext(JobEngine engine, Job job, CancellationToken cancellation) { _engine = engine; + _time = engine.Options.Time; + _started = _time.GetTimestamp(); + _lastPersist = _started; Job = job; Cancellation = cancellation; Checkpoint = job.Checkpoint; Done = job.ProgressDone; Total = job.ProgressTotal; - _rateDone = Done; + _throughput = new JobThroughput(Done); if (job.LogTail is { Length: > 0 } tail) { foreach (var line in tail.Split('\n')) _log.Enqueue(line); @@ -122,35 +124,25 @@ public sealed class JobContext } } - /// Throughput as a moving average over windows of at least two seconds, and the time left at that rate. + /// Throughput and time left (); never throws, whatever the progress reported. internal (double? Rate, TimeSpan? Eta) Rate() { - lock (_gate) - { - var seconds = _clock.Elapsed.TotalSeconds; - var span = seconds - _rateSeconds; - if (span >= 2 && Done >= _rateDone) - { - var sample = (Done - _rateDone) / span; - _rate = _rate is { } previous ? previous * 0.7 + sample * 0.3 : sample; - _rateDone = Done; - _rateSeconds = seconds; - } - TimeSpan? eta = _rate is > 0 && Total > Done ? TimeSpan.FromSeconds((Total - Done) / _rate.Value) : null; - return (_rate, eta); - } + lock (_gate) return _throughput.Sample(_time.GetElapsedTime(_started).TotalSeconds, Done, Total); } + /// True the first time publishing this job's progress failed, so the failure is logged once. + internal bool FirstProgressFailure() => Interlocked.Increment(ref _progressFailures) == 1; + private async ValueTask ReportCoreAsync(long done, long total, string? message, bool force) { Done = done; Total = total; Message = message; - var now = _clock.ElapsedTicks; - var due = now - Interlocked.Read(ref _lastPersistTicks) >= _engine.Options.CheckpointInterval.TotalSeconds * Stopwatch.Frequency; + var now = _time.GetTimestamp(); + var due = _time.GetElapsedTime(Interlocked.Read(ref _lastPersist), now) >= _engine.Options.CheckpointInterval; _engine.PublishProgress(this); if (!force && !due) return; - Interlocked.Exchange(ref _lastPersistTicks, now); + Interlocked.Exchange(ref _lastPersist, now); if (!await _engine.PersistAsync(this).ConfigureAwait(false)) _engine.StopJob(Job.Id); // cancelled or paused by someone else } diff --git a/src/Titano.Data/Jobs/JobThroughput.cs b/src/Titano.Data/Jobs/JobThroughput.cs new file mode 100644 index 00000000..c57fd529 --- /dev/null +++ b/src/Titano.Data/Jobs/JobThroughput.cs @@ -0,0 +1,58 @@ +namespace Titano.Data.Jobs; + +/// +/// Time left of a job: unknown (null) when nothing remains, the rate is unknown, or the result is not a finite duration +/// of at most . Every conversion of a stored or reported time left goes through here, so a stalled job +/// shows no time left instead of overflowing . +/// +public static class JobEta +{ + /// Longest time left worth showing; beyond it the job reads as stalled. + public static readonly TimeSpan Max = TimeSpan.FromDays(365); + + /// The time items take at . + public static TimeSpan? Of(long remaining, double? perSecond) => + remaining > 0 && perSecond is > 0 and var rate ? FromSeconds(remaining / rate) : null; + + /// A stored or reported number of seconds as a time left, or null when it is not a usable one. + public static TimeSpan? FromSeconds(double? seconds) => + seconds is { } s && double.IsFinite(s) && s >= 0 && s <= Max.TotalSeconds ? TimeSpan.FromSeconds(s) : null; +} + +/// +/// Throughput of a running job as a moving average over windows of at least two seconds. The first window that saw +/// progress seeds the average; each later window weighs 30 %. A window without progress lowers the rate, which tends to +/// zero without reaching it: below it reads as unknown, and the time left with it. +/// +internal sealed class JobThroughput(long done) +{ + private const double WindowSeconds = 2; + + /// Items per second below which a job counts as stalled. + internal const double MinRate = 1e-6; + + private long _done = done; + private double _seconds; + private double? _rate; + + /// Takes a sample at since the job started and returns the rate and time left. + public (double? Rate, TimeSpan? Eta) Sample(double seconds, long done, long total) + { + if (done < _done) + { + // Progress went back (a handler restarted its count): start a new window there. + _done = done; + _seconds = seconds; + } + else if (seconds - _seconds >= WindowSeconds) + { + var sample = (done - _done) / (seconds - _seconds); + if (_rate is { } previous) _rate = previous * 0.7 + sample * 0.3; + else if (sample > 0) _rate = sample; + _done = done; + _seconds = seconds; + } + var rate = _rate is >= MinRate ? _rate : null; + return (rate, JobEta.Of(total - done, rate)); + } +} diff --git a/src/Titano.Data/Jobs/JobWire.cs b/src/Titano.Data/Jobs/JobWire.cs index 40498295..a893598d 100644 --- a/src/Titano.Data/Jobs/JobWire.cs +++ b/src/Titano.Data/Jobs/JobWire.cs @@ -48,7 +48,7 @@ public static class JobWire ProgressDone = dto.ProgressDone, ProgressTotal = dto.ProgressTotal, ItemsPerSecond = dto.ItemsPerSecond, - Eta = dto.EtaSeconds is { } eta ? TimeSpan.FromSeconds(eta) : null, + Eta = JobEta.FromSeconds(dto.EtaSeconds), LogTail = dto.LogTail, NodeId = dto.NodeId, Attempts = dto.Attempts, diff --git a/src/Titano.Data/Processing/AnalysisFollowUp.cs b/src/Titano.Data/Processing/AnalysisFollowUp.cs index 771df7a0..2f44bd23 100644 --- a/src/Titano.Data/Processing/AnalysisFollowUp.cs +++ b/src/Titano.Data/Processing/AnalysisFollowUp.cs @@ -40,10 +40,14 @@ internal static class AnalysisFollowUp await context.EnqueueFollowUpAsync(request.Kind, request.Targets, request.Label, request.ParametersJson, request.Priority).ConfigureAwait(false); } - /// Sequences of without a current light analysis (new, adopted, or with frames a scan added). + /// + /// Sequences of without a current light analysis (new, adopted, or with frames a scan added), + /// and those with frames stored as GPR that are DNGs: the light analysis probes them again and records the DNG format + /// and its native tier (R4, owner review 1). + /// public static async Task> UnanalysedAsync(TitanoDatabase db, Guid archiveId, CancellationToken cancellationToken) { - var ids = new List(); + var ids = new List(await db.Frames.ListSequencesWithStaleGprAsync(archiveId, cancellationToken).ConfigureAwait(false)); var query = new SequenceQuery { ArchiveId = archiveId, WithoutStatus = SequenceStatus.AnalyzedLight, Sort = SequenceSort.Oldest, Limit = 1000 }; do { @@ -52,6 +56,6 @@ internal static class AnalysisFollowUp query = query with { Cursor = page.NextCursor }; } while (query.Cursor is not null); - return ids; + return [.. ids.Distinct()]; } } diff --git a/src/Titano.Data/Processing/RenderNodeClient.cs b/src/Titano.Data/Processing/RenderNodeClient.cs index c01cf157..9fa8c598 100644 --- a/src/Titano.Data/Processing/RenderNodeClient.cs +++ b/src/Titano.Data/Processing/RenderNodeClient.cs @@ -300,8 +300,11 @@ public sealed class RenderNodeClient : IAsyncDisposable } try { - var jpeg = await Task.Run(() => ArchiveImages.MakeProxy(_processing.Archive.Decoder, original, frame, camera, spec.LongEdge, spec.Quality, - cancellationToken), cancellationToken).ConfigureAwait(false); + var jpeg = await Task.Run(async () => + { + await Task.Yield(); + return ArchiveImages.MakeProxy(_processing.Archive.Decoder, original, frame, camera, spec.LongEdge, spec.Quality, cancellationToken); + }, cancellationToken).ConfigureAwait(false); if (jpeg is null) { unsent++; diff --git a/src/Titano.Data/Processing/SequenceFrameSource.cs b/src/Titano.Data/Processing/SequenceFrameSource.cs index bdf7591c..8ffcba43 100644 --- a/src/Titano.Data/Processing/SequenceFrameSource.cs +++ b/src/Titano.Data/Processing/SequenceFrameSource.cs @@ -191,7 +191,9 @@ internal sealed class SequenceFrameSource : IFrameSource, IRenderFrameSource, IA try { var companion = proxied ? null : Companions?.GetValueOrDefault(frame.Id); - decoded = _decoder.Decode(new DecodeRequest(file, maxLongEdge, purpose, Companion: companion), cancellationToken); + // Analyses and previews take an adequate embedded preview of a RAW (fast); renders develop it (R4, owner review 1). + decoded = _decoder.Decode(new DecodeRequest(file, maxLongEdge, purpose, Companion: companion, PreferPreview: purpose != DecodePurpose.Render), + cancellationToken); } catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { @@ -200,7 +202,8 @@ internal sealed class SequenceFrameSource : IFrameSource, IRenderFrameSource, IA return null; } // A file that vanished is missing, not undecodable (a verify flags it); only what decoding found is recorded. - if (Originals && !proxied && (decoded is not null || File.Exists(file))) + // A preview taken by choice says how these pixels were made, not what the file can give. + if (Originals && !proxied && decoded is not { ByChoice: true } && (decoded is not null || File.Exists(file))) { _observed[index] = decoded switch { diff --git a/src/Titano.Data/Repositories/FrameRepository.cs b/src/Titano.Data/Repositories/FrameRepository.cs index 61beae27..a8c715b2 100644 --- a/src/Titano.Data/Repositories/FrameRepository.cs +++ b/src/Titano.Data/Repositories/FrameRepository.cs @@ -23,7 +23,7 @@ public sealed record DuplicateFrame(string Sha256, Guid FrameId, Guid SequenceId public readonly record struct FrameLightStats(Guid FrameId, double? MeanLogLuminance, double? ClipLow, double? ClipHigh); /// Decode-tier fields of one frame (BRIEF §8.2): its flags and the stored size of its largest embedded preview. -public readonly record struct FrameTierFields(Guid FrameId, FrameFlags Flags, int PreviewWidth, int PreviewHeight); +public readonly record struct FrameTierFields(Guid FrameId, FrameFlags Flags, int PreviewWidth, int PreviewHeight, ImageFileFormat Format); /// Per-format totals and flagged-frame counts of one sequence. public sealed record SequenceFrameStats(IReadOnlyList ByFormat, long Missing, long Corrupt, long Duplicate, long Excluded); @@ -175,19 +175,20 @@ public sealed class FrameRepository for (var start = 0; start < frames.Count; start += Batch) { var count = Math.Min(Batch, frames.Count - start); - var sql = new StringBuilder("UPDATE frames AS f SET flags = v.fl, preview_width = v.w, preview_height = v.h FROM (VALUES "); - var args = new DbParam[count * 4]; + var sql = new StringBuilder("UPDATE frames AS f SET flags = v.fl, preview_width = v.w, preview_height = v.h, format = v.fmt FROM (VALUES "); + var args = new DbParam[count * 5]; for (var i = 0; i < count; i++) { var f = frames[start + i]; - sql.Append(i > 0 ? ", (" : "(").Append('$').Append(4 * i + 1).Append(", $").Append(4 * i + 2) - .Append(", $").Append(4 * i + 3).Append(", $").Append(4 * i + 4).Append(')'); - args[4 * i] = f.FrameId; - args[4 * i + 1] = (int)f.Flags; - args[4 * i + 2] = f.PreviewWidth; - args[4 * i + 3] = f.PreviewHeight; + sql.Append(i > 0 ? ", (" : "(").Append('$').Append(5 * i + 1).Append(", $").Append(5 * i + 2) + .Append(", $").Append(5 * i + 3).Append(", $").Append(5 * i + 4).Append(", $").Append(5 * i + 5).Append(')'); + args[5 * i] = f.FrameId; + args[5 * i + 1] = (int)f.Flags; + args[5 * i + 2] = f.PreviewWidth; + args[5 * i + 3] = f.PreviewHeight; + args[5 * i + 4] = (int)f.Format; } - sql.Append(") AS v(id, fl, w, h) WHERE f.id = v.id"); + sql.Append(") AS v(id, fl, w, h, fmt) WHERE f.id = v.id"); updated += await session.ExecuteAsync(sql.ToString(), args, cancellationToken).ConfigureAwait(false); } } @@ -195,8 +196,8 @@ public sealed class FrameRepository { foreach (var f in frames) { - updated += await session.ExecuteAsync("UPDATE frames SET flags = $2, preview_width = $3, preview_height = $4 WHERE id = $1", - [f.FrameId, (int)f.Flags, f.PreviewWidth, f.PreviewHeight], cancellationToken).ConfigureAwait(false); + updated += await session.ExecuteAsync("UPDATE frames SET flags = $2, preview_width = $3, preview_height = $4, format = $5 WHERE id = $1", + [f.FrameId, (int)f.Flags, f.PreviewWidth, f.PreviewHeight, (int)f.Format], cancellationToken).ConfigureAwait(false); } } return updated; @@ -263,6 +264,16 @@ public sealed class FrameRepository "ORDER BY f.sha256, s.first_capture, f.sequence_id, f.idx", [archiveId], r => new DuplicateFrame(r.GetString(0), r.GetGuid(1), r.GetGuid(2), r.GetInt32(3), r.GetString(4)), cancellationToken); + /// + /// Sequences of an archive with frames stored as GPR whose file is not a .gpr: indexed before GoPro DNGs converted by + /// Adobe software counted as DNG (R4, owner review 1); their next light analysis probes them again. + /// + public Task> ListSequencesWithStaleGprAsync(Guid archiveId, CancellationToken cancellationToken = default) => + _db.ListAsync( + "SELECT DISTINCT f.sequence_id FROM frames f JOIN sequences s ON s.id = f.sequence_id " + + "WHERE s.archive_id = $1 AND f.format = $2 AND lower(f.file_name) NOT LIKE '%.gpr'", + [archiveId, (int)ImageFileFormat.Gpr], r => r.GetGuid(0), cancellationToken); + /// Frames of an archive that carry every bit of . public Task> ListFlaggedAsync(Guid archiveId, FrameFlags flags, CancellationToken cancellationToken = default) => _db.ListAsync( diff --git a/src/Titano.Data/Repositories/JobRepository.cs b/src/Titano.Data/Repositories/JobRepository.cs index 1226f9dc..acf1f804 100644 --- a/src/Titano.Data/Repositories/JobRepository.cs +++ b/src/Titano.Data/Repositories/JobRepository.cs @@ -1,5 +1,6 @@ using System.Globalization; using Titano.Core.Model; +using Titano.Data.Jobs; namespace Titano.Data.Repositories; @@ -209,7 +210,7 @@ public sealed class JobRepository ProgressDone = r.GetInt64(7), ProgressTotal = r.GetInt64(8), ItemsPerSecond = r.GetDoubleOrNull(9), - Eta = r.GetDoubleOrNull(10) is { } seconds ? TimeSpan.FromSeconds(seconds) : null, + Eta = JobEta.FromSeconds(r.GetDoubleOrNull(10)), Checkpoint = r.GetStringOrNull(11), LogTail = r.GetStringOrNull(12), CreatedBy = r.GetGuidOrNull(13), diff --git a/src/Titano.Server/Jobs/RenderNodeService.cs b/src/Titano.Server/Jobs/RenderNodeService.cs index 4bb8a0d8..2fd11956 100644 --- a/src/Titano.Server/Jobs/RenderNodeService.cs +++ b/src/Titano.Server/Jobs/RenderNodeService.cs @@ -2,6 +2,7 @@ using System.Globalization; using System.Text.Json; using Titano.Core.Model; using Titano.Data; +using Titano.Data.Jobs; using Titano.Data.Repositories; using Titano.Protocol; using Titano.Server.Api; @@ -99,13 +100,14 @@ public sealed class RenderNodeService( { if (await OwnedNodeAsync(caller, nodeId, cancellationToken) is not { } node) return Outcome.Fail(404, "not_found", "node"); if (await AssignedJobAsync(node, jobId, cancellationToken) is not { } job) return Outcome.Fail(409, "job_not_assigned"); - double? eta = progress.ItemsPerSecond is > 0 && progress.Total > progress.Done ? (progress.Total - progress.Done) / progress.ItemsPerSecond.Value : null; + // A node reports any rate (a tiny one when it stalls): only a usable time left is stored and broadcast. + var rate = progress.ItemsPerSecond is { } r && double.IsFinite(r) && r > 0 ? r : (double?)null; + var eta = JobEta.Of(progress.Total - progress.Done, rate); var tail = AppendLog(job.LogTail, progress.LogLine); - if (!await db.Jobs.UpdateNodeProgressAsync(jobId, NodeKey(node), progress.Done, progress.Total, progress.ItemsPerSecond, - eta is { } seconds ? TimeSpan.FromSeconds(seconds) : null, tail, cancellationToken)) + if (!await db.Jobs.UpdateNodeProgressAsync(jobId, NodeKey(node), progress.Done, progress.Total, rate, eta, tail, cancellationToken)) return Outcome.Fail(409, "job_not_assigned"); await TouchAsync(node, cancellationToken); - events.Publish(new JobProgressEvent(jobId, progress.Done, progress.Total, progress.ItemsPerSecond, eta)); + events.Publish(new JobProgressEvent(jobId, progress.Done, progress.Total, rate, eta?.TotalSeconds)); return true; } diff --git a/tests/Titano.App.Tests/Editor/ProjectStoreTests.cs b/tests/Titano.App.Tests/Editor/ProjectStoreTests.cs index 6fd23079..9ad8357a 100644 --- a/tests/Titano.App.Tests/Editor/ProjectStoreTests.cs +++ b/tests/Titano.App.Tests/Editor/ProjectStoreTests.cs @@ -289,6 +289,44 @@ public sealed class ProjectStoreTests(TestContext context) } /// A temporary archive with one adopted folder of synthetic JPEGs, indexed. + /// + /// A decode superseded by a newer edit (R4, owner review 1): the caller sees a cancellation, never an unreadable frame, + /// and the provider's cancellation stays inside the source's own task. + /// + [Test] + public async Task ACancelledDecodeIsACancellationNotAnUnreadableFrame() + { + var (db, sequenceId, _) = await ArchiveAsync(4); + await using (db) + { + var entered = new TaskCompletionSource(); + var blocking = new ImageDecoder([new BlockingProvider(entered)]); + var options = new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) }; + await using var source = new LocalSequenceSource(db, sequenceId, blocking, null, options); + await source.LoadAsync(context.Cancellation); + using var cts = new CancellationTokenSource(); + var decode = source.DecodeAsync(1, 64, DecodePurpose.Proxy, cts.Token).AsTask(); + await entered.Task.WaitAsync(TimeSpan.FromSeconds(10)); + await cts.CancelAsync(); + await Assert.ThrowsAsync(() => decode); + } + } + + /// Decodes nothing until its token is cancelled, then throws the cancellation, as WIC does between bands. + private sealed class BlockingProvider(TaskCompletionSource entered) : IImageDecoderProvider + { + public string Name => "blocking"; + public DecodeTier? TierFor(ImageFileFormat format) => DecodeTier.Native; + + public DecodedImage? Decode(DecodeRequest request, CancellationToken cancellationToken = default) + { + entered.TrySetResult(); + cancellationToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(10)); + cancellationToken.ThrowIfCancellationRequested(); + return null; + } + } + private async Task<(TitanoDatabase Db, Guid SequenceId, string Root)> ArchiveAsync(int frames) { var directory = context.CreateTempDirectory("editor"); diff --git a/tests/Titano.App.Tests/Editor/SchedulingTests.cs b/tests/Titano.App.Tests/Editor/SchedulingTests.cs index 0132922e..80a17bec 100644 --- a/tests/Titano.App.Tests/Editor/SchedulingTests.cs +++ b/tests/Titano.App.Tests/Editor/SchedulingTests.cs @@ -48,6 +48,25 @@ public sealed class SchedulingTests Assert.True(first.IsCompletedSuccessfully, "a superseded run ends quietly"); } + /// Synchronous work that throws when superseded (the export estimates) ends quietly as well (R4, owner review 1). + [Test] + public async Task ASupersededSynchronousRunEndsQuietly() + { + using var runner = new LatestRunner(TimeSpan.Zero); + var started = new ManualResetEventSlim(); + var first = runner.Schedule(token => + { + started.Set(); + token.WaitHandle.WaitOne(TimeSpan.FromSeconds(10)); + token.ThrowIfCancellationRequested(); + return Task.CompletedTask; + }); + Assert.True(started.Wait(TimeSpan.FromSeconds(10))); + var second = runner.Schedule(_ => Task.CompletedTask); + await Task.WhenAll(first, second); + Assert.True(first.IsCompletedSuccessfully, "a superseded run ends quietly"); + } + [Test] public async Task ImmediateRequestsSkipTheDelay() { diff --git a/tests/Titano.App.Tests/Jobs/JobListModelTests.cs b/tests/Titano.App.Tests/Jobs/JobListModelTests.cs index be90578c..dc319bbf 100644 --- a/tests/Titano.App.Tests/Jobs/JobListModelTests.cs +++ b/tests/Titano.App.Tests/Jobs/JobListModelTests.cs @@ -1,4 +1,5 @@ using System.Globalization; +using Titano.App.Infrastructure; using Titano.App.Jobs; using Titano.Core.Localization; using Titano.Core.Model; @@ -154,7 +155,11 @@ public sealed class JobListModelTests }; Assert.Equal("Render · Harbour sunset · 2,232 / 3,600 · 11.3 fps · 2 min left", JobText.Bar(running)); Assert.Equal("2 min", JobText.Left(running, 0)); - Assert.Equal("118/s", JobText.Speed(JobKind.Import, 118)); + // Imports and verifies count bytes; scans count folders; frame jobs read in fps (owner review 1). + Assert.Equal("118 B/s", JobText.Speed(JobKind.Import, 118)); + Assert.Equal(JobText.Speed(JobKind.Verify, 57_000_000), Loc.L("Jobs.Speed.Bytes", Formatting.Bytes(57_000_000))); + Assert.Equal("4/s", JobText.Speed(JobKind.Scan, 4)); + Assert.Equal("1.7 fps", JobText.Speed(JobKind.Proxies, 1.7)); Assert.Equal(string.Empty, JobText.Speed(JobKind.Render, null)); Assert.Equal("this PC", JobText.Where("STUDIO#2", "studio")); Assert.Equal("render-box", JobText.Where("render-box", "studio")); diff --git a/tests/Titano.Core.Tests/Decoding/ManagedDecoderProviderTests.cs b/tests/Titano.Core.Tests/Decoding/ManagedDecoderProviderTests.cs index aa161f84..cbb677f8 100644 --- a/tests/Titano.Core.Tests/Decoding/ManagedDecoderProviderTests.cs +++ b/tests/Titano.Core.Tests/Decoding/ManagedDecoderProviderTests.cs @@ -306,6 +306,57 @@ public sealed class ManagedDecoderProviderTests(TestContext context) Assert.Throws(() => DecoderFactory.CreateServer().Decode(new DecodeRequest(Path.Combine(_dir, "vanished.jpg")))); } + /// + /// The owner's archive (R4, owner review 1): GoPro DNGs converted by Lightroom or DNG Converter carry a full-size JPEG + /// preview in IFD0 and a lossless or lossy raw image in a SubIFD. They are DNGs, developed natively; only a VC-5 raw + /// image (or the .gpr extension) makes a GPR. + /// + [Test] + public void AGoProDngIsGprOnlyWhenItsRawImageIsVc5() + { + using var scene = SyntheticRaw.Smooth(W, H); + var converted = Write("GOPR0100.dng", SyntheticDng.Write(scene, new DngSpec { Make = "GoPro", RawInSubIfd = true, PreviewJpeg = JpegFile(W, H, 1) })); + Assert.Equal(ImageFileFormat.Dng, Signature(converted)); + using (var decoded = DecoderFactory.CreateServer().Decode(new DecodeRequest(converted))) + Assert.Equal((DecodeTier.Native, "managed-dng"), (decoded!.Tier, decoded.Decoder)); + + var vc5 = new IfdSpec().Long(TiffTags.NewSubfileType, 0).Long(TiffTags.ImageWidth, 64).Long(TiffTags.ImageLength, 48) + .Short(TiffTags.BitsPerSample, 16).Short(TiffTags.Compression, 9).Short(TiffTags.PhotometricInterpretation, 32803); + var gpr = Write("GOPR0101.dng", TiffFile.Build(Fixtures.Ifd0("GoPro", "HERO8 Black", 1).Bytes(TiffTags.DngVersion, 1, 4, 0, 0).Child(TiffTags.SubIfds, vc5))); + Assert.Equal(ImageFileFormat.Gpr, Signature(gpr)); + var renamed = Write("GOPR0102.GPR", File.ReadAllBytes(converted)); + Assert.Equal(ImageFileFormat.Gpr, Signature(renamed)); + } + + private static ImageFileFormat Signature(string path) + { + using var stream = File.OpenRead(path); + return ImageSignature.Detect(stream, path); + } + + [Test] + public void APreferredPreviewIsTakenByChoiceOnlyWhenItIsLargeEnough() + { + using var scene = SyntheticRaw.Smooth(W, H); + var dng = Write("preview.dng", SyntheticDng.Write(scene, new DngSpec { RawInSubIfd = true, PreviewJpeg = JpegFile(W, H, 1) })); + var server = DecoderFactory.CreateServer(); + + // Analysis size within the preview: the preview, marked as taken by choice (the frame still decodes natively). + using (var quick = server.Decode(new DecodeRequest(dng, MaxLongEdge: 48, Purpose: DecodePurpose.Analysis, PreferPreview: true))) + { + Assert.Equal((DecodeTier.EmbeddedPreview, "managed-preview", true), (quick!.Tier, quick.Decoder, quick.ByChoice)); + Assert.Equal(48, quick.Pixels.Width); + } + // Larger than the preview, or no size limit: developed. + using (var native = server.Decode(new DecodeRequest(dng, MaxLongEdge: 4 * W, Purpose: DecodePurpose.Analysis, PreferPreview: true))) + Assert.Equal((DecodeTier.Native, "managed-dng", false), (native!.Tier, native.Decoder, native.ByChoice)); + using (var whole = server.Decode(new DecodeRequest(dng, PreferPreview: true))) + Assert.Equal((DecodeTier.Native, false), (whole!.Tier, whole.ByChoice)); + // Renders never prefer the preview. + using (var render = server.Decode(new DecodeRequest(dng, MaxLongEdge: 48))) + Assert.Equal((DecodeTier.Native, "managed-dng", false), (render!.Tier, render.Decoder, render.ByChoice)); + } + /// A GoPro GPR as far as Titano reads it: a DNG made by "GoPro" whose only decodable image is a YCbCr JPEG preview. private static byte[] Gpr(int previewWidth, int previewHeight) { diff --git a/tests/Titano.Core.Tests/Raw/SyntheticRaw.cs b/tests/Titano.Core.Tests/Raw/SyntheticRaw.cs index b8c16155..07f36387 100644 --- a/tests/Titano.Core.Tests/Raw/SyntheticRaw.cs +++ b/tests/Titano.Core.Tests/Raw/SyntheticRaw.cs @@ -186,6 +186,12 @@ internal sealed record DngSpec /// Put the raw image in a SubIFD behind an IFD0 thumbnail, like camera DNGs. public bool RawInSubIfd { get; init; } + /// With : IFD0 holds this JPEG as the embedded preview (like Adobe-converted DNGs). + public byte[]? PreviewJpeg { get; init; } + + /// IFD0 Make. + public string Make { get; init; } = "Titano"; + /// Raw-value transform applied after mosaicking (e.g. the inverse of a gain map), stored-unit domain. public Func? RawTransform { get; init; } } @@ -301,7 +307,25 @@ internal static class SyntheticDng if (spec.OpcodeList3 is { } o3) raw.Add(TiffTags.OpcodeList3, TiffType.Undefined, o3.Length, o3); var ifd0 = raw; - if (spec.RawInSubIfd) + if (spec.RawInSubIfd && spec.PreviewJpeg is { } jpeg) + { + if (output.Position % 2 != 0) output.WriteByte(0); + var offset = output.Position; + output.Write(jpeg); + var info = Titano.Core.Codecs.Jpeg.JpegDecoder.ReadInfo(jpeg); + ifd0 = new TiffDirectory(); + ifd0.Long(TiffTags.NewSubfileType, 1); + ifd0.Long(TiffTags.ImageWidth, (uint)info.Width); + ifd0.Long(TiffTags.ImageLength, (uint)info.Height); + ifd0.Short(TiffTags.BitsPerSample, 8, 8, 8); + ifd0.Short(TiffTags.Compression, 7); + ifd0.Short(TiffTags.PhotometricInterpretation, 6); + ifd0.Short(TiffTags.SamplesPerPixel, 3); + ifd0.Long(TiffTags.StripOffsets, (uint)offset); + ifd0.Long(TiffTags.StripByteCounts, (uint)jpeg.Length); + ifd0.Child(TiffTags.SubIfds, raw); + } + else if (spec.RawInSubIfd) { ifd0 = new TiffDirectory(); ifd0.Long(TiffTags.NewSubfileType, 1); @@ -315,7 +339,7 @@ internal static class SyntheticDng ifd0.Long(TiffTags.StripByteCounts, 48); ifd0.Child(TiffTags.SubIfds, raw); } - ifd0.Ascii(TiffTags.Make, "Titano"); + ifd0.Ascii(TiffTags.Make, spec.Make); ifd0.Ascii(TiffTags.Model, "Synthetic"); ifd0.Short(TiffTags.Orientation, spec.Orientation); ifd0.Bytes(TiffTags.DngVersion, 1, 6, 0, 0); diff --git a/tests/Titano.Data.Tests/Archiving/PartialRowWriterTests.cs b/tests/Titano.Data.Tests/Archiving/PartialRowWriterTests.cs index 5014e921..daa423e2 100644 --- a/tests/Titano.Data.Tests/Archiving/PartialRowWriterTests.cs +++ b/tests/Titano.Data.Tests/Archiving/PartialRowWriterTests.cs @@ -473,7 +473,7 @@ public abstract class PartialRowWriterTests(TestContext context) : DatabaseTest( ManifestStore.WriteSequence(folder.ManifestPath, tiered); var first = tiered.Frames[0]; await tx.Sequences.RecordTiersAsync(sequence.Id, SequenceStatus.None, 1, fx.Ct); - await tx.Frames.UpdateTiersAsync([new FrameTierFields(first.Id, first.Flags, first.PreviewW ?? 0, first.PreviewH ?? 0)], fx.Ct); + await tx.Frames.UpdateTiersAsync([new FrameTierFields(first.Id, first.Flags, first.PreviewW ?? 0, first.PreviewH ?? 0, first.Format)], fx.Ct); await tx.CommitAsync(fx.Ct); } Assert.SequenceEqual([sequence.Id], (await scan).Sequences); diff --git a/tests/Titano.Data.Tests/Jobs/JobThroughputTests.cs b/tests/Titano.Data.Tests/Jobs/JobThroughputTests.cs new file mode 100644 index 00000000..0ff61454 --- /dev/null +++ b/tests/Titano.Data.Tests/Jobs/JobThroughputTests.cs @@ -0,0 +1,147 @@ +using Titano.Core.Model; +using Titano.Data.Jobs; +using Titano.Protocol; +using Titano.Testing; + +namespace Titano.Data.Tests.Jobs; + +/// A clock the test moves by hand (BCL , no package). +internal sealed class ManualTime : TimeProvider +{ + private long _ticks; + + public override long TimestampFrequency => TimeSpan.TicksPerSecond; + + public override long GetTimestamp() => Interlocked.Read(ref _ticks); + + public void Advance(TimeSpan by) => Interlocked.Add(ref _ticks, by.Ticks); +} + +[Category("jobs")] +public sealed class JobThroughputTests(TestContext context) +{ + [Test] + public void TheFirstWindowWithProgressSeedsTheRate() + { + var throughput = new JobThroughput(0); + Assert.Null(throughput.Sample(2, 0, 100).Rate); + var (rate, eta) = throughput.Sample(4, 10, 100); + Assert.Equal(5.0, rate); + Assert.Equal(TimeSpan.FromSeconds(18), eta); + } + + [Test] + public void AStalledJobLosesItsRateAndTimeLeftWithoutOverflowing() + { + // The owner's log: one sequence of 17 done, then a long one checkpointed every 10 s without moving the count. + var throughput = new JobThroughput(0); + throughput.Sample(600, 1, 17); + (double? Rate, TimeSpan? Eta) last = default; + for (var i = 1; i <= 2000; i++) last = throughput.Sample(600 + i * 10, 1, 17); + Assert.Null(last.Rate); + Assert.Null(last.Eta); + } + + [Test] + public void ProgressThatGoesBackStartsANewWindow() + { + var throughput = new JobThroughput(0); + throughput.Sample(2, 20, 100); + throughput.Sample(3, 5, 100); + var (rate, _) = throughput.Sample(5, 15, 100); + Assert.Approximately(0.7 * 10 + 0.3 * 5, rate!.Value, 1e-9); + } + + [Theory] + [Case(double.NaN)] + [Case(double.PositiveInfinity)] + [Case(-1.0)] + [Case(1e300)] + [Case(4e7)] + public void UnusableSecondsGiveNoTimeLeft(double seconds) => Assert.Null(JobEta.FromSeconds(seconds)); + + [Test] + public void UsableSecondsAndRatesGiveTheTimeLeft() + { + Assert.Equal(TimeSpan.FromSeconds(90), JobEta.FromSeconds(90)); + Assert.Equal(TimeSpan.FromSeconds(4), JobEta.Of(8, 2)); + Assert.Null(JobEta.Of(0, 2)); + Assert.Null(JobEta.Of(8, null)); + Assert.Null(JobEta.Of(8, 1e-300)); + } + + [Test] + public void ServerTimeLeftBeyondTheMaximumReadsUnknown() + { + var dto = new JobDto(Guid.NewGuid(), "render", [], null, "running", "normal", 1, 17, 1e-11, 1e300, null, null, 0, null, + DateTimeOffset.UtcNow, null, null); + Assert.Null(JobWire.FromDto(dto)!.Eta); + } + + [Test] + public async Task AJobWhoseCountStallsForHoursStillEndsDone() + { + var time = new ManualTime(); + var reported = new List(); + await using var db = await TitanoDatabase.OpenAsync(DatabaseOptions.Sqlite(Path.Combine(context.CreateTempDirectory(), "jobs.db")), context.Cancellation); + var handler = new CallbackHandler(JobKind.Proxies, async c => + { + time.Advance(TimeSpan.FromSeconds(600)); + await c.CheckpointAsync("1:0", 1, 17); + for (var frame = 1; frame <= 400; frame++) + { + time.Advance(TimeSpan.FromSeconds(11)); + await c.CheckpointAsync($"1:{frame}", 1, 17); + } + }); + await using var engine = new JobEngine(db, [handler], new JobEngineOptions { Workers = 1, WorkerId = "t", Time = time }); + engine.Progress += p => + { + lock (reported) reported.Add(p); + }; + await engine.StartAsync(); + var job = await engine.EnqueueAsync(JobKind.Proxies, [Guid.NewGuid()]); + var done = await WaitForAsync(db, job.Id, JobState.Done); + Assert.Null(done.Eta); + Assert.Null(done.ItemsPerSecond); + lock (reported) Assert.Null(reported[^1].Eta); + } + + [Test] + public async Task AProgressSubscriberThatThrowsNeverFailsTheJob() + { + await using var db = await TitanoDatabase.OpenAsync(DatabaseOptions.Sqlite(Path.Combine(context.CreateTempDirectory(), "jobs.db")), context.Cancellation); + var handler = new CallbackHandler(JobKind.Verify, async c => + { + for (var i = 1; i <= 5; i++) await c.CheckpointAsync(i.ToString(System.Globalization.CultureInfo.InvariantCulture), i, 5); + }); + await using var engine = new JobEngine(db, [handler], new JobEngineOptions { Workers = 1, WorkerId = "t" }); + engine.Progress += _ => throw new InvalidOperationException("broken subscriber"); + await engine.StartAsync(); + var first = await engine.EnqueueAsync(JobKind.Verify, [Guid.NewGuid()]); + var second = await engine.EnqueueAsync(JobKind.Verify, [Guid.NewGuid()]); + Assert.Equal(5L, (await WaitForAsync(db, first.Id, JobState.Done)).ProgressDone); + await WaitForAsync(db, second.Id, JobState.Done); + } + + private sealed class CallbackHandler(JobKind kind, Func run) : IJobHandler + { + public JobKind Kind => kind; + + public Task RunAsync(JobContext context) => run(context); + } + + private static async Task WaitForAsync(TitanoDatabase db, Guid id, JobState state) + { + var until = DateTime.UtcNow.AddSeconds(15); + Job? job = null; + while (DateTime.UtcNow < until) + { + job = await db.Jobs.GetAsync(id); + if (job?.State == state) return job; + await Task.Delay(20); + } + Assert.Fail($"Job {id} is {job?.State}, not {state}"); + return null!; + } +} diff --git a/tests/Titano.Data.Tests/Processing/AnalysisJobTests.cs b/tests/Titano.Data.Tests/Processing/AnalysisJobTests.cs index 05f0416c..d5c94413 100644 --- a/tests/Titano.Data.Tests/Processing/AnalysisJobTests.cs +++ b/tests/Titano.Data.Tests/Processing/AnalysisJobTests.cs @@ -708,6 +708,60 @@ public sealed class AnalysisJobTests(TestContext context) Assert.Empty(SequenceAnalyser.ReadReport(fx.Folder(sequence), sequence.FrameCount)!.Issues.Undecodable); } + /// + /// The owner's archive (R4, owner review 1): GoPro DNGs converted by Adobe software were indexed as GPR and recorded + /// preview-only. The scan follow-up lists their sequences again, and the light analysis probes them: they become + /// DNGs decoded natively, in the sidecar and the index. + /// + [Test] + public async Task GoProDngsIndexedAsGprAreProbedAgainAndBecomeNativeDngs() + { + await using var fx = await ProcessingFixture.CreateAsync(context); + var card = Path.Combine(context.CreateTempDirectory("card"), "DCIM", "100GOPRO"); + Directory.CreateDirectory(card); + var start = new DateTime(2024, 10, 11, 18, 0, 0); + for (var i = 0; i < 3; i++) + { + var metadata = new FrameMetadata { Make = "GoPro", Model = "HERO8 Black", BodySerial = "C3441", CapturedAt = start.AddSeconds(5 * i) }; + using var sensor = new ImageBuffer(64, 48); + sensor.Plane(1).Fill(0.2f + 0.1f * i); + File.WriteAllBytes(Path.Combine(card, $"GOPR{i + 1:0000}.dng"), + LinearDngWriter.Write(sensor, new LinearDngOptions { Exif = ExifWriter.BuildTiff(metadata), TileSize = 64 })); + } + var service = fx.Archive.Service; + var plan = await service.PlanImportAsync(fx.Archive.Archive.Id, Path.GetDirectoryName(Path.GetDirectoryName(card))!, new ImportOptions(), + cancellationToken: fx.Ct); + await service.Imports.ExecuteAsync(new ImportJobParameters(fx.Archive.Archive.Id, plan, null, true, null), Guid.NewGuid(), 0, + _ => ValueTask.CompletedTask, null, fx.Ct); + var session = plan.Sessions.Single(); + Assert.Equal(ImageFileFormat.Dng, session.Format); + var id = await fx.Db.Sequences.FindBySessionKeyAsync(fx.Archive.Archive.Id, session.SessionKey, fx.Ct); + var sequence = (await fx.Db.Sequences.GetAsync(id!.Value, fx.Ct))!; + + // What an index from before owner review 1 holds: GPR, preview-only, already light-analysed. + var folder = fx.Folder(sequence); + var manifest = ManifestStore.ReadSequence(folder.ManifestPath); + ManifestStore.WriteSequence(folder.ManifestPath, manifest with + { + Frames = [.. manifest.Frames.Select(f => f with { Format = ImageFileFormat.Gpr, Tier = DecodeTier.EmbeddedPreview, Flags = f.Flags | FrameFlags.PreviewOnly, PreviewW = 64, PreviewH = 48 })], + }); + var rows = await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct); + await fx.Db.Frames.UpdateTiersAsync([.. rows.Select(r => new FrameTierFields(r.Id, r.Flags | FrameFlags.PreviewOnly, 64, 48, ImageFileFormat.Gpr))], fx.Ct); + await fx.Db.Sequences.UpsertAsync(sequence with { Status = sequence.Status | SequenceStatus.AnalyzedLight }, fx.Ct); + Assert.Contains(sequence.Id, await AnalysisFollowUp.UnanalysedAsync(fx.Db, fx.Archive.Archive.Id, fx.Ct)); + + await fx.StartEngineAsync(); + var light = await fx.EnqueueAsync(ProcessingJobs.LightAnalysis([sequence.Id])); + await fx.WaitForAsync(light.Id, JobState.Done); + var sidecar = ManifestStore.ReadSequence(folder.ManifestPath).Frames; + Assert.True(sidecar.All(f => f is { Format: ImageFileFormat.Dng, Tier: DecodeTier.Native } && (f.Flags & FrameFlags.PreviewOnly) == 0), + string.Join(", ", sidecar.Select(f => $"{f.Format}/{f.Tier}/{f.Flags}"))); + var indexed = await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct); + Assert.True(indexed.All(f => f.Format == ImageFileFormat.Dng && (f.Flags & FrameFlags.PreviewOnly) == 0), "the index follows"); + Assert.Equal(0, (await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!.PreviewOnlyCount); + Assert.DoesNotContain(sequence.Id, await AnalysisFollowUp.UnanalysedAsync(fx.Db, fx.Archive.Archive.Id, fx.Ct)); + } + [Test] public async Task DeepAnalysisNeverFlagsFramesThatVanishedOrCouldNotBeRead() { diff --git a/tests/Titano.Data.Tests/Repositories/CatalogRepositoryTests.cs b/tests/Titano.Data.Tests/Repositories/CatalogRepositoryTests.cs index b9bd4b22..d95a3c5b 100644 --- a/tests/Titano.Data.Tests/Repositories/CatalogRepositoryTests.cs +++ b/tests/Titano.Data.Tests/Repositories/CatalogRepositoryTests.cs @@ -323,7 +323,7 @@ public abstract class CatalogRepositoryTests(TestContext context) : RepositoryTe var frames = Enumerable.Range(0, count).Select(i => TestData.Frame(sequence.Id, i) with { Flags = FrameFlags.Duplicate }).ToList(); await db.Frames.BulkInsertAsync(frames, Ct); - var tiers = frames.Select(f => new FrameTierFields(f.Id, f.Index % 2 == 0 ? FrameFlags.PreviewOnly : FrameFlags.Undecodable, 1620 + f.Index, 1080)).ToList(); + var tiers = frames.Select(f => new FrameTierFields(f.Id, f.Index % 2 == 0 ? FrameFlags.PreviewOnly : FrameFlags.Undecodable, 1620 + f.Index, 1080, f.Format)).ToList(); Assert.Equal(count, await db.Frames.UpdateTiersAsync(tiers, Ct)); var read = await Titano.Data.Processing.SequenceFrames.ListAsync(db, sequence.Id, Ct); Assert.SequenceEqual(tiers.Select(t => (t.Flags, t.PreviewWidth, t.PreviewHeight)), read.Select(f => (f.Flags, f.PreviewWidth, f.PreviewHeight))); diff --git a/tests/Titano.Server.Tests/Api/SequenceTests.cs b/tests/Titano.Server.Tests/Api/SequenceTests.cs index 31226433..ef8eed1a 100644 --- a/tests/Titano.Server.Tests/Api/SequenceTests.cs +++ b/tests/Titano.Server.Tests/Api/SequenceTests.cs @@ -327,7 +327,7 @@ public sealed class SequenceTests(TestContext context) } // What a light analysis on the server records for CR3s it reads only through their previews. var frames = await db.Frames.ListBySequenceAsync(first.SequenceId); - await db.Frames.UpdateTiersAsync([.. frames.Select(f => new Titano.Data.Repositories.FrameTierFields(f.Id, Titano.Core.Model.FrameFlags.PreviewOnly, 1620, 1080))]); + await db.Frames.UpdateTiersAsync([.. frames.Select(f => new Titano.Data.Repositories.FrameTierFields(f.Id, Titano.Core.Model.FrameFlags.PreviewOnly, 1620, 1080, f.Format))]); var sequence = (await db.Sequences.GetAsync(first.SequenceId))!; await db.Sequences.UpsertAsync(sequence with { PreviewOnlyCount = 2 });