3

JavaFX with a crazy frame rate?

I was giving a demo of different JavaFX animation options today. However, on the machine I used for the demo, the AnimationTimer behaves very strangely.

As I understand it, JavaFX is supposed to aim for a rate of around 60FPS, and the "handle" method of the animation timer is called before each frame. However, on this machine, the speed is immensely faster. I ran the diagnostic program from the accepted answer of this StackOverflow post, and it reports more than 1000FPS.

Environment: Ubuntu 16.04, Java 1.8.0_131

Any ideas what could be causing this problem and/or how to control it?

Brad Richards
  • 1,233
  • 3
  • 13
  • 23
  • There are some undocumented system properties that can be set to turn off (or override) the 60fps throttling. See https://stackoverflow.com/questions/28819409/how-to-create-100fps-animation-in-javafx8 Maybe one of those is set for your application? – James_D Jun 02 '17 at 11:59
  • The same application behaves correctly on other machines; I wrote it, it's only a few lines of code to demonstrate the use of AnimationTimer. I tried various settings for the undocumented options (from the post you mention), both from the command-line and in code, but they have no effect on the problem. Of course, I've tried the obvious things, like reinstalling Java. – Brad Richards Jun 02 '17 at 12:35
  • Hmm. I tested that animation timer on my Ubuntu laptop and I also saw high FPS (~250-300, but it's not a very powerful machine). On my Mac I see the expected ~60fps. Not sure. – James_D Jun 02 '17 at 12:47
  • Following the comments at http://tomasmikula.github.io/blog/2015/02/08/measuring-fps-with-reactfx.html (which is linked in a comment below my answer to the question you linked), try the system property `quantum.multithreaded=false`. Note you need to set this *before* the `Application` class is loaded (e.g. from the command line). That fixed it on my Ubuntu box. Seems like it might be a bug? – James_D Jun 02 '17 at 13:02
  • @James_D: Thanks for the info; setting quantum.multithreaded does solve the problem (fascinating - this doesn't work if done directly in the java command; only if done beforehand). Bug report submitted; if/when it is confirmed, I will add the bug number here. – Brad Richards Jun 07 '17 at 09:25
  • I think it only works from code if it is called before your `Application` class is loaded. So if you have a main class separate from the fx application class, with a `main(...)` method that does `System.setProperty(...);` before `Application.launch(MyApp.class, args)`, it works. But otherwise you have to set the system property from the command line. – James_D Jun 07 '17 at 09:35
  • This has been accepted as bug [JDK-8181764](http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8181764). The behavior is also present in the the current Java-9 release (9-ea-172). – Brad Richards Jun 16 '17 at 05:39
  • 1
    This behaviour is still present in JavaFX 11, since the bug has been closed as "cannot reproduce". I'm using Fedora 30. Maintainer who closed the bug had an NVIDIA card and NVIDIA drivers use its own GL implementation. I have Intel HD. I believe this is where the problem lies. – graynk May 28 '19 at 07:28
  • Original reporter here: The system with the original problem also has an NVIDIA card; using NVIDIA drivers under Ubuntu. I have not pursued the bug farther, since I have never found another system that can reproduce it. Glad to finally hear from someone else who sees the same problem! But how to isolate it? – Brad Richards May 29 '19 at 08:38

0 Answers0