Hello!
I've recently made another project on OpenGL-ES for ARM with LWJGL. And I am using GLFW now (I was previously using EGL rendering with no issue)
But I noticed noticeable stuttering in my program. I investigated it and found that every 4th cycle of my main loop - glfwSwapBuffers(window) takes A LOT longer than in other cycles. We are talking of the difference between 0.0003 seconds and 0.28 seconds.
I have no idea what caused this. As you can see from the code (below), I am explicitly testing the time it takes swapBuffers to work. I can guarantee that the rest of my program (which is extremely small BTW) doesn't really take that much time at all, and nothing should cause any issues. I think.
I'm using LWJGUI, which is also a first time for me, but I tested its performance and it seems like it's doing completely OK.
Vsync is off, but I think double-buffering is on.
Here's my loop:
while (running)
{
context.updateGlfwWindow();
Vector2i windowSize = context.getFramebufferSize();
glClearColor(1, 1, 1, 1);
glViewport(0, 0, windowSize.x, windowSize.y);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
renderer.render(frame, context);
glfwPollEvents();
double timeStart = System.nanoTime() / 1000_000_000.0;
glfwSwapBuffers(window);
double timeEnd = System.nanoTime() / 1000_000_000.0;
double delta = timeEnd - timeStart;
System.err.printf("%f\n", delta);
initializer.getSystemEventProcessor().processEvents(frame, context);
initializer.getGuiEventProcessor().processEvents();
}
Here's the sample output (timings). notice that the dip happens exactly every 4th time.
0.000372
0.000378
0.000370
0.274361
0.000344
0.000367
0.000395
0.275922
0.000393
0.000365
0.000370
0.274104
0.0003989
0.000477
0.000393
0.273459