**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.
-------------
Commit messages:
- disposeLCDBuffer b4 nRelease(pContext)
Changes: https://git.openjdk.org/jfx/pull/1931/files
Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1931&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8368879
Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jfx/pull/1931.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/1931/head:pull/1931
PR: https://git.openjdk.org/jfx/pull/1931