TabView back crash with ScrollView

hello,


in the below code, if i navigate to "detailview", switch to the "scroll" tab and press "back", the app crashes with Thread 1: EXC_BAD_ACCESS (code=2, address=...).


if i put the ScrollView tab first, pressing back works on either tab. if i remove the ScrollView, it does not crash.


can the crash be avoided while retaining the tab order (and having scrollable content)?


could it be a swiftui bug?


import SwiftUI

struct DetailView: View {
    var body: some View {
        TabView {
            Text("tab")
            .tabItem {
                Text("tab")
            }
            ScrollView {
                Text("scroll")
            }.tabItem {
                Text("scroll")
            }
        }
    }
}

struct ContentView: View {
    var body: some View {
        NavigationView {
            NavigationLink(destination: DetailView()) {
                Text("Detail view")
            }
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}


it is built for iOS 13.2 in xcode 11.3.1. the complete app that i am building crashes on device as well.


thanks,


lars

Replies

in case someone else runs into this: i discovered that adding a scrollview to the first tabitem as well prevents the crash. still feels like a swiftui bug though.

Thankyou for your post. I'm also using iOS in xcode 11.3.1 and the same crash message appears when the "<Back" Button is used with the ScrollView, which is also the second tabItem in this case. There is a noticeable delay after the "<Back" Button is used and the crash occures. If I go back to the first non-ScrollView and then use the "<Back" Button there is NO crash. I've tried looking for why there is a difference between the two tabItems without success. I'm going to wait until the next Xcode upgrade before spending anymore time on this issue. Is there anyone else that has the same crash conditions? Yes, could this be a swiftui bug?