cocoa: fix destroyed windows lingering on screen when the app stops pumping - #15992
Open
pseudo-rnd-thoughts wants to merge 1 commit into
Open
cocoa: fix destroyed windows lingering on screen when the app stops pumping#15992pseudo-rnd-thoughts wants to merge 1 commit into
pseudo-rnd-thoughts wants to merge 1 commit into
Conversation
…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
This was referenced Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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