Skip to content

fix(macos): Close the windows through AppWindow.Closing when the app is asked to quit (backport #26063) - #26064

Merged
agneszitte merged 11 commits into
unoplatform:servicing/6.8from
ajpinedam:dev/anpi/backport-26063-6.8
Nov 9, 2026
Merged

agneszitte merged 11 commits into
unoplatform:servicing/6.8from
ajpinedam:dev/anpi/backport-26063-6.8

Conversation

@ajpinedam

@ajpinedam ajpinedam commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: related to #26075, which #26063 closes on master

PR Type:

🐞 Bugfix

What changed? 🚀

Manual servicing/6.8 backport of #26063, synced to its head bb777cabc6; this one is synced again if it changes. The same commits are backported to release/stable/6.7 in #26097.

What it fixes (same as the master PR): on macOS, Cmd+Q, the application menu's Quit and the Dock's Quit end the app without raising AppWindow.Closing or Window.Closed. Now:

  • Such a quit closes the windows the user can see as the user would, front to back: AppWindow.Closing first, which can cancel the quit, then Closed. If one window cancels, the windows asked before it are closed; it and the windows behind it stay open.
  • Once they are closed, the app exits, whatever DispatcherShutdownMode is. OnExplicitShutdown still keeps the app running after the user closes its last window, and a later Quit still ends it.
  • Hidden windows are not asked. The quit is refused while a modal panel (a file picker) or a sheet is up.
  • A logout, restart or shutdown is never refused: it ends the app without Closing or Closed, as before and as on Windows.
  • Application.Exit() now matches WinUI's FrameworkApplication::ExitImpl: it closes every window as Window.Close() does, raising Window.Closed but not AppWindow.Closing, then exits. A Closed handler that sets Handled keeps its window open, and with OnLastWindowClose that keeps the app running.
  • A Closing handler that throws logs an Error; a cancelled close and OnExplicitShutdown keeping the app running log at Debug.
  • doc/articles/features/app-close-handler.md gains a macOS section, and the manual sample Windowing/AppWindow_QuitClosesWindows covers the scenarios.

The behaviour changes and the manual test steps are in #26063.

Why not a Mergify backport: files moved for 7.0. On 6.8 the macOS host is Uno.UI.Runtime.Skia.MacOS (not Uno.UI.Runtime.MacOS), and the sample folder is Microsoft_UI_Windowing (not Microsoft/UI/Windowing). The commits apply unchanged otherwise: the net diff is line for line the same as master's.

One 6.8 difference, now harmless: a closed window leaves the windows set only when it is deallocated, not when it closes. It is no longer visible, so a quit does not ask it.

Validated on 6.8 with Studio Live, the downstream app that needs this (it runs its shutdown sequence when its window closes). The same change was applied to the Uno commit behind its 6.8.0-dev.187 (91e6b404), and its macOS host (Uno.UI.Runtime.Skia.MacOS.dll and libUnoNativeMac.dylib) swapped into the app's build output. Quits were sent as the Dock's quit request, on macOS 27, Apple silicon:

Case Stock 6.8.0-dev.187 With this change
Quit ends at once, no shutdown sequence Closing → the app closes its window → Closed → its sequence → Application.Exit() ends it
Two quits back to back — one sequence, ends by itself
Ten quit cycles — 10/10 complete the sequence and end by themselves; no crash reports
Logout (quit carrying kAEReallyLogOut) — ends in about 1 s without the sequence

On this branch itself, SamplesApp.Skia.Generic builds, and the sample logs Closing → Closed → exit on a quit.

The individual behaviours (cancel, front-to-back order, hidden windows, file picker, throwing handler, OnExplicitShutdown, Exit() parity) were checked on master with SamplesApp; see #26063.

PR Checklist ✅

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@github-actions github-actions Bot added area/automation Categorizes an issue or PR as relevant to project automation kind/documentation labels Nov 5, 2026
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@agneszitte
agneszitte merged commit ca1ea13 into unoplatform:servicing/6.8 Nov 9, 2026
59 of 64 checks passed
@ajpinedam
ajpinedam deleted the dev/anpi/backport-26063-6.8 branch November 9, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants