Movement stutter/skips

I’ve been getting movement stutter ( moving the camera) No screen tearing, just choppy movement, almost as if it wobbles, yet the fps remains to be a solid 60.

This only occurs in windows mode, and it appears to be random (smooth more often than not).
I print to canvas using a BufferStrategy(2).
I have tried various gameloop timers. None of them fix the issue.
Every time I try to fix this. The “wobbles” go away but then come back several runs later.
Curiously, when I activate something that makes an impact on fps, It seems to actually fix the stutter.
I’ve commented my gameloop out, and still get these stutters while moving a sprite across the canvas.

Trying this on another machine (fresh win10) gave me constant interval stutter. And only in Window mode.

Ive noticed the same stutter in a fresh LibGDX project. (moving the badlogics logo x+=8)
I’m using JDK 8

public void run() {
    createBufferStrategy(2);
    long inititalTime = System.nanoTime();
    final double ns = 1000000000 / 60.0;
    double delta = 0;

    while (running) {
        long now = System.nanoTime();
        delta += (now - inititalTime) / ns;
        inititalTime = now;
        if (delta >= 1) {

            update();
            delta--;
        }
    }
}

Thank you.

Maybe you have a memory leak and it’s garbage collecting?

While that is something I will certainly look in to.(Edit, there does not seem to be any GC activity during the stutters. And actually seems to improve over time, is this because of hotspotting?). Not entirely convinced this is due to my code. As I mentioned, it happens in a clean LibGDX project, aswell as other java games on steam (Zomboid).

Is your graphics card messed up then? Or maybe upgrade the newest java and see what happens?

This is something i had experienced when misconfiguring vsync.

Try this to see if it’s vsync-related:

  1. Go to your GPU-Controlpanel and enable VSYNC (either forced or let app decide option)
  2. Configure your game (Use LibGDX for this) to use VSYNC and start in fullscreen mode with the resolution being set correctly. Do not change any other setting in the libgdx-launch-config (like fps)!

If it’s still stuttering consistently then you have a special case :smile:

1 Like

@FabulousFellini I’ve already done that and tried it on various machines. But thank you any way.

@VaTTeRGeR I’ve activated the VSYNC from the gpu. Seems to have fixed it! But ill give it more time and tests before I celebrate.

As for GDX, with vsync enabled:
Fullscreen is silky smooth. not a single skip/stutter(Same as what happens in my Java2D game).

Windows mode: skips every now and then.

Can any one please explain why this is happening? Is it really because of some priority issues with Windows OS and windows mode java? I’m using win7.

Short answer is windows aren’t vsynced, only fullscreen graphics. Although the Win7 window compositor is itself double buffered and vsynced, there’s no actual hardware vsync timer being used to sync your window udpates.

2 Likes

Sigh. Thought It was something like that. Thanks.

I never knew that, and thanks for the information.

Also worth noting that fullscreen borderless windows are not the same as fullscreen. Only true fullscreen is really vsynced though there may have been mitigations in newer OSes about this, I lost track of it all a few years ago.