How to ignore the 60fps limit in javafx?

I need to create a 100fps animation that display 3d data from a file that contains 100 frames per second. But the AnimationTimer in javaFx allows me to get 60fps only. How to get over it?


Removing the JavaFX Frame Rate Cap

You can remove the 60fps JavaFX frame rate cap by setting a system property, e.g.,

java -Djavafx.animation.fullspeed=true MyApp

Which is an undocumented and unsupported setting.

Removing the JavaFX frame rate cap may make your application considerably less efficient in terms of resource usage (e.g. a JavaFX application without a frame rate cap will consume more CPU than an application with the frame rate cap in place).

Configuring the JavaFX Frame Rate Cap

Additionally, there is another undocumented system property you could try:

javafx.animation.framerate

I have not tried it.

Debugging JavaFX Frames (Pulses)

There are other settings like -Djavafx.pulseLogger=true which you could enable to help you debug the JavaFX architecture and validate that your application is actually running at the framerate you expect.

JavaFX 8 has a Pulse Logger (-Djavafx.pulseLogger=true system property) that "prints out a lot of crap" (in a good way) about the JavaFX engine's execution. There is a lot of provided information on a per-pulse basis including pulse number (auto-incremented integer), pulse duration, and time since last pulse. The information also includes thread details and events details. This data allows a developer to see what is taking most of the time.

Warning

Normal warnings for using undocumented features apply, as Richard Bair from the JavaFX team notes:

Just a word of caution, if we haven't documented the command line switches, they're fair game for removal / modification in subsequent releases :-)


Fullspeed=true will give you a high framerate without control (and thereby decrease performance of your app as it renders too much), framerate doesn't work indeed. Use:

-Djavafx.animation.pulse=value

You can check your framerate with the following code. I checked if it actually works too by setting the pulserate to 2, 60 and 120 (I have a 240Hz monitor) and you see a difference in how fast the random number changes.

 private final long[] frameTimes = new long[100];
    private int frameTimeIndex = 0 ;
    private boolean arrayFilled = false ;
    Label label = new Label();
        root.getChildren().add(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" +", Random number:" + Math.random(), frameRate));
                }
            }
        };

        frameRateMeter.start();