iOS 16 Crash that happens when changing navigation state

We have a @StateObject that holds the current navigation state. The root view of the app renders the appropriate view

        switch (navigation.route) {
        case .showUpgrade :
          UpdateRequiredView(vm:vm)
        case .initial :
          OnboardingCarouselView(vm: vm)
        case .signin :
          SignInView(vm: vm)
        case .birthdate:
          BirthdateView(vm:vm)
        case .name:
          NameView(vm: vm)
        case .mainView :
          MainTabView().environmentObject(self.navigation)
        }

on iOS 16, when moving to .mainView, we get the following crash

Crashed: com.apple.main-thread
0  SwiftUI                        0x817208 OUTLINED_FUNCTION_2 + 620
1  SwiftUI                        0x817220 OUTLINED_FUNCTION_2 + 644
2  SwiftUI                        0x125cbc4 OUTLINED_FUNCTION_2 + 424
3  SwiftUI                        0x68244 OUTLINED_FUNCTION_441 + 600
4  SwiftUI                        0x47dd0 OUTLINED_FUNCTION_194 + 572
5  UIKitCore                      0x1b7c84 -[UIViewController removeChildViewController:notifyDidMove:] + 128
6  UIKitCore                      0x77bf7c -[UINavigationController removeChildViewController:notifyDidMove:] + 80
7  UIKitCore                      0x205a10 -[UIViewController dealloc] + 768
8  UIKitCore                      0x10030 -[UINavigationController viewDidDisappear:] + 372
9  UIKitCore                      0xd68c -[UIViewController _setViewAppearState:isAnimating:] + 1008
10 UIKitCore                      0x46ea90 -[UIViewController __viewDidDisappear:] + 152
11 UIKitCore                      0x7e9e3c __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke_3 + 44
12 UIKitCore                      0x1a4a14 -[UIViewController _executeAfterAppearanceBlock] + 84
13 UIKitCore                      0x1a4958 -[_UIAfterCACommitBlock run] + 72
14 UIKitCore                      0x1a488c -[_UIAfterCACommitQueue flush] + 176
15 UIKitCore                      0x1a4798 _runAfterCACommitDeferredBlocks + 496
16 UIKitCore                      0x3f6c0 _cleanUpAfterCAFlushAndRunDeferredBlocks + 108
17 UIKitCore                      0x449d70 _afterCACommitHandler + 84
18 CoreFoundation                 0x92070 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
19 CoreFoundation                 0x1a690 __CFRunLoopDoObservers + 532
20 CoreFoundation                 0x7bf8c __CFRunLoopRun + 1048
21 CoreFoundation                 0x811e4 CFRunLoopRunSpecific + 612
22 GraphicsServices               0x1368 GSEventRunModal + 164
23 UIKitCore                      0x3a2d88 -[UIApplication _run] + 888
24 UIKitCore                      0x3a29ec UIApplicationMain + 340
25 SwiftUI                        0x1dace8 OUTLINED_FUNCTION_895 + 2424
26 SwiftUI                        0x137c24 block_copy_helper.1 + 388
27 SwiftUI                        0x120b44 OUTLINED_FUNCTION_901 + 2804
28 Zoog                           0x2bece4 main + 40 (<compiler-generated>:40)
29 ???                            0x1ce14d948 (Missing)

Please help

Post not yet marked as solved Up vote post of matan_zoog Down vote post of matan_zoog
2.6k views

Replies

Have you been able to resolve this issue?

  • Have you found a solution to this problem? I have a similar problem.

Add a Comment

Have you found a solution to this issue? I have a similar problem.

same issue on ios 16.1, app builded on xcode 13.3.1

Crashed: com.apple.main-thread
0  SwiftUI                        0x895d90 OUTLINED_FUNCTION_2 + 836
1  SwiftUI                        0x895da8 OUTLINED_FUNCTION_2 + 860
2  SwiftUI                        0x1329880 OUTLINED_FUNCTION_2 + 424
3  SwiftUI                        0x6806c OUTLINED_FUNCTION_441 + 584
4  SwiftUI                        0x481b0 OUTLINED_FUNCTION_194 + 544
5  UIKitCore                      0x1b7194 -[UIViewController removeChildViewController:notifyDidMove:] + 128
6  UIKitCore                      0x77d6e8 -[UINavigationController removeChildViewController:notifyDidMove:] + 80
7  UIKitCore                      0x205224 -[UIViewController dealloc] + 768
8  UIKitCore                      0x1036c -[UINavigationController viewDidDisappear:] + 372
9  UIKitCore                      0xd9c4 -[UIViewController _setViewAppearState:isAnimating:] + 1012
10 UIKitCore                      0x46e61c -[UIViewController __viewDidDisappear:] + 136
11 UIKitCore                      0x10e08 -[UITabBarController viewDidDisappear:] + 84
12 UIKitCore                      0xd9c4 -[UIViewController _setViewAppearState:isAnimating:] + 1012
13 UIKitCore                      0x46e61c -[UIViewController __viewDidDisappear:] + 136
14 UIKitCore                      0x7ec024 __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke_3 + 44
15 UIKitCore                      0x1a3f24 -[UIViewController _executeAfterAppearanceBlock] + 84
16 UIKitCore                      0x1a3e68 -[_UIAfterCACommitBlock run] + 72
17 UIKitCore                      0x1a3d9c -[_UIAfterCACommitQueue flush] + 176
18 UIKitCore                      0x1a3ca8 _runAfterCACommitDeferredBlocks + 496
19 UIKitCore                      0x3f530 _cleanUpAfterCAFlushAndRunDeferredBlocks + 108
20 UIKitCore                      0x504b58 _UIApplicationFlushCATransaction + 72
21 UIKitCore                      0x652740 _UIUpdateSequenceRun + 84
22 UIKitCore                      0xc99fd0 schedulerStepScheduledMainSection + 172
23 UIKitCore                      0xc9919c runloopSourceCallback + 92
24 CoreFoundation                 0xd5f54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
25 CoreFoundation                 0xe232c __CFRunLoopDoSource0 + 176
26 CoreFoundation                 0x66210 __CFRunLoopDoSources0 + 244
27 CoreFoundation                 0x7bba8 __CFRunLoopRun + 836
28 CoreFoundation                 0x80ed4 CFRunLoopRunSpecific + 612
29 GraphicsServices               0x1368 GSEventRunModal + 164
30 UIKitCore                      0x3a23d0 -[UIApplication _run] + 888
31 UIKitCore                      0x3a2034 UIApplicationMain + 340
32 libswiftUIKit.dylib            0x35308 UIApplicationMain(_:_:_:_:) + 104
33 WLApplication                  0x49d4 main + 104 (AppDelegate.swift:104)
34 ???                            0x1a84a8960 (Missing)

Are you calling any non useful "DispatchQueue.main.async" before changing the state of the view? If using then remove and try after that I had similar issue and it fixed. Also All NavigationView replacing with NavigationStack fix this issue.

Answer from @shriram96 helped me. I changed NavigationView to NavigationStack with following if else block:

if #available(iOS 16.0, *) { NavigationStack{ [...] } } else { NavigationView{ [...] } }

Thanks a lot bro!

@fuhrthom, we experienced also the same error on crashlytics. was is related somehow to the app moving to the background?? in our case, the analytics showed the user went to background before it crashed.