nanovg icon indicating copy to clipboard operation
nanovg copied to clipboard

Frequent JVM crashes

Open Chryfi opened this issue 1 year ago • 0 comments

I frequently get JVM crashes. Specs: Java 17, Windows 11, NanoVG 3.3.3 and LWJGL 3.3.1. They are sometimes random and never happen immediately after rendering. I create the NanoVGL3 context once and load my fonts to it like this int fontHandle = NanoVG.nvgCreateFontMem(this.vg, font.getIdentifier().toString(), buffer.flip(), false);

in the end I do this NanoVGGL3.nvgDelete(this.vg);

this is how I render

glEnable(GL_STENCIL_TEST);
int vertexArray = GLUtils.getVertexArrayBinding();
int activeTexture = GLUtils.getActiveTexture();
int currentProgram = GLUtils.getCurrentProgram();
int[] windowSize = GLUtils.getGLFWWindowSize(window);
int[] fbsize = GLUtils.getGLFWFrameBufferSize(window);
NanoVG.nvgBeginFrame(this.vg, windowSize[0], windowSize[1], (float) fbsize[0] / windowSize[0]);

NVGColor textColor = NVGColor.create();
textColor.r(color.getR());
textColor.g(color.getG());
textColor.b(color.getB());
textColor.a(color.getA());

this.setupNanoVGFont(font, fontSize, this.defaultAlignMode);
NanoVG.nvgFillColor(this.vg, textColor);
NanoVG.nvgText(this.vg, x, y, text);

NanoVG.nvgEndFrame(this.vg);
glClear(GL_STENCIL_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_STENCIL_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
GL30.glBindVertexArray(vertexArray);
glActiveTexture(activeTexture);
glUseProgram(currentProgram);

Besides that the only methods I call in other places are

float[] bounds = new float[4];
float[] lineh = new float[1];
float[] asc = new float[1];
float[] desc = new float[1];

NanoVG.nvgFontFace(this.vg, font.toString());
NanoVG.nvgFontSize(this.vg, fontSize);
NanoVG.nvgTextAlign(this.vg, alignMode);
NanoVG.nvgTextBounds(this.vg, 0, 0, text, bounds);
NanoVG.nvgTextMetrics(this.vg, asc, desc, lineh);

here is the thread dump. hs_err_pid36308.log

Is this a bug or am I doing something wrong?

Chryfi avatar Mar 16 '24 01:03 Chryfi