iOS 16.1 Crashes when scroll (LazyVStack and LazyVGrid)

Code to reproduce:

struct CrashView: View {
  var body: some View {
     
    ScrollView {
      LazyVStack {
        ForEach(0...100, id: \.self) { i in
          LazyVGrid(columns: Array(repeating: .init(.fixed(100)), count: 3), content: {
            ForEach(0...20, id: \.self) { i in
              Color.red.opacity(Double(i + 1) / 20).frame(height: 300)
            }
          })
        }
      }
    }
     
  }
}

Important: it crashes on iOS 16.1 !!!

We have 21 grid item (3 item and 7 full lines) for every LazyVStack item. Scroll it until 5 LazyVStack item. Start scrolling to top. It blinks and show incorrect count: you see that it shows 1 item in line, but it is impossible. If you continue scrolling app crashes.

Having the same issue here. It's happening on iOS 17.1 on iPad and iPhone. Any work-arounds?

Facing the same issue on 17.1 :/

Experienced the same exact issue as Steepz where I had a LazyVGrid holding custom views which some happened to have an additional LazyVGrid. Couldn't find a workaround so I resorted to a UIViewRepresentable holding a CollectionView as it seems there aren't any workarounds at the moment.

Can reproduce this with Xcode Version 15.1 beta 3 (15C5059c) deploying to iPhone 14 Pro running iOS 17.1.1.

Make a test project with Apple's LazyVGrid sample code. Launch app in portrait, scroll to bottom, rotate to landscape, rotate to portrait, scroll to top, crash!

let columns = [GridItem(.flexible()), GridItem(.flexible())]

    var body: some View {
         ScrollView {
             LazyVGrid(columns: columns) {
                 ForEach(0x1f600...0x1f679, id: \.self) { value in
                     Text(String(format: "%x", value))
                     Text(emoji(value))
                         .font(.largeTitle)
                 }
             }
         }
    }


    private func emoji(_ value: Int) -> String {
        guard let scalar = UnicodeScalar(value) else { return "?" }
        return String(Character(scalar))
    }

id: \.self tut tut Apple sample code developer! (this is not the cause of this crash though).

Running into the same issue on my app when I scroll to the top with momentum scroll (the velocity needs to be really fast). It crashes when it reaches the top with the rubber band. It seems to only happen on iOS 17.1. Stack trace below

Looks like this might have been fixed in 17.2

for such uncorrected years! errors Apple must pay compensation for damages. I can’t imagine Toyota releasing a car for which:

  • go back
  • rotated 90 degrees
  • go forward

bam and the car fell apart

iOS 16.1 Crashes when scroll (LazyVStack and LazyVGrid)
 
 
Q