JDK-8148827 : Indeterminate ProgressBar initially tree invisible does not animate until layoutChildren()
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u71
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: other
  • CPU: x86
  • Submitted: 2016-02-01
  • Updated: 2016-07-06
  • Resolved: 2016-07-06
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 9
9Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_71"
Java(TM) SE Runtime Environment (build 1.8.0_71-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.71-b15, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 10.0.10586]

A DESCRIPTION OF THE PROBLEM :
If an indeterminate ProgressBar that is initially not tree visible becomes tree visible in a manner that does not call ProgressBarSkin.layoutChildren(...), then it fails to animate.

Inspection of class ProgressBarSkin source code reveals that it only plays indeterminateTransition in its layoutChildren(...) call.
It seems that ProgressBarSkin should listen for changes in tree visibility of the ProgressBar to play the animation, because that is the condition enclosing the play() call.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a TabPane with 2 tabs. Add an indeterminate ProgressBar on the second tab. Show a Scene containing the TabPane. Select the second tab.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The ProgressBar should animate.
ACTUAL -
The ProgressBar does not animate.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package materialcss;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;

/**
 * Demonstrates ProgressBar failure to animate after becoming tree visible
 * without ProgressBarSkin getting a layoutChildren() call.
 **/
public class ProgressBarTest extends Application {

   @Override
   public void start( final Stage primaryStage ) throws Exception {
      final TabPane root = new TabPane();
      root.getTabs()
          .add( new Tab( "1" ) );
      final Tab progressTab = new Tab( "2" );
      root.getTabs()
          .add( progressTab );
      progressTab.setContent( new ProgressBar() );
      final Scene scene = new Scene( root );
      primaryStage.setScene( scene );
      primaryStage.show();
   }

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

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

CUSTOMER SUBMITTED WORKAROUND :
Ensure in an ad hoc manner that the ProgressBar is tree visible during its Skin's initial layoutChildren(...) call.
Or, when you know by some ad hoc means that the ProgressBar has become tree visible, do something that causes its Skin to receive a layoutChildren(...) call. For example, call ProgressBar.setVisible(false) followed by ProgressBar.setVisible(true).

Creating a good workaround is hampered by client code's prohibition from listening to tree visibility due to it being marked as a private API.


Comments
This has been resolved as part of JDK-8151165.
06-07-2016

This issue is related to JDK-8094078, and in particular my comments here: https://bugs.openjdk.java.net/browse/JDK-8094078?focusedCommentId=13800851l#comment-13800851 https://bugs.openjdk.java.net/browse/JDK-8094078?focusedCommentId=13800950#comment-13800950 Simply adding a listener to treeVisible will basically reintroduce the issue in JDK-8094078, so we either need to handle this better, or ideally, come up with API similar to treeVisible that works as required. JDK-8090322 might also be related...
08-02-2016