3

I'm working on a JavaFX animation which uses the AnimationTimer() class. It should work at 60 fps by default, according to all possible sources. However, on my laptop it refreshes at much higher rates: 300 - 700, depending on the window size. I use IntelliJ IDEA Community Edition, and the Oracle JDK8 on Manjaro Linux GNOME Edition. I've already given a try to other JDKs - still the same situation. It behaves as if the JVM option javafx.animation.fullspeed was set true, but it's not. Same happens on a different machine, also running Manjaro GNOME edition.

I tried (undocumented) JVM options:

javafx.animation.fullspeed=false | true

javafx.animation.framerate=value

javafx.animation.pulse=value

They change nothing, even if Settings.get(key) returns values as set.

On another, Windows 10-powered computer, FPS behaves correctly: keeps 60 value on default/none VM options, runs full speed when javafx.animation.fullspeed=true, as well on Windows, as on Manjaro / VirtualBox.

Piotr Miller
  • 311
  • 2
  • 12
  • Have a look at https://stackoverflow.com/questions/44327853/crazy-javafx-frame-rate-any-ideas and the comments below it. – James_D Aug 22 '17 at 12:47
  • 1
    Here is the link to the bug report James_D mentioned above. https://bugs.openjdk.java.net/browse/JDK-8181764 But the problem is that this bug was rejected because the JavaFX team could not reproduce it. So this seems to be a very specific setup which triggers this bug. – mipa Aug 22 '17 at 14:25
  • Thank you @James_D, the workaround resolves the issue very well. I'll add a snippet to the question above. I wouldn't have found the solution ever on my own. – Piotr Miller Aug 22 '17 at 20:25
  • You can [self-answer questions](https://stackoverflow.com/help/self-answer), it's better than editing the question and putting the solution in the question. – jewelsea Aug 22 '17 at 22:05
  • @jewelsea - I wasn't sure. Thank you. – Piotr Miller Aug 22 '17 at 22:28

1 Answers1

4

Sample solution thanks to the comment posted by @James_D and the following:

import javafx.application.Application;

public class Start {

    public static void main(String[] args) {

        //must be set before launching the Main class
        System.setProperty("quantum.multithreaded", "false");

        Application.launch(Main.class, args);
    }
}

Please read comments to this question to learn more.

Furthermore: this may be a dual graphics related issue. Forcing use of the secondary graphics like # optirun ./idea.sh resolves it, too. However, in the production version I think it would be better to set quantum.multithreaded false.

Piotr Miller
  • 311
  • 2
  • 12
  • Just found out my Ubuntu 17.04 with Java 1.8.0..131 was running at 2500fps... No wonder the CPU was busy. – M. le Rutte Aug 23 '17 at 10:06
  • My app on Manjaro Linux used to use 12 - 15% of the processor, now uses 1 - 2%. Also CPU temperature got back to stable 45 degrees. – Piotr Miller Aug 23 '17 at 10:55