This is an FYI to demonstrate that this scary yet relatively harmless error message from AppKit is possible when using a Settings window. The message logged is Setting [some view] as the first responder for window [settings window] ... but it is in a different window ((null))! This would eventually crash when the view is freed. The complete message is below. I characterize the error as harmless because a Settings window and its panels are normally never freed, right?
It's happened on occasion when running a debug build of my app from Xcode, where I've later noticed this error logged to its debug console. I've only noticed this error printed there it a couple of times and haven't figured out yet how to reproduce it on demand. This doesn't bode well for active debugging the problem, however my wishful thinking is that this issue contains enough information for someone to recognize what might be going on and identify a potentially obvious workaround.
My app has a NSStatusItem as its only UI, plus a few alerts and windows it can open, like Settings. It doesn't have its own menu bar or icon in the dock. Choosing my menu option to open the Settings window, my app first does NSApp.activate(ignoringOtherApps: true) and then settingsWindowController.show(pane: nil). (if someone can point out to me reasons for not doing that NSApp.activate call, please do, I inherited it from the source I forked and my knowledge about it is limited)
Each of my panels are in nib files, and in the first I have a KeyboardShortcuts.RecorderCocoa (thanks for that too btw1) that the error is specifically complaining about. This control isn't in the nib, I instantiate it at launch in a class let of my panel's view controller, and in viewDidLoad() add it as a subview of a container NSView. Perhaps that is relevant to the error, IDK. And unfortunately I don't know if this error was from the first time opening the window, or a subsequent time.
The full error message is (word-wrapped instead of on 1 line like it is below):
Setting <_TtCO17KeyboardShortcuts17KeyboardShortcuts13RecorderCocoa: 0x7fee54a1c100> as the first responder for window <Settings.UserInteractionPausableWindow: 0x7fee5497fea0> windowNumber=2791, but it is in a different window ((null))! This would eventually crash when the view is freed. The first responder will be set to nil.
macOS 15.6, Intel MBP
ERROR: Setting <_TtCO17KeyboardShortcuts17KeyboardShortcuts13RecorderCocoa: 0x7fee54a1c100> as the first responder for window <Settings.UserInteractionPausableWindow: 0x7fee5497fea0> windowNumber=2791, but it is in a different window ((null))! This would eventually crash when the view is freed. The first responder will be set to nil.
(
0 AppKit 0x00007ff8147b5dc9 -[NSWindow _validateFirstResponder:] + 459
1 AppKit 0x00007ff8147b5bb8 -[NSWindow _setFirstResponder:] + 31
2 AppKit 0x00007ff8148b574c -[NSWindow _realMakeFirstResponder:] + 663
3 AppKit 0x00007ff8148c6381 -[NSWindow _selectFirstKeyView] + 763
4 AppKit 0x00007ff8148c594c -[NSWindow _setUpFirstResponder] + 187
5 AppKit 0x00007ff8148c2b64 -[NSWindow _doWindowWillBeVisibleAsSheet:] + 153
6 AppKit 0x00007ff815417cbb -[NSWindow _reallyDoOrderWindowAboveOrBelow:] + 1334
7 AppKit 0x00007ff815418b36 -[NSWindow _reallyDoOrderWindow:] + 106
8 AppKit 0x00007ff815418dbe -[NSWindow _doOrderWindow:] + 298
9 AppKit 0x00007ff8148b76a6 -[NSWindow makeKeyAndOrderFront:] + 47
10 QuickLookUI 0x00007ffb1cea1c1a -[QLSeamlessDocumentOpener showWindow:contentFrame:withBlock:] + 166
11 AppKit 0x00007ff8149b3db7 -[NSWindowController showWindow:] + 648
12 Batch Clipboard MAS.debug.dylib 0x000000010368a83d $s8Settings0A16WindowControllerC4show4paneyA2AO14PaneIdentifierVSg_tF + 781
13 Batch Clipboard MAS.debug.dylib 0x00000001034b5603 $s19Batch_Clipboard_MAS8AppModelC12showSettings13selectingPaney0G0AFO0I10IdentifierVSg_tF + 147
14 Batch Clipboard MAS.debug.dylib 0x00000001034b555c $s19Batch_Clipboard_MAS8AppModelC12showSettingsyyyXlF + 44
15 Batch Clipboard MAS.debug.dylib 0x00000001034b56e4 $s19Batch_Clipboard_MAS8AppModelC12showSettingsyyyXlFTo + 52
16 AppKit 0x00007ff814984a66 -[NSApplication(NSResponder) sendAction:to:from:] + 444
17 AppKit 0x00007ff814a6f36f -[NSMenuItem _corePerformAction] + 455
18 AppKit 0x00007ff81525fed9 _NSMenuPerformActionWithHighlighting + 185
19 AppKit 0x00007ff814ab17d9 -[NSMenu performActionForItemAtIndex:] + 113
20 AppKit 0x00007ff814ab175f -[NSMenu _internalPerformActionForItemAtIndex:] + 82
21 AppKit 0x00007ff815254a91 +[NSCocoaMenuImpl _performActionForMenuItem:] + 208
22 AppKit 0x00007ff815002d00 -[NSMenuTrackingSession _performPostTrackingDismissalActions] + 443
23 AppKit 0x00007ff81500296f -[NSMenuTrackingSession startRunningMenuEventLoop:] + 2401
24 AppKit 0x00007ff815001fae -[NSMenuTrackingSession startMonitoringEvents:] + 315
25 AppKit 0x00007ff81577921c -[NSContextMenuTrackingSession startMonitoringEvents:] + 192
26 AppKit 0x00007ff814fabac6 +[NSContextMenuImpl presentPopup:fromView:withContext:animated:] + 1173
27 AppKit 0x00007ff815261b6b _NSPopUpMenu + 3210
28 AppKit 0x00007ff815260e17 -[NSCocoaMenuImpl popUpMenu:atLocation:width:view:selectedItemIndexProvider:font:positioningRect:flags:options:] + 562
29 AppKit 0x00007ff815260bdf -[NSCocoaMenuImpl popUpMenu:atLocation:width:view:selectedItemIndexProvider:font:flags:options:] + 53
30 AppKit 0x00007ff815260b9a -[NSCocoaMenuImpl popUpMenu:atLocation:width:forView:withSelectedItem:withFont:withFlags:withOptions:] + 81
31 AppKit 0x00007ff81521c821 +[NSStatusBarButtonCell popUpStatusBarMenu:ofItem:ofBar:inRect:ofView:withEvent:] + 417
32 AppKit 0x00007ff81521c175 -[NSStatusBarButtonCell performClick:] + 326
33 Batch Clipboard MAS.debug.dylib 0x000000010346bb4e $s19Batch_Clipboard_MAS11MenuBarIconC06statusE13ButtonClicked6senderySo08NSStatuseH0C_tF + 926
34 Batch Clipboard MAS.debug.dylib 0x000000010346c074 $s19Batch_Clipboard_MAS11MenuBarIconC06statusE13ButtonClicked6senderySo08NSStatuseH0C_tFTo + 52
35 AppKit 0x00007ff814984a66 -[NSApplication(NSResponder) sendAction:to:from:] + 444
36 AppKit 0x00007ff81498486e -[NSControl sendAction:to:] + 86
37 AppKit 0x00007ff8150e90a7 __NSControlTrackMouse_block_invoke + 60
38 AppKit 0x00007ff8149810cc NSControlTrackMouse + 888
39 AppKit 0x00007ff814980d30 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 125
40 AppKit 0x00007ff814980bb3 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 700
41 AppKit 0x00007ff81521bc38 -[NSStatusBarButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 344
42 AppKit 0x00007ff81497ff9a -[NSControl mouseDown:] + 669
43 AppKit 0x00007ff81497e920 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4689
44 AppKit 0x00007ff8148f8349 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 531
45 AppKit 0x00007ff8148f7f15 -[NSWindow(NSEventRouting) sendEvent:] + 344
46 AppKit 0x00007ff81521f311 -[NSStatusBarWindow sendEvent:] + 674
47 AppKit 0x00007ff81522d669 -[NSApplication(NSEventRouting) sendEvent:] + 1905
48 AppKit 0x00007ff814d90c37 -[NSApplication _handleEvent:] + 65
49 AppKit 0x00007ff814791ec5 -[NSApplication run] + 654
50 AppKit 0x00007ff814765005 NSApplicationMain + 803
51 Batch Clipboard MAS.debug.dylib 0x00000001034097c9 __debug_main_executable_dylib_entry_point + 9
52 dyld 0x00007ff8108af530 start + 3056
)
This is an FYI to demonstrate that this scary yet relatively harmless error message from AppKit is possible when using a Settings window. The message logged is
Setting [some view] as the first responder for window [settings window] ... but it is in a different window ((null))! This would eventually crash when the view is freed.The complete message is below. I characterize the error as harmless because a Settings window and its panels are normally never freed, right?It's happened on occasion when running a debug build of my app from Xcode, where I've later noticed this error logged to its debug console. I've only noticed this error printed there it a couple of times and haven't figured out yet how to reproduce it on demand. This doesn't bode well for active debugging the problem, however my wishful thinking is that this issue contains enough information for someone to recognize what might be going on and identify a potentially obvious workaround.
My app has a NSStatusItem as its only UI, plus a few alerts and windows it can open, like Settings. It doesn't have its own menu bar or icon in the dock. Choosing my menu option to open the Settings window, my app first does
NSApp.activate(ignoringOtherApps: true)and thensettingsWindowController.show(pane: nil). (if someone can point out to me reasons for not doing thatNSApp.activatecall, please do, I inherited it from the source I forked and my knowledge about it is limited)Each of my panels are in nib files, and in the first I have a KeyboardShortcuts.RecorderCocoa (thanks for that too btw1) that the error is specifically complaining about. This control isn't in the nib, I instantiate it at launch in a
class letof my panel's view controller, and inviewDidLoad()add it as a subview of a container NSView. Perhaps that is relevant to the error, IDK. And unfortunately I don't know if this error was from the first time opening the window, or a subsequent time.The full error message is (word-wrapped instead of on 1 line like it is below):
Setting <_TtCO17KeyboardShortcuts17KeyboardShortcuts13RecorderCocoa: 0x7fee54a1c100> as the first responder for window <Settings.UserInteractionPausableWindow: 0x7fee5497fea0> windowNumber=2791, but it is in a different window ((null))! This would eventually crash when the view is freed. The first responder will be set to nil.macOS 15.6, Intel MBP
Footnotes
@sindresorhus let me know if you want an App Store promo code for my app as a thank you. It's open source but the App Store version has in-app purchase for extra features not in GitHub builds (unless you tweak the source and build yourself). It's yet another clipboard utility, forked from Maccy before its recent migration to SwiftUI, taking out of the UI and provides mostly an unobtrusive serial paste feature. Soon with saving and recalling clipboard sets. ↩