qzind / tray

Browser plugin for sending documents and raw commands to a printer or attached device.
https://qz.io
Other
851 stars 276 forks source link

HTML printing 2.1.1 illegal reflective access operation #699

Open klabarge opened 4 years ago

klabarge commented 4 years ago

When using HTML printing on Windows, the logs warn about an illegal reflective access operation. This happens when Monocle is on and off.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.prism.j2d.J2DFontFactory (file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar) to method sun.font.FontUtilities.getCompositeFontUIResource(java.awt.Font)
WARNING: Please consider reporting this to the maintainers of com.sun.prism.j2d.J2DFontFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

OS: Windows 10 1909 Java: AOJDK 11.0.7 QZ Tray: 2.1.1+1

Full stack trace

[DEBUG] 2020-08-19 11:50:30,385 @ qz.ws.PrintSocketClient:?
        Message: {"call":"print","promise":{},"params":{"printer":{"name":"PDFCreator"},"options":{"bounds":null,"colorType":"color","copies":1,"density":0,"duplex":false,"fallbackDensity":null,"interpolation":"bicubic","jobName":null,"legacy":false,"margins":0,"orientation":null,"paperThickness":null,"printerTray":null,"rasterize":false,"rotation":0,"scaleContent":true,"size":null,"units":"in","altPrinting":false,"encoding":null,"endOfDoc":null,"perSpool":1},"data":[{"type":"pixel","format":"html","flavor":"plain","data":"<html><body>  <table style=\"font-family: monospace; width: 100%\">    <tr>      <td>        <h2>* QZ Tray HTML Sample Print *</h2>        <span style=\"color: #D00;\">Version:</span> 2.1.1+1<br/>        <span style=\"color: #D00;\">Source:</span> https://qz.io/      </td>      <td align=\"right\">        <img src=\"file:///C:/Program%20Files/QZ%20Tray/demo/assets/img/image_sample.png\" />      </td>    </tr>  </table></body></html>","options":{"pageWidth":"","pageHeight":""}}]},"timestamp":1597852230382,"uid":"g62bl7","signAlgorithm":"SHA512","position":{"x":960,"y":520}}
[WARN] 2020-08-19 11:50:30,387 @ qz.ws.PrintSocketClient:?
        Bad signature on request
[DEBUG] 2020-08-19 11:50:30,395 @ qz.common.TrayManager:?
        Calculated dialog centered at: java.awt.Point[x=808,y=428]
[INFO] 2020-08-19 11:50:31,190 @ qz.common.TrayManager:?
        Allowed localhost to print to PDFCreator
[DEBUG] 2020-08-19 11:50:31,249 @ qz.utils.PrintingUtilities:?
        Allowing 16 simultaneous processors based on memory available (8520 MB)
[TRACE] 2020-08-19 11:50:31,249 @ qz.utils.PrintingUtilities:?
        Waiting for processor, 0/16 already in use
[DEBUG] 2020-08-19 11:50:31,255 @ qz.utils.PrintingUtilities:?
        Using qz.printer.action.PrintHTML to print
[DEBUG] 2020-08-19 11:50:31,256 @ qz.printer.PrintServiceMatcher:?
        Searching for PrintService matching PDFCreator
[DEBUG] 2020-08-19 11:50:31,257 @ qz.printer.PrintServiceMatcher:?
        Found 14 printers
[DEBUG] 2020-08-19 11:50:31,257 @ qz.printer.PrintServiceMatcher:?
        Found match: PDFCreator
[TRACE] 2020-08-19 11:50:31,280 @ qz.printer.action.WebApp:?
        Waiting for JavaFX..
[TRACE] 2020-08-19 11:50:31,509 @ qz.printer.action.WebApp:?
        Running a test snapshot to size the stage...
[DEBUG] 2020-08-19 11:50:31,509 @ qz.printer.action.WebApp:?
        Started JavaFX
[TRACE] 2020-08-19 11:50:31,510 @ qz.printer.action.WebApp:?
        Waiting on capture..
[TRACE] 2020-08-19 11:50:31,833 @ qz.printer.action.WebApp:?
        Setting starting size 0.0:0.0
[TRACE] 2020-08-19 11:50:31,852 @ qz.printer.action.WebApp:?
        Done: -1.0 > 0.0
[TRACE] 2020-08-19 11:50:31,853 @ qz.printer.action.WebApp:?
        New state: READY > SCHEDULED
[TRACE] 2020-08-19 11:50:31,854 @ qz.printer.action.WebApp:?
        New state: SCHEDULED > RUNNING
[TRACE] 2020-08-19 11:50:31,885 @ qz.printer.action.WebApp:?
        Done: 0.0 > 100.0
[TRACE] 2020-08-19 11:50:31,885 @ qz.printer.action.WebApp:?
        New state: RUNNING > SUCCEEDED
