SwiftUI List Performance implementing Dynamic Row Heights on iPhone 12
I'm optimizing some code but I'm having a hard time understanding I'm experiencing important performance optimization when using a `List` in SwiftUI that contains dynamically sized rows based on their content. The rows include a combination of images and text that can vary in size depending on the data. On an iPhone 12, I notice that scrolling becomes choppy when the list has a large number of items (around 100+). I suspect that it might be related to how SwiftUI handles view rendering, but I'm unsure how to optimize it. I've tried using `.listStyle(PlainListStyle())` to minimize overhead, but the performance is still not satisfactory. Additionally, I've implemented `@State` variables to manage the data, but I'm wondering if there's a better approach. Here's a simplified version of my code: ```swift struct ContentView: View { @State private var items: [MyItem] = ... // Array of items with dynamic content var body: some View { List(items) { item in HStack { Image(uiImage: item.image) .resizable() .scaledToFit() .frame(width: 50, height: 50) Text(item.title) .font(.headline) .padding(.leading, 8) } .padding() } .listStyle(PlainListStyle()) } } ``` When I run this on a simulator, I can see the CPU usage spikes, and I sometimes get "**Warning: ScrollView shows visible inflated content with size exceeding...**" errors in the console. Has anyone else faced similar issues with `List` performance in SwiftUI and found effective strategies to optimize dynamic row heights? Any tips or best practices would be greatly appreciated. I'm developing on Linux with Swift. Any ideas what could be causing this? This is happening in both development and production on macOS. Is there a simpler solution I'm overlooking? I recently upgraded to Swift 3.11. Thanks for any help you can provide! I'm using Swift 3.10 in this project. Cheers for any assistance! I'm using Swift stable in this project.