RFR: 8352209: NPE com.sun.prism.d3d.D3DTextureData.getContext
Andy Goryachev
angorya at openjdk.org
Tue Oct 28 21:36:17 UTC 2025
On Tue, 28 Oct 2025 15:54:13 GMT, Lukasz Kostyra <lkostyra at openjdk.org> wrote:
> This PR fixes NPE thrown when trying to update D3D texture in some rare scenarios.
>
> On more stressful cases (like the one using Canvas attached to this issue) it is possible that a D3DTexture.update() call will go through after the Resource Pool already pruned the underlying Texture's resource. This in turn caused an NPE, which propagated to higher levels and disrupted the rendering loop, causing the Canvas to not be drawn anymore. The update() call seems not to be called more than once on an already freed resource, suggesting this is some sort of rare race between the pool and the drawing code.
>
> This change prevents the NPE from being thrown. I noticed no visual problems with the test even when the update() call is rejected by the newly added check. Best way to verify it is to add a log call inside added `if (!resource.isValid())` blocks when running the test, it will occasionally get printed but the test itself won't change its behavior like it does without this change.
code review only - I did not test it.
modules/javafx.graphics/src/main/java/com/sun/prism/d3d/D3DTexture.java line 91:
> 89: public void update(MediaFrame frame, boolean skipFlush)
> 90: {
> 91: if (!resource.isValid()) {
related - D3DTextureResource line 40 is
public void free() {
if (resource != null) {
resource.dispose();
}
}
should there be `resource = null;` after `resource.dispose()` ?
modules/javafx.graphics/src/main/java/com/sun/prism/d3d/D3DTexture.java line 93:
> 91: if (!resource.isValid()) {
> 92: return;
> 93: }
are these the only two places where we need the check?
-------------
Marked as reviewed by angorya (Reviewer).
PR Review: https://git.openjdk.org/jfx/pull/1951#pullrequestreview-3390861433
PR Review Comment: https://git.openjdk.org/jfx/pull/1951#discussion_r2471094140
PR Review Comment: https://git.openjdk.org/jfx/pull/1951#discussion_r2471089531
More information about the openjfx-dev
mailing list