Skip to content

fix(macos): close a window that closes itself while it is key - #2767

Merged
oneo-me merged 1 commit into
mainfrom
agiox/fix-issue-2746
Nov 29, 2026
Merged

oneo-me merged 1 commit into
mainfrom
agiox/fix-issue-2746

Conversation

@oneo-me

@oneo-me oneo-me commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2746. On macOS, desktop.CloseWindow called from inside a key window, such as from an OnKey("escape", ...) handler, ran OnClosing and disposed the window's tree but left its NSWindow on screen for good.

performClose: runs inside the batch that carries WindowClose, and on a key window it spins a run loop. That run loop delivered the wakeup Mount posted for the batch destroying the window, and applyBatches, already applying, returned without taking it. As queue.Batches wakes the main thread once per drain, nothing woke it again: the WindowDestroy batch, and every later one, stayed queued.

applyBatches now records a wakeup that arrives while it applies and takes what was queued before it returns. Windows and Linux had the same drop in their applyBatches (a modal loop or a GTK allocation while applying), so they now drain again too.

I left performClose: synchronous rather than deferring it with apple.OnMain as the issue also suggested: with the drain fixed, the destroy batch applies right after performClose: returns. Deferring it closed windows one turn later, which left a test's window on screen into the next test and made TestMenuAutoEditingKey and TestBackdropColorFiltersChangeWhatIsBehind flaky.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None

Verification

  • head: 477ef28c20d7193bb92cda78b8c508e384c4a402
  • base: 1d16f441dd4e6642376fd33fead4d8898e0e7305
  • commands:
    • go tool nsgo check → 0
    • go tool nsgo check -target linux,windows -jobs 4 → 0
    • go tool nsgo test → 1
  • result: fail
  • not covered: the one failure, TestQuickLookThumbnailDrawsTheAppOffTheScreen (1 surface left open), fails the same way on the base commit in a full run, and passes when internal/platform/macos runs on its own. The new TestApply* tests also pass on a Windows 11 desktop session and on Linux (Wayland). In both places the rest of each backend's native package fails identically with and without this change, so the device is to blame. No automated test makes a window key, which this bug needs, so the key-window path itself was not run end to end.

Checklist

  • The title is a Conventional Commit, such as fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and a capability users can see has a line in a changelog.d/ fragment, not in CHANGELOG.md.
  • New third-party code, assets and dependencies name their source and license.

🤖 Generated with Claude Code

🤖 Claude Opus 5.5

@oneo-me oneo-me self-assigned this Nov 29, 2026
@github-actions github-actions Bot added size/XS bug Something isn't working local-ci-skipped labels Nov 29, 2026
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

The Local CI block declares fail for this pull request's head commit, so a maintainer audits the pull request before merging it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oneo-me
oneo-me force-pushed the agiox/fix-issue-2746 branch from a25944e to 477ef28 Compare November 29, 2026 15:44
@github-actions github-actions Bot added size/M documentation Improvements or additions to documentation macOS Windows Linux and removed size/XS labels Nov 29, 2026
@oneo-me
oneo-me marked this pull request as ready for review November 29, 2026 15:44
@github-actions github-actions Bot added local-ci-fail The head commit declares failing local checks, so a maintainer audits it and removed local-ci-skipped labels Nov 29, 2026
@oneo-me
oneo-me merged commit 7433585 into main Nov 29, 2026
52 of 54 checks passed
@oneo-me
oneo-me deleted the agiox/fix-issue-2746 branch November 29, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation Linux local-ci-fail The head commit declares failing local checks, so a maintainer audits it macOS size/M Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS: desktop.CloseWindow on an active window drops WindowDestroy and leaves a zombie NSWindow

1 participant