Closed Bug 1134891 Opened 9 years ago Closed 9 years ago

Printing results in the progress dialog never going away and the print never happening

Categories

(Toolkit :: Printing, defect)

x86
All
defect
Not set
major

Tracking

()

VERIFIED FIXED
mozilla39
Iteration:
39.1 - 9 Mar
Tracking Status
firefox35 --- unaffected
firefox36 --- unaffected
firefox37 --- unaffected
firefox38 + verified
firefox39 --- verified

People

(Reporter: mconley, Assigned: mconley)

References

(Blocks 1 open bug)

Details

(Keywords: regression)

Attachments

(3 files, 4 obsolete files)

1.86 KB, patch
mconley
: review+
Gijs
: checkin+
Details | Diff | Splinter Review
39 bytes, text/x-review-board-request
mconley
: review+
Details
39 bytes, text/x-review-board-request
mconley
: review+
Details
STR:

1) On Linux in a non-e10s window, open some web page
2) Go to File > Print to print the document
3) Set some print settings and hit "Print"

ER: This should briefly show the print progress dialog as the document-to-print gets rendered, and then it should print.

AR: We show the print progress dialog permanently, and show an error in this console:

JavaScript error: chrome://global/content/dialogOverlay.js, line 74: TypeError: opener is null

A quick mozregression session and a local backout points the finger at the patch for bug 1115333.
Flags: firefox-backlog+
[Tracking Requested - why for this release]:

This is a particularly nasty regression that I'd hate for us to propagate up the trains. Especially since 38 is an ESR.
Hopefully I'm doing the right thing with these flags.
Delightful. I should have known that we have no tests for printing code... :-\
comment #0 specifically says "non-e10s window". Does the same not happen on e10s?

