JDK-8117892 : Poor Path rendering performance.
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: fx2.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2012-04-06
  • Updated: 2015-06-17
  • Resolved: 2012-04-06
Related Reports
Duplicate :  
Description
This report is related to RT-20405 but I had to create a new one because it does not seem to be possible to attach files to other peoples reports. (Maybe I have just not found it.)

I just could not believe what was stated in the comments of the above mentioned report. So in order to have some comparison I have developed two test programs, one in JavaFX and one in Swing, and have attached them to this report.

Both programs are configured to draw a path which consists of 10_000 lines. With the mouse-wheel you can zoom in and out.

The Swing version starts up and draws the path almost instantaneously. Also zooming is done without any noticeable delay.

The JavaFX version starts up slower and then it takes several seconds until the first path is displayed. Each zoom step also takes several seconds to be completed.

It simply cannot be true that this is supposed to be the substitute for good all AWT/Graphics2D.

But there may be a hint where the actual performance bottleneck is. If I configure the Swing version to NOT limit the scale to values < 1 then I can provoke a similar bad performance in Swing too, when I zoom in so that the path has to be clipped. In order to further examine this I have added another option to use an offset position for the rendering, so that the path has to be clipped even for scale values < 1. But in this case I do not see any performance degradations. This is strange but it might help to track down this problem. Maybe JavaFX is using this unterlying feature which causes this drop in performance all the time and Swing is using it only under certain conditions.

Comments
To answer the basic issue of why FX by default is slower than Swing with a scale of 1, FX is using antialiasing. If the Swing version is modified to use antialiasing then the performance is similar. To answer the confusion about scales > 1 - if the current stroke is less than or equal to a pixel wide then it is rendered at the smallest representable line width - which is a pixel for non-aa lines, then we can use a fast bresenham renderer. As soon as the scale goes above 1.0, though, we have to use the more general line rendering algorithms that take longer. The optimization used by Swing/Java2D only applies to non-AA lines of 1.0 pixels or smaller in line width, which isn't yet supported in FX (we only do AA rendering for now).
26-04-2012

Resolving as a duplicate of RT-20405. Note that the submitter can still add comments or attachments to this report.
06-04-2012