leeta wrote on Thursday, September 11, 2014:
This question is about some lag spikes that I can’t currently explain.
I have a simple interactive GLFW GUI application, using the regular system cursor for point-and-click, and rendering everything in the window using simple OpenGL 2D sprites. I use mouse event callbacks for capturing UI, and then actually “act” on that UI within my main game loop, turning the evented delivery into polled game logic.
This is in Windows 8.1 on a 64 bit system with GeForce GTX 870M graphics and Intel HD4600 frame buffer. The CPU is a Core i7 with four cores, eight threads. The application also spawns two threads for sound playback and background loading, but communication with those threads uses a non-blocking FIFO so they shouldn’t be able to block the main thread (and I’ve verified that that’s not where the time is being spent.)
I’m using glfw3.dll and glfw3d.dll (for the release/debug builds) from version 3.0.4.
I also use a repaint callback that calls the same function as my once-per-frame re-paint function.
After opening the window, I’m having all kinds of weird pauses and stutters in responsiveness. This always happens in the GL render function, and the actual time is spent somewhere in GL, not in the swapbuffers call. Sometimes the pauses are a few hundred milliseconds, but I’ve measured them going up to 5 seconds.
I’ve tried running with glfwPollEvents() and glfwWaitEvents() and the behavior is the same in both cases. My internal watchdog timers tell me it’s always in the GL rendering function somewhere, when it happens.
I further traced this problem to a call to glGetError(). Note that glGetError() only returns the state of the client commands issued – it should not need to syncronize with the GPU like a frame buffer read-back would. However, even if it does, 5 seconds seems excessive – the game runs at 60 Hz.
Thus this post: Has anyone else seen this? What could possibly cause this? How do I cure this?