qzind / qz-print

Archive for legacy qz-print versions (1.8, 1.9). See https://github.com/qzind/tray for modern versions.
Other
141 stars 101 forks source link

PDF printing crashes QZ Tray 2.0 on OSX #155

Closed klabarge closed 8 years ago

klabarge commented 8 years ago

Tested in OSX 10.7 and 10.11 using Chrome

When trying to print a PDF, either through a file or base64, QZ Tray crashes and does not print anything.

This is reproducible using the sample.html page that ships with the software.

/Applications/QZ Tray.app/Contents/MacOS/QZ Tray: line 6: ${javac.socket.target}+: bad substitution
WARNING: GL pipe is running in software mode (Renderer ID=0x1020400)
Feb  1 22:29:30 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:29:30 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
Feb  1 22:29:30 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:29:30 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
Feb  1 22:29:32 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:29:32 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
Feb  1 22:29:32 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:29:32 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
Feb  1 22:29:46 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:29:46 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
Feb  1 22:29:46 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:29:46 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
Feb  1 22:29:48 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:29:48 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
Feb  1 22:30:12 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:30:12 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
Feb  1 22:30:13 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:30:13 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
Feb  1 22:30:22 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:30:22 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
Feb  1 22:30:24 Tress-Mac.local java[440] <Error>: CGContextGetCTM: invalid context 0x0
Feb  1 22:30:24 Tress-Mac.local java[440] <Error>: CGContextSetBaseCTM: invalid context 0x0
2016-02-01 22:30:41.541 java[440:b003] Cocoa AWT: Not running on AppKit thread 0 when expected. (
    0   libosxapp.dylib                     0x0000000172eef702 +[ThreadUtilities getJNIEnv] + 38
    1   libawt_lwawt.dylib                  0x0000000172e63e69 syncFromJavaPixels + 1842
    2   libawt_lwawt.dylib                  0x0000000172e642ff LockImage + 75
    3   libawt_lwawt.dylib                  0x0000000172e76c4c Java_sun_java2d_CRenderer_doImage + 170
    4   ???                                 0x0000000101bc92d4 0x0 + 4324102868
    5   ???                                 0x0000000101bbbc4d 0x0 + 4324047949
)
2016-02-01 22:30:41.543 java[440:b003]  Please file a bug report at http://java.net/jira/browse/MACOSX_PORT with this message and a reproducible test case.
2016-02-01 22:30:41.545 java[440:b003] java.lang.StackOverflowError
    at sun.java2d.CRenderer.doImage(Native Method)
    at sun.java2d.OSXSurfaceData.blitImage(OSXSurfaceData.java:1027)
    at sun.java2d.CRenderer.blitImage(CRenderer.java:461)
    at sun.java2d.CRenderer.scaleImage(CRenderer.java:455)
    at sun.java2d.CRenderer.transformImage(CRenderer.java:508)
    at sun.java2d.CRenderer.transformImage(CRenderer.java:582)
    at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3461)
    at sun.print.ProxyGraphics2D.drawImage(ProxyGraphics2D.java:1315)
    at org.apache.pdfbox.rendering.PageDrawer.drawBufferedImage(PageDrawer.java:815)
    at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:779)
    at org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:62)
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:814)
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:471)
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:445)
    at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149)
    at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:187)
    at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:208)
    at org.apache.pdfbox.rendering.PDFRenderer.renderPageToGraphics(PDFRenderer.java:169)
    at org.apache.pdfbox.printing.PDFPrintable.print(PDFPrintable.java:184)
    at sun.lwawt.macosx.CPrinterJob$4.run(CPrinterJob.java:657)
    at sun.lwawt.macosx.CPrinterJob.printToPathGraphics(CPrinterJob.java:671)
    at sun.lwawt.macosx.CPrinterJob.printLoop(Native Method)
    at sun.lwawt.macosx.CPrinterJob.print(CPrinterJob.java:307)
    at qz.printer.action.PrintPixel.printCopies(Unknown Source)
    at qz.printer.action.PrintPDF.print(Unknown Source)
    at qz.ws.PrintSocketClient.processPrintRequest(Unknown Source)
    at qz.ws.PrintSocketClient.processMessage(Unknown Source)
    at qz.ws.PrintSocketClient.onMessage(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.call(CallableMethod.java:71)
    at org.eclipse.jetty.websocket.common.events.annotated.OptionalSessionCallableMethod.call(OptionalSessionCallableMethod.java:68)
    at org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventDriver.onTextMessage(JettyAnnotatedEventDriver.java:209)
    at org.eclipse.jetty.websocket.common.message.SimpleTextMessage.messageComplete(SimpleTextMessage.java:69)
    at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.appendMessage(AbstractEventDriver.java:64)
    at org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventDriver.onTextFrame(JettyAnnotatedEventDriver.java:201)
    at org.eclipse.jetty.websocket.common.events.AbstractEventDriver.incomingFrame(AbstractEventDriver.java:160)
    at org.eclipse.jetty.websocket.common.WebSocketSession.incomingFrame(WebSocketSession.java:302)
    at org.eclipse.jetty.websocket.common.extensions.ExtensionStack.incomingFrame(ExtensionStack.java:214)
    at org.eclipse.jetty.websocket.common.Parser.notifyFrame(Parser.java:220)
    at org.eclipse.jetty.websocket.common.Parser.parse(Parser.java:258)
    at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.readParse(AbstractWebSocketConnection.java:613)
    at org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection.onFillable(AbstractWebSocketConnection.java:468)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:610)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:539)
    at java.lang.Thread.run(Thread.java:745)
