JDK-8202022 : Performance regression probably caused by correction of JDK-8183100
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u172,10,openjfx11
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: x86_64
  • Submitted: 2018-04-19
  • Updated: 2018-06-13
  • Resolved: 2018-04-20
Related Reports
Duplicate :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Microsoft Windows [version 10.0.16299.371]

A DESCRIPTION OF THE PROBLEM :
Jdk8.172 introduce a big performance regression with many levels of nested javafx Nodes with styleClass

REGRESSION : Last worked in version 8u162

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Run the attached example (same example that I attached for https://bugs.openjdk.java.net/browse/JDK-8199216).
- Type "300" in text Field 
- click on "click" button


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
in Jdk1.8.162, with same scenario, view is dispayed INSTANTANEOUSLY!!!!
ACTUAL -
in JDK1.8.172,  view takes at least 3 second to be displayed

In our application, time to build views is severely degraded, sometimes by a factor if 20!!!

---------- BEGIN SOURCE ----------
package perfo;

import javafx.application.Application;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.control.ToolBar;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author daniel
 */
public class Perfo extends Application {

    private BorderPane pane;

    @Override
    public void start(Stage primaryStage) throws Exception {
        String dialogStyleSheet = getClass().getResource("perfo.css").toExternalForm();
        pane = new BorderPane();
        final Button button = new Button("click");
        TextField textField = new TextField("10");
        pane.setTop(new ToolBar(button, textField));
        button.setOnAction(e -> {
            HBox hbox = new HBox();
            hbox.getStyleClass().add("myhbox");
            int nb = Integer.parseInt(textField.getText());
            for (int i = 0; i < nb; i++) {

                hbox = new HBox(new Text("y"), hbox);
                hbox.getStyleClass().add("myhbox");
                final HBox h = hbox;
                h.setPadding(new Insets(1));
                hbox.hoverProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean isHover) -> {
                    if (isHover) {
                        h.getStyleClass().add("myhbox-hover");
                    } else {
                        h.getStyleClass().remove("myhbox-hover");
                    }

//                    h.setStyle(isHover ? "-fx-border-color: red; -fx-border-width: 1;" : "");
//                    if (isHover) {
//                        h.setBorder(new Border(new BorderStroke(Color.RED, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
//                    } else {
//                        h.setBorder(null);
//                    }
                });
            }
            pane.setCenter(hbox);

        });

        Scene scene = new Scene(pane);
        scene.getStylesheets().add(dialogStyleSheet);
        primaryStage.setScene(scene);
        primaryStage.sizeToScene();
        primaryStage.show();
    }

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

--------------------
perfo.css
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
/*
    Created on : 6 f����vr. 2018, 15:04:17
    Author     : daniel
*/

.myhbox-hover {
    -fx-border-color: red;
    -fx-border-width: 1;
    -fx-padding : 1 ;
}

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

FREQUENCY : always



Comments
The issue with this is : CSS Performance Vs CSS correctness. A bit of history : The performance issue was earlier reported in 8u72 - as JDK-8151756 It was fixed - in 8u102 & JDK 9 This performance fix caused multiple CSS correctness regressions reported as - JDK-8185709, JDK-8183100, JDK-8168951. After a lot of discussion, it was decided that the performance fix (done for JDK-8151756) needs to be reverted. This patch reversal was done under JDK-8183100 (in 8u172 & 10) Now : 8u172, JDK 10 and JDK 11ea : have CSS correctness, but suffers performance lag in suggested cases. JDK 9 : has good CSS performance, but has CSS being incorrectly applied in some cases.
20-04-2018

Yes, i confirm this is regression started from 8u172, likely caused by JDK-8183100 (as claimed in the report) There is a slight delay introduced in display 8u161/8u162 - Pass 8u171 - Pass 8u172 - Fail --> Regression introduced here 9.0.4 - Pass 10 GA - Fail 11 ea b09 - Fail
19-04-2018