Closed
Bug 1227611
Opened 10 years ago
Closed 10 years ago
Silent print setting on Linux without default printer leads to modal dialog, failure
Categories
(Core :: Printing: Setup, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: WeirdAl, Unassigned)
Details
(Keywords: testcase)
Attachments
(1 file)
|
18.29 KB,
text/plain
|
Details |
Environment: CentOS 6.5, no default printer set, Firefox ESR 38.4 running a XULRunner app. We're trying to convert a HTML page to PDF using the Print to File setting, PDF option:
var wbPrint = win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebBrowserPrint);
var settings = wbPrint.globalPrintSettings;//.clone();
settings.printerName = "Print to File";
settings.printToFile = true;
settings.toFileName = this.filename;
settings.printSilent = true;
settings.printRange = Ci.nsIPrintSettings.kRangeAllPages;
settings.outputFormat = Ci.nsIPrintSettings.kOutputFormatPDF;
wbPrint.print(settings, this);
Frame 74 of attached stack: In nsPrintSettingsGTK::SetupSilentPrinting, if a default printer isn't set, it's supposed to just pick the first one:
gtk_enumerate_printers(printer_enumerator, this, nullptr, TRUE);
// XXX If no default printer set, get the first one.
if (!GTK_IS_PRINTER(mGTKPrinter))
gtk_enumerate_printers(ref_printer, this, nullptr, TRUE);
But we never get to the second gtk_enumerate_printers call. Instead, while enumerating using printer_enumerator, we end up in a call to a timer and JavaScript (frames 58-72), which then calls a bunch of JS code to eventually land on nsDocumentViewer::Print (frame 28). At that point, since we're already trying to print, we get a call to nsPrintEngine::ShowPrintErrorDialog and a return of NS_ERROR_NOT_AVAILABLE.
I'm specifically looking for a patch I can apply to Firefox 38.x ESR.
Flags: needinfo?(mconley)
Comment 1•10 years ago
|
||
Are you able to dump the JS on the stack?
Flags: needinfo?(mconley) → needinfo?(ajvincent)
| Reporter | ||
Comment 2•10 years ago
|
||
No, I can't: "there is no JSContext on the stack!"
Flags: needinfo?(ajvincent)
| Reporter | ||
Comment 3•10 years ago
|
||
OOPS: Now I can when I set a breakpoint in nsDocumentViewer::Print, and it's embarrassing:
function go() {
try {
wbPrint.print(settings, this);
}
catch (e) {
if (e instanceof Ci.nsIException) {
if (e.result == Components.results.NS_ERROR_GFX_PRINTER_DOC_IS_BUSY) {
setTimeout(go, 5000);
return;
}
}
throw e;
}
}
go = go.bind(this);
go();
I guess that's not very smart anymore...
Comment 4•10 years ago
|
||
So I feel like I'm missing some context here. It looks like this is some add-on code that's attempting to print, and on an exception, waits 5 seconds before re-attempting, in a semi-infinite loop if the printer always reports that it is busy. So I guess this is basically jackhammering the printjob until the printer is ready.
Is that right? And in your test case, are we hitting that the case that the printer is busy?
Flags: needinfo?(ajvincent)
| Reporter | ||
Comment 5•10 years ago
|
||
Not quite correct, but close: the _document_ hasn't finished loading yet (there's a throbber firing in the tab where I enabled tabbrowsing). Also, this used to be addon code for our XULRunner app, but I moved it to an app module. The native code doesn't want to print when the doc is still in a loading state, apparently.
Flags: needinfo?(ajvincent)
| Reporter | ||
Comment 6•10 years ago
|
||
I'm no longer convinced this is a Firefox bug. The JS code I wrote worked with Firefox 28, but it was a brute-force "get the damn thing working" solution at the time. Now that I'm under another "get the damn thing working" situation with 38, and I couldn't earlier trace it to my code...
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•