On Wed, 29 Oct 2025 11:21:31 GMT, Lukasz Kostyra <[email protected]> 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.
>
> Lukasz Kostyra has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   D3DTextureResource: Set resource to null after disposing

Marked as reviewed by jhendrikx (Reviewer).

I've added this fix to my application, and I don't know exactly how the 
resources are now managed, but it seems that it does solve the problem and the 
program no longer gets stuck in an NPE loop, even with more large images 
showing than usual.

Very happy with the fix, it was something I already looked into but didn't have 
time to further investigate :)

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

PR Review: https://git.openjdk.org/jfx/pull/1951#pullrequestreview-3397909427
PR Comment: https://git.openjdk.org/jfx/pull/1951#issuecomment-3466573951

Reply via email to