From 3ef91ec45af2e29aa1e4ff0e0471494aec88b8ba Mon Sep 17 00:00:00 2001 From: Triwarr <170976175+Triwarr@users.noreply.github.com> Date: Sun, 8 Nov 2026 02:41:37 +0100 Subject: [PATCH] PDF: widen the dense-page cancellation margin Raise the synthetic page to a million strokes so the 45 ms watcher threshold keeps a wide margin on an optimised test build, and record why the importer keeps one RenderCache per page. --- crates/io/src/pdf_import.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/io/src/pdf_import.rs b/crates/io/src/pdf_import.rs index d4c8aa4eac..d55676ac16 100644 --- a/crates/io/src/pdf_import.rs +++ b/crates/io/src/pdf_import.rs @@ -147,6 +147,9 @@ pub fn import(name: &str, bytes: &[u8], opts: &ImportOptions, ctl: &Interrupt) - if width > raster::MAX_SIDE || height > raster::MAX_SIDE || u64::from(width) * u64::from(height) > raster::MAX_PIXELS { return Err(IoError::Unsupported(format!("PDF page {page_number} is too large at {dpi:.0} dpi; lower the import DPI"))); } + // A cache per page, deliberately: a shared one would keep decoded images and fonts alive + // across up to 16 pages outside the pixel budget, and would hide an image-decode warning + // on a later page after the page that first hit it. let cache = RenderCache::new(); let options = raster::Options { scale: [(dpi / 72.0) as f32; 2], @@ -347,10 +350,11 @@ mod tests { } /// Hundreds of thousands of path operators take far longer than the watcher's polling - /// interval, so the interrupt lands mid-render and the page reports Cancelled. + /// interval, so the interrupt lands mid-render and the page reports Cancelled. A million + /// strokes leaves a wide margin even on a fast, optimised test build. #[test] fn a_dense_page_stops_when_the_interrupt_fires_mid_render() { - let pdf = dense_operator_pdf(300_000).expect("writing the dense PDF"); + let pdf = dense_operator_pdf(1_000_000).expect("writing the dense PDF"); let document = craft_pdf::open_slice_with_options(&pdf, None, &craft_pdf::OpenOptions::default()).expect("the dense PDF opens"); let cache = RenderCache::new(); let options =