J2SE Version (please include all output from java -version flag):
java version "1.8.0_75"
Java(TM) SE Runtime Environment (build 1.8.0_75-b07)
Java HotSpot(TM) Client VM (build 25.75-b07, mixed mode)
Does this problem occur on J2SE 6ux or 7ux or 8ux? Yes / No (pick one)
8U72, maybe more
Operating System Configuration Information (be specific):
HP EliteBook 8760W
Windows 7 Professional 64-bit (SP1)
8G Ram
Bug Description:
Spooling print jobs takes far too long. Using the javax.print libraries, a
print job where can spool 1053 pages in less than 15 seconds. Using the new
javafx libraries, this takes about 20 minutes. This calculates being to over
60 times slower than the javax.print APIs.
Realize that printing, in general, is limited to the physical printing of the
pages, but the user experience here is a factor as well. Previously, a user
could start a print, wait 15 seconds, exit the application, and then just
wait for the printer to finish.
An instance where this may be even more of a factor is printing to a virtual
printer, like a "Print to PDF" printer. Doing this on my desktop, printing
to a PDF file does not add any appreciable amount of time, so I have my 1053
page PDF ready to go in roughly 15 seconds. With the javafx API, this would
take 20 minutes of actual user time.
One option would be to make the wait time smaller. There are some 1 second
waits in the print code, which is far too long in my situation.
A better possibility would be to make the notify() more aggressive. In
waitForNextPage(), "pageDone" is set to true, but never notifies threads
waiting on it to wake up. This seems like an oversight. Since a thread is
waiting on this flag, like implPrintPage(), it seems like code changing the
value of this flag should notify it so it can re-check the value.
The proposed change seems as safe as the existing code, since nothing in the
existing code prevents the printing thread from sporadically waking up at
this point anyway. This change would just encourage that to happen every
time.
private boolean waitForNextPage(int pageIndex) {
<snip>
pageDone = true;
<snip>
currPageInfo = newPageInfo;
newPageInfo = null;
currPageIndex = pageIndex;
currPageFormat = getPageFormatFromLayout(currPageInfo.getPageLayout());
//Suggested Addition Start
synchronized (monitor) {
monitor.notify();
}
//Suggested Addition End
return true;
}
private void implPrintPage(PageLayout pageLayout, Node node) {
<snip>
while (!pageDone) {
synchronized (monitor) {
try {
monitor.wait(1000);
} catch (InterruptedException e) {
}
}
<snip>
}