Closed Bug 1666473 Opened 4 years ago Closed 4 years ago

[macOS] Paper size settings unexpectedly revert to default on actually submitting a print job

Categories

(Core :: Printing: Setup, defect, P2)

Unspecified
macOS
defect

Tracking

()

VERIFIED FIXED
83 Branch
Tracking Status
firefox82 --- verified
firefox83 --- verified
firefox84 --- verified

People

(Reporter: jfkthame, Assigned: jfkthame)

References

Details

(Whiteboard: [print2020_v82])

Attachments

(1 file)

STR:

  • Open the Print UI and choose a real printer as destination
  • Click More Settings to reveal the Paper Size selector
  • Choose a non-default paper size (e.g. A5)
  • Click Cancel to dismiss the UI
  • Re-open the Print UI and open More Settings again
  • Observe that the chosen paper size is still selected
    • all good :)
  • Click Print to submit an actual print job
  • Re-open the Print UI and open More Settings again
  • Observe that the paper size has reverted to a default (e.g. A4 or Letter)
    • unexpected! :(

It's unclear to me if this is a regression or has always been broken (as long as the paper size selector has been available in the new UI).

Severity: -- → S3
Priority: -- → P2
Whiteboard: [print2020_v83]

AFAICT this has been broken ever since the paper size control was added. It looks like choosing a paper size "works" inasmuch as the preview is updated to reflect the new size, and when the print job is submitted, it will have that layout; but at the same time, the saved size (which will be the initial setting when the UI is reopened) goes back to the printer's default as recorded in the print.macosx.pagesetup-2 pref.

This also results in the wrong paper size being reported by the (pending) new telemetry in bug 1666110.

URL: 1666110
Blocks: 1666110
URL: 1666110

It seems that what happens here is that the paper size we really wanted to use, which has been recorded in the base nsPrintSettings::mPaperWidth and mPaperHeight fields, is getting overridden by values retrieved from the Cocoa NSPrintInfo in nsPrintSettingsServiceX::SerializeToPrintDataParent here. If I remove that chunk of code, the issue here seems to be fixed, though I'm concerned that may result in other issues somewhere.... it probably had a purpose at some point in its life!

The paper size we get from the NSPrintInfo there is the result of calling ReadPageFormatFromPrefs() here, which retrieves a serialized PMPageFormat and applies it. That PMPageFormat in the prefs does not reflect what the user has most recently chosen in the UI.

So maybe this means we're failing to call nsIPrintSettingsService.savePrintSettingsToPrefs at the right time, or it's failing for some reason? Guess I'll poke some more...

Hah. See bug 1659928 comment 30. nsPrintDialogServiceX::Show only stores the paper size in the NSPrintInfo. So we need that serialization code currently in order to pass the correct paper size to the content process. This code is a mess though...

For now, we should probably override Get/SetPaperWidth/Height on nsPrintSettingsX and remove the chunk of code you linked to in nsPrintSettingsServiceX::SerializeToPrintDataParent so that we have one source of truth for paper width/height instead of two. That doesn't solve the issue of mPaperSizeUnit not being set by nsPrintDialogServiceX::Show that I mentioned in bug 1659928 comment 30, but we can fix that separately.

(In reply to Jonathan Watt [:jwatt] from comment #4)

For now, we should probably override Get/SetPaperWidth/Height on nsPrintSettingsX

So nsPrintSettingsX already has overrides of SetPaperWidth/Height, because it maintains "adjusted" versions as well as the base mPaperWidth/Height fields. But it doesn't update the NSPrintInfo when they change. AFAICT, if we extend these methods to update the NSPrintInfo in sync with the base dimensions, the bug here appears to be resolved. That may be the minimal-risk approach here, I suspect.

With that change, removing the chunk in nsPrintSettingsServiceX::SerializeToPrintDataParent that reads from the NSPrintInfo doesn't seem to be necessary, though it may be harmless. I don't think I understand all the interdependencies here, so I'm inclined to touch as little as possible. :)

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7d8ce79d27a4
Update mPrintInfo in SetPaperWidth/Height overrides. r=jwatt
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ee8039174ab7
Update mPrintInfo in SetPaperWidth/Height overrides. r=jwatt
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 83 Branch

Comment on attachment 9177598 [details]
Bug 1666473 - Update mPrintInfo in SetPaperWidth/Height overrides. r=jwatt

Beta/Release Uplift Approval Request

  • User impact if declined: After a user selects a paper size to print to on macOS, it will be reverted the next print. Since the paper selector is hidden by default in the new UI, this has particular potential to upset people.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Medium
  • Why is the change risky/not risky? (and alternatives if risky):
  • String changes made/needed:
Attachment #9177598 - Flags: approval-mozilla-beta?

Comment on attachment 9177598 [details]
Bug 1666473 - Update mPrintInfo in SetPaperWidth/Height overrides. r=jwatt

macos printing fix, approved for 82.0b5

Flags: needinfo?(jfkthame)
Attachment #9177598 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Whiteboard: [print2020_v83] → [print2020_v82]
Flags: qe-verify+
QA Whiteboard: [qa-triaged]

I have managed to reproduce this 83.0a1(20200922154306).

Confirming this issue as verified fixed with 83.0b6 and 84.0a1(20201101092255) on macOS 10.15.7

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: