Obscure assertion crash in com.apple.NSScrollingConcurrentVBLMonitor thread

I have received a few crash reports for my app "Find Any File" with an assertion failure as follows:

assertion failure: "displayTiming != ((void *)0)" -> %lld

Googling this turns up nothing, though.

I wonder if someone has some insight into why this might happen, and how to prevent it.

One reporting user suggests that it happens when my app shows a very long list of items in an NSTableView (>10000 elements).

I have 4 reports from 3 users, and the main thread is doing something related to the table view each time, though not the same (the few other threads are all idle):

Crash 1, in macOS 14.0 (23A344:

Thread 0::  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib               	       0x182c69400 objc_msgSend + 0
1   AppKit                        	       0x186f15400 -[CALayer(NSViewVisibleRect) NS_viewVisibleRectDidChange] + 40
2   AppKit                        	       0x186900e10 NSViewHierarchyInvalidateVisibleRect + 276
3   AppKit                        	       0x186900db0 NSViewHierarchyInvalidateVisibleRect + 180
4   AppKit                        	       0x186900db0 NSViewHierarchyInvalidateVisibleRect + 180
5   AppKit                        	       0x186900db0 NSViewHierarchyInvalidateVisibleRect + 180
6   AppKit                        	       0x186900db0 NSViewHierarchyInvalidateVisibleRect + 180
7   AppKit                        	       0x186900db0 NSViewHierarchyInvalidateVisibleRect + 180
8   AppKit                        	       0x1869990e0 -[NSView translateOriginToPoint:] + 164
9   AppKit                        	       0x186984108 -[NSClipView _immediateScrollToPoint:] + 420
10  AppKit                        	       0x186983eb8 -[NSClipView scrollToPoint:] + 184
11  AppKit                        	       0x186998d80 -[NSScrollView scrollClipView:toPoint:] + 84
12  AppKit                        	       0x1869448dc -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] + 480
13  AppKit                        	       0x186b65b24 __62-[NSScrollingBehaviorConcurrentVBL _stopGestureScrollTracking]_block_invoke + 192
14  AppKit                        	       0x186e6a6e8 ___NSMainRunLoopPerformBlockInModes_block_invoke + 44
15  CoreFoundation                	       0x18310b8c0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 28

Crash 2, in macOS 14.1.1 (23B81):

Thread 0::  Dispatch queue: com.apple.main-thread
0   CoreFoundation                	       0x18ba401f4 DYLD-STUB$$_Block_object_assign + 0
1   libsystem_blocks.dylib        	       0x18b506118 _call_copy_helpers_excp + 80
2   libsystem_blocks.dylib        	       0x18b505c68 _Block_copy + 376
3   libdispatch.dylib             	       0x18b641c7c _dispatch_Block_copy + 32
4   libdispatch.dylib             	       0x18b658df0 _dispatch_source_set_handler + 92
5   CoreFoundation                	       0x18b99e1e4 __CFRunLoopCopyMode + 540
6   CoreFoundation                	       0x18b8b7458 CFRunLoopAddObserver + 220
7   AppKit                        	       0x18f0a687c _PerfAddRunLoopObserver + 192
8   AppKit                        	       0x18f87cd60 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 368
9   AppKit                        	       0x18f323318 -[_NSScrollingConcurrentEventMonitor startMonitoring] + 380
10  AppKit                        	       0x18f321df8 -[NSScrollingBehaviorConcurrentVBL _scrollView:trackGestureScrollWithEvent:] + 884
11  AppKit                        	       0x18f2e67f8 -[NSScrollingBehaviorConcurrentVBL scrollView:scrollWheelWithEvent:] + 512
12  AppKit                        	       0x18f241770 forwardMethod + 252
13  AppKit                        	       0x18f2e62a0 -[NSView scrollWheel:] + 408
14  AppKit                        	       0x18f241770 forwardMethod + 252
15  AppKit                        	       0x18f2e62a0 -[NSView scrollWheel:] + 408
16  AppKit                        	       0x18f241770 forwardMethod + 252
17  AppKit                        	       0x18f2e62a0 -[NSView scrollWheel:] + 408
18  AppKit                        	       0x18f241770 forwardMethod + 252
19  AppKit                        	       0x18f2e62a0 -[NSView scrollWheel:] + 408
20  AppKit                        	       0x18fc45880 -[NSCollectionView scrollWheel:] + 180
21  AppKit                        	       0x18f241770 forwardMethod + 252
22  AppKit                        	       0x18f241770 forwardMethod + 252
23  AppKit                        	       0x18f2e62a0 -[NSView scrollWheel:] + 408
24  AppKit                        	       0x18f241770 forwardMethod + 252
25  AppKit                        	       0x18f2e62a0 -[NSView scrollWheel:] + 408
26  AppKit                        	       0x18f241770 forwardMethod + 252
27  AppKit                        	       0x18f2e62a0 -[NSView scrollWheel:] + 408
28  AppKit                        	       0x18f1d27b0 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 652

