-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
8u131
-
x86_64
-
linux_ubuntu
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 16.04
4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Nothing special
A DESCRIPTION OF THE PROBLEM :
On some (but not all) Ubuntu machines, the JavaFX framerate is essentially unlimited (in excess of 1000fps), which destroys animation effects. I have two machines (one laptop, one PC) with the same OS and the same Java version; the problem occurs on one machine but not the other. Posting on StackOverflow, another person confirmed the problem on their machine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the "SimpleFrameRateMeter" program in the accepted answer to this StackOverflow question: https://stackoverflow.com/questions/28287398/what-is-the-preferred-way-of-getting-the-frame-rate-of-a-javafx-application
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Framerate should be around 60fps
ACTUAL -
On affected machines, the framerate is much higher, often over 1000fps
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
* Program to display the JavaFX framerate. This program comes from
* https://stackoverflow.com/questions/28287398/what-is-the-preferred-way-of-
* getting-the-frame-rate-of-a-javafx-application
*
* Normally, the framerate should be around 60fps. On some Ubuntu machines,
* however, the framerate appears to be unlimited; this program displays more
* than 1000fps, which destroys certain animation effects. This occurs under
* Java 1.8.0_131 and Ubuntu 16.04, but unfortunately, not on all machines.
*
* On the affected machines, this behavior can be corrected by setting the
* option "quantum.multithreaded=false" on the command line:
*
* export _JAVA_OPTIONS="-Dquantum.multithreaded=false"
*
* before executing the program. Oddly, setting this option in the java command
* itself
*
* java -Dquantum.multithreaded=false SimpleFrameRateMeter
*
* does *not* work.
*/
public class SimpleFrameRateMeter extends Application {
private final long[] frameTimes = new long[100];
private int frameTimeIndex = 0;
private boolean arrayFilled = false;
@Override
public void start(Stage primaryStage) {
Label label = new Label();
AnimationTimer frameRateMeter = new AnimationTimer() {
@Override
public void handle(long now) {
long oldFrameTime = frameTimes[frameTimeIndex];
frameTimes[frameTimeIndex] = now;
frameTimeIndex = (frameTimeIndex + 1) % frameTimes.length;
if (frameTimeIndex == 0) {
arrayFilled = true;
}
if (arrayFilled) {
long elapsedNanos = now - oldFrameTime;
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length;
double frameRate = 1_000_000_000.0 / elapsedNanosPerFrame;
label.setText(String.format("Current frame rate: %.3f", frameRate));
}
}
};
frameRateMeter.start();
primaryStage.setScene(new Scene(new StackPane(label), 250, 150));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
On the affected machines, this behavior can be corrected by setting the option "quantum.multithreaded=false" on the command line:
export _JAVA_OPTIONS="-Dquantum.multithreaded=false"
before executing the program. Oddly, setting this option in the java command itself
java -Dquantum.multithreaded=false SimpleFrameRateMeter
does *not* work.
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 16.04
4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Nothing special
A DESCRIPTION OF THE PROBLEM :
On some (but not all) Ubuntu machines, the JavaFX framerate is essentially unlimited (in excess of 1000fps), which destroys animation effects. I have two machines (one laptop, one PC) with the same OS and the same Java version; the problem occurs on one machine but not the other. Posting on StackOverflow, another person confirmed the problem on their machine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the "SimpleFrameRateMeter" program in the accepted answer to this StackOverflow question: https://stackoverflow.com/questions/28287398/what-is-the-preferred-way-of-getting-the-frame-rate-of-a-javafx-application
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Framerate should be around 60fps
ACTUAL -
On affected machines, the framerate is much higher, often over 1000fps
REPRODUCIBILITY :
This bug can be reproduced occasionally.
---------- BEGIN SOURCE ----------
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
* Program to display the JavaFX framerate. This program comes from
* https://stackoverflow.com/questions/28287398/what-is-the-preferred-way-of-
* getting-the-frame-rate-of-a-javafx-application
*
* Normally, the framerate should be around 60fps. On some Ubuntu machines,
* however, the framerate appears to be unlimited; this program displays more
* than 1000fps, which destroys certain animation effects. This occurs under
* Java 1.8.0_131 and Ubuntu 16.04, but unfortunately, not on all machines.
*
* On the affected machines, this behavior can be corrected by setting the
* option "quantum.multithreaded=false" on the command line:
*
* export _JAVA_OPTIONS="-Dquantum.multithreaded=false"
*
* before executing the program. Oddly, setting this option in the java command
* itself
*
* java -Dquantum.multithreaded=false SimpleFrameRateMeter
*
* does *not* work.
*/
public class SimpleFrameRateMeter extends Application {
private final long[] frameTimes = new long[100];
private int frameTimeIndex = 0;
private boolean arrayFilled = false;
@Override
public void start(Stage primaryStage) {
Label label = new Label();
AnimationTimer frameRateMeter = new AnimationTimer() {
@Override
public void handle(long now) {
long oldFrameTime = frameTimes[frameTimeIndex];
frameTimes[frameTimeIndex] = now;
frameTimeIndex = (frameTimeIndex + 1) % frameTimes.length;
if (frameTimeIndex == 0) {
arrayFilled = true;
}
if (arrayFilled) {
long elapsedNanos = now - oldFrameTime;
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length;
double frameRate = 1_000_000_000.0 / elapsedNanosPerFrame;
label.setText(String.format("Current frame rate: %.3f", frameRate));
}
}
};
frameRateMeter.start();
primaryStage.setScene(new Scene(new StackPane(label), 250, 150));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
On the affected machines, this behavior can be corrected by setting the option "quantum.multithreaded=false" on the command line:
export _JAVA_OPTIONS="-Dquantum.multithreaded=false"
before executing the program. Oddly, setting this option in the java command itself
java -Dquantum.multithreaded=false SimpleFrameRateMeter
does *not* work.
- duplicates
-
JDK-8191179 Uncontrolled Frame Rate in AnimationTimer
- Closed
-
JDK-8210547 [linux] Uncontrolled framerate
- Open