Skip to content

Window crash bug #19

@secondsky

Description

@secondsky

The menu bar app crashes when:

  1. Opening settings window
  2. Closing the settings window → CRASH
  3. The crash occurs during the window close animation

What Needs to Be Changed

File: src/Sources/AppDelegate.swift

Change 1: Add NSWindowDelegate Protocol (Line 6)

Current:
class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {

Change to:
class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
UNUserNotificationCenterDelegate {

Why: This allows the AppDelegate to receive window lifecycle notifications.


Change 2: Make settingsWindow a Weak Reference (Line 9)

Current:
var settingsWindow: NSWindow?

Change to:
weak var settingsWindow: NSWindow?

Why: A weak reference automatically becomes nil when the window is deallocated, preventing dangling
pointers.


Change 3: Add Two Lines in createSettingsWindow() Function (After Line 137)

Current:
window.title = "VibeProxy"
window.center()

let contentView = SettingsView(serverManager: serverManager)

Change to:
window.title = "VibeProxy"
window.center()
window.delegate = self
window.isReleasedWhenClosed = false

let contentView = SettingsView(serverManager: serverManager)

Why:

  • window.delegate = self → Connects the window to receive delegate callbacks
  • window.isReleasedWhenClosed = false → CRITICAL FIX - Prevents the window from being deallocated
    during its close animation, which causes the crash on macOS 26.0.1

Change 4: Add windowDidClose Delegate Method (After Line 144)

Add this new function after the createSettingsWindow() function:

func windowDidClose(_ notification: Notification) {
if notification.object as? NSWindow === settingsWindow {
settingsWindow = nil
}
}

Why: This clears the weak reference when the window is fully closed, allowing it to be recreated
next time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions