fix: prefill native print dialog options on macOS with OOP printing#50600
Conversation
0057821 to
eabdd32
Compare
| + // 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()) { |
There was a problem hiding this comment.
Is this part upstreamable ? unsure if its specific to us .
There was a problem hiding this comment.
I can try but Chrome would never take these paths so it'd be unlikely to be accepted imo
There was a problem hiding this comment.
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 ?
eabdd32 to
bf10089
Compare
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.
bf10089 to
b4ef6aa
Compare
|
Release Notes Persisted
|
|
I was unable to backport this PR to "41-x-y" cleanly; |
|
I was unable to backport this PR to "40-x-y" cleanly; |
|
I have automatically backported this PR to "42-x-y", please check out #50643 |
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:ScriptedPrint()silently aborted becauseRegisterSystemPrintClient()was only called fromGetDefaultPrintSettings(), but Electron's flow callsUpdatePrintSettings()instead when options are provided.PrinterQueryOop::UpdatePrintSettings()sends settings to the remotePrintBackendservice, but on macOS the native dialog runs in-browser using the localPrintingContextMac::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
npm testpassesRelease Notes
Notes: Fixed an issue where custom options in
webContents.print()did not prefill the print dialog on macOS.