[BUG] Frame-rate stutters on tutorial code

Started by SudoDave, August 14, 2017, 15:42:50

Previous topic - Next topic

SudoDave

I've been working on a game using LWJGL and noticed that I would get a lag spike every second.  The frame rate would drop to around 10-12 fps while the rest of the time it was running fine (60fps w/ vsync, 120+ w/o vsync).

Thinking it was a problem with my code I started stripping things out and testing.  Turns out it would happen only if I made any lwjgl function calls in my render thread, even glfwpollevents, or glfwSwapBuffers even if I didn't render anything.

Finally I tried the basic tutorial code here https://www.lwjgl.org/guide, only changing the render loop to be this

long fu = 0;
		while ( !glfwWindowShouldClose(window) ) {
			fu = System.currentTimeMillis();
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer

			glfwSwapBuffers(window); // swap the color buffers

			// Poll for window events. The key callback above will only be
			// invoked during this call.
			glfwPollEvents();
			for (int i = 0; i < (System.currentTimeMillis() - fu) / 5; i++){
				System.out.print("#");
			}
			System.out.println();
			//System.out.println(System.currentTimeMillis() - fu);
		}


I still get the same problem.

I've since updated LWJGL to the latest version (3.1.2 and 3.1.3), Updated my graphics card drivers, Updated java, and checked for windows updates, to no avail.

I also tried other computers in my house, the two most powerful ones got a similar error, but the lag spikes were not consistent and were much smaller.  The weakest computer in my house had no lag spikes at all.  I also tried swapping out my graphics card on my main computer and got the same bug.

My computer
Windows 10
Radeon R9 380 / Radeon 7700
OpenGL Version 6.14.10.13491

Computer that worked fine (least powerful)
Windows 10
Radeon 7700
OpenGL version 6.14.10.13474


As far as I can tell this can't be a problem with my code.  I know that currentTimeMillis probably isn't the best way of measuring this,  but it's accurate enough to find a 50+ millisecond lag that can also be confirmed visually.

I can't find any other references to this kind of problem on the internet, but if someone has seen something that I missed, or has an idea of what to try, I'd appreciate the help.

spasi

I cannot reproduce this. You could try:

- Make sure no other programs/services run on your system.
- Use verbose GC output to see if the spikes are GC related.
- Test the native GLFW demos to see if the spikes happen there too.

SudoDave

I tried running with everything closed and all the background processes stopped that I could.  Still had the error.

For some reason I can't get the GC to output no matter what flags I try, I'm currently using this...
java -Xloggc -cp lib/*;. HelloWorld -Xmx 10G

Also I can't find the "Native GLFW demos" anywhere.  Where do I find them?