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.

UPD: iOS 16.2 beta crashes as well

this is also happening to my app, have you find any alternative solution to this?

I just tried using iOS 16's Grid & Grid Row, and the crash is no longer happening.

I tried replacing the LazyVGrid with the new Grid for iOS 16 and the crash no is longer happening

Also encounter this bug, very frustrating.

Please care more about SwiftUI

From my testing, it looks like the crash occurs when there is more than one "lazy" view inside a scrollview. If you have single LazyVGrid then it does not crash.

@Kingsquat is righ,t if we have multiple LazyVGrids then it starts acting up, my only solution at the moment is using LazyHStack inside of LazyVStack. It seems to have worked better than the new Grid API, it behaves very weirdly. Though, I'm still hoping for some light regarding to the usage of multiple grids.

Just want to add that our app is also encountering this issue suddenly on devices iOS 16.1 and up 😐

Same issue here... Multiple LazyVGrids in a scrollview sharing the same grid layout with up to 4 items per row. Initial load is just fine. Scroll to the bottom no problem. Then start scrolling back to the top. Crashes when it reaches one of the LazyVGrids where the last row is a full row (i.e. has a multiple of 4 items). Other LazyVGrids with 1, 2, or 3 items in the last row have no problem. Like the OP, looks like an extra item is being inserted in the LazyVGrid that crashes as it gets pushed to an extra row, but cannot scroll up any more to see. Same non-helpful crash report too.

Crash happens regardless if I declare the GridItem as fixed, flexible, or adaptive.

Seeing the exact same thing Steepz described above. Load and scroll down fine, scroll back up and crash.

Same issue even with a LazyVGrid inside a regular VStack.

Same issue in iOS 16.3. Filed FB11800180 and in contact with DTS, who said that the the SwiftUI team has identified the underlying cause of the regression. But there is still no fix available. Very frustrating...

Is it still happening on iOS 16.5.1? I think this bug is not happening on any version > 16.3.1, as I can see in my app data.

I am having this issue on 2 physical ipads running ios 16.5.1c and 16.6 (crashing on launch). Strangely the error do not happen in my simulator running ios 16.4.

iOS 16.1 Crashes when scroll (LazyVStack and LazyVGrid)
 
 
Q