On Mon, 15 Jul 2024 22:34:27 GMT, Michael Strauß <mstra...@openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/glass/ui/View.java line 533:
>> 
>>> 531:     private boolean shouldHandleEvent() {
>>> 532:         // Don't send any more events if the application has shutdown
>>> 533:         if (Application.GetApplication() == null) {
>> 
>> Should we declare `Application.application` field as volatile?
>> 
>> I see interleaved multi-threaded access pattern:
>> 
>> 
>> thread=JavaFX-Launcher
>> CREATE thread=JavaFX-Launcher
>> thread=JavaFX-Launcher
>> thread=Thread-2
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX-Launcher
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX-Launcher
>> thread=JavaFX Application Thread
>> thread=PulseTimer-CVDisplayLink thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=QuantumRenderer-0
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=PulseTimer-CVDisplayLink thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Application Thread
>> thread=JavaFX Applicati...
>
> Other threads may still not see the current value of the 
> `Application.application` field. Is it safe for other threads to use the 
> `Application` instance after the field has been set to `null`?

This is unrelated to the current bug, since all accesses are happening on the 
FX app thread, so I'd like to file a follow-up to look into this.

To answer the question, there might be a potential problem with other threads 
not seeing that the `Application.application` field has been set to null.

Other threads do not access the glass Application directly. Most methods 
requires the app to be on the application thread, and will correctly detect and 
fail whether they see the old or new value of `Application.application`, so 
those operations will be fine.

One scenario that should be examined is `Platform.runLater`, which could call 
into glass and see the old value of application. There are related fields in 
`Tooklit` (e.g., the `fxUserThread` variable) that ought to be examined at the 
same time.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1506#discussion_r1678482756

Reply via email to