As you can see, there's no code of mine involved at the time of crash.

The other (and older) reports are similar, in macOS 13.6.1 and macOS 13.1. All four happened on ARM architecture (which may not be significant due to small number of samples). Memory use of app was not critical (in one case it was about 9 GB total, in others below 4 GB).

The "Binary Images" section only lists Apple libs, apart from my app's. So, there seems to be no 3rd party ext involved.

I've attached a full report as well.

Answered by DTS Engineer in 775154022

I recommend that you file a bug about this. Please post your bug number, just for the record.

The immediate cause of this bug is that AppKit has a subsystem that monitor’s the display’s timing while you’re scrolling (VBL should sound familiar to you!). This subsystem has asked another subsystem for a timer that’s appropriate for the screen that it’s monitoring. That subsystem has return nil, and thus you trap in this assert.

It’s hard to imagine how your code might be causing this, and hence my recommendation above.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

I recommend that you file a bug about this. Please post your bug number, just for the record.

The immediate cause of this bug is that AppKit has a subsystem that monitor’s the display’s timing while you’re scrolling (VBL should sound familiar to you!). This subsystem has asked another subsystem for a timer that’s appropriate for the screen that it’s monitoring. That subsystem has return nil, and thus you trap in this assert.

It’s hard to imagine how your code might be causing this, and hence my recommendation above.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

We ran into this issue as well. I filed feedback for this: FB22102831

Several users report they see our crash reporter window after they woke their Mac(Book) from sleep, the crash logs suggest the crash occurred while adding or removing a display, which might be the cause of nil being returned by the subsystem.

Here are two main thread stack traces for crash reports:

