This PR creates a native owned copy of the pixel buffer passed to GlassPixels::getImage, to let AppKit start, at any later time, the rasterization of the images for the system menu bars with a native object that outlives the Java buffer. Therefore, if under certain conditions of high memory pressure, the latter is reclaimed and collected, the former is still available.
A manual test has been included. Since this is a memory pressure/timing issue, it is not deterministic, and depends on several conditions. Therefore, it needs to be run several times to spot the issue (before the proposed fix). After the fix, the issue should never happen again. When running it from `tests/manual/systemmenu`, with: $JAVA_HOME/bin/java @../../../build/run.args MacOSSystemMenuImageGraphicTest.java it might not trigger the crash, but still the icons might be missing or garbled most of the runs. However, with: $JAVA_HOME/bin/javac @../../../build/run.args MacOSSystemMenuImageGraphicTest.java // remove --enable-native-access from run.args $JAVA_HOME/bin/java @../../../build/run.args MacOSSystemMenuImageGraphicTest the crash is more likely to happen in different runs. Other options to increase the likelihood of failure is to use a low Xmx, or to increase the `COUNTER` value. --------- - [X] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - Create native owned copy of pixel buffer, and include manual test Changes: https://git.openjdk.org/jfx/pull/2219/files Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=2219&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8388508 Stats: 178 lines in 2 files changed: 170 ins; 0 del; 8 mod Patch: https://git.openjdk.org/jfx/pull/2219.diff Fetch: git fetch https://git.openjdk.org/jfx.git pull/2219/head:pull/2219 PR: https://git.openjdk.org/jfx/pull/2219
