From 058b047760dfe5ba51f6f526faa3b0c833552dfa Mon Sep 17 00:00:00 2001 From: Mustafa Ertan Date: Sun, 8 Nov 2026 04:42:38 +0300 Subject: [PATCH] print: winprint 64e7afd4, whose Direct2D factory is multi-threaded (#605) 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: mertan-wq <235487900+mertan-wq@users.noreply.github.com> 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 5da93977..9804fc5c 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=417ac3c4d14d3da5485a99c7d5ce8f05664ec312#417ac3c4d14d3da5485a99c7d5ce8f05664ec312" +source = "git+https://github.com/storytold/winprint.rs?rev=64e7afd4d1483512385012c340ecaaaf0f3beb7f#64e7afd4d1483512385012c340ecaaaf0f3beb7f" dependencies = [ "windows-sys 0.61.2", ] @@ -7106,7 +7106,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 cd3dd0c4..61d4c7cf 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.