Skip to content

Fix UniGetUI not quitting properly on macOS#4890

Open
Gabriel Dufresne (GabrielDuf) wants to merge 1 commit into
mainfrom
fix/macos-quit-issue
Open

Fix UniGetUI not quitting properly on macOS#4890
Gabriel Dufresne (GabrielDuf) wants to merge 1 commit into
mainfrom
fix/macos-quit-issue

Conversation

@GabrielDuf
Copy link
Copy Markdown
Contributor

@GabrielDuf Gabriel Dufresne (GabrielDuf) commented Jun 5, 2026

On macOS, UniGetUI couldn't be quit normally and had to be Force Quit from Activity Monitor. Three distinct issues (#4887):

  1. The process never terminated. Quitting only called ApplicationLifetime.Shutdown(), which doesn't stop the background loops (auto-update checker, telemetry, icon database) or the Kestrel IPC host. The process lingered at 2-3% CPU after "closing."
  2. Native quit gestures did nothing. Cmd+Q, the application-menu Quit, and Dock → Quit raise the lifetime's ShutdownRequested event, which was unhandled — so they fell through to the hide-to-dock path and the app could never actually be quit.
  3. Closing to the Dock was a dead end. Once the window was hidden, clicking the Dock icon never brought it back.

Changes

  • Single hard-exit quit path. All real quits now funnel through QuitApplication(), which releases window resources (saves geometry, disposes the tray icon) and hard-exits via Environment.Exit(0) after stopping the IPC server — mirroring the WinUI app's existing StopIpcAndExitAsync. A re-entrancy guard (IsQuitting) prevents double-teardown.
  • Handle ShutdownRequested in App so macOS quit gestures (Cmd+Q, app menu, Dock → Quit) and OS session-end route into the clean quit path.
  • Handle IActivatableLifetime Reopen so clicking the Dock icon restores a hidden window.
  • Platform-correct close button. On macOS the close button always hides the window to the Dock (the platform standard) regardless of the tray setting; the app is quit via Cmd+Q / app menu / Dock. On Windows/Linux, close-to-tray is unchanged when the tray is enabled, and closing with the tray disabled now fully terminates the process instead of leaving background threads alive.
  • The in-app Quit (PageType.Quit) and app-restart helper already route through the same path.

Cross-platform safety

  • Environment.Exit(0) loses no data: logs, settings, and operation history all write synchronously, and window geometry is saved continuously. This matches what the WinUI app already does.
  • The new ShutdownRequested handler doesn't affect the normal Windows/Linux flow — Avalonia's OnLastWindowClose calls Shutdown() internally without raising ShutdownRequested.
  • The Dock-reopen handler is a no-op off macOS (TryGetFeature() is guarded; Reopen is macOS-only).
  • The tray icon is explicitly disposed before exit to avoid a ghost notification-area icon on Windows.

@GabrielDuf Gabriel Dufresne (GabrielDuf) changed the title Fix UniGetUI not quitting properly on macOS (#4887) Fix UniGetUI not quitting properly on macOS Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants