Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8307622

JavaFX AnimationTimer fails to v-sync (unbounded FPS)

XMLWordPrintable

    • x86_64
    • linux

      ADDITIONAL SYSTEM INFORMATION :
      System:
      Acer Aspire 5 laptop
      11th Gen Intel Core i3-1115G4
      Intel Corporation Tiger Lake-LP GT2 [UHD Graphics G4] (rev 01)

      OS: Manjaro Linux x64

      Java:
      openjdk version "17.0.7" 2023-04-18 LTS
      OpenJDK Runtime Environment Zulu17.42+19-CA (build 17.0.7+7-LTS)
      OpenJDK 64-Bit Server VM Zulu17.42+19-CA (build 17.0.7+7-LTS, mixed mode, sharing)


      A DESCRIPTION OF THE PROBLEM :
      On this Acer Aspire 5 laptop, AnimationTimer always render as many frames as possible instead of using the screen refresh rate.
      I've tried to use some system properties but it didn't work:
      -Djavafx.animation.pulse=60
      -Djavafx.animation.framerate=60
      -Djavafx.animation.fullspeed=false

      Using this Java code as an example, I get between 2 and 3 ms per frame on this laptop, no matter what.
      https://github.com/zarandok/megabounce

      The expected value is 16~17ms (the screen runs at 60Hz).
      The very same code ran on a Windows machine (same jdk/jfx version) and gave correct FPS.
      I've also ran it on a virtual machine (VMWare) hosting the same Manjaro as the laptop, and it works perfectly fine at 60 fps.
      I tried with OpenJDK19 on the laptop with the latest javafx from Gluon, but I still have the same bug.

      Manjaro is using Cinnamon DE (X11). The driver is the default opensource one for this chipset:
      0000:00:02.0 VGA compatible controller: Intel Corporation Tiger Lake-LP GT2 [UHD Graphics G4] (rev 01) (prog-if 00 [VGA controller])
              Subsystem: Acer Incorporated [ALI] Device 149d
              Flags: bus master, fast devsel, latency 0, IRQ 122
              Memory at 6002000000 (64-bit, non-prefetchable) [size=16M]
              Memory at 4000000000 (64-bit, prefetchable) [size=256M]
              I/O ports at 4000 [size=64]
              Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
              Capabilities: <access denied>
              Kernel driver in use: i915
              Kernel modules: i915

      Summary:
      JavaFX (both jre 17 and 19) on this particular laptop (linux, X11, i915), spits out as many frames as possible, making all animations stutter and CPU usage very high.
      The very same code shows a correct fps limit (based on monitor refresh rate) when run on Windows or a Linux VM.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the provided example

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Average frame time should be around 1/(monitor refresh rate), so 17ms for 60 fps.
      ACTUAL -
      2~4 ms on this laptop, correct result everywhere else.

      ---------- BEGIN SOURCE ----------
      https://github.com/zarandok/megabounce
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      For now, I bypass this bug by having AnimationTimer.handle() to only execute code after 16ms have passed.

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: