Upon calling ImGui.getIO().getFonts().build(), after providing fonts via the addFontFromMemoryTTF method, the JVM crashes due to an EXCEPTION_ACCESS_VIOLATION relating to a null pointer.
I expected it to work the same as in prior releases. This has always been finicky for some reason, as minute changes to other irrelevant java code makes the difference between this error occuring and not.
Reproduction
The ImGui context is created on the main thread, however, calling build from the main thread after creating the fonts has no change in effect. There is only 1 thread ever modifying the font atlas, and normally all the below happens on a dedicated asset loading thread.
Font loading code:
// TTF file from the stream
byte[] array = stream.readAllBytes();
// Only used to configure the font data. Must be specified.
FontData fontData = getFontData(assetManager.getResource(relativePath + ".info"));
this.size = fontData.size;
ImFontConfig italicCfg = new ImFontConfig(), boldCfg = new ImFontConfig(), italicBoldCfg = new ImFontConfig();
italicCfg.setFontBuilderFlags(Oblique);
boldCfg.setFontBuilderFlags(Bold);
italicBoldCfg.setFontBuilderFlags(Oblique | Bold);
ImFontAtlas fontAtlas = ImGui.getIO().getFonts();
ImFont font = this.font = fontAtlas.addFontFromMemoryTTF(array, fontData.size, fontData.glyphRanges),
italic = this.italic = fontAtlas.addFontFromMemoryTTF(array, fontData.size, italicCfg, fontData.glyphRanges),
bold = this.bold = fontAtlas.addFontFromMemoryTTF(array, fontData.size, boldCfg, fontData.glyphRanges),
italicBold = this.italicBold = fontAtlas.addFontFromMemoryTTF(array, fontData.size, italicBoldCfg, fontData.glyphRanges);
On the same thead, the following is called (afterwards):
Version
1.87.5
What happened?
Upon calling
ImGui.getIO().getFonts().build()
, after providing fonts via theaddFontFromMemoryTTF
method, the JVM crashes due to an EXCEPTION_ACCESS_VIOLATION relating to a null pointer.I expected it to work the same as in prior releases. This has always been finicky for some reason, as minute changes to other irrelevant java code makes the difference between this error occuring and not.
Reproduction
The ImGui context is created on the main thread, however, calling
build
from the main thread after creating the fonts has no change in effect. There is only 1 thread ever modifying the font atlas, and normally all the below happens on a dedicated asset loading thread. Font loading code:On the same thead, the following is called (afterwards):
Relevant log output
hs_err_pid1452.log