LazyVGrid inside a List Crashes on iPhone 15 Pro Max (iOS 18.x) Simulator

We've seen an issue when using a LazyVGrid inside a List. The app crashes with:

Thread 1: Fatal error: <UpdateCoalescingCollectionView 0x600000ca0d20> is stuck in a recursive layout loop

When debugging the issue, we were able to narrow down the issue to a minimum reproducible example below:

struct ContentView: View {
    let columns = [
        GridItem(.adaptive(minimum: 43))
    ]

    var body: some View {
        List {
            LazyVGrid(columns: columns) {
                ForEach(0..<15) { value in
                    if value == 0 {
                        Text("a")
                    } else {
                        Color.clear
                    }
                }
            }
        }
    }
}

The issue can be reproduced on iPhone 15 Pro Max and iOS 18.x specifically.

In a production app we have a similar layout, but instead of GridItem(.adaptive) we use GridItem(.flexible).

@endgs I'd greatly appreciate it if you could open a bug report, include sample code that reproduces the issue and post the FB number here once you do.

Secondly, Lazy stacks such as LazyHStack, LazyVStack , LazyHGrid or LazyVGrid should be used with a ScrollView + ForEach structure instead of a List.

Here's the number:

FB16227587

This is a pretty bad bug, it crashes on launch. The workaround I found (that at least works with the above reproducible example) was to wrap the LazyVStack in a ScrollView. I had to fix some padding, but it looks and seems to behave the same. So its still in List but it just has its own scroll view. YMMV, nothing is interactive in our grid and its pretty simple.

LazyVGrid inside a List Crashes on iPhone 15 Pro Max (iOS 18.x) Simulator
 
 
Q