Window resizing Linux

I am experiencing somethig unexpected with recent SDL3 from git and, window resizing on Linux.

Trying to figure out if it’s a bug or not.

I have a really basic window (callback mode) with OpenGL setup, with some “hello square” code, and a dynamic ortho projection linked to the window size.

When i resize the window vertically, the rendered square jitters up and down, like it’s tracking the bottom of the window, before being restored to its correct position. Faster I resize, the worse the jitter.

However the horizontal resize has no noticable effect - the square never moves.

I looked over the source, but i cannot not see anything obvious that could cause this. Have some familiarity with xcb.

Is this behaviour expected, or is it a possible bug?

I have the code on github if that helps.

Thanks.

This sounds very similar: Text Flickering on Window Resize in SDL2

This issue is likely caused by improper configuration of SDL2, which makes objects lose their positions. Yes, I can confirm that objects visibly jitter vertically when the window height is adjusted. I even ran a test using Nuklear with the sdl_renderer backend, and the problem is quite evident – objects jump vertically during resizing.

You can easily reproduce this by setting the flags to SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_RESIZABLE. With these settings, the issue becomes very apparent.

I hadn’t mentioned this before because there wasn’t any interest in solving the problem, here in the group, so I put it aside for the time being.

Thanks Peter, somehow had managed to not find that post - but it does sound like the same issue.

Interesting, thanks for the verification.

So no interest in fixing? Is that because games don’t usually use window resizing perhaps?

It would be great if this could be fixed, SDL is more broadly useful than just games. I looked at the X11/Xlib code, but i am going to need a lot more time to figure out if anything can be done.

Thanks

Can you try SDL3? We added support for [ _NET_WM_SYNC_REQUEST] (X11: support _NET_WM_SYNC_REQUEST · libsdl-org/SDL@123306b · GitHub) recently that might take care of this.

For me, migrating to SDL3 is quite a time-consuming process as I am currently using SDL2 version 2.30.8 with language bindings for Harbour. I would also like to mention a memory leak issue that I’ve encountered. The leak originates from the library libdbus-1.so.3.32.4 and is related to its usage within libSDL2. The memory allocation trace clearly points to calloc in libdbus-1, which suggests the issue lies in SDL2’s integration with D-Bus.

This is already on SDL3, using the call back mode.

I pulled the latest version a couple of hours ago and retested - and it was still there.

However, I have come up with what I consider to be a work around, rather than a fix.

In the process I have tried a few things:
I tried adding gravity settings to the window setup to move it away from the default bit_gravity value with no change.

I tried to change the redraw spped in the event loop via:
GL_Swap_Interval(0);
GL_SwapBuffers();
GL_Swap_Interval(1);

in the event code for Expose, which significantly improved the effect, but did not remove it.

After more fiddling I have the Expose event setting a redraw flag only, Resize updating the window size data only, and SDL_App_Iterate only drawing and swapping buffers on the redraw flag - then clearing the flag.

It is now rock solid when resizing.

If it I let App_Iterate draw every frame, it flickers during resize.

It looks to me like a weird race condition around window size parameters during resize.

Definitely feels like a work around to me, rather than a solid fix - but it does solve this immediate flickering problem.

Is there a GitHub issue for tracking? It seems worth investigating before release.

I haven’t yet, but I will do that soon.

Be good to see if this can be solved.