RFR: 8368629: Texture.update sometimes invoked for a disposed Texture [v5]
Lukasz Kostyra
lkostyra at openjdk.org
Thu Nov 6 12:32:32 UTC 2025
On Wed, 5 Nov 2025 11:25:31 GMT, Alessadro Parisi <duke at openjdk.org> wrote:
>>> I was finally able to compile JavaFX with this PR and integrate it into my maven project. This does not seem to fix my issue entirely. While I don't see expections like these anymore: `NullPointerException: Cannot invoke "com.sun.prism.RTTexture.createGraphics()" because <local9> is null` I now see this: `java.lang.NullPointerException: Cannot invoke "com.sun.prism.RTTexture.createGraphics()" because "newtex" is null` or this `java.lang.NullPointerException: Cannot invoke "com.sun.prism.Texture.assertLocked()" because "this.maskTex" is null` and the app still freezes
>>>
>>> Is this related or an entirely different issue?
>>
>> Hard to judge just from those messages, but it is possible the root cause is similar. The check I added is only in one place and it might not cover all cases. Can you provide a full stacktrace for each of those NPEs?
>
>> Hard to judge just from those messages, but it is possible the root cause is similar. The check I added is only in one place and it might not cover all cases. Can you provide a full stacktrace for each of those NPEs?
>
> Sure thing, here are the full stack traces:
> <details>
> <summary><code>createGraphics()</code> exception</summary>
> <pre>
> java.lang.NullPointerException: Cannot invoke "com.sun.prism.RTTexture.createGraphics()" because "newtex" is null
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGCanvas$RenderBuf.validate(NGCanvas.java:216)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGCanvas.initCanvas(NGCanvas.java:646)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGCanvas.renderContent(NGCanvas.java:609)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2063)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1955)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:266)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:579)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGNode.renderForClip(NGNode.java:2279)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGNode.renderRectClip(NGNode.java:2186)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGNode.renderClip(NGNode.java:2213)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2057)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1955)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:266)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:579)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NodeEffectInput.getImageDataForBoundedNode(NodeEffectInput.java:237)
> at javafx.graphics at 26-internal/com.sun.javafx.sg.prism.NodeEffectInput.filter(NodeEffectInput.java:131)
> at javafx.graphics at 26-internal/com.sun.scenario.effect.FilterEffect.filter(FilterEffect.java:185)
> at javafx.graphics at 26-internal/com.sun.scenario.effect.Offset.filter(Offset.java:160)
> at javafx.graphics at 26-internal/com.sun.scenario.effect.Merge.filter(Merge.java:148)
> at javafx.graphics at 26-internal/com.sun.scenario.effect.DelegateEffect.filter(DelegateEffect.java:70)
> at javafx.graphics at 26-internal/com.sun.scenario.effect.impl.prism.PrEffectHelper.render(PrEffectHelper.java:166)
> at jav...
@palexdev these seem to come from a similar root cause (Pool pruning some Textures that are not locked when they should be) however these seem to be different spots than this one; in other words, to me this seems unrelated to this fix.
Independently @arapte notified me of one more situation that causes an NPE when the mask texture is updated, this happens only on ES2 backend on macOS despite these changes. NPE stack trace comes from the same place (`BaseContext.flushMask()`) but for some reason current fix does not handle those. I'm pretty sure I know why so I'll fix that as part of this change.
To summarize, I think this is how we're going to tackle this:
- I will fix the ES2 problem on macOS as part of this PR, since this one is way more related than other NPEs attached here
- The "proper" solution (managing Textures lifetime better) - including the new more "extreme" cases of NPEs attached here - I think should be solved as part of [JDK-8371192](https://bugs.openjdk.org/browse/JDK-8371192). I'll file a separate PR for this and we'll give it proper, more exhaustive testing.
@kevinrushforth what do you think of this?
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1951#issuecomment-3497041222
More information about the openjfx-dev
mailing list