[TRACE] 2020-08-19 11:50:31,894 @ qz.printer.action.WebApp:?
        Zooming in by x2.0 for increased quality
[TRACE] 2020-08-19 11:50:31,900 @ qz.printer.action.WebApp:?
        Set HTML page height to 67.0
[DEBUG] 2020-08-19 11:50:31,911 @ qz.printer.action.WebApp:?
        Attempting image capture
[DEBUG] 2020-08-19 11:50:31,955 @ qz.printer.action.PrintHTML:?
        Parsed 1 html records
[TRACE] 2020-08-19 11:50:32,051 @ qz.printer.action.PrintHTML:?
         Collation = COLLATED
 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=600dpi. Cross Feed res=600dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: Default size=612.0x792.0 POINT Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2020-08-19 11:50:32,055 @ qz.printer.action.WebApp:?
        Waiting on print..
[TRACE] 2020-08-19 11:50:32,055 @ qz.printer.action.WebApp:?
        Setting starting size 816.0:0.0
[TRACE] 2020-08-19 11:50:32,057 @ qz.printer.action.WebApp:?
        Done: 100.0 > -1.0
[TRACE] 2020-08-19 11:50:32,058 @ qz.printer.action.WebApp:?
        New state: SUCCEEDED > READY
[TRACE] 2020-08-19 11:50:32,058 @ qz.printer.action.WebApp:?
        Done: -1.0 > 0.0
[TRACE] 2020-08-19 11:50:32,058 @ qz.printer.action.WebApp:?
        New state: READY > SCHEDULED
[TRACE] 2020-08-19 11:50:32,059 @ qz.printer.action.WebApp:?
        New state: SCHEDULED > RUNNING
[TRACE] 2020-08-19 11:50:32,091 @ qz.printer.action.WebApp:?
        Done: 0.0 > 22.62260840504637
[TRACE] 2020-08-19 11:50:32,112 @ qz.printer.action.WebApp:?
        Done: 22.62260840504637 > 100.0
[TRACE] 2020-08-19 11:50:32,112 @ qz.printer.action.WebApp:?
        New state: RUNNING > SUCCEEDED
[TRACE] 2020-08-19 11:50:32,113 @ qz.printer.action.WebApp:?
        Zooming in by x1.0 for increased quality
[TRACE] 2020-08-19 11:50:32,114 @ qz.printer.action.WebApp:?
        Set HTML page height to 102.0
[DEBUG] 2020-08-19 11:50:32,121 @ qz.printer.action.WebApp:?
        Paper area: 0,0:612,792
[DEBUG] 2020-08-19 11:50:32,122 @ qz.printer.action.WebApp:?
        Document will be printed across 1 pages
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.prism.j2d.J2DFontFactory (file:/C:/Program%20Files/QZ%20Tray/qz-tray.jar) to method sun.font.FontUtilities.getCompositeFontUIResource(java.awt.Font)
WARNING: Please consider reporting this to the maintainers of com.sun.prism.j2d.J2DFontFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
tresf commented 4 years ago

@klabarge thanks for reporting this. It's a know issue caused by a workaround that we created in https://github.com/qzind/tray/pull/516. We were unable to get a reliable vector print size unless we explicitly call an internal, private function doUpdatePeer. There's no way to suppress this message without either exposing this function publicly (would require Gluon to patch in this functionality) or work from an upstream bug report of the same nature.

tresf commented 4 years ago

This https://github.com/qzind/tray/issues/513#issuecomment-554002309 explains it best actually, quoting:

I think I found a technique that works...

JavaFX 11 just renamed impl_updatePeer to doUpdatePeer and made it private.

Using reflection, I should be able to detect and call whichever is available.

Edit... done via c2c380e.

Edit: Quoting:

This issue has been reported upstream:

https://support.gluonhq.com/browse/SUPQZ-1 (license required) https://bugs.openjdk.java.net/browse/JDK-8235831 (public)

tresf commented 3 years ago

FYI, bumped the upstream (private) bug report to see where this is at.

tresf commented 3 years ago

Heads up, this has risen in priority since #778 and newer JavaFX versions (e.g. 17-ea+9) also suffer from a regression which renders c2c380e useless. We should have an update on this soon.

tresf commented 3 years ago

Heads up, this has risen in priority since #778 and newer JavaFX versions (e.g. 17-ea+9) also suffer from a regression which renders c2c380e useless. We should have an update on this soon.

Upstream has reverted the code which introduced the regression observed in #778. Relevant conversation here: https://github.com/openjdk/jfx/pull/603#discussion_r689845070.

This doesn't fix the reflective access problems that this bug report describes, but at least brings baseline back to something without random wait times. I'm not sure when the upstream patches will land, but I'll provide an update once they do.