Skip to content

cocoa: fix destroyed windows lingering on screen when the app stops pumping - #15992

Open
pseudo-rnd-thoughts wants to merge 1 commit into
libsdl-org:SDL2from
pseudo-rnd-thoughts:fix-macos-ghost-window
Open

cocoa: fix destroyed windows lingering on screen when the app stops pumping#15992
pseudo-rnd-thoughts wants to merge 1 commit into
libsdl-org:SDL2from
pseudo-rnd-thoughts:fix-macos-ghost-window

Conversation

@pseudo-rnd-thoughts

@pseudo-rnd-thoughts pseudo-rnd-thoughts commented Jul 14, 2026

Copy link
Copy Markdown

Description

I'm developing visualisations on MacOS using Jupyter notebooks and PyGame however found that when I want to close the window mid notebook it would hang and require killing the process and the jupyter notebook. Very annoying.

Using Fable, I was able to track the PyGame issue down to #10081, reporting the same issue.

I was able to narrow down the issue to servicing a window out starts an implicit AppKit transform animation that only progresses while the main runloop is serviced, and the window server keeps compositing the window until it completes. The problem is that an app that destroys its window and then stops pumping events (like in the case of Jupyter) leaves a frozen ghost window on screen until the process exits (i.e., hangs indefinitely).

To solve this, we can disable the implicit show/hide animation at window creation, and give AppKit one short main-runloop pass after [NSWindow close] so the deferred order-out is committed even if the app never pumps again. This means that the hide and show animation on windows is removed so if maintainers wish I can see if we can condition this logic to only remove the animation on closes or hides.

Existing Issue(s)

Fixes #10081

…umping

Ordering a window out starts an implicit AppKit transform animation
(~250ms) that only progresses while the main runloop is serviced, and
the window server keeps compositing the window until it completes. An
app that destroys its window and then stops pumping events (common in
interactive environments like Jupyter) leaves a frozen ghost window on
screen until the process exits.

Disable the implicit show/hide animation at window creation, and give
AppKit one short main-runloop pass after [NSWindow close] so the
deferred order-out is committed even if the app never pumps again.

Fixes libsdl-org#10081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants