On Mon, 31 Jul 2023 17:11:06 GMT, Andy Goryachev <[email protected]> wrote:
>> This PR adds a check to the Animation and AnimationTimer public methods to
>> verify that these are called from the JavaFX Application thread. If the call
>> is done from any other thread, an IllegalStateException will be thrown.
>>
>> This will prevent users from getting unexpected errors (typically NPE, like
>> the one posted in the JBS issue), and will fail fast with a clear exception
>> and reason for it.
>>
>> The javadoc of the Animation and AnimationTimer classes and public methods
>> has been updated accordingly.
>>
>> Tests for both classes have been included, failing (as in no exceptions were
>> thrown when calling from a background thread) before this patch, and passing
>> (as in ISE was thrown).
>
> modules/javafx.graphics/src/main/java/javafx/animation/Animation.java line
> 990:
>
>> 988: */
>> 989: public void play() {
>> 990: Toolkit.getToolkit().checkFxUserThread();
>
> minor: perhaps this should first check for non-null parent, then for fx
> thread (here and below)
Our pattern everywhere else where we require the method to be called on the FX
Application Thread is to do the thread check first.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1167#discussion_r1279660911