Recently a crash popped up in Firebase Crashlytics and I have no clue what it means. The message says:
Fatal Exception: NSInternalInconsistencyException
Trying to complete an interactive gesture but the animation coordinator is nil! (gesture=<_UIBarPanGestureRecognizer: 0x109f177c0; state = Ended; view = <UILayoutContainerView 0x1059153a0>; target= <(action=_gestureRecognizedInteractiveHide:, target=<UINavigationController 0x106837800>)>> action=Show)
and the stack trace looks like this:
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x9904c __exceptionPreprocess
1 libobjc.A.dylib 0x15f54 objc_exception_throw
2 Foundation 0x1306cc _userInfoForFileAndLine
3 UIKitCore 0x918cec -[UINavigationController _gestureRecognizedInteractiveHide:]
4 UIKitCore 0x1e042c -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:]
5 UIKitCore 0x1a9560 _UIGestureRecognizerSendTargetActions
6 UIKitCore 0x172260 _UIGestureRecognizerSendActions
7 UIKitCore 0x1ab910 -[UIGestureRecognizer _updateGestureForActiveEvents]
8 UIKitCore 0x163ad0 _UIGestureEnvironmentUpdate
9 UIKitCore 0x1978c8 -[UIGestureEnvironment _updateForEvent:window:]
10 UIKitCore 0x1a4a68 -[UIWindow sendEvent:]
11 UIKitCore 0x354318 -[UIApplication sendEvent:]
12 UIKitCore 0x177c30 __dispatchPreprocessedEventFromEventQueue
13 UIKitCore 0x16ca1c __processEventQueue
14 UIKitCore 0xfae7dc updateCycleEntry
15 UIKitCore 0x7dd7d8 _UIUpdateSequenceRun
16 UIKitCore 0xe57008 schedulerStepScheduledMainSection
17 UIKitCore 0xe565f8 runloopSourceCallback
18 CoreFoundation 0xbb020 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
19 CoreFoundation 0xcbce0 __CFRunLoopDoSource0
20 CoreFoundation 0x5fe8 __CFRunLoopDoSources0
21 CoreFoundation 0xb7f4 __CFRunLoopRun
22 CoreFoundation 0x1f3b8 CFRunLoopRunSpecific
23 GraphicsServices 0x138c GSEventRunModal
24 UIKitCore 0x5196a8 -[UIApplication _run]
25 UIKitCore 0x2987f4 UIApplicationMain
26 libswiftUIKit.dylib 0x31184 UIApplicationMain(_:_:_:_:)
27 MYAPPNAME 0x7220 main (MyAppStruct.swift)
28 ??? 0x104bb9a24 (Missing)
The MyAppStruct.swift
is the only file in the trace that comes from my source code. It is just a struct which holds data and has some static methods for calculations. There is absolutely no relation with gestures and animations in this struct.
This only happened on iOS 15.1.1 devices (iPhone 12 and iPhone 13 Pro) for now.
2
Answers
I've managed to constantly reproduce this on an iPad 10.2 (9th gen). In my view controller, I have a scroll view as the top-most view in the hierarchy, and I was hiding/showing the navigation bar using the
navigationController?.hidesBarsOnSwipe
property. This property was set to true only when the scrollView'scontentSize.height
was greater than theview.bounds.height
. The idea is to hide the navigation bar if the content scrolls, otherwise leave it visible and ignore the swipe gesture.The issue only occurred when the scrollView's
contentSize.height
was just about 50pt larger than the view.height, which happens really, really rarely.I removed the
navigationController?.hidesBarsOnSwipe
and used thescrollViewDidScroll
method instead:FYI, I have a bug scenario that shows a similarly weird traceback (GUI event dispatched from inside UIKit’s update cycle!?), and I have posted a report to Apple Developer Forums here:
https://developer.apple.com/forums/thread/699670
I don’t think this is the "normal" way for GUI events to be dispatched. Seems hardly surprising that things could go wrong in the event handler.