Integrated: 8368879: Intermittent crash on exit when disposing MTLRTTextureData

Ambarish Rapte arapte at openjdk.org
Thu Oct 9 11:48:33 UTC 2025


On Wed, 8 Oct 2025 04:47:10 GMT, Ambarish Rapte <arapte at openjdk.org> wrote:

> **Issue**:
> Intermittent crash on exit in `MTLRTTextureData::dispose()` during toolkit shutdown
> The crash is very rare and difficult to reproduce.
> 
> **Cause**:
> While exiting an app, in `MTLContext.dispose()`, a Texture is released **after** the native peer MetalConext is disposed.
> - MTLContext.dispose() method:
> 
>     @Override
>     public void dispose() {
>         nRelease(pContext);
>         state = null;
>         super.dispose();
>     }
> 
> 
> 1. The `MTLContext.dispose()` method releases the native peer (`nRelease(pContext)`) before calling `super.dispose()` (i.e., `BaseShaderContext.dispose()`).
> 2. `BaseShaderContext.dispose()` calls `disposeLCDBuffer()` to dispose the LCD texture, which in turn invokes `MTLRTTextureData::dispose()`
> => As native MetalContext is already disposed, it causes a crash.
> 
> **Fix**:
> Call `disposeLCDBuffer()` before `nRelease(pContext)`. so that the Texture is released **before** disposing the native peer MetalContext.
> The scenario is very rare to reproduce, so no test is added.

This pull request has now been integrated.

Changeset: 1b16ebaa
Author:    Ambarish Rapte <arapte at openjdk.org>
URL:       https://git.openjdk.org/jfx/commit/1b16ebaa8c583ce6094ad5717969967b8c9f2c9e
Stats:     1 line in 1 file changed: 1 ins; 0 del; 0 mod

8368879: Intermittent crash on exit when disposing MTLRTTextureData

Reviewed-by: kcr, jdv

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

PR: https://git.openjdk.org/jfx/pull/1931


More information about the openjfx-dev mailing list