caprica / vlcj-javafx-demo

Sample application showing vlcj rendering video in a JavaFX scene.
113 stars 46 forks source link

JavaFX glitchy rendering on Linux #31

Open caprica opened 4 years ago

caprica commented 4 years ago

This is IMO a problem with JavaFX on Linux, but I am documenting here for reference.

With simple Scenes this will not be apparent, but there are two cases where glitchy flickering rendering occurs, especially with complex scenes or especially when putting the scene graph under "stress" I suppose, e.g. by rendering many video views at the same time.

  1. Resizing causes all sorts of bad rendering, especially with e.g. menus in the top part of a border pane. The resizing/repositioning of the menu bar will badly lag the resizing of the frame, leading to the menu bar being out of position until it catches up and looking pretty ugly.

  2. Flickering/leaking of the background scene fill - here it looks like some race condition or some other sort of thread synchronisation issue which becomes apparent the more you add to a scene (the glitching appears to happen on later components rather than earlier ones, or the busier the scene gets (e.g. I render a grid of 2x2 or more concurrent video views). These glitches are really bad.

The stranger thing about #2 is that sometimes when you run the application it will be flawless. Other times when you run the exact same application (e.g. immediately after, without making any changes) the glitches will occur. Once your application runs it seems either locked in to a glitching or non glitching state.

This page documents some flags that can be used that may help:

http://werner.yellowcouch.org/log/javafx-8-command-line-options/

  1. -Dprism.forceUploadingPainter=true (it is false by default) for the menu glitch
  2. -Dprism.dirtyopts=false (it is true by default) for the other glitches

In my own tests, #2 so far has fixed the second glitching/flickering case, but it will come with a performance penalty. The conclusion here is the "dirty optimisations" that JavaFX is doing, on Linux at least, are broken in some way.

When I tested on macOS I did not see these problems, but my macOS testing is less extensive.

I do not routinely test on any Microsoft platform.

caprica commented 4 years ago

Note to self: check OpenGL page-flipping settings.