Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaFX did not start #622

Closed
designgears opened this issue Apr 22, 2020 · 22 comments
Closed

JavaFX did not start #622

designgears opened this issue Apr 22, 2020 · 22 comments
Assignees
Labels
Milestone

Comments

@designgears
Copy link

Simplest way I was able to reproduce the issue was using the demo page pixel printing tab and clicking the print html button.

It works fine when using my windows 10 dev env with the same versions of QZ and Java.

I also tried compiling from source, but got the same results, works in windows, fails in ubuntu.

OS Version:

Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic

QZ Tray Version:

version | 2.1.0+1

Java Version:

java 14.0.1 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

Log:

Apr 22 12:11:51 qztray java[12190]: [DEBUG] 2020-04-22 12:11:51,817 @ qz.printer.PrintServiceMatcher:?
Apr 22 12:11:51 qztray java[12190]: Found 7 printers
Apr 22 12:11:51 qztray java[12190]: [DEBUG] 2020-04-22 12:11:51,818 @ qz.printer.PrintServiceMatcher:?
Apr 22 12:11:51 qztray java[12190]: Found match: Gizmo
Apr 22 12:11:51 qztray java[12190]: [TRACE] 2020-04-22 12:11:51,868 @ qz.printer.action.WebApp:?
Apr 22 12:11:51 qztray java[12190]: Waiting for JavaFX..
Apr 22 12:11:51 qztray java[12190]: Exception in thread "Thread-39" java.lang.UnsupportedOperationException:
Apr 22 12:11:51 qztray java[12190]: at com.sun.glass.ui.gtk.GtkApplication.lambda$new$6(GtkApplicatio
Apr 22 12:11:51 qztray java[12190]: at java.base/java.security.AccessController.doPrivileged(AccessCo
Apr 22 12:11:51 qztray java[12190]: at com.sun.glass.ui.gtk.GtkApplication.(GtkApplication.java
Apr 22 12:11:51 qztray java[12190]: at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkP
Apr 22 12:11:51 qztray java[12190]: at com.sun.glass.ui.Application.run(Application.java:144)
Apr 22 12:11:51 qztray java[12190]: at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolki
Apr 22 12:11:51 qztray java[12190]: at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.j
Apr 22 12:11:51 qztray java[12190]: at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.j
Apr 22 12:11:51 qztray java[12190]: at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherI
Apr 22 12:11:51 qztray java[12190]: at com.sun.javafx.application.LauncherImpl.launchApplication1(Lau
Apr 22 12:11:51 qztray java[12190]: at com.sun.javafx.application.LauncherImpl.lambda$launchApplicati
Apr 22 12:11:51 qztray java[12190]: at java.base/java.lang.Thread.run(Thread.java:832)
Apr 22 12:11:52 qztray java[12190]: [TRACE] 2020-04-22 12:11:52,123 @ qz.printer.action.WebApp:?
Apr 22 12:11:52 qztray java[12190]: Waiting for JavaFX..
Apr 22 12:11:52 qztray java[12190]: [TRACE] 2020-04-22 12:11:52,375 @ qz.printer.action.WebApp:?
...
Apr 22 12:12:52 qztray java[12190]: [TRACE] 2020-04-22 12:12:52,183 @ qz.printer.action.WebApp:?
Apr 22 12:12:52 qztray java[12190]: Waiting for JavaFX..
Apr 22 12:12:52 qztray java[12190]: [ERROR] 2020-04-22 12:12:52,435 @ qz.utils.PrintingUtilities:?
Apr 22 12:12:52 qztray java[12190]: Failed to print
Apr 22 12:12:52 qztray java[12190]: java.lang.UnsupportedOperationException: Unable to start JavaFX service
Apr 22 12:12:52 qztray java[12190]: at qz.printer.action.PrintHTML.parseData(Unknown Source)
Apr 22 12:12:52 qztray java[12190]: at qz.utils.PrintingUtilities.processPrintRequest(Unknown Source)
Apr 22 12:12:52 qztray java[12190]: at qz.ws.PrintSocketClient.processMessage(Unknown Source)
Apr 22 12:12:52 qztray java[12190]: at qz.ws.PrintSocketClient.onMessage(Unknown Source)
Apr 22 12:12:52 qztray java[12190]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke
Apr 22 12:12:52 qztray java[12190]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke
Apr 22 12:12:52 qztray java[12190]: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.in
Apr 22 12:12:52 qztray java[12190]: at java.base/java.lang.reflect.Method.invoke(Method.java:564)
Apr 22 12:12:52 qztray java[12190]: at org.eclipse.jetty.websocket.common.events.annotated.CallableMe
Apr 22 12:12:52 qztray java[12190]: at org.eclipse.jetty.websocket.common.events.annotated.OptionalSe
Apr 22 12:12:52 qztray java[12190]: at org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventD
Apr 22 12:12:52 qztray java[12190]: at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedTh
Apr 22 12:12:52 qztray java[12190]: at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(Queu
Apr 22 12:12:52 qztray java[12190]: at java.base/java.lang.Thread.run(Thread.java:832)
Apr 22 12:12:52 qztray java[12190]: Caused by: java.io.IOException: JavaFX did not start
Apr 22 12:12:52 qztray java[12190]: at qz.printer.action.WebApp.initialize(Unknown Source)
Apr 22 12:12:52 qztray java[12190]: ... 14 more
Apr 22 12:12:52 qztray java[12190]: [TRACE] 2020-04-22 12:12:52,437 @ qz.utils.PrintingUtilities:?
Apr 22 12:12:52 qztray java[12190]: Returning processor back to pool

@tresf
Copy link
Contributor

tresf commented Apr 22, 2020

We haven't tried Java 14 yet, so there might be a bug. I assume this is on x86_64? I have to ask because we don't yet provide Java FX for Linux ARM64 with our installer.

@designgears
Copy link
Author

It is x86_64, what version of Java would you recommend for the current version of QZ?

@tresf
Copy link
Contributor

tresf commented Apr 22, 2020

AdoptOpenJDK11 will work on 18.04. Note, although this will fix your issue it's still on us to find out why Java 14 is failing.

https://qz.io/wiki/upgrading-java#linux

@designgears
Copy link
Author

I'll swap that on my server and give it a go and report back.

@tresf
Copy link
Contributor

tresf commented Apr 22, 2020

Great. Note:

  1. Java 11 is chosen for strategic purposes per:
  1. JavaFX may have issues starting on a headless server. We're working hard to fix this by working directly with the JavaFX developers on JavaFX 15 using the early access builds from Gluon but the code isn't ported to 2.1 yet (and 2.0 offered absolutely no headless support) so you may need to start the JVM in a virtual framebuffer if you require JavaFX until this project is completed. The project is being tracked for 2.0 here: Switch JavaFX to Monocle Implementation #576 but will be landing a new PR once we've ported that over to 2.1.

@designgears
Copy link
Author

Getting the same issue. How would I go about starting the JVM in a virtual framebuffer?

openjdk 11.0.7 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)

@tresf
Copy link
Contributor

tresf commented Apr 22, 2020

I haven't done it in ages, but xvfb I believe is how it's done. We don't have a tutorial yet but can create one in a few days if you run into trouble.

@designgears
Copy link
Author

A quick test produced the same results, I saw there were more complex setups for xvfb but haven't tried them yet.

This yielded the same result unfortunately.

xvfb-run /usr/bin/java -Xms512m -jar /opt/qz-tray/qz-tray.jar

@designgears
Copy link
Author

I've had some success with this setup, however it takes about 1s per page. Is that what I should expect?

The page contains text, 2 tables, base64 encoded jpg logo, svg barcode.

@tresf
Copy link
Contributor

tresf commented Apr 22, 2020

I've had some success with this setup, however it takes about 1s per page. Is that what I should expect?

The page contains text, 2 tables, base64 encoded jpg logo, svg barcode.

Possibly. We completely reworked the timing over on #623 if you're interested in testing it. We're a bit backlogged and haven't tested it yet, but it's expected to be merged for 2.1.1 or possibly 2.1.2.

@designgears
Copy link
Author

designgears commented Apr 22, 2020

Possibly. We completely reworked the timing over on #623 if you're interested in testing it. We're a bit backlogged and haven't tested it yet, but it's expected to be merged for 2.1.1 or possibly 2.1.2.

Well, that was much faster, it printed the proper number of pages, but every page after the first one was blank.

@tresf
Copy link
Contributor

tresf commented Apr 22, 2020

Thanks, can you provide your feedback over there and we'll take a look.

@tresf
Copy link
Contributor

tresf commented Apr 28, 2020

@designgears as we attempt to fix the behavior for the 2.1.1 release, we're also finalizing the 2.0.12 release which also adds performance improvements. If interested, a build is available for download here. Note, this uses the older, slower { rasterize: true } technique, but should be identical in behavior to the original bug report, but with improved performance and reliablity.

@designgears
Copy link
Author

designgears commented Apr 28, 2020

This is working well headless, but I'm unable to control the content zoom, it blows everything up to x4.166666666666667

The text below is; font-size: 2em font-weight: bolder
image
image

@tresf
Copy link
Contributor

tresf commented Apr 29, 2020

Can you use { scaleContent: true }? I think we may have missed something.

@designgears
Copy link
Author

designgears commented Apr 29, 2020

That corrected the scaling issue, isn't that reverse of what it's supposed to do?

@tresf
Copy link
Contributor

tresf commented Apr 29, 2020

2.0 defaulted to true whereas 2.1 defaulted to false. Of course 2.1 uses a different technique so it's not the same result. I'm looking into it but @bberenz says this is how it's always behaved so it may be a nuance of 2.0 that we can't fix. I'll know more as our testers run regression tests.

@tresf
Copy link
Contributor

tresf commented Apr 29, 2020

To add a bit more context, 2.1's sample defaults to false, so if you're switching back and forth that would explain it.

@designgears
Copy link
Author

designgears commented Apr 29, 2020

I swapped from 2.1 to 2.0 test build you posted, scaleContent has always been set to false, pretty sure the only version I've used until now has been 2.1. So the switching certainly explains it if that has always been that way on 2.0.

Totally fine with that, I had to make some code tweaks to make scaleContent: true work the way I wanted it to, other than that things look good. I plan on testing this in production tomorrow.

@tresf
Copy link
Contributor

tresf commented May 1, 2020

I'm closing this as resolved for two reasons:

  • 2.0.12 offers Monocle, a true headless HTML renderer (note, 2.0 is NOT compatible with pure headless environments)
  • 2.1.1 will bring forward all 2.0 HTML improvements as well as provide the vector printing via { rasterize: true }. (note, 2.1 is compatible with pure headless environments).

So I think this is good to close. Please request a reopen if you believe it was closed incorrectly or prematurely.

@designgears
Copy link
Author

Sounds good, HTML rendering is pretty intense, doing around 94 pages around 100+ times a day. Even with a 4cores at 2.3ghz per it takes about 30 seconds to hit the printer. Ultimately went back to passing the HTML off to wkhtmltopdf on the webserver to generate a base64encoded pdf, pass that back to the tablet, and send that off to qz.

Not sure if it's possible but I would love to see an wkhtmltopdf/wkhtmltoimage implementation down the road. :)

@tresf
Copy link
Contributor

tresf commented May 2, 2020

2.0 is pretty taxing because it has to snapshot the webpage each time and for higher dpi printers, that's a lot. 2.1 fixes that by sending vector data to the printer, but the performance improvements won't land there until early next week.

wkhtmltopdf actually uses WebKit (as does JavaFX) to perform the PDF conversion, it's likely a better long-term solution (per #558) but replacing it would be quite the undertaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants