Commit Graph
8500 Commits
Author SHA1 Message Date
FredApps afa0a86341 psd: widen staged RLE data to PSB in short reads, never reading it back whole 2026-11-03 13:06:09 +01:00
FredApps 0a528eea19 automation: remove the temp file on every exit but a rename, a panicking writer included
A drop guard armed only once this call created the temp file replaces the error-path
remove_file, so a writer panic no longer leaves a temp file and a create_new collision
never removes a file this call did not make.
2026-11-03 12:16:23 +01:00
FredApps be3b2918c3 raster: checksum stage-file appends and fail a read pass over changed bytes
Like the tile scratch file, each append records a CRC-32; a save copying it (whole or
in consecutive parts) fails on the last part if the scratch disk returned different
bytes, so the document is never replaced with them.
2026-11-03 12:16:23 +01:00
FredApps 7cffeef725 Merge remote-tracking branch 'upstream/main' into pr-5333 2026-11-03 11:16:05 +01:00
FredApps 503aa60f5a Merge pull request #10897 from wanikhawar/fix/adaptive-psd-memory
Size PSD import memory limits from available RAM
2026-11-03 11:14:59 +01:00
FredApps d1f112c38e automation: stream workspace saves instead of buffering the encoded file
AuthorizedWorkspace::write_stream keeps write()'s refusals and atomic replace but
lets the encoder write (and seek back) straight into the temp file, so an
automation PSB save no longer builds the whole file in a Vec.
2026-11-03 10:49:38 +01:00
FredApps dbcee2ba47 io: stage encoded PSD/PSB channels on the scratch disk for large saves
Each colour channel and the merged image is parked in a scratch stage file as
soon as it is encoded (documents of 1 GiB+ raw pixels, chunks of 64 KiB+), so a
save no longer holds every encoded plane in memory before #8115's checked write.
The written file is byte-identical; when staging is unavailable the data stays
in memory.
2026-11-03 10:49:38 +01:00
FredApps 4b27da939f raster: anonymous append-only stage file on the scratch disk
Shares ScratchFile's private open (0600, unlinked at once, delete-on-close on
Windows) so encoded save data can be parked off the heap and read back by offset.
2026-11-03 10:49:38 +01:00
FredApps 2bad559628 psd: copy source-backed channel and merged data through in short reads
A channel or merged image still in its source (an imported file's, or one
spilled to scratch) is copied to the output in 8 MiB pieces instead of being
read whole into memory first.
2026-11-03 10:33:52 +01:00
FredApps 5f70428dfc Merge storytold/main (d0bff086d) into PR #10897 branch
Resolve conflicts with #5331 (EXR streaming): the block-by-block EXR import now
reads from the same identity-verified handle as the rest of the open path, and
docs/scratch-disks.md keeps both the EXR streaming pointer and the RAM/scratch
admission notes.
2026-11-03 10:33:10 +01:00
FredApps d077cd14fc Merge remote-tracking branch 'upstream/main' into pr-5333
# Conflicts:
#	crates/codecs/src/exr_stream.rs
#	crates/codecs/tests/it/exr_stream.rs
#	crates/io/src/exr_native.rs
#	crates/io/src/lib.rs
#	crates/io/tests/it/streaming_exr.rs
#	docs/roadmap.md
#	docs/scorecard.md
#	docs/scratch-disks.md
#	docs/streaming-io.md
#	scorecard/reliability.toml
2026-11-03 10:28:35 +01:00
FredApps d0bff086d6 Merge pull request #5331 from vistaero/codex/psd-exr-streaming
Stream native PSD/PSB and EXR imports through bounded bands
2026-11-03 10:07:47 +01:00
FredApps d3e4bcd03d Merge main into codex/streamed-psb-save (rescope onto #8115)
Rescope: this merge takes main's tree as is. The stacked #5331 commit
(streaming PSD import reader, EXR, duplicate atomic/streaming save infra,
the try_reserve_operation export pre-check) and the #5332 GPU commit stay in
their own PRs; main's Services::save_file/SaveCtl and #8115's streamed PSD
writer replace this branch's save plumbing. The band-wise PSB writer is
re-added on top in the next commit.
2026-11-03 10:04:00 +01:00
FredApps 75e967b467 Merge pull request #8115 from VishnuByrraju/fix/save-memory-6607
Save: stop doubling the encoded file in memory (#6607)
2026-11-03 10:03:07 +01:00
FredApps 3695186329 Consolidate RAM detection in raster::memory::system; scratch-aware PSD/TIFF admission
One RAM detector: the cgroup v1/v2, macOS reclaimable and Windows commit providers move from
photocraft-io into photocraft_raster::memory::system (L0), which the residency budget (#5330)
and photocraft_io::memory both read. Unreadable container limits still fail closed, swap is
never counted as RAM. sysinfo is unified on =0.40.1 (raster only).

While the scratch disk is spilling (on, not paused), import admission credits the tile pixels
of an estimate against spill::scratch_capacity() (free space above the reserve, within the
Scratch Size Limit); decode buffers, conversion copies and merged planes stay RAM-only. Spilling
off/paused and the web keep the RAM-only policy unchanged. PsdMemoryEstimate gains tile_bytes;
the flat TIFF streaming check credits its tile surface the same way; engine approveMemory's
fast pre-check uses the credited hard limit and the import re-checks exactly.
2026-11-03 09:48:22 +01:00
FredApps 05fc07b538 Merge main into fix/save-memory-6607
Resolve against main's save restructure (Services::save_file/SaveCtl, scratch-integrity checks,
ZipWriter::with_entries, exact encoded_len):
- PSD/PSB saves stream the file model through atomic_write_stream_progress; the length used for
  progress and reservations is main's exact encoded_len (the PR's size_bound under-counted lazy
  data); export_with/encode_with share checked_stages, so main's scratch checks (previews
  included) still refuse unreadable scratch.
