Quick answer: Pygame RESIZABLE window flickering or briefly black during drag-resize? SDL recreates the display surface (and GL context) per resize event — expensive on every drag frame.
User drags a window edge; the game flickers black during the drag. SDL is recreating the display each VIDEORESIZE.
Render to Logical Surface
Always render to a fixed-size logical Surface. On VIDEORESIZE, resize display only; blit logical to display scaled. Display recreation cost paid once per resize, not per frame.
Coalesce Resize Events
last_resize = pygame.time.get_ticks()
if event.type == VIDEORESIZE:
pending_size = event.size
if pending_size and ticks - last_resize > 100:
pygame.display.set_mode(pending_size, RESIZABLE)
pending_size = NoneApply once user stops dragging. Far smoother.
Use SCALED Flag
pygame.SCALED with RESIZABLE has the engine scale automatically. Less control but no flicker.
Vsync Coordination
If you also have OPENGL, the GL context recreation is most of the cost. Avoid resize during gameplay or invest in the SCALED path.
Verifying
Resize is smooth; no flicker. Final size matches user drag.
“Resize recreates the display. Coalesce events or use SCALED flag.”
Add a small ‘currently resizing’ state — freeze ambient gameplay during drag so the user gets responsive resize without inputs going stray.