"Impossible to set up layout with view hierarchy unprepared for constraint." crash in ios 13

Hello fellow ios devs.


After ios 13 we see lots of crashes related with keyboard. We only see this from crash reporting and can never reproduce it.

We suspect it is related to keyboard since there is referances to keyboard methods in call stack.


Here is the crash report coming from Fabric:


Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x1a96a898c __exceptionPreprocess
1  libobjc.A.dylib                0x1a93d10a4 objc_exception_throw
2  CoreFoundation                 0x1a95aad1c +[_CFXNotificationTokenRegistration keyCallbacks]
3  Foundation                     0x1a99e08f4 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4  UIKitCore                      0x1ada67a3c __120-[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:]_block_invoke_2
5  UIKitCore                      0x1ada676e8 -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:]
6  UIKitCore                      0x1ada67be0 -[UIView(UIConstraintBasedLayout) _tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutuallyExclusiveConstraints:]
7  UIKitCore                      0x1ada682bc -[UIView(UIConstraintBasedLayout) nsli_addConstraint:]
8  UIKitCore                      0x1ada6850c __50-[UIView(UIConstraintBasedLayout) addConstraints:]_block_invoke
9  Foundation                     0x1a998030c -[NSISEngine withBehaviors:performModifications:]
10 UIKitCore                      0x1ada683d8 -[UIView(UIConstraintBasedLayout) addConstraints:]
11 UIKitCore                      0x1ad4ba138 -[UIInputWindowControllerHostingItem updateVisibilityConstraintsForPlacement:]
12 UIKitCore                      0x1ad4b7a84 -[UIInputWindowControllerHostingItem updateViewConstraints]
13 UIKitCore                      0x1ad4b268c -[UIInputWindowControllerHosting updateViewConstraints]
14 UIKitCore                      0x1ad4a7824 -[UIInputWindowController updateViewConstraints]
15 UIKitCore                      0x1ad4afa6c -[UIInputWindowController changeToInputViewSet:]
16 UIKitCore                      0x1ad4b0350 __43-[UIInputWindowController setInputViewSet:]_block_invoke_3
17 UIKitCore                      0x1ad4ac1f8 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.926
18 Foundation                     0x1a9a7d874 __NSFireDelayedPerform
19 CoreFoundation                 0x1a9626e1c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
20 CoreFoundation                 0x1a9626b58 __CFRunLoopDoTimer
21 CoreFoundation                 0x1a9626228 __CFRunLoopDoTimers
22 CoreFoundation                 0x1a9621364 __CFRunLoopRun
23 CoreFoundation                 0x1a96208bc CFRunLoopRunSpecific
24 GraphicsServices               0x1b348c328 GSEventRunModal
25 UIKitCore                      0x1ad6b66d4 UIApplicationMain
26 YemeksepetiProd                0x1023d7440 main + 28 (AppDelegate.swift:28)
27 libdyld.dylib                  0x1a94ab460 start

Crashed: com.twitter.crashlytics.ios.exception
0  YSMarket                       0x105532a94 CLSProcessRecordAllThreads
1  YSMarket                       0x105532e7c CLSProcessRecordAllThreads
2  YSMarket                       0x105521e7c CLSHandler
3  YSMarket                       0x105530e90 __CLSExceptionRecord_block_invoke
4  libdispatch.dylib              0x1a9376184 _dispatch_client_callout
5  libdispatch.dylib              0x1a9359dd8 _dispatch_lane_barrier_sync_invoke_and_complete
6  YSMarket                       0x1055308fc CLSExceptionRecord
7  YSMarket                       0x105530728 CLSExceptionRecordNSException
8  YSMarket                       0x10553031c CLSTerminateHandler()
9  libc++abi.dylib                0x1a9476304 std::__terminate(void (*)())
10 libc++abi.dylib                0x1a9475ed8 __cxa_rethrow
11 libobjc.A.dylib                0x1a93d1258 objc_exception_rethrow
12 CoreFoundation                 0x1a962092c CFRunLoopRunSpecific
13 GraphicsServices               0x1b348c328 GSEventRunModal
14 UIKitCore                      0x1ad6b66d4 UIApplicationMain
15 YemeksepetiProd                0x1023d7440 main + 28 (AppDelegate.swift:28)
16 libdyld.dylib                  0x1a94ab460 start

Which call to keyboard function did you identifiy ?

isn’t UIInputWindowController related with keyboard?

That's an extension, when you define custom keyboard. Is it your case ?


Class

UIInputViewController

The primary view controller for a custom keyboard app extension.

Declaration

class UIInputViewController : UIViewController

Overview

To create a custom keyboard, first subclass the UIInputViewController class, then add your keyboard’s user interface to the inputView property of your subclass. In Xcode, you can start a custom keyboard by choosing the Custom Keyboard target template.


Surprinsingly, when searching for UIInputViewController in XCode documentation, nothing is found.


What is YemeksepetiProd ? Is it the name of app ?

YemeksepetiProd is the name of the app. We don’t have any keyboard extension. It is related to system keyboard. When you open the keyboard and pause the app in view debugger it is in the view hierarch.

Hello myusuf6716,

Did you resolve this issue? I am facing the same crash, but can not reproduce it by myself.

"Impossible to set up layout with view hierarchy unprepared for constraint." crash in ios 13
 
 
Q