On Mon, 16 Mar 2026 11:10:00 GMT, Jose Pereda <[email protected]> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/glass/ui/Menu.java line 187:
>> 
>>> 185:     protected void notifyMenuOpening() {
>>> 186:         if (this.eventHandler != null) {
>>> 187:             Utils.runOnFxThread(() -> 
>>> eventHandler.handleMenuOpening(this, System.nanoTime()));
>> 
>> These methods `notifyMenuOpening` and `notifyMenuClosed` are already 
>> executing on JavaFX Application Thread. So, the calling 
>> `Utils.runOnFxThread()` does not defer the eventHandler call for later, but 
>> runs immediately.
>> The fix behavior does not change when these two changes are reverted. Could 
>> you please recheck.
>
> As I mentioned in the description of this PR, running the test with
> 
> sh gradlew --continue --info -PFULL_TEST=true -PUSE_ROBOT=true 
> :systemTests:cleanTest :systemTests:test --tests 
> "test.robot.javafx.scene.SystemMenuBarHelpMenuTest"
> 
> the test passes, but I got:
> 
> SystemMenuBarHelpMenuTest STANDARD_ERROR
>     Exception in thread "JavaFX Application Thread" 
> java.lang.IllegalStateException: Not on FX application thread; currentThread 
> = JavaFX Application Thread
>         at 
> javafx.graphics@27-internal/com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:282)
>         at 
> javafx.graphics@27-internal/com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:480)
>         at 
> javafx.controls@27-internal/javafx.scene.control.Menu.hide(Menu.java:428)
>         at 
> javafx.graphics@27-internal/com.sun.javafx.tk.quantum.GlassMenuEventHandler.handleMenuClosed(GlassMenuEventHandler.java:46)
>         at 
> javafx.graphics@27-internal/com.sun.glass.ui.Menu.notifyMenuClosed(Menu.java:196)
> 
> 
> Which is really weird, because `Not on FX application thread; currentThread = 
> JavaFX Application Thread` is contradictory. Also weird that using 
> `Utils::runOnFxThread` bypasses this check.
> 
> In any case, with some debug, I can see that `Menu::hide` calls 
> `Toolkit.getToolkit().checkFxUserThread();`, which checks 
> `Thread.currentThread() == fxUserThread`, else throws `Not on FX application 
> thread; currentThread: <Thread.currentThread().getName()>`.
> 
> So my current thread is indeed the JavaFX thread, but `fxUserThread` is not, 
> it is actually `null`. 
> 
> When running the system test, `fxUserThread` gets nullified in the exit call 
> from `Toolkit.getToolkit().exit();` that is invoked from `@AfterAll -> 
> Utils.shutdown -> Platform.exit()`, before the cleanup at the end of the 
> tests, that doesn' have time enough to finish the menu hiding animation.
> 
> I'll revert the change in Menu, and add more time in the test.

Sorry, I jumped to review without reading the description. Thanks for 
re-investigating it and the change in test.
The fix and test lgtm, I shall test some more and update.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/2107#discussion_r2940155817

Reply via email to