- Drop ZipWriter::for_entries in favour of main's with_entries.
- TIFF: take_from_psd moves layer data out of the export's own model (never the document);
  body() reserves its exact length, failures are OutOfMemory (not LimitExceeded, which would
  trigger the PSB retry).
- Streaming writer: AlreadyExists from the writer is a failed save, not a name collision.
- Remove dead Vec put_widened_rle; channel_data_len is test-only.
2026-11-03 09:23:16 +01:00
FredApps 7e29a9999c Wire EXR band streaming into main's path open
- import_file_for_open_with decodes single-part flat scanline EXR block by block into
  tiles; headers the band decoder refuses fall back to the whole-file decoder, so files
  main opened still open. Band-time failures and cancellation publish no document.
- The RAM tile budget and scratch-disk checks live in exr_native (the PSD stream module
  they came from is dropped); over-budget opens fail with IoError::OutOfMemory.
- The band decoder picks colour channels with exr_color_channels, like the byte decoder.
- Tests move into the per-crate it binaries and use import_file; an engine open-job test
  covers the OpenSource::Path route. The ui-egui sync open test is dropped: main's
  synchronous open reads bytes, and the io test covers the oversized header.
- docs/streaming-io.md, roadmap, scratch-disks and REL-212-1 describe EXR only.
2026-11-03 09:23:15 +01:00
FredApps fdab6c0a33 Merge remote-tracking branch 'upstream/main' into pr-5331 2026-11-03 09:06:31 +01:00
FredApps f7b7e7f618 Rescope to EXR streaming: drop the separate PSD/PSB reader, seekable outputs and export pre-check
Main already opens PSD/PSB from the file in bands (4915f0970, #5106) through
psd_to_document_owned, which keeps damaged-file flagging, failed-layer drops,
type-layer setup and the PSD pixel budget; PSD limits are handled in #10778.
This drops the second PSD/PSB stream reader (psd::stream, io::psd_stream),
the seekable PSB writer and atomic stream helpers, the authorized-workspace
seekable open plumbing and the working-memory pre-check that refused
ordinary exports. The flat scanline EXR band decoder and its tests stay and
are wired into main's path open after merging main.
2026-11-03 09:06:31 +01:00
Khawar Zamman Wani 259b5590ae Merge origin/main (655295b2a2) into PR #10897 branch
Keep the PSD memory admission work and upstream's scratch storage
together. Conflicts resolved:
- Cargo.lock: both sysinfo versions are required. 0.40.1 serves
  photocraft-io's adaptive import budget; 0.37.2 serves
  photocraft-raster's scratch volume and memory supervision. Cargo
  metadata resolved the lock with no other changes.
- crates/engine/src/lib.rs: Session keeps pending_preflights and
  next_pending_preflight beside scratch_runtime and scratch_epoch.
  Session derives Default, so neither set needs a manual initializer.

Upstream: 655295b2a2
2026-11-03 12:54:59 +05:30
Khawar Zamman Wani da41a65811 docs: document PSD memory admission and open queue functions
(cherry picked from commit 07c6a3f87cff39dde8ec2b334f4e9b388667bfc8)
2026-11-03 12:51:53 +05:30
FredApps 655295b2a2 Merge pull request #5330 from vistaero/codex/scratch-storage
Add guarded scratch storage and owned memory supervision
2026-11-03 08:16:41 +01:00
FredApps f4d8886f6e Refuse scripted .pcraft saves whose previews read unreadable scratch
The automation .pcraft save renders the previews and main's optional
full-size composite before the bundle writer takes its scratch snapshot,
so a tile that failed and recovered in between could be saved as
placeholder pixels. Check the document's scratch health and the read-error
generation around that render, as io's export path already does.
2026-11-03 07:19:16 +01:00
FredApps 8ce599da3a Merge remote-tracking branch 'upstream/main' into pr-5330 2026-11-03 07:12:38 +01:00
Khawar Zamman Wani d8e0dde8b5 fix: pass footage import options to the single-file fallback
`load_frames`'s single-file path called `file_cmds::import`, which uses default
import options, so the footage command's lowered PSD/layered-TIFF memory limit
never reached a single-page layered TIFF or PSD. Multi-page TIFF pages already
passed their `opts`.

Give the engine import one shared `import_result_with` path and an
`import_with_options` entry that keep the allocation checkpoint, native
`.pcraft` and format dispatch, typed memory refusals and the preview-only
refusal; the existing `import` delegates with default options, so every other
caller behaves exactly as before. The single-file fallback now passes `opts`.

Add a command-level regression: a single-page layered TIFF under a thread-scoped
`psd_max_pixel_bytes` of 1 must reach `file.import.videoFramesToLayers` as a
typed `EngineError::PsdHardBudget` with its name, required and limit fields
intact and the document unchanged, then import as one frame when the limit is
not lowered.
2026-11-03 10:41:03 +05:30
Dylan M. Taylor c6af3dcb98 Merge pull request #9913 from dotCooCoo/feat/pcraft-full-composite
Save the flattened document at full size into .pcraft files as an option
2026-11-02 23:29:23 -05:00
Khawar Zamman Wani 06d00e06a9 fix: keep multipage TIFF frames inside the footage budget and refusals typed
The multi-page TIFF branch of `load_frames` pushed each flattened page
straight into `frames`, bypassing the `keep` closure, so `MAX_FOOTAGE_BYTES`
was never checked for those pages: many large pages could retain more than
the cap without an error. Route every flattened page through `keep`, with the
same file-context error mapping as the single-file and GIF/WebP paths, and
keep typed page admission refusals typed.

Add command-level regressions. A per-thread test scope lowers the footage and
PSD limits, so neither test allocates gibibytes: one proves an over-budget
multi-page TIFF is refused with nothing imported, and one proves a page with
Photoshop layer data reaches `file.import.videoFramesToLayers` as a typed
`EngineError::PsdHardBudget` with its name, required and limit fields intact
and the document unchanged.
2026-11-03 09:33:29 +05:30
Khawar Zamman Wani 27e0735af6 Revert "fix: apply special Fill semantics to CMYK adjustment layers"
This reverts commit b8621fd1ca.

The CMYK adjustment-layer Fill fix is independent of the PSD/TIFF memory
admission work and ships in its own PR. Reverting it here keeps this
branch's compose tree identical to main.
2026-11-03 08:36:10 +05:30
Khawar Zamman Wani dcd21f81b4 fix: keep multipage TIFF page memory refusals typed
The multipage TIFF import loop mapped every page-import error to EngineError::Other, so a PsdApprovalRequired or PsdImportBudget from a layered page reached the UI, control channel and agents as text only, without the required/limit fields. Route those two through io_open_error and keep the page-specific text for every other error.
2026-11-03 08:21:00 +05:30
dotCooCoo fef15729aa Merge main into feat/pcraft-full-composite
Main now takes the manifest envelope from craft-pcraft-format, which has
no full_composite member. The save writes the member after the envelope
when it writes composite/full.png, and read_full_composite reads it back.
2026-11-02 17:02:14 -08:00
Brandon ThomasandClaude Opus 5.5 327c4cc82e Release 0.20.1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
v0.20.1
2026-11-02 19:47:05 -05:00
Brandon ThomasandClaude Opus 5.5 eed8bd27d2 Packaging: run the cross-built CLI's --version check without the malloc re-exec
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 19:47:01 -05:00
Brandon ThomasandClaude Opus 5.5 24d4f4db9f Release 0.20.0
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 19:27:12 -05:00
FredApps ed681787c3 Add a Scratch Size Limit preference and honour the web memory cap in the memory policy 2026-11-03 01:16:52 +01:00
FredApps c9478d0501 Expect the Windows scratch entry until its delete-on-close handle closes
Windows keeps delete-on-close (unlinking an open file is not portable there), so a
live scratch file still has a directory entry. Only Unix unlinks it right after
opening. Check that the directory is empty once the file is closed on both.
2026-11-03 00:54:09 +01:00
FredApps 51e9bed8b7 Borrow guarded tile bytes in the profile dither from main
Main's new profile dither (8a0f959d2) matched on the tile bytes by value inside the
per-pixel loop. On this branch Tile::bytes returns a TileBytes guard rather than a
slice, so borrow it for the loop instead, and compare the test's tiles as owned
bytes since the guard has no Debug or PartialEq.
2026-11-03 00:13:34 +01:00
FredApps fb684cd114 Merge remote-tracking branch 'upstream/main' into pr-5330 2026-11-03 00:02:18 +01:00
FredApps 9eddf1d8ca Pause and retry a failed or full scratch disk instead of turning spilling off
A scratch write or create failure, or a volume about to drop below max(1 GiB, 5%)
free space, now pauses spilling with exponential backoff (1 s doubling to 60 s)
instead of disabling it for the session. Tiles stay resident, set_budget keeps
the latest budget for the resume, preference changes retry at once, and
spill::epoch lets the engine re-apply History's byte limit while paused.
spill::set_size_cap adds an explicit size limit; free space comes from sysinfo's
disk feature.
2026-11-02 22:31:56 +01:00
FredApps 44f13e5498 Scope scratch read failures to the document that holds the tile
One unreadable tile used to block editing, saving and exporting every open document
(spill::check_integrity was process-global). Add Tile/Surface/Document::scratch_health
(free while no tile has failed) and Document::for_each_surface (ops' history walk now
delegates to it). edit_with checks the document before and after, jobs the document they
captured, import the result, save/export the document written; check_since is now
generation-only so a failure or recovery during an operation refuses it once and a retry
works. Caches check their own sources and purge once per new failure instead of every
frame. Fault-injection tests use a duplicated handle (the Unix file has no name).
2026-11-02 22:23:42 +01:00
FredApps 947038d0db Unlink Unix scratch files right after opening
The spill manager is process-global and never dropped, so the Unix scratch file was only
removed by the next launch's reap. Unlink it immediately after opening and read/write
through the one handle with pread/pwrite (readers can no longer reopen it by path).
Windows keeps delete-on-close and per-thread readers. The abrupt-exit test now asserts
that no file remains on every platform; docs/scratch-disks.md updated.
2026-11-02 22:17:50 +01:00
FredApps 13271f58fa Size filter working sets by area and serialize overlapping operations
working_bytes reserved three 256 MiB result groups for every filter, so two
concurrent filters on a 24x18 image could exhaust the transient allowance and
actions.play reported 'not enough working memory'. Bound the result groups by
the area, charge only untiled RSS when resident tiles are evictable, always admit
the transient allowance, and let an operation that fits on its own wait (bounded,
30 s, native only) for concurrent reservations instead of failing.

Replace the deprecated AtomicU64::fetch_update with try_update (stable since
1.95, the MSRV).
2026-11-02 22:16:32 +01:00
FredApps b0f3c7516b Merge current main into codex/scratch-storage
Resolve conflicts with main's prefs UI split, session/execute.rs move, GPU memory
budget (gpuMemoryMb, 0 = auto, kept from main) and effective_memory_usage_mb history
budget. Port the Memory Usage % and Scratch Disks preferences into prefs_ui, the edit
integrity guard into session/execute.rs, and adapt main's new pixel readers to the
guarded TileBytes API. Cargo.lock regenerated; scorecard regenerated.
2026-11-02 22:16:22 +01:00
Khawar Zamman Wani ac14963dd2 test: pass display names separately from source paths on memory retry 2026-11-03 02:17:39 +05:30
Khawar Zamman Wani 03cbe19f08 fix: clear assertion lints and UI test borrow errors 2026-11-03 01:49:57 +05:30
aiongg b957878f3f Merge pull request #10776 from davidmann4/integration-batch-12
Integration batch 12: 14 Actions PRs on main
2026-11-02 15:13:40 -05:00
Khawar Zamman Wani e97480ac76 fix: synchronize test dependencies and repair CI compile diagnostics 2026-11-03 01:31:34 +05:30
Khawar Zamman Wani 5992650b36 fix: address PSD admission review and enable platform memory consent 2026-11-03 01:26:13 +05:30
David Mann 673bfb4d9c Merge remote-tracking branch 'origin/main' into integration-batch-12
# Conflicts:
#	docs/file-format-parity.md
2026-11-02 20:15:23 +01:00
FredApps f8e393fdb6 Merge pull request #6266 from danielmigueltejedor/fix/gnome-window-decorations
Enable font-free GNOME/Wayland controls for system title bars
2026-11-02 19:59:41 +01:00
9034223c4b TIFF: open YCbCr images as RGB (#10316) (#10319)
* TIFF: open YCbCr images as RGB (#10316)

Scanners often write JPEG-compressed YCbCr TIFFs with 2x2 chroma
subsampling. The tiff crate decodes and upsamples them but returns raw
YCbCr samples, which the decoder rejected with "colour type YCbCr(8)".

The new tiff/ycbcr.rs converts them to RGB after decoding: JPEG data
uses the JFIF full-range BT.601 conversion (as libtiff does), other
compressions honour ReferenceBlackWhite and YCbCrCoefficients with the
TIFF defaults as fallback. 8 and 16-bit. YCbCr with extra samples, or
in other sample formats, fails with a clear unsupported error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Contributors: add Yuki-init's display name

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* TIFF YCbCr: test that YCbCrCoefficients set the luma weights

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* TIFF: YCbCr tags with the wrong value count use the defaults

tag_f64s now returns None unless the tag holds exactly n values, so a
YCbCrCoefficients or ReferenceBlackWhite tag with extra values falls
back to the TIFF defaults instead of being truncated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Lrgj5pnShYtsSnrsZq5iRn

* TIFF YCbCr: tests for tiled JPEG with ICC, big-endian 16-bit and planar

Covers the layouts the review asked for: a tiled 4:2:0 JPEG file with an
embedded profile (checked against an independent JPEG decoder), a
big-endian 16-bit file, and planar data in both byte orders.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Lrgj5pnShYtsSnrsZq5iRn

* TIFF YCbCr: cite the formula sources and pin the green-channel choice

Documents where the conversion comes from: TIFF 6.0 Section 21
(YCbCrCoefficients, pp. 90-91) and libtiff's tif_color.c
(TIFFYCbCrToRGBInit, TIFFYCbCrtoRGB). Red and blue follow the spec;
green follows libtiff and adds Y unscaled, which matches the spec only
when the luma weights sum to 1. The module doc records this as a
deliberate compatibility choice, and a new test pins it: with weights
0.25/0.25/0.25, mid gray stays (128, 128, 128).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Lrgj5pnShYtsSnrsZq5iRn

* Codecs README: YCbCr TIFFs with three 8- or 16-bit samples decode to RGB

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Lrgj5pnShYtsSnrsZq5iRn

* Format tiff_ycbcr tests with rustfmt

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(tiff): compare grouped YCbCr decoding and update support notes

* style(tiff): align grouped decode call with test formatting

* style(tiff): apply repository rustfmt to grouped YCbCr regression

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: FredApps <[email protected]>
Co-authored-by: FredApps <[email protected]>
2026-11-02 19:31:22 +01:00