From 6485116bca1996db2d33d2bea58135f527fa7f04 Mon Sep 17 00:00:00 2001 From: mertan-wq <235487900+mertan-wq@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:10:54 +0300 Subject: [PATCH 1/5] print: winprint 64e7afd4, whose Direct2D factory is multi-threaded Windows.Data.Pdf draws a page on several of its own worker threads, which share the print control's device context. With winprint 5f80b9b's single-threaded factory Direct2D takes no locks, so those threads race in d2d1.dll and the app closes while printing, most often on pages with Type 3 fonts (storytold/pdfcraft#5006, storytold/pdfcraft#2684). storytold/winprint.rs#11 made the factory multi-threaded; it was merged as 64e7afd4. craft-winprint-gdi moves to the same revision, so one checkout of winprint.rs serves both; crates/gdi is unchanged between 417ac3c and 64e7afd4. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 4 ++-- crates/print/Cargo.toml | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c9994c69..598d3002c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1225,7 +1225,7 @@ dependencies = [ [[package]] name = "craft-winprint-gdi" version = "0.1.0" -source = "git+https://github.com/storytold/winprint.rs?rev=417ac3c4d14d3da5485a99c7d5ce8f05664ec312#417ac3c4d14d3da5485a99c7d5ce8f05664ec312" +source = "git+https://github.com/storytold/winprint.rs?rev=64e7afd4d1483512385012c340ecaaaf0f3beb7f#64e7afd4d1483512385012c340ecaaaf0f3beb7f" dependencies = [ "windows-sys 0.61.2", ] @@ -7034,7 +7034,7 @@ dependencies = [ [[package]] name = "winprint" version = "0.2.1" -source = "git+https://github.com/storytold/winprint.rs?rev=5f80b9baf6b58937c401656634e42d33f00ddf49#5f80b9baf6b58937c401656634e42d33f00ddf49" +source = "git+https://github.com/storytold/winprint.rs?rev=64e7afd4d1483512385012c340ecaaaf0f3beb7f#64e7afd4d1483512385012c340ecaaaf0f3beb7f" dependencies = [ "flate2", "fmt-derive", diff --git a/crates/print/Cargo.toml b/crates/print/Cargo.toml index cd3dd0c41..61d4c7cf0 100644 --- a/crates/print/Cargo.toml +++ b/crates/print/Cargo.toml @@ -9,7 +9,7 @@ description = "System PDF print spooler for the Craft apps: CUPS and Windows" [dependencies] # Safe API; Win32 calls are isolated in this maintained MIT OR Apache-2.0 dependency. -craft-winprint-gdi = { git = "https://github.com/storytold/winprint.rs", rev = "417ac3c4d14d3da5485a99c7d5ce8f05664ec312" } +craft-winprint-gdi = { git = "https://github.com/storytold/winprint.rs", rev = "64e7afd4d1483512385012c340ecaaaf0f3beb7f" } [lints] workspace = true @@ -23,9 +23,10 @@ log = "0.4" # and the job (Windows.Data.Pdf drawn with Direct2D into the XPS print API, options as a # PrintTicket) are safe wrappers over Win32 and WinRT (BSD-3-Clause). Its default `pdfium` # feature downloads PDFium at build time and is off. The maintained BSD-3-Clause fork -# preserves terminal failures/cancellation and bounds the completion notification wait. -# Pinned to an immutable revision; review before bumping. -winprint = { git = "https://github.com/storytold/winprint.rs", rev = "5f80b9baf6b58937c401656634e42d33f00ddf49", default-features = false } +# preserves terminal failures/cancellation and bounds the completion notification wait, and +# creates the Direct2D factory multi-threaded, since Windows.Data.Pdf draws on its own worker +# threads (storytold/pdfcraft#5006). Pinned to an immutable revision; review before bumping. +winprint = { git = "https://github.com/storytold/winprint.rs", rev = "64e7afd4d1483512385012c340ecaaaf0f3beb7f", default-features = false } # GetDefaultPrinter (MIT). winsafe = { version = "0.0.29", default-features = false, features = ["winspool"] } # The job file's private folder. From e398084b63413aa5d872da43496f0c0822cb749a Mon Sep 17 00:00:00 2001 From: Zhihui Song Date: Sat, 7 Nov 2026 14:44:13 +0800 Subject: [PATCH 2/5] print: take stream loading alongside the multithreaded Direct2D fix --- Cargo.lock | 4 ++-- crates/print/Cargo.toml | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 598d3002c..506a38cb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1225,7 +1225,7 @@ dependencies = [ [[package]] name = "craft-winprint-gdi" version = "0.1.0" -source = "git+https://github.com/storytold/winprint.rs?rev=64e7afd4d1483512385012c340ecaaaf0f3beb7f#64e7afd4d1483512385012c340ecaaaf0f3beb7f" +source = "git+https://github.com/storytold/winprint.rs?rev=17f5f1e3c5038be6bd122df36fc5b5aa2672502c#17f5f1e3c5038be6bd122df36fc5b5aa2672502c" dependencies = [ "windows-sys 0.61.2", ] @@ -7034,7 +7034,7 @@ dependencies = [ [[package]] name = "winprint" version = "0.2.1" -source = "git+https://github.com/storytold/winprint.rs?rev=64e7afd4d1483512385012c340ecaaaf0f3beb7f#64e7afd4d1483512385012c340ecaaaf0f3beb7f" +source = "git+https://github.com/storytold/winprint.rs?rev=17f5f1e3c5038be6bd122df36fc5b5aa2672502c#17f5f1e3c5038be6bd122df36fc5b5aa2672502c" dependencies = [ "flate2", "fmt-derive", diff --git a/crates/print/Cargo.toml b/crates/print/Cargo.toml index 61d4c7cf0..24037f6b4 100644 --- a/crates/print/Cargo.toml +++ b/crates/print/Cargo.toml @@ -9,7 +9,7 @@ description = "System PDF print spooler for the Craft apps: CUPS and Windows" [dependencies] # Safe API; Win32 calls are isolated in this maintained MIT OR Apache-2.0 dependency. -craft-winprint-gdi = { git = "https://github.com/storytold/winprint.rs", rev = "64e7afd4d1483512385012c340ecaaaf0f3beb7f" } +craft-winprint-gdi = { git = "https://github.com/storytold/winprint.rs", rev = "17f5f1e3c5038be6bd122df36fc5b5aa2672502c" } [lints] workspace = true @@ -25,8 +25,10 @@ log = "0.4" # feature downloads PDFium at build time and is off. The maintained BSD-3-Clause fork # preserves terminal failures/cancellation and bounds the completion notification wait, and # creates the Direct2D factory multi-threaded, since Windows.Data.Pdf draws on its own worker -# threads (storytold/pdfcraft#5006). Pinned to an immutable revision; review before bumping. -winprint = { git = "https://github.com/storytold/winprint.rs", rev = "64e7afd4d1483512385012c340ecaaaf0f3beb7f", default-features = false } +# threads (storytold/pdfcraft#5006). PDF jobs load through a stream to avoid StorageFile +# access denial (storytold/winprint.rs#15). Includes the multi-threaded factory fix. +# Pinned to an immutable revision; review before bumping. +winprint = { git = "https://github.com/storytold/winprint.rs", rev = "17f5f1e3c5038be6bd122df36fc5b5aa2672502c", default-features = false } # GetDefaultPrinter (MIT). winsafe = { version = "0.0.29", default-features = false, features = ["winspool"] } # The job file's private folder. From 93d7c7b57afc6d2d60a0b12485c4c9ca96884596 Mon Sep 17 00:00:00 2001 From: Zhihui Song Date: Sat, 7 Nov 2026 15:06:10 +0800 Subject: [PATCH 3/5] print: adopt on-demand file loading without whole-job buffering --- Cargo.lock | 4 ++-- crates/print/Cargo.toml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 506a38cb4..7c720e578 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1225,7 +1225,7 @@ dependencies = [ [[package]] name = "craft-winprint-gdi" version = "0.1.0" -source = "git+https://github.com/storytold/winprint.rs?rev=17f5f1e3c5038be6bd122df36fc5b5aa2672502c#17f5f1e3c5038be6bd122df36fc5b5aa2672502c" +source = "git+https://github.com/storytold/winprint.rs?rev=b334ebbbfe2ddfdc8b2deb2a7b372f0cf0a0d3e7#b334ebbbfe2ddfdc8b2deb2a7b372f0cf0a0d3e7" dependencies = [ "windows-sys 0.61.2", ] @@ -7034,7 +7034,7 @@ dependencies = [ [[package]] name = "winprint" version = "0.2.1" -source = "git+https://github.com/storytold/winprint.rs?rev=17f5f1e3c5038be6bd122df36fc5b5aa2672502c#17f5f1e3c5038be6bd122df36fc5b5aa2672502c" +source = "git+https://github.com/storytold/winprint.rs?rev=b334ebbbfe2ddfdc8b2deb2a7b372f0cf0a0d3e7#b334ebbbfe2ddfdc8b2deb2a7b372f0cf0a0d3e7" dependencies = [ "flate2", "fmt-derive", diff --git a/crates/print/Cargo.toml b/crates/print/Cargo.toml index 24037f6b4..529819dcb 100644 --- a/crates/print/Cargo.toml +++ b/crates/print/Cargo.toml @@ -9,7 +9,7 @@ description = "System PDF print spooler for the Craft apps: CUPS and Windows" [dependencies] # Safe API; Win32 calls are isolated in this maintained MIT OR Apache-2.0 dependency. -craft-winprint-gdi = { git = "https://github.com/storytold/winprint.rs", rev = "17f5f1e3c5038be6bd122df36fc5b5aa2672502c" } +craft-winprint-gdi = { git = "https://github.com/storytold/winprint.rs", rev = "b334ebbbfe2ddfdc8b2deb2a7b372f0cf0a0d3e7" } [lints] workspace = true @@ -25,10 +25,10 @@ log = "0.4" # feature downloads PDFium at build time and is off. The maintained BSD-3-Clause fork # preserves terminal failures/cancellation and bounds the completion notification wait, and # creates the Direct2D factory multi-threaded, since Windows.Data.Pdf draws on its own worker -# threads (storytold/pdfcraft#5006). PDF jobs load through a stream to avoid StorageFile +# threads (storytold/pdfcraft#5006). PDF jobs load on demand through a read-only file stream to avoid StorageFile # access denial (storytold/winprint.rs#15). Includes the multi-threaded factory fix. # Pinned to an immutable revision; review before bumping. -winprint = { git = "https://github.com/storytold/winprint.rs", rev = "17f5f1e3c5038be6bd122df36fc5b5aa2672502c", default-features = false } +winprint = { git = "https://github.com/storytold/winprint.rs", rev = "b334ebbbfe2ddfdc8b2deb2a7b372f0cf0a0d3e7", default-features = false } # GetDefaultPrinter (MIT). winsafe = { version = "0.0.29", default-features = false, features = ["winspool"] } # The job file's private folder. From e6489d9226e6bf4f235ed9f21286c0c39dd53d8a Mon Sep 17 00:00:00 2001 From: Zhihui Song Date: Sun, 8 Nov 2026 11:05:10 +0800 Subject: [PATCH 4/5] print: preserve the public GDI dependency identity while updating the PDF loader --- Cargo.lock | 2 +- crates/print/Cargo.toml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eef03eddb..b818a65ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1250,7 +1250,7 @@ dependencies = [ [[package]] name = "craft-winprint-gdi" version = "0.1.0" -source = "git+https://github.com/storytold/winprint.rs?rev=03a4fb638734dc0f2b8e173de9e8dc895a8b1c75#03a4fb638734dc0f2b8e173de9e8dc895a8b1c75" +source = "git+https://github.com/storytold/winprint.rs?rev=64e7afd4d1483512385012c340ecaaaf0f3beb7f#64e7afd4d1483512385012c340ecaaaf0f3beb7f" dependencies = [ "windows-sys 0.61.2", ] diff --git a/crates/print/Cargo.toml b/crates/print/Cargo.toml index 46b9aa5da..64287a194 100644 --- a/crates/print/Cargo.toml +++ b/crates/print/Cargo.toml @@ -9,7 +9,10 @@ description = "System PDF print spooler for the Craft apps: CUPS and Windows" [dependencies] # Safe API; Win32 calls are isolated in this maintained MIT OR Apache-2.0 dependency. -craft-winprint-gdi = { git = "https://github.com/storytold/winprint.rs", rev = "03a4fb638734dc0f2b8e173de9e8dc895a8b1c75" } +# Keep the public rgb re-export at main's GDI revision: a different Git rev gives +# downstream GDI values a different Rust type identity even when the code is unchanged. +# PDF loader updates below are independent of this public transport API. +craft-winprint-gdi = { git = "https://github.com/storytold/winprint.rs", rev = "64e7afd4d1483512385012c340ecaaaf0f3beb7f" } [lints] workspace = true From 7ee35a9fbd47af572d55fd63dbf0333d1f00da17 Mon Sep 17 00:00:00 2001 From: Zhihui Song Date: Sun, 8 Nov 2026 19:07:09 +0800 Subject: [PATCH 5/5] chore(print): refresh internal winprint pin after bounded stream test repair --- Cargo.lock | 2 +- crates/print/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b818a65ce..0c741c3a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7106,7 +7106,7 @@ dependencies = [ [[package]] name = "winprint" version = "0.2.1" -source = "git+https://github.com/storytold/winprint.rs?rev=03a4fb638734dc0f2b8e173de9e8dc895a8b1c75#03a4fb638734dc0f2b8e173de9e8dc895a8b1c75" +source = "git+https://github.com/storytold/winprint.rs?rev=51934db382f225454cf152a8657eb03789be63c4#51934db382f225454cf152a8657eb03789be63c4" dependencies = [ "flate2", "fmt-derive", diff --git a/crates/print/Cargo.toml b/crates/print/Cargo.toml index 64287a194..9edae26ee 100644 --- a/crates/print/Cargo.toml +++ b/crates/print/Cargo.toml @@ -31,7 +31,7 @@ log = "0.4" # threads (storytold/pdfcraft#5006). File-backed PDF loading avoids StorageFile access # denial without whole-job buffering; includes the #15 test cleanup and explicit WinRT # feature. Pinned to an immutable revision; review before bumping. -winprint = { git = "https://github.com/storytold/winprint.rs", rev = "03a4fb638734dc0f2b8e173de9e8dc895a8b1c75", default-features = false } +winprint = { git = "https://github.com/storytold/winprint.rs", rev = "51934db382f225454cf152a8657eb03789be63c4", default-features = false } # GetDefaultPrinter (MIT). winsafe = { version = "0.0.29", default-features = false, features = ["winspool"] } # The job file's private folder.