All this code (in dialogOverlay.js) is trying to do is center a dialog on top of the opener window. Seems to me like it should always be opened from the chrome window, and that will fix this (the reason opener is now null is because it's being opened from a content window).
Flags: needinfo?(mconley)
Also, inasmuch as this is breaking printing, the trivial fix that will forgo the centering would be to nullcheck opener before trying to use it.
(In reply to :Gijs Kruitbosch from comment #4)
> comment #0 specifically says "non-e10s window". Does the same not happen on
> e10s?
> 

Until bug 1090448 is fixed, printing is just flat-out disabled on Linux with e10s, so I guess it doesn't matter there - but if printing was enabled, it would also be affected.

> All this code (in dialogOverlay.js) is trying to do is center a dialog on
> top of the opener window. Seems to me like it should always be opened from
> the chrome window, and that will fix this (the reason opener is now null is
> because it's being opened from a content window).

I see. This is the code that, eventually, opens the dialog:

https://dxr.mozilla.org/mozilla-central/source/embedding/components/printingui/unixshared/nsPrintingPromptService.cpp#127

So I suppose nsPrintingPromptService::ShowProgress is getting passed the content window for whatever's being printed.

Strange - I don't see much variation between what we do on Linux with what we do on Windows. I don't see why this shouldn't have broken the dialog on Windows as well, tbh.
Flags: needinfo?(mconley)
Oh snap - it _IS_ busted on Windows. This just got more serious.
OS: Linux → All
Note that one needs to be running with e10s disabled.
This should unbreak stuff for the moment, although really printing should always be passing the toplevel (browser, rather than content) window, even in non-e10s. Mike said he could do that. In the meantime, does this look sane and does it unbreak printing, even if the dialog might be weirdly positioned? :-)
Attachment #8567140 - Flags: review?(mconley)
Keywords: leave-open
Comment on attachment 8567140 [details] [diff] [review]
stopgap: don't break if opener is null,

Review of attachment 8567140 [details] [diff] [review]:
-----------------------------------------------------------------

So while this might fix things for other dialogs that make use of dialogOverlay.js, it doesn't fix the printing case as there are still references to opener in printProgress.js. :/

I think we should still take this for anything else that might use dialogOverlay, but we need to make it so that the dialogs are all being opened such that the parent is the browser window, and not the content window for what's being printed.
Attachment #8567140 - Flags: review?(mconley) → review+
Attachment #8567262 - Attachment is obsolete: true
This does the job on Linux, testing on Windows now...
Assignee: nobody → mconley
Attachment #8567265 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Comment on attachment 8567285 [details] [diff] [review]
Make the print progress dialog for Windows and Linux be opened by the browser window's nsIDOMWindow instead of the content window. r=?

bsmedberg - you're listed as the module owner for embedding, which is why I'm r?ing you.

I have no idea if you're the right person to review this, but if not, perhaps you know who I should redirect it to?
Attachment #8567285 - Flags: review?(benjamin)
Attachment #8567140 - Flags: checkin+
Comment on attachment 8567285 [details] [diff] [review]
Make the print progress dialog for Windows and Linux be opened by the browser window's nsIDOMWindow instead of the content window. r=?

smaug has heroically stepped up to the plate.
Attachment #8567285 - Flags: review?(benjamin) → review?(bugs)
Comment on attachment 8567285 [details] [diff] [review]
Make the print progress dialog for Windows and Linux be opened by the browser window's nsIDOMWindow instead of the content window. r=?

Could you please add a MOZ_ASSERT or some such to
mac's nsPrintProgress::OpenProgressDialog, since that is not supposed to be called, and file a followup to remote nsPrintProgress.h|cpp from mac/
(Probably also nsPrintProgressParams.h|cpp)

>+    // We will set the opener of the dialog to be the nsIDOMWindow for the
>+    // browser XUL window itself, as opposed to the content. That way, the
>+    // progress window has access to the opener.
>+    nsCOMPtr<nsPIDOMWindow> pParentWindow = do_QueryInterface(parent);
>+    NS_ENSURE_STATE(pParentWindow);
>+
>+    nsCOMPtr<nsIDocShell> docShell = pParentWindow->GetDocShell();
>+    NS_ENSURE_STATE(docShell);
>+
>+    nsCOMPtr<nsIDocShellTreeOwner> owner;
>+    rv = docShell->GetTreeOwner(getter_AddRefs(owner));
>+    NS_ENSURE_SUCCESS(rv, rv);
>+
>+    nsCOMPtr<nsIXULWindow> ownerXULWindow = do_GetInterface(owner);
do_GetInterface is null safe so you don't need NS_ENSURE_SUCCESS(rv, rv);

>+    NS_ENSURE_STATE(ownerXULWindow);
>+
>+    nsCOMPtr<nsIDOMWindow> ownerWindow = do_GetInterface(ownerXULWindow);
do_GetInterface is null safe so you don't need NS_ENSURE_STATE(ownerXULWindow)

>+    // We will set the opener of the dialog to be the nsIDOMWindow for the
>+    // browser XUL window itself, as opposed to the content. That way, the
>+    // progress window has access to the opener.
>+    nsCOMPtr<nsPIDOMWindow> pParentWindow = do_QueryInterface(parent);
>+    NS_ENSURE_STATE(pParentWindow);
>+
>+    nsCOMPtr<nsIDocShell> docShell = pParentWindow->GetDocShell();
>+    NS_ENSURE_STATE(docShell);
>+
>+    nsCOMPtr<nsIDocShellTreeOwner> owner;
>+    rv = docShell->GetTreeOwner(getter_AddRefs(owner));
>+    NS_ENSURE_SUCCESS(rv, rv);
>+
>+    nsCOMPtr<nsIXULWindow> ownerXULWindow = do_GetInterface(owner);
>+    NS_ENSURE_STATE(ownerXULWindow);
>+
>+    nsCOMPtr<nsIDOMWindow> ownerWindow = do_GetInterface(ownerXULWindow);
>+    NS_ENSURE_STATE(ownerWindow);
Same here.
Attachment #8567285 - Flags: review?(bugs) → review+
Thanks! Filed bug 1135901 for removing that dead code.
See Also: → 1135901
Blocks: 1090448
/r/4171 - Bug 1134891 - Make the print progress dialog for Windows and Linux be opened by the browser window's nsIDOMWindow instead of the content window. r=smaug.
/r/4169 - Bug 1134891 - Print progress code paths for OS X should be unreachable. r=trivial.

Pull down these commits:

hg pull review -r 7b021e23ff21c9cc010cd8410e3940b51dad9390
Attachment #8567285 - Attachment is obsolete: true
Attachment #8568743 - Attachment description: MozReview Request: bz://1134891/mconley → MozReview Request: bz://1134891/mconley (r+'d by smaug)
Attachment #8568743 - Flags: review+
https://reviewboard.mozilla.org/r/4167/#review3433

::: embedding/components/printingui/unixshared/nsPrintProgress.cpp
(Diff revision 1)
> +    MOZ_ASSERT_UNREACHABLE("This is a test to see if this can even compile. "
> +                           "I don't remember if C++ is this cool.");

Oh ffs, this was not supposed to land with that stuff.

I have a patch to remove this that I can land once the tree re-opens.
Flags: needinfo?(mconley)
Well, you can reland the patches without that once the tree reopens. I just backed both patches out in https://hg.mozilla.org/integration/mozilla-inbound/rev/e8cef690bc3c
Re-landed without that silly MOZ_ASSERT_UNREACHABLE in there. Sorry about that.

remote:   https://hg.mozilla.org/integration/mozilla-inbound/rev/613f2ec644b9
remote:   https://hg.mozilla.org/integration/mozilla-inbound/rev/6c6f4873629d
Flags: needinfo?(mconley)
(In reply to Mike Conley (:mconley) - Needinfo me! from comment #10)
> Comment on attachment 8567140 [details] [diff] [review]
> stopgap: don't break if opener is null,
> 
> Review of attachment 8567140 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> So while this might fix things for other dialogs that make use of
> dialogOverlay.js, it doesn't fix the printing case as there are still
> references to opener in printProgress.js. :/
> 
> I think we should still take this for anything else that might use
> dialogOverlay, but we need to make it so that the dialogs are all being
> opened such that the parent is the browser window, and not the content
> window for what's being printed.

Does this implementation of moveToAlertPosition() need to be fixed as well?
http://mxr.mozilla.org/comm-central/source/mozilla/toolkit/content/widgets/dialog.xml?rev=0c9ed31fcb96#98
Flags: needinfo?(mconley)
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Flags: needinfo?(mconley)
Keywords: leave-open
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
Iteration: --- → 39.1 - 9 Mar
Flags: qe-verify?
Comment on attachment 8568743 [details]
MozReview Request: bz://1134891/mconley (r+'d by smaug)

Approval Request Comment
[Feature/regressing bug #]:

Fixing regression caused by bug 1115333.

[User impact if declined]:

Printing is broken on Windows and Linux. When attempting to print, the user will see the print progress dialog appear, but then not disappear. On Linux, at least, this means the print job never occurs. It's possible that the print job will still occur on Windows despite the progress dialog not going away.

So for the affected systems, in the best case, printing will occur and the dialog will never go away (which isn't a great experience), and in the worst case, printing will never occur and the dialog will never go away (which is a horrible experience).

[Describe test coverage new/current, TreeHerder]:

The fix has been manually tested on Linux and Windows - both with e10s enabled and disabled.

[Risks and why]: 

We're changing some native code to retarget the window to be opened such that the parent is the browser window itself, instead of the content window. I don't believe there's much risk - though QA can (and probably should) kick the tires on printing on these systems just to be sure.

[String/UUID change made/needed]:

None.
Attachment #8568743 - Flags: approval-mozilla-aurora?
(In reply to Philip Chee from comment #26)
> (In reply to Mike Conley (:mconley) - Needinfo me! from comment #10)
> > Comment on attachment 8567140 [details] [diff] [review]
> > stopgap: don't break if opener is null,
> > 
> > Review of attachment 8567140 [details] [diff] [review]:
> > -----------------------------------------------------------------
> > 
> > So while this might fix things for other dialogs that make use of
> > dialogOverlay.js, it doesn't fix the printing case as there are still
> > references to opener in printProgress.js. :/
> > 
> > I think we should still take this for anything else that might use
> > dialogOverlay, but we need to make it so that the dialogs are all being
> > opened such that the parent is the browser window, and not the content
> > window for what's being printed.
> 
> Does this implementation of moveToAlertPosition() need to be fixed as well?
> http://mxr.mozilla.org/comm-central/source/mozilla/toolkit/content/widgets/
> dialog.xml?rev=0c9ed31fcb96#98

Only if the dialog in question ever gets called with a content opener... Can you file a followup bug to investigate the remaining callers and assign to me? It's hard to tell from MXR whether the opener will always be OK or not...
Flags: needinfo?(philip.chee)
Tracking 38 and approving the uplift, Kairo can you ensure this is on the test plan for 38?   No need to track or mark for ESR since the first ESR 38 is exactly FF38.
Flags: needinfo?(kairo)
Marking for verification and additional exploratory testing for printing.
Flags: qe-verify?
Flags: qe-verify+
Flags: needinfo?(kairo)
Comment on attachment 8568743 [details]
MozReview Request: bz://1134891/mconley (r+'d by smaug)

Approving for aurora uplift since Lukas already said she would accept it.
Attachment #8568743 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
I was able to reproduce this issue on Firefox 38.0a2 (2015-03-01) using Windows 7 x64.

Verified fixed on Firefox 39.0a1 (2015-03-05) non-e10s, Firefox 39.0a1 (2015-03-06) non-e10s and Firefox 38.0a2 (2015-03-06) using Windows 7 x64 and Ubuntu 14.04 x32.
Status: RESOLVED → VERIFIED
See Also: → 1148807
(In reply to :Gijs Kruitbosch (away 26-30/3) from comment #29)

> Only if the dialog in question ever gets called with a content opener... Can
> you file a followup bug to investigate the remaining callers and assign to
> me? It's hard to tell from MXR whether the opener will always be OK or not...

I filed Bug 1148807
Flags: needinfo?(philip.chee)
Attachment #8568743 - Attachment is obsolete: true
Attachment #8619545 - Flags: review+
Attachment #8619546 - Flags: review+
Blocks: 778106
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: