Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Crashing upon building the font atlas #293

Open
Mjrlun opened this issue Oct 30, 2024 · 1 comment
Open

Bug: Crashing upon building the font atlas #293

Mjrlun opened this issue Oct 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Mjrlun
Copy link

Mjrlun commented Oct 30, 2024

Version

1.87.5

What happened?

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):

			ImFontAtlas fontAtlas = ImGui.getIO().getFonts();
			fontAtlas.build();

Relevant log output

hs_err_pid1452.log

@Mjrlun Mjrlun added the bug Something isn't working label Oct 30, 2024
@Mjrlun Mjrlun changed the title Bug: TrueType renderer crashes upon building font atlas Bug: Crashing upon building the font atlas Oct 30, 2024
@Mjrlun
Copy link
Author

Mjrlun commented Oct 30, 2024

This crash is likely related to an older report I made, which is still unresolved, unfortunately: #229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant