JDK-8181192 : [macos] javafx.print.PrinterJob.showPrintDialog() hangs on macOS
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8u152,9,10
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: generic
  • Submitted: 2017-05-29
  • Updated: 2018-02-08
  • Resolved: 2017-06-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8 JDK 9
10Fixed 8u131Fixed 9 b174Fixed
Related Reports
Relates :  
Relates :  
Description
When attempting to print on macOS the call to showPrintDialog never returns and no print dialog is shown.
Comments
Fix Request: - Fix for Release : JDK 9 - Justification : Showstopper regression caused by JDK-8167102. - Risk Analysis : low (affects only OS X platform, is back out of the fix JDK-8167102) - Webrev : http://cr.openjdk.java.net/~alitvinov/8181192/jdk9/webrev.01 - Testing (done/to-be-done) : Description of this bug with the test attached to JDK-8129364. - Back port (done/to-be-done) : It is necessary to port the fix to JDK 8. - Reviewers : prr, serb
02-06-2017

Reproduced the bug on OS X 10.9.5 with JDK 10 b09, JDK 9 compiled from the latest version of the source code in "jdk9/client" forest, JDK 9 b171, JDK 9 b166, JDK 8u152 b04. Could not reproduce the bug on the same host with JDK 9 b165. It was practically proven that reversion of the fix JDK-8167102 allows to eliminate this bug, therefore the bug is a regression of the fix JDK-8167102. Complete back out of the fix JDK-8167102 was considered as the most appropriate solution at current time which is close to release of JDK 9.
01-06-2017

There are many threads involved but looking at this one is worrying. PrintDialog" #28 prio=5 os_prio=31 tid=0x00007fd7a5292000 nid=0x14b1f in Object.wait() [0x000070000c71a000] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait(java.base@9-ea/Native Method) - waiting on <no object reference available> at com.sun.prism.j2d.print.J2DPrinterJob$J2DPageable.waitForNextPage(javafx.graphics@9-ea/J2DPrinterJob.java:1006) - waiting to re-lock in wait() <0x00000006d6325ea8> (a java.lang.Object) at com.sun.prism.j2d.print.J2DPrinterJob$J2DPageable.getPage(javafx.graphics@9-ea/J2DPrinterJob.java:1066) at com.sun.prism.j2d.print.J2DPrinterJob$J2DPageable.getPageFormat(javafx.graphics@9-ea/J2DPrinterJob.java:1110) at sun.lwawt.macosx.CPrinterJob.getPageFormat(java.desktop@9-ea/CPrinterJob.java:588) at sun.lwawt.macosx.CPrinterJobDialog.showDialog(java.desktop@9-ea/Native Method) at sun.lwawt.macosx.CPrinterDialogPeer.lambda$setVisible$0(java.desktop@9-ea/CPrinterDialogPeer.java:58) at sun.lwawt.macosx.CPrinterDialogPeer$$Lambda$655/261391134.run(java.desktop@9-ea/Unknown Source) at java.lang.Thread.run(java.base@9-ea/Thread.java:844) We have a transition FX->2D->FX and then go into waitForNextPage() and stop there. That next page won't arrive until we start printing but the application is still in showDialog. I suspect this is a regression from the JDK bug fix https://bugs.openjdk.java.net/browse/JDK-8167102 As can be seen here : http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/e0f119ab7b1c it changed from having native call getPageFormatFromAttributes to getPageFormat() as seen in the stack trace That fix went into JDK 9 b166 (and has since been backported to 8u). I suspect this makes FX printing DOA on Mac.
30-05-2017

Stack trace while blocked waiting for Print Dialog
30-05-2017

I have not tested with earlier Java 9 builds. I will have to find time to do some testing with older builds. With the latest Java 8 update I can't even get a PrinterJob (it comes back null), so I'll have to file a new issue for that. I'm attaching the stack trace.
30-05-2017

Also is this being reported as new in b171 or just reproduced in that build ? Are there earlier builds (or releases) that exhibit the same problem ?
30-05-2017

Assign to Phil to triage, but this may be a window-toolkit (glass) bug.
30-05-2017

Can you provide a stack trace (e.g., using 'jstack <PID>')?
30-05-2017

The test case from JDK-8129364 can be used to reproduce this.
29-05-2017