On Mon, 17 Nov 2025 16:35:50 GMT, Prasanta Sadhukhan <[email protected]>
wrote:
>> NPE is seen while accessing transient "scenePeer" variable between reads..
>> Fix is made to store it in a temp variable rather than reading it twice
>> since the value can change between successive reads in many places it is
>> accessed.
>> Also some debug logs added to be enabled via `jfxpanel.debug` property
>
> Prasanta Sadhukhan has updated the pull request incrementally with one
> additional commit since the last revision:
>
> Remove debug, store transient var in temp var in EDT methods
I wonder if we are going to continue chasing the issues until we do it right.
What do you think of the following idea:
1. rename all the variables to have `fx` and `edt` (or `sw` ?) prefix to
clearly indicate which thread controls the variable (sets, mutates, etc.)
2. similarly rename the methods that can be renamed, and add comments to
methods that cannot be renamed
3. whenever the fields are read in a wrong thread, make a local copy (and
declare the field as `volatile`)
modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 659:
> 657: var hScenePeer = scenePeer;
> 658: if (hScenePeer != null) {
> 659: hScenePeer.setPixelScaleFactors((float) newScaleFactorX,
minor: the indentation is now a bit off (maybe remove the wrapping altogether?)
modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 683:
> 681:
> 682: private void sendMoveEventToFX() {
> 683: if (stagePeer != null) {
`stagePeer` is set in the FX thread (L1009), but this method is called from the
EDT (L608).
Please assign to a temp. variable like the other cases.
Ideally, this component should be redesigned to ensure proper communication
between threads.
modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 796:
> 794: }
> 795: if (scenePeer != null) {
> 796: scenePeer.inputMethodEvent(
did we trip over the same problem again here?
which thread modifies the `scenePeer` field? which thread calls
`sendInputMethodEventToFX()` ?
-------------
Changes requested by angorya (Reviewer).
PR Review: https://git.openjdk.org/jfx/pull/1968#pullrequestreview-3474249713
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2535273644
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2535288747
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2535295365