2016-02-01 22:30:41.572 java[440:b003] NSAlert is being used from a background thread, which is not safe.  This is probably going to crash sometimes. Break on _NSAlertWarnUnsafeBackgroundThreadUsage to debug.  This will be logged only once.  This may break in the future.
2016-02-01 22:30:43.728 java[440:b003] An uncaught exception was raised
2016-02-01 22:30:43.728 java[440:b003] Printing failed because PMSessionEndDocumentNoDialog() returned -30871.
2016-02-01 22:30:43.729 java[440:b003] (
    0   CoreFoundation                      0x00007fff93a70f56 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8e951d5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff93a70d8a +[NSException raise:format:arguments:] + 106
    3   CoreFoundation                      0x00007fff93a70d14 +[NSException raise:format:] + 116
    4   AppKit                              0x00007fff985a1163 -[NSPrintSpoolingGraphicsContext endDocument] + 177
    5   AppKit                              0x00007fff985a1479 -[NSPrintSpoolingGraphicsContext dealloc] + 42
    6   libobjc.A.dylib                     0x00007fff8e94a03c _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 434
    7   CoreFoundation                      0x00007fff939fe915 _CFAutoreleasePoolPop + 37
    8   libawt_lwawt.dylib                  0x0000000172e59c00 Java_sun_lwawt_macosx_CPrinterJob_printLoop + 165
    9   ???                                 0x0000000101bc92d4 0x0 + 4324102868
    10  ???                                 0x0000000101bbb420 0x0 + 4324045856
    11  ???                                 0x0000000101bbbc4d 0x0 + 4324047949
)
2016-02-01 22:30:43.732 java[440:b003] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Printing failed because PMSessionEndDocumentNoDialog() returned -30871.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff93a70f56 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff8e951d5e objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff93a70d8a +[NSException raise:format:arguments:] + 106
    3   CoreFoundation                      0x00007fff93a70d14 +[NSException raise:format:] + 116
    4   AppKit                              0x00007fff985a1163 -[NSPrintSpoolingGraphicsContext endDocument] + 177
    5   AppKit                              0x00007fff985a1479 -[NSPrintSpoolingGraphicsContext dealloc] + 42
    6   libobjc.A.dylib                     0x00007fff8e94a03c _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 434
    7   CoreFoundation                      0x00007fff939fe915 _CFAutoreleasePoolPop + 37
    8   libawt_lwawt.dylib                  0x0000000172e59c00 Java_sun_lwawt_macosx_CPrinterJob_printLoop + 165
    9   ???                                 0x0000000101bc92d4 0x0 + 4324102868
    10  ???                                 0x0000000101bbb420 0x0 + 4324045856
    11  ???                                 0x0000000101bbbc4d 0x0 + 4324047949
)
terminate called throwing an exception/Applications/QZ Tray.app/Contents/MacOS/QZ Tray: line 14:   440 Abort trap: 6           "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" -Xdock:name="QZ Tray" -Xdock:icon="$iconpath" -jar "$jarpath"
tresf commented 8 years ago

Upstream bug reports: https://issues.apache.org/jira/browse/PDFBOX-2682 http://stackoverflow.com/questions/28471579/pdfbox-on-mac-critical-error-when-silent-printing https://bugs.openjdk.java.net/browse/JDK-8042693 https://bugs.openjdk.java.net/browse/JDK-8038142

Noticed from this stacktrace an unrelated issue bad substitution, which is now patched via 5c572f4

Vzor- commented 8 years ago

I'm going to see if I can find a workaround for now.

tresf commented 8 years ago

So setting a dpi does circumvent this now per c7acaac. @Vzor- if you find a way to fix the threading issue without forcing a dpi, that is still ideal, so I'll leave this open for investigation.

tresf commented 8 years ago

Closing as not-our-bug. This is quite sad as there seems to be no solution in sight. :confused:

I tried filing an upstream bug report to Oracle. After using the link from the stack trace (read only), then trying to use the openjdk bug database (exclusive to devs) I found a form to fill out on Oracle's website.

Here's their canned response:

Dear Java Developer,

Thank you for reporting this issue.

We are evaluating this report and have assigned it a Review ID: JI-9031796. In the event this report is determined to be a defect or enhancement request, it will be referenced with a new Bug ID and will be listed on Bugs.java.com. For other related issues, please visit our Bug Database at http://bugs.java.com.

We try to process all newly posted bugs in a timely manner, but make no promises about the amount of time in which a bug might be fixed. If the issue just reported could have a major impact on your project, consider using one of the technical support offerings available at Oracle Support.

Regards, Java Community Developer Support

tresf commented 7 years ago

Update: Oracle has provided a patch for this issue and it has been tested on macOS 10.11 El Capitan and macOS Sierra 10.12 successfully. It should appear in the next public release (> 8u121)