From b2fafcf68ccca13e0236caa1f7f3d6add03a84b0 Mon Sep 17 00:00:00 2001 From: skylartaylor <26588250+skylartaylor@users.noreply.github.com> Date: Thu, 15 Oct 2026 04:27:54 +0200 Subject: [PATCH 1/4] ci: add comfortable runtime limits to unbounded jobs --- .github/workflows/ci.yml | 6 ++++++ .github/workflows/docs.yml | 1 + .github/workflows/packaging-lint.yml | 1 + 3 files changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bec29abaf5..07c11a4eb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,7 @@ jobs: # platform: the app shell, UI, text and fonts, GPU, pen input, build scripts or the lockfile. # macOS is tested only by release.yml. platforms: + timeout-minutes: 10 name: select platforms runs-on: ubuntu-latest outputs: @@ -77,6 +78,7 @@ jobs: fi test: + timeout-minutes: 100 name: test (${{ matrix.os }}) needs: platforms runs-on: ${{ matrix.os }} @@ -158,6 +160,7 @@ jobs: run: cargo xtask scorecard --check corpus: + timeout-minutes: 30 # Real-file corpus tests (cargo feature `corpus`), on every PR and on main. The corpora are # pinned in xtask/src/corpus_pins.rs and sha256-verified (xtask/*.sha256) after both a cache # restore and a download; a missing corpus fails the tests. The cache key changes only when a @@ -190,6 +193,7 @@ jobs: run: cargo xtask test-corpus wasm: + timeout-minutes: 30 name: wasm32 check runs-on: ubuntu-latest steps: @@ -206,6 +210,7 @@ jobs: run: cargo xtask wasm web: + timeout-minutes: 60 name: web build and wasm size gate # PRs run it only when web-relevant files change (see `platforms`); main always does. needs: platforms @@ -250,6 +255,7 @@ jobs: } >> "$GITHUB_STEP_SUMMARY" fuzz: + timeout-minutes: 60 name: fuzz (${{ matrix.target.crate }}/${{ matrix.target.name }}) # Placeholder: manual trigger only until a nightly schedule is enabled. if: github.event_name == 'workflow_dispatch' && inputs.fuzz diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1d6c4c1f56..67e6b31894 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -27,6 +27,7 @@ concurrency: jobs: build: + timeout-minutes: 15 name: mdBook build runs-on: ubuntu-latest steps: diff --git a/.github/workflows/packaging-lint.yml b/.github/workflows/packaging-lint.yml index 272715dc81..1d110e28f2 100644 --- a/.github/workflows/packaging-lint.yml +++ b/.github/workflows/packaging-lint.yml @@ -23,6 +23,7 @@ jobs: uses: storytold/craft-common-actions/.github/workflows/packaging-lint.yml@main verified-appimage-inputs: + timeout-minutes: 10 name: Verified AppImage inputs runs-on: ubuntu-latest steps: From 9660dca2637acd1252859db0ccf11cf28d9f5fdb Mon Sep 17 00:00:00 2001 From: David Mann Date: Thu, 15 Oct 2026 14:22:13 +0200 Subject: [PATCH 2/4] CI: run clippy, layers and scorecard checks before the tests (#6119) They take about 1.5 min together but ran after all the test passes, so a clippy failure (15 s) showed red only 41-48 min into the job. Same steps, reordered: no cost on a green run. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/ci.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dfc2564a59..a0b3360db3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,10 +111,24 @@ jobs: save-if: ${{ github.ref == 'refs/heads/main' }} cache-on-failure: true + # The cheap checks run first: a format, lint, layering or stale-scorecard failure is red + # after a few minutes instead of after the test passes (#6119). Clippy restores main's cache. - name: Format if: runner.os == 'Linux' run: cargo fmt --all -- --check + - name: Clippy + run: cargo clippy --workspace --all-targets --locked --features heif -- -D warnings + + - name: Dependency layering + run: cargo xtask layers + + # docs/scorecard.md must match its sources (checklists, budgets, baseline, corpus floors, + # prefs audit). Static: it reads committed files only, no benchmarks run here. + - name: Scorecard up to date + if: runner.os == 'Linux' + run: cargo xtask scorecard --check + # `--features heif`: official builds open HEIC photos via the optional photocraft-heif crate. - name: Test run: cargo test --workspace --locked --features heif @@ -145,18 +159,6 @@ jobs: CRAFT_FONTS_REQUIRED: "1" run: cargo test --workspace --locked --features heif - - name: Clippy - run: cargo clippy --workspace --all-targets --locked --features heif -- -D warnings - - - name: Dependency layering - run: cargo xtask layers - - # docs/scorecard.md must match its sources (checklists, budgets, baseline, corpus floors, - # prefs audit). Static: it reads committed files only, no benchmarks run here. - - name: Scorecard up to date - if: runner.os == 'Linux' - run: cargo xtask scorecard --check - corpus: # Real-file corpus tests (cargo feature `corpus`), on every PR and on main. The corpora are # pinned in xtask/src/corpus_pins.rs and sha256-verified (xtask/*.sha256) after both a cache From 4e7a17cd5d5723313f459753663d0d155f047e19 Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Thu, 15 Oct 2026 08:18:21 -0600 Subject: [PATCH 3/4] fix(compose): serialize effect identity cache misses Keep effect-identity memo lookup, pure hashing and insertion atomic across concurrent render callers. Preserve existing identities and add a contention regression with eight synchronized callers. --- crates/compose/src/lib.rs | 12 ++++++------ crates/compose/src/tests.rs | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/crates/compose/src/lib.rs b/crates/compose/src/lib.rs index f688ffedb3..3cf2f1dc19 100644 --- a/crates/compose/src/lib.rs +++ b/crates/compose/src/lib.rs @@ -563,14 +563,14 @@ impl LayerKeys { fn identity(&self, layer: &Layer, doc: Option<&Document>) -> u64 { let addr = std::ptr::from_ref(layer) as usize; let in_doc = doc.is_some_and(|d| self.in_doc.get_or_init(|| doc_layer_addresses(d)).contains(&addr)); - if in_doc && let Some(id) = self.ids.lock().unwrap_or_else(|e| e.into_inner()).get(&addr) { - return *id; - } - let id = self.compute(layer); if in_doc { - self.ids.lock().unwrap_or_else(|e| e.into_inner()).insert(addr, id); + let mut ids = self.ids.lock().unwrap_or_else(|e| e.into_inner()); + // Computing an identity only hashes immutable layer data; it does not run Rayon + // work or re-enter this memo. Keep the miss and insertion atomic across callers. + *ids.entry(addr).or_insert_with(|| self.compute(layer)) + } else { + self.compute(layer) } - id } fn compute(&self, layer: &Layer) -> u64 { diff --git a/crates/compose/src/tests.rs b/crates/compose/src/tests.rs index eb4b250728..ddd4871548 100644 --- a/crates/compose/src/tests.rs +++ b/crates/compose/src/tests.rs @@ -3190,3 +3190,27 @@ fn effect_cache_keeps_no_pixels_of_a_dropped_layer() { assert_eq!(std::sync::Arc::strong_count(&own), 1); assert_eq!(std::sync::Arc::strong_count(&child), 1); } + +// Concurrent callers share one memoized effect identity. +#[test] +fn concurrent_effect_identity_misses_compute_once() { + let mut doc = identity_doc(SampleType::U8); + // Make the existing pure identity hash long enough to expose overlapping misses. + doc.layers[1].effects.items = vec![Effect::DropShadow(shadow(4.0, 120.0)); 512]; + let layer = &doc.layers[1]; + let keys = LayerKeys::default(); + let start = std::sync::Barrier::new(8); + std::thread::scope(|scope| { + let handles: Vec<_> = (0..8) + .map(|_| { + scope.spawn(|| { + start.wait(); + keys.identity(layer, Some(&doc)) + }) + }) + .collect(); + let ids: Vec<_> = handles.into_iter().map(|h| h.join().unwrap()).collect(); + assert!(ids.iter().all(|id| *id == ids[0])); + }); + assert_eq!(keys.built.load(std::sync::atomic::Ordering::Relaxed), 1, "concurrent cache misses must compute one memoized identity"); +} From c06eca9b681ff362bd83c0ca0cf189f1f6e42153 Mon Sep 17 00:00:00 2001 From: midasmatterhorn <248507632+midasmatterhorn@users.noreply.github.com> Date: Thu, 15 Oct 2026 20:23:57 +0300 Subject: [PATCH 4/4] fix(psd): preserve PSB foreign-order block lengths Choose PSB block length width from the canonical big-endian key before converting the key for little-endian TIFF output. Preserve foreign payloads, padding and conversion of following blocks. Addresses #5599, finding 2 only. Fixes #6104. --- crates/psd/src/tiff.rs | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/crates/psd/src/tiff.rs b/crates/psd/src/tiff.rs index 67142921ba..31c85d4885 100644 --- a/crates/psd/src/tiff.rs +++ b/crates/psd/src/tiff.rs @@ -681,13 +681,12 @@ pub mod transcode { if !self.from.is_little() && TaggedBlock::is_foreign_order_signature(self.r.peek_rest()) { let sig = self.r.array::<4>()?; let mut key = self.r.array::<4>()?; - let long = uses_long_length(self.version, &{ - let mut k = key; - if self.to.is_little() { - k.reverse(); - } - k - }); + // Only reached with `from == Big`: the key is canonical here whatever the + // target order. `TaggedBlock::write` sizes the length field from that same key. + // Reversing it for the target order before the check + // asked about a key `PSB_LONG_KEYS` never contains, so a PSB long key's 8-byte + // length was read as 4 and every later block was copied unconverted. + let long = uses_long_length(self.version, &key); let len = self.r.len_field(long)?; let data = self.r.bytes_u64(len)?; if self.to.is_little() { @@ -2211,6 +2210,25 @@ mod tests { assert_eq!(ImageSourceData::from_bytes(&big).unwrap().0.global_blocks, back.global_blocks); } + /// A PSB keeps `Mt16`/`Mt32`/`Mtrn`/`Alph` blocks of unknown layout verbatim, and their + /// length field is 8 bytes (a PSB long key). Writing them into a little-endian TIFF must + /// read that width; the old code looked the key up after reversing it for the target + /// order, which never matches `PSB_LONG_KEYS`. + #[test] + fn psb_foreign_order_long_key_roundtrips() { + let d = ImageSourceData { + version: Version::Psb, + byte_order: ByteOrder::Little, + global_blocks: vec![TaggedBlock { signature: *b"MIB8", key: *b"Mt16", data: vec![9, 8, 7, 6, 5, 4], padding: None }], + ..Default::default() + }; + let (little, w) = d.to_bytes(ByteOrder::Little).unwrap(); + assert!(w.is_empty(), "{w:?}"); + let (back, w) = ImageSourceData::from_bytes(&little).unwrap(); + assert!(w.is_empty(), "{w:?}"); + assert_eq!(back.global_blocks, d.global_blocks, "the 8-byte length and the bytes survive"); + } + #[test] fn rle_counts_follow_the_container_and_samples_do_not() { let file = testgen::layered(Version::Psd, ColorMode::Rgb, 16, Compression::Rle);