<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Some more information for Windows platform:</p>
    <p>The FX thread is woken up by the pulse mechanism, and then will
      pin down a time using `System.nanoTime`.  However, the wake up
      process on Windows can take anywhere from 1-30 milliseconds as it
      by default uses a 64 Hz clock for scheduling purposes.  This means
      that the frame time you receive for animation callbacks is wildly
      inaccuratel.  One way to significantly improve this (on Windows)
      is to have your application change the timer resolution -- it can
      be set as high as 2000 Hz -- allowing threads (like the FX thread)
      to be scheduled much more quickly in response to a pulse.  This is
      however a native call (timeBeginPeriod), and is a global change
      for the system (it can't be done per application).</p>
    <p>On a Windows system, setting pulse to 120 Hz by itself probably
      will not show significant improvement as the animation
      calculations are likely still using badly calculated frame times,
      resulting in the animation to look stuttery.  One way to improve
      this may be to also set
      "-D-com.sun.scenario.animation.fixed.pulse.length=true", but I'm
      not entirely sure it works in conjunction with setting the pulse
      duration.<br>
    </p>
    <p>See <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8339606">https://bugs.openjdk.org/browse/JDK-8339606</a> for more detailed
      information.</p>
    <p>--John<br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 26/02/2025 21:33, Kevin Rushforth
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:989dae1a-856f-40a9-be41-6b4190dc608e@oracle.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      Yes, I think that's the best advice for now.<br>
      <br>
      Really, though, a good RFE would be to provide a way to adapt to
      the refresh rate of the monitor when vsync is being used. That's
      really the point of doing vsync in the first place.<br>
      <br>
      -- Kevin<br>
      <br>
      <div class="moz-cite-prefix">On 2/26/2025 10:17 AM, Johan Vos
        wrote:<br>
      </div>
      <blockquote type="cite"
cite="mid:CABxFH2HWopOcYAxmdJpegJ2KD7-Ozg9gVLom_cCg2cLBT_fRwg@mail.gmail.com">
        <div dir="ltr">Hi Glavo,
          <div><br>
          </div>
          <div>I believe setting the javafx.animation.pulse is indeed
            the best way to increase the render frequency (or to
            minimize the time between 2 pulses). It is independent of
            the hardware/pipeline being used. </div>
          <div>Of course, you may see a higher load in the JavaFX
            Application Thread and in the Quantum Renderer, but I guess
            you're aware of that -- but even at 10 fps those threads can
            be under pressure (same for the GPU cache).</div>
          <div><br>
          </div>
          <div>- Johan</div>
          <div><br>
          </div>
        </div>
        <br>
        <div class="gmail_quote gmail_quote_container">
          <div dir="ltr" class="gmail_attr">On Wed, Feb 26, 2025 at
            7:01 PM Glavo <<a href="mailto:zjx001202@gmail.com"
              moz-do-not-send="true" class="moz-txt-link-freetext">zjx001202@gmail.com</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
            <div dir="ltr">
              <div dir="ltr">
                <div dir="ltr">
                  <div dir="ltr">I found that setting
                    `javafx.animation.pulse` to a higher value worked
                    for me.</div>
                  <div dir="ltr">I considered setting
                    `javafx.animation.pulse` to 120 for all users to get
                    smooth animation.</div>
                  <div dir="ltr">Is this the most recommended approach
                    at this time?</div>
                  <div dir="ltr"><br>
                  </div>
                  <div>Glavo</div>
                </div>
              </div>
            </div>
            <br>
            <div class="gmail_quote">
              <div dir="ltr" class="gmail_attr">On Wed, Feb 26, 2025 at
                3:55 AM Glavo <<a href="mailto:zjx001202@gmail.com"
                  target="_blank" moz-do-not-send="true"
                  class="moz-txt-link-freetext">zjx001202@gmail.com</a>>
                wrote:<br>
              </div>
              <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                <div dir="ltr">
                  <div dir="ltr">
                    <div dir="ltr">
                      <div dir="ltr">
                        <div dir="ltr">
                          <div dir="ltr">
                            <div dir="ltr">
                              <div dir="ltr">
                                <div dir="ltr">
                                  <div dir="ltr">
                                    <div dir="ltr">
                                      <div dir="ltr">
                                        <div dir="ltr">
                                          <div dir="ltr">
                                            <div dir="ltr">
                                              <div dir="ltr">
                                                <div dir="ltr">
                                                  <div dir="ltr">
                                                    <div dir="ltr">
                                                      <div dir="ltr">Hi,</div>
                                                      <div dir="ltr"><br>
                                                      </div>
                                                      <div dir="ltr">Recently
                                                        I was
                                                        investigating
                                                        how to improve
                                                        the user
                                                        experience of
                                                        our JavaFX
                                                        applications.</div>
                                                      <div dir="ltr">I
                                                        noticed that
                                                        JavaFX
                                                        applications
                                                        seem to be
                                                        limited to 60fps
                                                        by default, </div>
                                                      <div dir="ltr">which
                                                        makes JavaFX
                                                        applications
                                                        appear to
                                                        animate less
                                                        smoothly than
                                                        many other
                                                        applications</div>
                                                      <div dir="ltr">when
                                                        users are using
                                                        high refresh
                                                        rate monitors.</div>
                                                      <div dir="ltr">In
                                                        particular, we
                                                        used a
                                                        self-drawn title
                                                        bar, which
                                                        caused users to
                                                        drag our app
                                                        more slowly than
                                                        dragging other
                                                        applications.</div>
                                                      <div dir="ltr"><br>
                                                      </div>
                                                      <div dir="ltr">I
                                                        learned that
                                                        there is an
                                                        undocumented
                                                        property
                                                        `javafx.animation.fullspeed` </div>
                                                      <div dir="ltr">and
                                                        that setting it
                                                        to true would
                                                        significantly
                                                        improve the user
                                                        experience of
                                                        our application.</div>
                                                      <div dir="ltr">While
                                                        it works fine on
                                                        my computer, it
                                                        seems to have a
                                                        lot of potential
                                                        problems,</div>
                                                      <div dir="ltr">such
                                                        as conflicts
                                                        with vsync, may
                                                        have
                                                        significantly
                                                        higher CPU/GPU
                                                        utilization, and
                                                        has been less
                                                        tested,</div>
                                                      <div dir="ltr">so
                                                        I dare not push
                                                        it to users.</div>
                                                      <div dir="ltr">There
                                                        is also a
                                                        property `javafx.animation.framerate`
                                                        which seems to
                                                        be safer, but it
                                                        didn't work for
                                                        me.</div>
                                                      <div dir="ltr"><br>
                                                      </div>
                                                      <div dir="ltr">So,
                                                        what is the best
                                                        way to get a
                                                        high frame rate
                                                        for a JavaFX
                                                        application?</div>
                                                      <div dir="ltr">Can
                                                        we get more than
                                                        60fps in a
                                                        JavaFX
                                                        application with
                                                        vsync enabled?</div>
                                                      <div dir="ltr">Is
                                                        it possible to
                                                        make JavaFX
                                                        applications
                                                        adapt to the
                                                        monitor's
                                                        refresh rate
                                                        without us
                                                        setting it to a
                                                        fixed value?</div>
                                                      <div dir="ltr"><br>
                                                      </div>
                                                      <div>Glavo</div>
                                                      <div dir="ltr"><br>
                                                      </div>
                                                      <div dir="ltr"><br>
                                                      </div>
                                                    </div>
                                                  </div>
                                                </div>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </blockquote>
            </div>
          </blockquote>
        </div>
      </blockquote>
      <br>
    </blockquote>
  </body>
</html>