Skip to content

fix: prefill native print dialog options on macOS with OOP printing#50600

Merged
codebytere merged 1 commit into
mainfrom
print-prefill-macos
Apr 2, 2026
Merged

fix: prefill native print dialog options on macOS with OOP printing#50600
codebytere merged 1 commit into
mainfrom
print-prefill-macos

Conversation

@codebytere

Copy link
Copy Markdown
Member

Description of Change

Chromium enabled out-of-process (OOP) printing by default on macOS in CL:6032774. This broke webContents.print() option prefilling (e.g. copies, collate, duplex) in two ways:

  1. ScriptedPrint() silently aborted because RegisterSystemPrintClient() was only called from GetDefaultPrintSettings(), but Electron's flow calls UpdatePrintSettings() instead when options are provided.

  2. PrinterQueryOop::UpdatePrintSettings() sends settings to the remote PrintBackend service, but on macOS the native dialog runs in-browser using the local PrintingContextMac::print_info_, which was never updated with the user's requested settings.

Fix by registering the system print client in UpdatePrintSettings() and applying cached settings to the local printing context before showing the in-browser system print dialog.

Checklist

Release Notes

Notes: Fixed an issue where custom options in webContents.print() did not prefill the print dialog on macOS.

@codebytere codebytere requested a review from a team as a code owner March 31, 2026 12:30
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Mar 31, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Mar 31, 2026
@codebytere codebytere force-pushed the print-prefill-macos branch 2 times, most recently from 0057821 to eabdd32 Compare April 1, 2026 08:18
@codebytere codebytere requested a review from deepak1556 April 1, 2026 08:21
+ // system print dialog is prefilled with user-specified options (e.g. copies,
+ // collate, duplex). OOP UpdatePrintSettings only applies settings to the
+ // remote service context, not the local one used by the native dialog.
+ if (settings().dpi()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part upstreamable ? unsure if its specific to us .

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try but Chrome would never take these paths so it'd be unlikely to be accepted imo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just curious since the browser dialog path existed there must be some component apart from chrome that uses it and if they share the same issue. If its not upstreamable that is fine.

Slightly related, its been a while since I had to look at the printing implementation, why are we using the browser dialog path and not let the utility service create it ?

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Apr 1, 2026
@codebytere codebytere force-pushed the print-prefill-macos branch from eabdd32 to bf10089 Compare April 1, 2026 21:06
Chromium enabled out-of-process (OOP) printing by default on macOS in
https://chromium-review.googlesource.com/c/chromium/src/+/6032774. This
broke webContents.print() option prefilling (e.g. copies, collate,
duplex) in two ways:

1. ScriptedPrint() silently aborted because RegisterSystemPrintClient()
   was only called from GetDefaultPrintSettings(), but Electron's flow
   calls UpdatePrintSettings() instead when options are provided.

2. PrinterQueryOop::UpdatePrintSettings() sends settings to the remote
   PrintBackend service, but on macOS the native dialog runs in-browser
   using the local PrintingContextMac::print_info_, which was never
   updated with the user's requested settings.

Fix by registering the system print client in UpdatePrintSettings() and
applying cached settings to the local printing context before showing
the in-browser system print dialog.
@codebytere codebytere force-pushed the print-prefill-macos branch from bf10089 to b4ef6aa Compare April 2, 2026 10:07
@codebytere codebytere merged commit f41438f into main Apr 2, 2026
66 checks passed
@codebytere codebytere deleted the print-prefill-macos branch April 2, 2026 14:06
@release-clerk

release-clerk Bot commented Apr 2, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed an issue where custom options in webContents.print() did not prefill the print dialog on macOS.

@trop

trop Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "41-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/41-x-y and removed target/41-x-y PR should also be added to the "41-x-y" branch. labels Apr 2, 2026
@trop

trop Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "40-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/40-x-y and removed target/40-x-y PR should also be added to the "40-x-y" branch. labels Apr 2, 2026
@trop

trop Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #50643

@trop trop Bot added in-flight/42-x-y merged/42-x-y PR was merged to the "42-x-y" branch. and removed target/42-x-y PR should also be added to the "42-x-y" branch. in-flight/42-x-y labels Apr 2, 2026
@trop

trop Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

@ckerr has manually backported this PR to "41-x-y", please check out #51682

@trop

trop Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

@ckerr has manually backported this PR to "40-x-y", please check out #51692

@trop trop Bot added in-flight/40-x-y merged/41-x-y PR was merged to the "41-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. and removed needs-manual-bp/40-x-y in-flight/41-x-y in-flight/40-x-y labels May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants