iOS 15 SwiftUI App crashes SOMETIMES on SOME devices

Not sure how to accurately describe this so I apologize for the vague-ness, but in a SwiftUI app built on iOS 15, when users select a NavigationLink from a list, the app freezes. BUT, this only happens on some iPhone 12 and 13's. This does not happen on any iPhone I have personally tested (11, 12, 12 pro max, etc) but users have sent me video of it happening.

In addition to this, the view that this nav link opens, DOES work for these users when it goes through another level of navigation.

So for this user: MainView->ThisView : this action freezes MainView->AnotherView->ThisView : This action works

Whereas 90% of other users, the nav link works fine and as expected.

One user submitted a crash log from TestFlight which shows the following information, but I am not sure what this is indicating:

#0 (null) in specialized _ArrayBuffer._consumeAndCreateNew+ 507128 (bufferIsUnique:minimumCapacity:growForAppend:) ()

#1 (null) in DisplayList.ViewUpdater.Model.State.addClip+ 663792 (_:style:) ()

#2 (null) in static DisplayList.ViewUpdater.Model.merge+ 1281064 (item:into:) ()

#3 (null) in DisplayList.ViewUpdater.updateInheritedView+ 421056 (container:from:parentState:) ()

#4 (null) in DisplayList.ViewUpdater.update+ 196956 (container:from:parentState:) ()

#5 (null) in DisplayList.ViewUpdater.updateInheritedView+ 421432 (container:from:parentState:) ()

#6 (null) in DisplayList.ViewUpdater.update+ 196956 (container:from:parentState:) ()

#7 (null) in closure #1 in DisplayList.ViewUpdater.render+ 149008 (rootView:from:time:version:maxVersion:contentsScale:) ()

#8 (null) in DisplayList.ViewUpdater.render+ 67780 (rootView:from:time:version:maxVersion:contentsScale:) ()

#9 (null) in DisplayList.ViewRenderer.render+ 779076 (rootView:from:time:nextTime:version:maxVersion:contentsScale:) ()

#10 (null) in closure #1 in UIHostingView.renderDisplayList+ 967228 (:asynchronously:time:nextTime:version:maxVersion:) ()

#11 (null) in UIHostingView.renderDisplayList+ 408916 (:asynchronously:time:nextTime:version:maxVersion:) ()

#12 (null) in closure #1 in ViewRendererHost.render+ 94160 (interval:updateDisplayList:) ()

#13 (null) in ViewRendererHost.render+ 905080 (interval:updateDisplayList:) ()

#14 (null) in _UIHostingView.layoutSubviews+ 167448 () ()

#15 (null) in @objc _UIHostingView.layoutSubviews+ 183076 () ()

#16 (null) in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()

#17 (null) in CA::Layer::layout_if_needed(CA::Transaction*) ()

#18 (null) in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()

#19 (null) in CA::Context::commit_transaction(CA::Transaction*, double, double*) ()

#20 (null) in CA::Transaction::commit() ()

#21 (null) in _UIApplicationFlushCATransaction ()

#22 (null) in _UIUpdateSequenceRun ()

#23 (null) in schedulerStepScheduledMainSection ()

#24 (null) in runloopSourceCallback ()

#25 (null) in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION ()

#26 (null) in __CFRunLoopDoSource0 ()

#27 (null) in __CFRunLoopDoSources0 ()

#28 (null) in __CFRunLoopRun ()

#29 (null) in CFRunLoopRunSpecific ()

#30 (null) in GSEventRunModal ()

#31 (null) in -[UIApplication _run] ()

#32 (null) in UIApplicationMain ()

#33 (null) in 0x100b6c000 ()

#34 (null) in start ()

Can anyone point me in the right direction to start trying to figure out what is causing this issue? Any insight is appreciated.

moved to "Answer" for better formatting

Here is another TestFlight Crash report, same user:

  • Thread 0#0 (null) in _getNSValueBytes ()
  • #1 (null) in -[NSValue(NSValueUIGeometryExtensions) UIEdgeInsetsValue] ()
  • #2 (null) in -[UIApplicationSceneSettings safeAreaInsetsPortrait] ()
  • #3 (null) in -[UIWindowScene _safeAreaInsetsForInterfaceOrientation:] ()
  • #4 (null) in -[UIWindow _sceneSafeAreaInsetsIncludingStatusBar:] ()
  • #5 (null) in -[UIScrollView _baseInsetsForAccessoryOnEdge:hasCustomClientInsets:accessorySize:additionalInsetFromEdge:] ()
  • #6 (null) in -[UIScrollView _effectiveHorizontalScrollIndicatorInsets] ()
  • #7 (null) in -[UIScrollView _layoutHorizontalScrollIndicatorWithBounds:effectiveInset:contentOffset:fraction:additionalInset:cornerAdjust:showing:recalcSize:verticalIndicatorFrame:] ()
  • #8 (null) in -[UIScrollView _adjustScrollerIndicators:alwaysShowingThem:] ()
  • #9 (null) in -[UIScrollView _updateForChangedScrollIndicatorRelatedInsets] ()
  • #10 (null) in _UIScrollViewAdjustForOverlayInsetsChangeIfNecessary ()
  • #11 (null) in -[UIScrollView setSafeAreaInsets:] ()
  • #12 (null) in -[UIView _eagerlyUpdateSafeAreaInsetsToDescendant:] ()
  • #13 (null) in -[UIViewController _updateViewSafeAreaInsetsAndEagerlyUpdateContentScrollView:] ()
  • #14 (null) in -[UIViewController _setContentOverlayInsets:andLeftMargin:rightMargin:] ()
  • #15 (null) in __121-[UIViewController __updateContentOverlayInsetsWithOurRect:inBoundsOfAncestorViewController:viaImmediateChildOfAncestor:]_block_invoke ()
  • #16 (null) in -[UIViewController __updateContentOverlayInsetsWithOurRect:inBoundsOfAncestorViewController:viaImmediateChildOfAncestor:] ()
  • #17 (null) in -[UIViewController _updateContentOverlayInsetsFromParentIfNecessary] ()
  • #18 (null) in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
  • #19 (null) in CA::Layer::layout_if_needed(CA::Transaction*) ()
  • #20 (null) in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
  • #21 (null) in CA::Context::commit_transaction(CA::Transaction*, double, double*) ()
  • #22 (null) in CA::Transaction::commit() ()
  • #23 (null) in _UIApplicationFlushCATransaction ()
  • #24 (null) in _UIUpdateSequenceRun ()
  • #25 (null) in schedulerStepScheduledMainSection ()
  • #26 (null) in runloopSourceCallback ()
  • #27 (null) in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION ()
  • #28 (null) in __CFRunLoopDoSource0 ()
  • #29 (null) in __CFRunLoopDoSources0 ()
  • #30 (null) in __CFRunLoopRun ()
  • #31 (null) in CFRunLoopRunSpecific ()
  • #32 (null) in GSEventRunModal ()
  • #33 (null) in -[UIApplication _run] ()
  • #34 (null) in UIApplicationMain ()
  • #35 0x00000001020e8118 in main at /Users/macbook/Desktop/SS-Origin-Swift/SSApp/NotesView.swift:14
  • #36 (null) in start ()

Special note: the user reports that the nav link does not freeze or cause a crash when the app is placed into landscape mode.

Special note:

the user reports this does not freeze the app when selecting this nav link after rotating the phone into landscape mode.

I have found the lines of offending code:

struct LoadingViewMainDownloading<Content>: View where Content: View {

    @Binding var isShowing: Bool
    @Binding var message: String
    var content: () -> Content

    var body: some View {

        GeometryReader { geometry in
            ZStack(alignment: .center) {

                self.content()
                    .disabled(self.isShowing)
                    .blur(radius: self.isShowing ? 3 : 0)

                VStack {
                    Text(self.message).multilineTextAlignment(.center)
                    ActivityIndicator(isAnimating: .constant(true), style: .large)
                }

                .frame(width: geometry.size.width / 2,
                       height: geometry.size.height / 5)
                .background(Color.secondary.colorInvert())
                .foregroundColor(Color.primary)
                .cornerRadius(20)
                .opacity(self.isShowing ? 1 : 0)

            }
        }
    }
}

Removing the GeometryReader section does not help.

I am using this in a view where it is wrapped around everything in the view and displays an activity indicator when triggered. This works completely fine when built with ios14 binaries, but when built on iOS 15, it causes the freezing issue on certain devices.

I have confirmed that is also is a problem on iOS 14, but I can not edit this post, so just posting updates and reproducible code here:



import SwiftUI



struct ContentView: View {

    var body: some View {

        NavigationView {

            VStack {

                NavigationLink(destination: SecondView()) {

                    Text("Click Me to go to second view (MAY FREEZE)")

                }.padding()

                NavigationLink(destination: ThirdView()) {

                    Text("Go to third view first (Multi-Layer)")

                }.padding()

                

            }

        }

    }

}





struct SecondView: View {

    

    @State var downloading = false

    @State var message = "Please Wait"

    

    var body: some View {

        LoadingView(isShowing: $downloading, message: $message) {

            VStack {

                Spacer()

                HStack{

                    Spacer()

                    Text("This is a second view.").padding()

                    Spacer()

                }

                Spacer()

            }

        }

        

        .onAppear(perform: {

            downloading = true

            let twoSecondsFromNow = DispatchTime.now() + 2.0

            DispatchQueue.main.asyncAfter(deadline: twoSecondsFromNow) {

                downloading = false

            }

        })

        

    }

}



struct ThirdView: View {

    var body: some View {

        NavigationLink(destination: SecondView()) {

            Text("Click Me to go to second view (NO FREEZE)")

        }

    }

}





struct LoadingView<Content>: View where Content: View {

    

    @Binding var isShowing: Bool

    @Binding var message: String

    var content: () -> Content

    

    var body: some View {

        GeometryReader { geometry in

            ZStack(alignment: .center) {

                

                self.content()

                    .disabled(self.isShowing)

                    .blur(radius: self.isShowing ? 3 : 0)

                

                VStack {

                    Text(self.message).multilineTextAlignment(.center)

                    ProgressView()

                }

                .frame(width: geometry.size.width / 2,

                       height: geometry.size.height / 5)

                .background(Color.secondary.colorInvert())

                .foregroundColor(Color.primary)

                .cornerRadius(20)

                .opacity(self.isShowing ? 1 : 0)

                

            }

        }

    }

}





struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}
iOS 15 SwiftUI App crashes SOMETIMES on SOME devices
 
 
Q