JDK-8102571 : Indeterminate progressbar uses too much CPU (even when invisible)
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: fx2.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2012-03-29
  • Updated: 2018-03-26
  • Resolved: 2012-08-28
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 8
8Fixed
Related Reports
Relates :  
Relates :  
Description
The indeterminate mode of ProgressBar uses 20-25% of my 2.6 GHz CPU (almost a whole core). This occurs also if the progressbar is invisible. The CPU load also depends on the width of the control and whether it is embedded in Swing or not. Above values are for a Swing application. Without Swing the load is about half of that.

Since the indeterminate mode is the default it is easy to fall into this trap, too: just add <Progressbar/> to your fxml inside an invisible container and you get high CPU load which is hard to debug. I noticed that suspending the quantum thread would stop the CPU load but that does not help much to find out exactly which control might be causing this.

I think that a fix should address two issues:
1. Less CPU load when the indeterminate progressbar is visible. It seems to run with too many frames per second...
2. No extra CPU load at all if the indeterminate progressbar is not visible. This was partially fixed with RT-11577 but that fix did not consider visibility of parent nodes in the scene graph. (Workaround for progressbar in invisible container: progress="0" or visible="false" on progressbar itself).

I have attached two example classes, an FX application and a Swing application with JFXPanel. In the Swing application things seem to be worse (uses more CPU). This is also how I noticed this because I am adding JFXPanels to a Swing application. In the examples, CPU load is reduced only if the progressbar itself is made invisible or if its width is reduced.
Comments
I just wasn't sure whether this is a general JFXPanel animation issue or specific to the progress bar. If the former I fully agree to handle it on that ticket.
28-08-2012

The Progress controls now avoid unnecessary animation, which was their main contribution to the CPU load issue. The Progress problem was fixed under this jira. Fixing two unrelated issues (or only related by testcase) under the same jira is a bad idea. The JFXPanel should be treated as a separate issue, as the JFXPanel issue isn't specific to ProgressBar.
28-08-2012

Mick, thanks for working on this. It seems though as if the main issue is not addressed: an indeterminate (visible) progressbar on a jfxpanel takes about 40% cpu on my dualcore hyperthreading processor. Hardware acceleration should be available as well. Checking for visibility does not help in this case, the progressbar is and should be visible. Might be related to RT-24278 but I don't know.
28-08-2012

This change pauses the timelines when they aren't visible to the user. changeset: 1664:c3d496ae74df tag: tip user: mickf date: Tue Aug 28 16:50:55 2012 +0100 summary: RT-20702 : Indeterminate progressbar uses too much CPU (even when invisible)
28-08-2012

Mick, thanks - I noticed that already. It is in the issue description. The workaround is easy enough (I prefer progress="0") but unfortunately it took some time to find what was causing the CPU load because at that time the progressbar already was a few days in the fxml and I had changed lots of other things meanwhile.
30-03-2012

In the FXProgressbar example the ProgressBar is visible, but the VBox is invisible. The ProgressBar only checks it's own visibility state and whether it has a Scene when toggling it's timeline. If you set the ProgressBar invisible, or remove it from the Scene then the CPU load will drop.
30-03-2012