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

Allow animation play/start/stop/pause methods to be called on any thread

    XMLWordPrintable

Details

    • b03

    Backports

      Description

        JavaFX Animations run on the JavaFX Application Thread. In JavaFX 21 and earlier, no checking was done in the Animation and AnimationTImer methods that start or stop an animation. Program that called these methods on a background thread -- especially the stop method -- ran into intermittent, hard-to-diagnose failures.

        JDK-8159048, implemented earlier in the JavaFX 22 release, restricted the following methods to be called on the JavaFX Application Thread:

        Animation:
          play
          pause
          stop

        AnimationTimer
          start
          stop

        Since implementing that approach we have become aware of compatibility issues where applications that create a timeline as part of a scene graph on a background thread start playing that animation by calling play on that same background thread. Those applications would largely run without problems as long as they didn't also call pause or stop on the background thread.

        This RFE proposes a solution that avoids the threading problems that existed prior to JavaFX 22 without introducing the compatibility problems that the threading restriction implemented in JDK-8159048 caused.

        The solution will be to document that the methods in question can be called on any thread, and that the implementation of those methods will be ensure that they are run on the JavaFX application thread. The implementation will then check the thread and wrap the implementation in a runLater if not already on the JavaFX application thread.

        Attachments

          Issue Links

            Activity

              People

                nlisker Nir Lisker
                kcr Kevin Rushforth
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: