uncaught exception 'NSInternalInconsistencyException', reason: 'Layout requested for visible navigation bar.

Hey,bros:

I meet this crash,but I can't find any useful infos to fix this crash.And this crash only happens on iOS17.

Here are the crash infos:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Layout requested for visible navigation bar, <UINavigationBar: 0x106128820; frame = (0 0; 430 44); opaque = NO; autoresize = W; tintColor = UIExtendedGrayColorSpace.

Here are the stacks:

Thread 0 name: com.apple.main-thread CoreFoundation ___exceptionPreprocess (in CoreFoundation) libobjc.A.dylib _objc_exception_throw (in libobjc.A.dylib) Foundation -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] (in Foundation) UIKitCore -[UINavigationBar layoutSubviews] (in UIKitCore) UIKitCore -[UIView(CALayerDelegate) layoutSublayersOfLayer:] (in UIKitCore) longbridge-ios-app -[UIView(Thread) ex_layoutSublayersOfLayer:] (in longbridge-ios-app:UIView+Thread.m:36) UIKitCore -[UINavigationBar layoutSublayersOfLayer:] (in UIKitCore) QuartzCore CA::Layer::layout_if_needed(CA::Transaction*) (in QuartzCore) UIKitCore -[UIView(Hierarchy) layoutBelowIfNeeded] (in UIKitCore) UIKitCore -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] (in UIKitCore) UIKitCore -[UINavigationController _positionNavigationBarHidden:edge:] (in UIKitCore) UIKitCore -[UINavigationController _updateBarsForCurrentInterfaceOrientationAndForceBarLayout:] (in UIKitCore) UIKitCore -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] (in UIKitCore) UIKitCore -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:] (in UIKitCore) UIKitCore -[UIView(Internal) _didMoveFromWindow:toWindow:] (in UIKitCore) UIKitCore ___45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke (in UIKitCore) CoreAutoLayout -[NSISEngine withBehaviors:performModifications:] (in CoreAutoLayout) UIKitCore -[UIView _postMovedFromSuperview:] (in UIKitCore) UIKitCore -[UIView(Internal) _addSubview:positioned:relativeTo:] (in UIKitCore) UIKitCore -[UITransitionView transition:fromView:toView:removeFromView:] (in UIKitCore) UIKitCore -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:] (in UIKitCore) UIKitCore ____UIViewControllerTransitioningRunCustomTransition_block_invoke_3 (in UIKitCore) UIKitCore +[UIKeyboardSceneDelegate _pinInputViewsForKeyboardSceneDelegate:onBehalfOfResponder:duringBlock:] (in UIKitCore) UIKitCore ____UIViewControllerTransitioningRunCustomTransition_block_invoke_2 (in UIKitCore) UIKitCore +[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:] (in UIKitCore) UIKitCore __UIViewControllerTransitioningRunCustomTransition (in UIKitCore) UIKitCore ___56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 (in UIKitCore) UIKitCore -[_UIAfterCACommitBlock run] (in UIKitCore) UIKitCore -[_UIAfterCACommitQueue flush] (in UIKitCore) UIKitCore __runAfterCACommitDeferredBlocks (in UIKitCore) UIKitCore __cleanUpAfterCAFlushAndRunDeferredBlocks (in UIKitCore) UIKitCore __UIApplicationFlushCATransaction (in UIKitCore) UIKitCore __UIUpdateSequenceRun (in UIKitCore) UIKitCore _schedulerStepScheduledMainSection (in UIKitCore) UIKitCore _runloopSourceCallback (in UIKitCore) CoreFoundation _CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION (in CoreFoundation) CoreFoundation ___CFRunLoopDoSource0 (in CoreFoundation) CoreFoundation ___CFRunLoopDoSources0 (in CoreFoundation) CoreFoundation ___CFRunLoopRun (in CoreFoundation) CoreFoundation _CFRunLoopRunSpecific (in CoreFoundation) GraphicsServices _GSEventRunModal (in GraphicsServices) UIKitCore -[UIApplication _run] (in UIKitCore) UIKitCore _UIApplicationMain (in UIKitCore) longbridge-ios-app main (in longbridge-ios-app:main.m:22) dyld start (in dyld)

This exception is new in iOS 17, and occurs when the same UINavigationItem has been added to two different UINavigationBars. Prior to iOS 17 this would have most likely manifested as a hang.

I am seeing the same crash, however my app is using SwiftUI, so I don't know how I could have added the same item to two navigation bars. Any idea what I am doing wrong?

Here is my backtrace:

Last Exception Backtrace:
0   CoreFoundation                	0x1a2c74f20 __exceptionPreprocess + 164 (NSException.m:249)
1   libobjc.A.dylib               	0x19ab7a018 objc_exception_throw + 60 (objc-exception.mm:356)
2   Foundation                    	0x1a217b868 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 188 (NSException.m:252)
3   UIKitCore                     	0x1a515542c -[UINavigationBar layoutSubviews] + 460 (UINavigationBar.m:3853)
4   UIKitCore                     	0x1a4e82a4c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1528 (UIView.m:20054)
5   UIKitCore                     	0x1a4fd9a58 -[UINavigationBar layoutSublayersOfLayer:] + 192 (UINavigationBar.m:3811)
6   QuartzCore                    	0x1a42e13b4 CA::Layer::layout_if_needed(CA::Transaction*) + 504 (CALayer.mm:10816)
7   UIKitCore                     	0x1a4ecbe90 -[UIView(Hierarchy) layoutBelowIfNeeded] + 296 (UIView.m:14159)
8   UIKitCore                     	0x1a4f74648 -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] + 580 (UINavigationController.m:2901)
9   UIKitCore                     	0x1a4fd6bd8 -[UINavigationController _positionNavigationBarHidden:edge:] + 268 (UINavigationController.m:0)
10  UIKitCore                     	0x1a4f7c6a8 -[UINavigationController _updateBarsForCurrentInterfaceOrientationAndForceBarLayout:] + 104 (UINavigationController.m:5388)
11  UIKitCore                     	0x1a512bc00 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 164 (UIViewController.m:7062)
12  UIKitCore                     	0x1a5129304 -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:] + 76 (UINavigationController.m:4486)
13  UIKitCore                     	0x1a4e9b854 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1128 (UIView.m:17495)
14  UIKitCore                     	0x1a4e9b698 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 684 (UIView.m:0)
15  UIKitCore                     	0x1a4e8ca70 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 124 (UIView.m:13611)
16  CoreAutoLayout                	0x1c3df4f14 -[NSISEngine withBehaviors:performModifications:] + 84 (NSISEngine.m:1995)
17  UIKitCore                     	0x1a4e8f914 -[UIView _postMovedFromSuperview:] + 504 (UIView.m:13594)
18  UIKitCore                     	0x1a4e8e3d0 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 2200 (UIView.m:18281)
19  UIKitCore                     	0x1a52270ec -[UITransitionView transition:fromView:toView:removeFromView:] + 868 (UITransitionView.m:368)
20  UIKitCore                     	0x1a5226d60 -[UITransitionView transition:toView:] + 116 (UITransitionView.m:270)
21  UIKitCore                     	0x1a5224c00 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 2072 (UITabBarController.m:4026)
22  UIKitCore                     	0x1a52996ac -[UITabBarController _setSelectedViewController:performUpdates:] + 352 (UITabBarController.m:2271)
23  UIKitCore                     	0x1a5298948 -[UITabBarController setSelectedViewController:] + 84 (UITabBarController.m:2237)
24  UIKitCore                     	0x1a56cec64 -[UITabBarController _setSelectedViewControllerAndNotify:] + 428 (UITabBarController.m:3535)
25  UIKitCore                     	0x1a56cea94 -[UITabBarController _tabBarItemClicked:] + 48 (UITabBarController.m:3484)
26  UIKitCore                     	0x1a526d31c -[UIApplication sendAction:to:from:forEvent:] + 100 (UIApplication.m:5616)
27  UIKitCore                     	0x1a55f7d18 -[UITabBar _sendAction:withEvent:] + 384 (UITabBar.m:1525)
28  UIKitCore                     	0x1a526d31c -[UIApplication sendAction:to:from:forEvent:] + 100 (UIApplication.m:5616)
29  UIKitCore                     	0x1a526d1f4 -[UIControl sendAction:to:forEvent:] + 112 (UIControl.m:920)
30  UIKitCore                     	0x1a526d044 -[UIControl _sendActionsForEvents:withEvent:] + 324 (UIControl.m:991)
31  UIKitCore                     	0x1a55f9054 -[UITabBar _buttonUp:] + 100 (UITabBar.m:2368)
32  UIKitCore                     	0x1a526d31c -[UIApplication sendAction:to:from:forEvent:] + 100 (UIApplication.m:5616)
33  UIKitCore                     	0x1a526d1f4 -[UIControl sendAction:to:forEvent:] + 112 (UIControl.m:920)
34  UIKitCore                     	0x1a526d044 -[UIControl _sendActionsForEvents:withEvent:] + 324 (UIControl.m:991)
35  UIKitCore                     	0x1a5785894 -[UIControl touchesEnded:withEvent:] + 400 (UIControl.m:670)
36  UIKitCore                     	0x1a51adeac -[UIWindow _sendTouchesForEvent:] + 776 (UIWindow.m:3330)
37  UIKitCore                     	0x1a51ad954 -[UIWindow sendEvent:] + 3204 (UIWindow.m:3658)
38  UIKitCore                     	0x1a502e9e0 -[UIApplication sendEvent:] + 564 (UIApplication.m:12721)
39  UIKitCore                     	0x1a50301d4 __dispatchPreprocessedEventFromEventQueue + 5552 (UIEventDispatcher.m:2598)
40  UIKitCore                     	0x1a5038ecc __processEventQueue + 5624 (UIEventDispatcher.m:2956)
41  UIKitCore                     	0x1a4f2b84c updateCycleEntry + 160 (UIEventDispatcher.m:126)
42  UIKitCore                     	0x1a4f2976c _UIUpdateSequenceRun + 84 (_UIUpdateSequence.mm:119)
43  UIKitCore                     	0x1a4f293b0 schedulerStepScheduledMainSection + 172 (_UIUpdateScheduler.m:1058)
44  UIKitCore                     	0x1a4f2a254 runloopSourceCallback + 92 (_UIUpdateScheduler.m:1221)
45  CoreFoundation                	0x1a2c47834 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1957)
46  CoreFoundation                	0x1a2c477c8 __CFRunLoopDoSource0 + 176 (CFRunLoop.c:2001)
47  CoreFoundation                	0x1a2c45298 __CFRunLoopDoSources0 + 244 (CFRunLoop.c:2038)
48  CoreFoundation                	0x1a2c44484 __CFRunLoopRun + 828 (CFRunLoop.c:2955)
49  CoreFoundation                	0x1a2c43cd8 CFRunLoopRunSpecific + 608 (CFRunLoop.c:3420)
50  GraphicsServices              	0x1e7af41a8 GSEventRunModal + 164 (GSEvent.c:2196)
51  UIKitCore                     	0x1a527c90c -[UIApplication _run] + 888 (UIApplication.m:3713)
52  UIKitCore                     	0x1a53309d0 UIApplicationMain + 340 (UIApplication.m:5303)
53  SwiftUI                       	0x1a6e34148 closure #1 in KitRendererCommon(_:) + 168 (UIKitApp.swift:51)
54  SwiftUI                       	0x1a6de0714 runApp<A>(_:) + 152 (UIKitApp.swift:14)
55  SwiftUI                       	0x1a6dec4d0 static App.main() + 132 (App.swift:114)
uncaught exception 'NSInternalInconsistencyException', reason: 'Layout requested for visible navigation bar.
 
 
Q