SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Linux - OpenGL content jitter on window vertical resize

Open andoryu opened this issue 1 year ago • 0 comments

I have identified an issue with window contents jittering on Linux with a vertical window resize, but not with horizontal resize.

Last commit I tested with was 123306b - xsync

I experimented with several things to resolve:

  • based on the behaviour I tried changing the bit_gravity setting for XWindowCreate as the default might have been the cause. No change.
  • tried re-drawing the window contents as quickly as possible with:
    GL_Swap_Interval(0);
    GL_SwapBuffers();
    GL_Swap_Interval(1);

in the Expose event handler. This improved the jitter significantly, but did not remove it entirely.

  • in the end I updated my test code to only:
    • update with window size in the Resize event
    • set a redraw flag in the Expose event
    • update the contents once in the SDL_AppIterate iterate once per Expose event.

This final experiment made the display completely jitter free.

When the if statement on line 176 is changed to

if(true)
{
  //update projection
  //draw, etc...
}

the jitter returns.

This has been verified on another, different Linux distro with a different video card.

It looks to me like there is some race condition or variation in the window size or origin parameters during resize - but only for vertical resizing.

Example code is available here: https://github.com/andoryu/sdl3-test

Please note the test code is in work-around state and the if statement change noted above will need to be made to make it misbehave.

The single write update flag feels like a work around and not a great solution.

andoryu avatar Dec 09 '24 07:12 andoryu