Hello
My system is Xcode 9.3, High Sierra 10.13.4.
I have an NSWindow containing only a subclass of NSOpenGLView. The view is displaying a simple texture. If I grab the corner of my window and start resizing, after a few seconds dragging the window edge around I get the following crash:
*** Assertion failure in -[MyOpenGLView _enableNeedsDisplayInRectNotifications], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.40.112/AppKit.subproj/NSView.m:18293
[General] Overflowed needs display in rect posting count.
The crash always occurs. If I move the mouse more slowly, it takes a little more time to occur. Move the mouse faster and the crash happens sooner.
I post the full stack trace below. Note that at no point is any of my code listed in the stack. I do not call setNeedsDisplay or setNeedsDisplayInRect: anywhere in response to resizing the window. My gl reshape method is empty. There is no recursion happening in drawRect:.
I can workaround the issue by adding these empty overrides to my view:
- (void)_enableNeedsDisplayInRectNotifications
{ }
- (void)_disableNeedsDisplayInRectNotifications
{ }
It looks and smells like a bug in AppKit. But what is triggering it?
Thanks in advance
Full stack trace:
** Assertion failure in -[MyOpenGLView _enableNeedsDisplayInRectNotifications], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.40.112/AppKit.subproj/NSView.m:18293
2018-04-18 12:08:14.785967-0700 MyApp[22899:701655] [General] Overflowed needs display in rect posting count.
2018-04-18 12:08:14.790419-0700 MyApp[22899:701655] [General] (
0 CoreFoundation 0x00007fff504d932b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff77b53c76 objc_exception_throw + 48
2 CoreFoundation 0x00007fff504df0c2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fff525fb340 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 AppKit 0x00007fff4e2a9a32 -[NSView(NSInternal) _enableNeedsDisplayInRectNotifications] + 202
5 AppKit 0x00007fff4e06829f -[NSPortalView layout] + 361
6 AppKit 0x00007fff4e299ad0 _NSViewLayout + 587
7 AppKit 0x00007fff4da93eff -[NSView _layoutSubtreeWithOldSize:] + 437
8 AppKit 0x00007fff4da94178 -[NSView _layoutSubtreeWithOldSize:] + 1070
9 AppKit 0x00007fff4da94178 -[NSView _layoutSubtreeWithOldSize:] + 1070
10 AppKit 0x00007fff4da94178 -[NSView _layoutSubtreeWithOldSize:] + 1070
11 AppKit 0x00007fff4e2a082c -[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:] + 1380
12 AppKit 0x00007fff4dab16ef -[NSWindow(NSConstraintBasedLayout) _layoutViewTree] + 163
13 AppKit 0x00007fff4da9888a -[NSWindow _setFrame:updateBorderViewSize:] + 1124
14 AppKit 0x00007fff4dab0c67 -[NSWindow _oldPlaceWindow:] + 604
15 AppKit 0x00007fff4dab021a -[NSWindow _setFrameCommon:display:stashSize:] + 3108
16 AppKit 0x00007fff4daaf5e9 -[NSWindow _setFrame:display:allowImplicitAnimation:stashSize:] + 222
17 AppKit 0x00007fff4daaf504 -[NSWindow setFrame:display:] + 67
18 AppKit 0x00007fff4e4f23e9 -[NSWindow(NSWindowResizing) _resizeSetFrame:withEvent:] + 124
19 AppKit 0x00007fff4dd1a37f -[NSWindow(NSWindowResizing) _resizeWithEvent:] + 3060
20 AppKit 0x00007fff4e258422 -[NSTitledFrame attemptResizeWithEvent:] + 177
21 AppKit 0x00007fff4dc243dd -[NSThemeFrame handleMouseDown:] + 297
22 AppKit 0x00007fff4dc24603 -[NSThemeFrame mouseDown:] + 30
23 AppKit 0x00007fff4e325d6d -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 5891
24 AppKit 0x00007fff4e3229c4 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2359
25 AppKit 0x00007fff4e321c70 -[NSWindow(NSEventRouting) sendEvent:] + 497
26 AppKit 0x00007fff4e183236 -[NSApplication(NSEvent) sendEvent:] + 2462
27 AppKit 0x00007fff4d9e38b5 -[NSApplication run] + 812
28 AppKit 0x00007fff4d9b2a72 NSApplicationMain + 804
29 MyApp 0x000000010003208a main + 170
30 libdyld.dylib 0x00007fff7876d015 start + 1
31 ??? 0x0000000000000001 0x0 + 1
)
2018-04-18 12:08:14.791393-0700 MyApp[22899:701655] *** Assertion failure in -[MyOpenGLView _disableNeedsDisplayInRectNotifications], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.40.112/AppKit.subproj/NSView.m:18297
2018-04-18 12:08:14.792496-0700 MyApp[22899:701655] [General] An uncaught exception was raised
2018-04-18 12:08:14.792513-0700 MyApp[22899:701655] [General] Unbalanced needs display in rect posting count.
2018-04-18 12:08:14.792573-0700 MyApp[22899:701655] [General] (
0 CoreFoundation 0x00007fff504d932b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff77b53c76 objc_exception_throw + 48
2 CoreFoundation 0x00007fff504df0c2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fff525fb340 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 AppKit 0x00007fff4e2a9af2 -[NSView(NSInternal) _disableNeedsDisplayInRectNotifications] + 190
5 AppKit 0x00007fff4e06876b -[_NSPortalView2 setSourceView:] + 166
6 AppKit 0x00007fff4e06802a -[NSPortalView dealloc] + 89
7 libobjc.A.dylib 0x00007fff77b49087 _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 817
8 CoreFoundation 0x00007fff50412a56 _CFAutoreleasePoolPop + 22
9 Foundation 0x00007fff525378ad -[NSAutoreleasePool drain] + 144
10 AppKit 0x00007fff4d9e3990 -[NSApplication run] + 1031
11 AppKit 0x00007fff4d9b2a72 NSApplicationMain + 804
12 MyApp 0x000000010003208a main + 170
13 libdyld.dylib 0x00007fff7876d015 start + 1
14 ??? 0x0000000000000001 0x0 + 1
)
2018-04-18 12:08:14.793037-0700 MyApp[22899:701655] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unbalanced needs display in rect posting count.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff504d932b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff77b53c76 objc_exception_throw + 48
2 CoreFoundation 0x00007fff504df0c2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fff525fb340 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 AppKit 0x00007fff4e2a9af2 -[NSView(NSInternal) _disableNeedsDisplayInRectNotifications] + 190
5 AppKit 0x00007fff4e06876b -[_NSPortalView2 setSourceView:] + 166
6 AppKit 0x00007fff4e06802a -[NSPortalView dealloc] + 89
7 libobjc.A.dylib 0x00007fff77b49087 _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 817
8 CoreFoundation 0x00007fff50412a56 _CFAutoreleasePoolPop + 22
9 Foundation 0x00007fff525378ad -[NSAutoreleasePool drain] + 144
10 AppKit 0x00007fff4d9e3990 -[NSApplication run] + 1031
11 AppKit 0x00007fff4d9b2a72 NSApplicationMain + 804
12 MyApp 0x000000010003208a main + 170
13 libdyld.dylib 0x00007fff7876d015 start + 1
14 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException