Open andreasgrabher opened 1 month ago
Out of curiosity, if you add SDL_SyncWindow(sdlWindow);
right after the SDL_SetWindowSize()
call, does the bug still occur?
Still the same with SDL_SyncWindow(). I may have to mention it only happens if rendering is done on a secondary thread. The function mentioned in the opening post is called from the main thread as is the creation of the window and renderer.
I may have to mention it only happens if rendering is done on a secondary thread.
While the bug might not be related to SDL_Render directly, it's probably worth mentioning SDL_Render is only supported in the main thread: https://wiki.libsdl.org/SDL3/CategoryRender
I know, but I have used threaded rendering on macOS ever since with SDL2 without any issues. Using SDL2 it also works on Windows. This bug makes rendering from the main thread a pain on macOS: https://github.com/libsdl-org/SDL/issues/10475
Energy impact of my application is more than doubled and performance is poor because of that issue.
Btw.: It seems that the crash described in https://github.com/libsdl-org/SDL/issues/9698 is gone. But using fixed aspect ratio does not work around the problem described in the initial post.
Update: This issue is only present when using gpu renderer. Using metal renderer all seems to be fine.
There seems to be a race condition with resize events and the window size reported by
SDL_GetWindowSize()
.If an event of type
SDL_EVENT_WINDOW_RESIZED
occurs my application executes this code to maintain aspect ratio:This works for most part but fails sometimes (see appended video).
Btw. I am not using the fixed aspect ratio feature because of this bug: https://github.com/libsdl-org/SDL/issues/9698
https://github.com/user-attachments/assets/b3972d8d-4871-4753-8114-bf00feef7d32