Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8143033

[CSS] Performance issue with JavaFX

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • 8u20
    • javafx
    • x86
    • windows_8

    Backports

      Description

        FULL PRODUCT VERSION :
        1.8.0_20 and after (tested using 1.8.0_45 and 1.8.0_66)



        ADDITIONAL OS VERSION INFORMATION :
        Windows 10 Professional 64 bits

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        i7 6700K
        GTX 980 TI

        A DESCRIPTION OF THE PROBLEM :
        Since Java 8u20, there is a performance regression in some specidic cases with JavaFX.
        I believe that the patch in the ticket JDK-8094828 is the cause of this problem, based on a CPU sampler test using Java VisualVM during the execution of the attached reproduction code.

        REGRESSION. Last worked in version 8u45

        ADDITIONAL REGRESSION INFORMATION:
        1.8.0_11 and before

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        There are multiple cases to reproduce this problem.
        A simple one is to add a chart to a scene and update its data regularly.
        The data node must have a tooltip (without the tooltip, the issue doesn't appear).
        I think this thread is also referring to the same issue but without solution : https://community.oracle.com/thread/3720889

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        When one runs the attached reproduction code with Java 1.8.0_11 and before, the performance which is printed on the standard output is fast and steady : between 0.002 and 0.005 seconds to update the chart data.
        ACTUAL -
        When one runs the attached reproduction code with Java 1.8.0_20 and after, the performance which is printed on the standard output is slow and is worsened with time.
        To update the chart data, at the beginning, it takes between 0.03 and 0.05 seconds (which is already 10 times slower than with Java 1.8.0_11 and before) and after a few minutes, it takes 0.5 seconds and more, causing the display to freeze.

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        No crash appears, it is a performance issue.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.security.SecureRandom;
        import java.time.LocalDateTime;
        import java.time.temporal.ChronoUnit;
        import java.util.Random;

        import javafx.application.Application;
        import javafx.application.Platform;
        import javafx.scene.Scene;
        import javafx.scene.chart.LineChart;
        import javafx.scene.chart.NumberAxis;
        import javafx.scene.chart.XYChart.Data;
        import javafx.scene.chart.XYChart.Series;
        import javafx.scene.control.Tooltip;
        import javafx.stage.Stage;

        public class Test extends Application {
        private LineChart<Number, Number> lineChart;

        @Override
        public void start(Stage primaryStage) throws Exception {
        lineChart = new LineChart<>(new NumberAxis(), new NumberAxis());
        lineChart.setAnimated(false);
        Scene scene = new Scene(lineChart);
        scene.getStylesheets().add("/test.css");
        primaryStage.setScene(scene);
        Thread thread = new Thread(this::update);
        thread.setDaemon(true);
        thread.start();
        primaryStage.show();
        }

        private void update() {
        boolean interrupted = false;
        while (!interrupted) {
        Random random = new SecureRandom();
        Series<Number, Number> series = new Series<>();
        for (int i = 0; i < 250; i++) {
        series.getData().add(new Data<>(i, random.nextInt(500)));
        }
        Platform.runLater(() -> {
        LocalDateTime start = LocalDateTime.now();
        lineChart.getData().clear();
        lineChart.getData().add(series);
        for (Data<Number, Number> data : series.getData()) {
        Tooltip.install(data.getNode(), new Tooltip(data.getXValue() + "," + data.getYValue()));
        }
        LocalDateTime end = LocalDateTime.now();
        System.out.println(start.until(end, ChronoUnit.MILLIS) / 1000d + " seconds");
        });
        try {
        Thread.sleep(100);
        } catch (InterruptedException e) {
        interrupted = true;
        }
        }
        }

        public static final void main(String[] args) {
        launch(args);
        }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        For the attached reproduction code, not using a tooltip on the data nodes removes the issue.
        However, there are other reproduction cases, like the one explained on this thread that I think is related : https://community.oracle.com/thread/3720889

        Attachments

          Issue Links

            Activity

              People

                jgiles Jonathan Giles
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: