MiMo42 / MMTabBarView

A Mac OS X tab bar view that works on 10.9+ with Xcode 9.3+. Pull requests welcomed.
http://mimo42.github.com/MMTabBarView/
243 stars 79 forks source link

Crash moving mouse over tab close button in MMRollOverButtonCell.mouseExited on MacOS 12.3 #82

Open greenius opened 2 years ago

greenius commented 2 years ago

This crash started with MacOS 12.3. Using MacOS 12.2.1 is fine. I suspect something to do with the new Universal Control feature introduced in MacOS 12.3.

Create a tab bar and set onlyShowCloseOnHover to YES. Create more than one tab.

_tabBar.onlyShowCloseOnHover = YES;

Moving the mouse over the [x] button in tab bar causes it to crash with a MacOS assertion.

The window has been marked as needing another Display Window pass, but it has already had more Display Window passes than there are views in the window.

Stack dump:

0   CoreFoundation                      0x00007ff80ab6c1e3 __exceptionPreprocess + 242
1   libobjc.A.dylib                     0x00007ff80a8ccc13 objc_exception_throw + 48
2   CoreFoundation                      0x00007ff80ab6c04a +[NSException exceptionWithName:reason:userInfo:] + 0
3   AppKit                              0x00007ff80d52de5d -[NSWindow(NSDisplayCycle) _postWindowNeedsDisplayUnlessPostingDisabled] + 1716
4   AppKit                              0x00007ff80dd7d2bb NSViewSetNeedsUpdateVibrancy + 64
5   AppKit                              0x00007ff80d531ba2 -[NSView setNeedsDisplayInRect:] + 212
6   AppKit                              0x00007ff80d531ab9 -[NSView setNeedsDisplay:] + 50
7   AppKit                              0x00007ff80d54607e -[NSButton updateCell:] + 47
8   MMTabBarView                        0x000000010c731eac -[MMRolloverButtonCell mouseExited:] + 108
9   MMTabBarView                        0x000000010c731329 -[MMRolloverButton updateTrackingAreas] + 713
10  AppKit                              0x00007ff80dd87e0b -[NSView _updateTrackingAreasWithInvalidCursorRects:] + 124
11  AppKit                              0x00007ff80dd885ef -[NSView _updateTrackingAreasWithInvalidCursorRects:] + 2144
12  AppKit                              0x00007ff80dd885ef -[NSView _updateTrackingAreasWithInvalidCursorRects:] + 2144
13  AppKit                              0x00007ff80dd885ef -[NSView _updateTrackingAreasWithInvalidCursorRects:] + 2144
14  AppKit                              0x00007ff80dd885ef -[NSView _updateTrackingAreasWithInvalidCursorRects:] + 2144
15  AppKit                              0x00007ff80d5e9ef9 _NSWindowDisplayCycleUpdateStructuralRegions + 212
16  AppKit                              0x00007ff80d5e646f __NSWindowGetDisplayCycleObserverForUpdateStructuralRegions_block_invoke + 420
17  AppKit                              0x00007ff80d5e0577 NSDisplayCycleObserverInvoke + 155
18  AppKit                              0x00007ff80d5e0104 NSDisplayCycleFlush + 921
19  AppKit                              0x00007ff80d5eb465 __37+[NSDisplayCycle currentDisplayCycle]_block_invoke.18 + 906
20  QuartzCore                          0x00007ff811b80382 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 98
21  QuartzCore                          0x00007ff811cf4421 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 875
22  QuartzCore                          0x00007ff811b7f231 _ZN2CA11Transaction6commitEv + 777
23  AppKit                              0x00007ff80d6817f1 __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 285
24  AppKit                              0x00007ff80ddc8688 ___NSRunLoopObserverCreateWithHandler_block_invoke + 41
25  CoreFoundation                      0x00007ff80aaefe90 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
26  CoreFoundation                      0x00007ff80aaefd22 __CFRunLoopDoObservers + 543
27  CoreFoundation                      0x00007ff80aaef1b4 __CFRunLoopRun + 840
28  CoreFoundation                      0x00007ff80aaee7ac CFRunLoopRunSpecific + 562
29  HIToolbox                           0x00007ff813775ce6 RunCurrentEventLoopInMode + 292
30  HIToolbox                           0x00007ff813775913 ReceiveNextEventCommon + 283
31  HIToolbox                           0x00007ff8137757e5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
32  AppKit                              0x00007ff80d5155cd _DPSNextEvent + 927
33  AppKit                              0x00007ff80d513c8a -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1394
34  AppKit                              0x00007ff80d506339 -[NSApplication run] + 586
35  AppKit                              0x00007ff80d4da2b7 NSApplicationMain + 817

Putting a breakpoint on ObjectiveC exceptions. It is thrown in MMRolloverButtonCell.mouseExited when it calls updateCell.

- (void)mouseExited:(NSEvent *)event {
    _mouseHovered = NO;
    [(NSControl *)self.controlView updateCell:self];
}
greenius commented 2 years ago

Sometimes it crashes with the same exception in MMAttachedTabBarButton.viewWillDraw when it calls setNeedsDisplayInrect:

 -(void)viewWillDraw {

    NSView *superview = self.superview;
    [superview setNeedsDisplayInRect:superview.bounds];

    [super viewWillDraw];
}

Stack dump:

    0   CoreFoundation                      0x00007ff80ab6c1e3 __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007ff80a8ccc13 objc_exception_throw + 48
    2   CoreFoundation                      0x00007ff80ab6c04a +[NSException exceptionWithName:reason:userInfo:] + 0
    3   AppKit                              0x00007ff80d52de5d -[NSWindow(NSDisplayCycle) _postWindowNeedsDisplayUnlessPostingDisabled] + 1716
    4   AppKit                              0x00007ff80dd7d2bb NSViewSetNeedsUpdateVibrancy + 64
    5   AppKit                              0x00007ff80d531ba2 -[NSView setNeedsDisplayInRect:] + 212
    6   MMTabBarView                        0x000000010bc8f092 -[MMAttachedTabBarButton viewWillDraw] + 178
    7   AppKit                              0x00007ff80d5e5a42 _NSViewWillDraw + 45
    8   AppKit                              0x00007ff80d5e5cbb NSViewSendViewWillDrawToSubviews + 588
    9   AppKit                              0x00007ff80d5e5a42 _NSViewWillDraw + 45
    10  AppKit                              0x00007ff80d5e57e3 -[_NSViewBackingLayer display] + 64
    11  AppKit                              0x00007ff80d5eb40a __37+[NSDisplayCycle currentDisplayCycle]_block_invoke.18 + 815
    12  QuartzCore                          0x00007ff811b80382 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 98
    13  QuartzCore                          0x00007ff811cf4421 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 875
    14  QuartzCore                          0x00007ff811b7f231 _ZN2CA11Transaction6commitEv + 777
    15  AppKit                              0x00007ff80d6817f1 __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 285
    16  AppKit                              0x00007ff80ddc8688 ___NSRunLoopObserverCreateWithHandler_block_invoke + 41
    17  CoreFoundation                      0x00007ff80aaefe90 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    18  CoreFoundation                      0x00007ff80aaefd22 __CFRunLoopDoObservers + 543
    19  CoreFoundation                      0x00007ff80aaef1b4 __CFRunLoopRun + 840
    20  CoreFoundation                      0x00007ff80aaee7ac CFRunLoopRunSpecific + 562
    21  HIToolbox                           0x00007ff813775ce6 RunCurrentEventLoopInMode + 292
    22  HIToolbox                           0x00007ff813775913 ReceiveNextEventCommon + 283
    23  HIToolbox                           0x00007ff8137757e5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
    24  AppKit                              0x00007ff80d5155cd _DPSNextEvent + 927
    25  AppKit                              0x00007ff80d513c8a -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1394
    26  AppKit                              0x00007ff80d506339 -[NSApplication run] + 586
    27  AppKit                              0x00007ff80d4da2b7 NSApplicationMain + 817