0   libsystem_kernel.dylib          0x3024c8c34         mach_msg2_trap
1   libsystem_kernel.dylib          0x3024db024         mach_msg2_internal
2   libsystem_kernel.dylib          0x3024d1988         mach_msg_overwrite
3   libsystem_kernel.dylib          0x3024c8fb0         mach_msg
4   SkyLight                        0x30f9896a8         _CGSGetRealtimeDisplayDataShmemPort
5   SkyLight                        0x30f6b0820         WS::RealtimeDisplayDataMapping::shmem
6   SkyLight                        0x30f6b06f0         WS::RealtimeDisplayDataMapping::data
7   SkyLight                        0x30f6b0cc8         realtime_data_for_display
8   SkyLight                        0x30f6b1fc4         SLSDisplayGetCurrentHeadroom
9   AppKit                          0x30bde35f8         -[NSCGSDisplay initWithDisplayID:flipOffset:]
10  AppKit                          0x30ae7dee4         ___NSCGSCreateDisplaysFromDisplayIDsUsingPredicate_block_invoke
11  AppKit                          0x30b8e8694         _NSCGSCreateUniqueDisplaysWithFlipOffset
12  AppKit                          0x30b8ea3cc         _NSCGSDisplayConfigurationUpdate
13  AppKit                          0x30b8e9734         _NSCGSDisplayConfigurationUpdateAndInvokeObservers
14  AppKit                          0x30b8e9d70         _NSCGSDisplayConfigurationDidReconfigureNotificationHandler
15  SkyLight                        0x30f5144e4         (anonymous namespace)::notify_datagram_handler
16  SkyLight                        0x30f95d70c         CGSDatagramReadStream::dispatchMainQueueDatagrams
17  SkyLight                        0x30f95d5d0         CGSDatagramReadStream::mainQueueWakeup
18  CoreFoundation                  0x30262d600         __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
19  CoreFoundation                  0x30262d540         __CFRunLoopDoBlocks
20  CoreFoundation                  0x30262c984         __CFRunLoopRun
21  CoreFoundation                  0x3026e6e30         _CFRunLoopRunSpecificWithOptions
22  HIToolbox                       0x31bba978c         RunCurrentEventLoopInMode
23  HIToolbox                       0x31bbacab4         ReceiveNextEventCommon
24  HIToolbox                       0x31bd36b60         _BlockUntilNextEventMatchingListInMode
25  AppKit                          0x30b397b58         _DPSBlockUntilNextEventMatchingListInMode
26  AppKit                          0x30ae91e44         _DPSNextEvent
27  AppKit                          0x30b95cd08         -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
28  AppKit                          0x30b95ca14         -[NSApplication(NSEventRouting) nextEventMatchingMask:untilDate:inMode:dequeue:]
29  AppKit                          0x30ae8a77c         -[NSApplication run]
30  AppKit                          0x30ae766d8         NSApplicationMain
31  dyld                            0x301db6d50         start
Thread 0
0   Foundation                      0x31d995f20         _NSRequestConcreteObject
1   Foundation                      0x31cc2cc2c         -[NSNumber hash]
2   CoreFoundation                  0x31a060574         -[__NSFrozenSetM containsObject:]
3   WindowManagement                0x4dc04b55c         -[_WMWindow applyTags:mask:]
4   AppKit                          0x321f1b530         -[NSWindow _setFrameCommon:display:fromServer:]
5   AppKit                          0x322a0933c         -[NSWindow(NSScreenLayout) _setFrame:fromAdjustmentToScreen:anchorIfNeeded:animate:]
6   AppKit                          0x3221b4488         -[NSWindow _adjustWindowToScreen]
7   AppKit                          0x3221d3ee4         -[NSWindow _displayChangedSoAdjustWindows:]
8   AppKit                          0x322d5b874         ___NSApplicationPerformScreenInvalidationReactions_block_invoke
9   AppKit                          0x321ed3804         -[NSApplication enumerateWindowsWithOptions:usingBlock:]
10  AppKit                          0x322d5b174         ___NSApplicationReactToScreenInvalidation_block_invoke
11  AppKit                          0x322d5a9b4         _NSApplicationReactToScreenInvalidation
12  AppKit                          0x322d5ac00         -[NSApplication(ScreenHandling) _reactToDisplayChanges:]
13  AppKit                          0x322808818         _NSCGSDisplayConfigurationUpdateAndInvokeObservers
14  AppKit                          0x322808cfc         _NSCGSDisplayConfigurationDidReconfigureNotificationHandler
15  SkyLight                        0x325f7d02c         (anonymous namespace)::notify_datagram_handler
16  SkyLight                        0x32638ad98         CGSDatagramReadStream::dispatchMainQueueDatagrams
17  SkyLight                        0x32638ac5c         CGSDatagramReadStream::mainQueueWakeup
18  libdispatch.dylib               0x319b7fb28         _dispatch_call_block_and_release
19  libdispatch.dylib               0x319b99858         _dispatch_client_callout
20  libdispatch.dylib               0x319bb6b54         _dispatch_main_queue_drain.cold.5
21  libdispatch.dylib               0x319b8edac         _dispatch_main_queue_drain
22  libdispatch.dylib               0x319b8ece8         _dispatch_main_queue_callback_4CF
23  CoreFoundation                  0x31a088da0         __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
24  CoreFoundation                  0x31a049a98         __CFRunLoopRun
25  CoreFoundation                  0x31a048c54         CFRunLoopRunSpecific
26  HIToolbox                       0x331529278         RunCurrentEventLoopInMode
27  HIToolbox                       0x33152c4e4         ReceiveNextEventCommon
28  HIToolbox                       0x3316b7480         _BlockUntilNextEventMatchingListInModeWithFilter
29  AppKit                          0x321ed8ab0         _DPSNextEvent
30  AppKit                          0x3228775ac         -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
31  AppKit                          0x321ecbc60         -[NSApplication run]
32  AppKit                          0x321ea2358         NSApplicationMain
33  dyld                            0x3197aab94         start

Unfortunately we have not been able to reproduce this on our side. But a fix would be appreciated!

Obscure assertion crash in com.apple.NSScrollingConcurrentVBLMonitor thread
 
 
Q