JDK-8168951 : Colors not display on LineChart
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u102,9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2016-10-28
  • Updated: 2017-12-15
  • Resolved: 2017-12-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10
10Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Darwin Liams-MacBook-Pro.local 14.5.0 Darwin Kernel Version 14.5.0: Sun Sep 25 22:07:15 PDT 2016; root:xnu-2782.50.9~1/RELEASE_X86_64 x86_64


A DESCRIPTION OF THE PROBLEM :
The attached program displays the LineChart in red on Java 8 update 101 and below. If I use Java 8 update 102 or later (I've tried 111 and 112) the line is black.



REGRESSION.  Last worked in version 8u101

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached program and look at the colour of the LineChart.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Line Chart should be red.
ACTUAL -
The Line Chart is black.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class GraphColorIssue extends Application
{
    private LineChart<Number, Number> mLineChart = 
            new LineChart<>(new NumberAxis(), new NumberAxis());
    private int mTime = 1;
    private GridPane mGridPane;
    
    public static void main(String[] args) 
    {
        launch(args);
    }
   
    @Override
    public void start(
        final Stage primaryStage) throws Exception
    {
        mGridPane = new GridPane();
        mGridPane.add(mLineChart, 1, 1);
        mGridPane.setMinWidth(300);
        mGridPane.setMinHeight(300);
        
        final Scene scene = new Scene(mGridPane);
        primaryStage.setScene(scene);
        primaryStage.show();
        simulateASyncGraphDataUpdate();
    }

    private void scheduleDataLoad()
    {
        final Timeline timeline = new Timeline(new KeyFrame(
                javafx.util.Duration.seconds(1),
                ae -> simulateASyncGraphDataUpdate()));
        timeline.play();
    }
    
    public void simulateASyncGraphDataUpdate()
    {
        setGridContents(0, new Label("Loading..."));
        
        final Timeline timeline = new Timeline(new KeyFrame(
                javafx.util.Duration.seconds(1),
                ae -> simulateDataReady()));
        timeline.play();
    }
    
    private void simulateDataReady()
    {
        updateLineChartData();
        setGridContents(0, mLineChart);
        scheduleDataLoad();
    }
    
    private void updateLineChartData()
    {
        // Comment this line in and you'll get colors.
        //mLineChart = new LineChart<>(new NumberAxis(), new NumberAxis());
        mLineChart.setTitle("Line Chart Color Issue - using Java " + System.getProperty("java.version"));
        
        ++mTime;
        final Series<Number, Number> series = new Series<>();
        for (int x = 0; x < mTime; x++)
        {
            final XYChart.Data<Number, Number> dataPoint = new XYChart.Data<>(x, 5);
            series.getData().add(dataPoint);
        }
        mLineChart.getData().clear();
        mLineChart.getData().add(series);
    }
    
    private void setGridContents(
        final int index,
        final Node node)
    {
        mGridPane.getChildren().set(index, node);
    }

}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use a new mLineChart instance each time - uncomment first line in updateLineChartData() method to see.


Comments
This regression has been fixed (by reverting JDK-8151756) under JDK-8183100. Hence closing this as duplicate.
14-12-2017

This is a regression caused due to JDK-8151756.
14-12-2017

As regression labeled and introduced in 8u or 9 -- targeted to 10
17-02-2017

Approved by component triage team to defer
31-01-2017

SQE: JDK 9: OK to defer
31-01-2017

no time resources to fix it 9, so defer request
31-01-2017

First, the chart is added to the root of the scene, causing reapplyCss to be called on the chart and its children so their styleHelpers are initialized. Then the chart is replaced with the label, then the scene is showed and processCSS is called on the root and the label but not on the chart. Now the chart's list of children is modified (the Path for new Series is added to the plotContent). Because the current scene for the chart is null, invalidatedScenes is not called from the Parent.children.onChanged->node.setScenes (which would cause the reapplyCss call for new children) Then the chart added back to the scene and scenesChanged is called which pass false as reapplyCSS for its children so it doesn't get called for the new children of the chart. Now when the reapplyCss is called for the chart itself it doesn't call reapplyCss for its children either because the styleHelper hasn't changed or the parent is clean. Eventually when the processCSS is called, the parent (plotContent) of the new child is also clean and so processCSS is not called for the new node.
23-12-2016

Adding Jonathan to the watch list since it was his CSS performance fix that introduced this regression.
02-11-2016

I have isolated that the fix to JDK-8151756 has caused the reported regression in 8u102 and 9.
02-11-2016

Bisecting 8udev found this changeset caused the regression: changeset: 9275:a1a7ab147c1b user: jgiles date: Sat Apr 02 14:15:37 2016 +1300 summary: 8151756: JavaFX CSS is applied redundantly leading to significant performance degradation
02-11-2016

Chien: you might want to bisect and see what changed in 9+112 build.
31-10-2016

Checked this issue against 8,8u101,8u102,8u111,8u112,9ea on Windows and could reproduce the issue as reported by the submitter. Steps to reproduce: ************************* - Run the attached test application(GraphColorIssue.java) with JDK. Result: ********* OS : Windows 7 64 bit [Version 6.1.7601], Linux ubuntu 14.04 LTS JDK: 8u76 b04 : Pass 8u101 b13 : Pass >> 8u102 b14 : Fail <<===== introduced in version [JDK 8 family] 8u111 b14 : Fail 8u112 b15 : Fail 8u122ea b02 : Fail ------------------------ 9eab01 : Pass 9ea+107 : Pass 9ea+111 : Pass >>9ea+112 : Fail <<====== introduced in version [JDK 9 family] 9ea+114 : Fail 9ea+116 : Fail 9ea+117 : Fail 9ea+126 : Fail 9ea+133 : Fail ================================================================================================================ Issue Found: =================== JDK 8 : From 8u102 onwards JDK9ea : From 9ea+112 onwards
31-10-2016