ResizableWindow::setMinimised() causes NSInvalidArgumentException (macOS 12.6, JUCE 7.0.2, XCode 14.1)

Has anyone else ran into an error like the log below when calling setMinimised() on a JUCE app window?

Weirdly, I get two different results depending on how the user triggers the setMinimised() function call.

  • If the user goes up to the macOS menu bar and clicks Window > Minimize, this error appears exactly as shown below and the application cannot continue because the NSException is uncaught.
  • But, if the user presses the key command I bound (⌘M) to trigger setMinimized() then the error appears without An uncaught exception was raised and without libc++abi: terminating with uncaught exception, and the application CAN continue.
[General] An uncaught exception was raised
[General] -[JUCEView_d68295ab189b7448 windowDidMiniaturize:]: unrecognized selector sent to instance 0x139665150
[General] (
	0   CoreFoundation                      0x00000001b8755148 __exceptionPreprocess + 240
	1   libobjc.A.dylib                     0x00000001b849fe04 objc_exception_throw + 60
	2   CoreFoundation                      0x00000001b87e8ef8 -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x00000001b86b4494 ___forwarding___ + 1764
	4   CoreFoundation                      0x00000001b86b3cf0 _CF_forwarding_prep_0 + 96
	5   CoreFoundation                      0x00000001b86c9468 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28
	6   CoreFoundation                      0x00000001b876dbb8 ___CFXRegistrationPost_block_invoke + 52
	7   CoreFoundation                      0x00000001b876db24 _CFXRegistrationPost + 456
	8   CoreFoundation                      0x00000001b86980f8 _CFXNotificationPost + 732
	9   Foundation                          0x00000001b955dc28 -[NSNotificationCenter postNotificationName:object:userInfo:] + 96
	10  AppKit                              0x00000001bbaed320 -[NSWindow(NSWindow_Theme) _finishMinimizeToDock] + 320
	11  AppKit                              0x00000001bb3ae784 _NSCGSDockMessageReceive + 520
	12  HIToolbox                           0x00000001c1339758 _ZL12DockCallbackjjPvS_ + 1540
	13  HIServices                          0x00000001be2ba1a8 _DCXTransactionComplete + 56
	14  HIServices                          0x00000001be2ba144 _XTransactionComplete + 60
	15  HIServices                          0x00000001be2aad50 mshMIGPerform + 204
	16  CoreFoundation                      0x00000001b86d5818 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
	17  CoreFoundation                      0x00000001b86d56d4 __CFRunLoopDoSource1 + 604
	18  CoreFoundation                      0x00000001b86d3b68 __CFRunLoopRun + 2372
	19  CoreFoundation                      0x00000001b86d2a84 CFRunLoopRunSpecific + 600
	20  HIServices                          0x00000001be2ba0c4 waitForTransaction + 196
	21  AppKit                              0x00000001bb382d68 minimizeItemsMaybeBatching + 148
	22  AppKit                              0x00000001bbaec8c0 -[NSWindow(NSWindow_Theme) _regularMinimizeToDock] + 84
	23  AppKit                              0x00000001bb5c00dc -[NSWindow(NSWindow_Theme) _minimizeToDock] + 52
	24  MMConnect                           0x0000000100d2e5f4 _ZN4juce19NSViewComponentPeer12setMinimisedEb + 76
	25  MMConnect                           0x0000000100c50cc4 _ZN4juce15ResizableWindow12setMinimisedEb + 128
	26  MMConnect                           0x000000010068f200 _ZN11Application10MainWindow7performERKN4juce24ApplicationCommandTarget14InvocationInfoE + 120
	27  MMConnect                           0x0000000100c58110 _ZN4juce24ApplicationCommandTarget11tryToInvokeERKNS0_14InvocationInfoEb + 176
	28  MMConnect                           0x0000000100cf86d4 _ZN4juce24ApplicationCommandTarget14CommandMessage15messageCallbackEv + 72
	29  MMConnect                           0x0000000100a49268 _ZN4juce12MessageQueue18deliverNextMessageEv + 112
	30  MMConnect                           0x0000000100a491c0 _ZN4juce12MessageQueue15runLoopCallbackEv + 64
	31  MMConnect                           0x0000000100a48e70 _ZN4juce12MessageQueue21runLoopSourceCallbackEPv + 24
	32  CoreFoundation                      0x00000001b86d4f94 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
	33  CoreFoundation                      0x00000001b86d4ee0 __CFRunLoopDoSource0 + 208
	34  CoreFoundation                      0x00000001b86d4be0 __CFRunLoopDoSources0 + 268
	35  CoreFoundation                      0x00000001b86d3560 __CFRunLoopRun + 828
	36  CoreFoundation                      0x00000001b86d2a84 CFRunLoopRunSpecific + 600
	37  HIToolbox                           0x00000001c1312338 RunCurrentEventLoopInMode + 292
	38  HIToolbox                           0x00000001c13120b4 ReceiveNextEventCommon + 564
	39  HIToolbox                           0x00000001c1311e68 _BlockUntilNextEventMatchingListInModeWithFilter + 72
	40  AppKit                              0x00000001bb23a51c _DPSNextEvent + 860
	41  AppKit                              0x00000001bb238e14 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1328
	42  AppKit                              0x00000001bb22afe0 -[NSApplication run] + 596
	43  MMConnect                           0x0000000100a32a94 _ZN4juce14MessageManager15runDispatchLoopEv + 152
	44  MMConnect                           0x0000000100a32970 _ZN4juce19JUCEApplicationBase4mainEv + 372
	45  MMConnect                           0x0000000100a327a4 _ZN4juce19JUCEApplicationBase4mainEiPPKc + 68
	46  MMConnect                           0x000000010068d548 main + 56
	47  dyld                                0x000000010321108c start + 520
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[JUCEView_d68295ab189b7448 windowDidMiniaturize:]: unrecognized selector sent to instance 0x139665150'
terminating with uncaught exception of type NSException

Ah, I’ve just seen JUCE 7.0.3 is available. I will try upgrading to that and report back.

Updating to JUCE 7.0.3 solved the issue!
Thanks JUCE team! :grinning:

I apologize for making a forum post before trying the latest release.