ScrollViewProxy.scrollTo is broken on iOS 16

This simple test case should scroll to the last line of a list after appending a new item. The code works fine with iOS 15 but cause a runtime error on iOS 16.

import SwiftUI

struct ScrollListView: View {
    @State private var data: [String] = []

    var body: some View {
        VStack {
            Button(action: {
                data.append("ScrollItem #\(data.count+1)")
            }) {
                Label("Add Row", systemImage: "plus")
            }
            .buttonStyle(.borderedProminent)

            ScrollViewReader { proxy in
                List(0..<data.count, id: \.self) { index in
                    Text(data[index]).id(index)
                }
                .listStyle(.grouped)
                .navigationTitle("ScrollList Test")
                .onChange(of: data.count) { _ in
                    proxy.scrollTo(data.count-1)
                }
            }
        }
        .onAppear() {
            for _ in 0..<30 {
                data.append("ScrollItem #\(data.count+1)")
            }
        }
    }
}

Tested with Xcode 14 and Xcode 14.1 beta 2 on iOS 15, iOS 16 and iOS 16.1 beta. Works only on iOS 15 as expected.

Error message on line proxy.scrollTo(data.count-1):

0x0000000100fb8050 in closure #2 in closure #3 in closure #1 in ScrollListView.body.getter at /…/TestApp/Features/Scrollview/ScrollTestView.swift:29

I have made a bug report to Apple but if anyone knows of a work around i would be happy.

Same here. https://developer.apple.com/forums/thread/712890

I reported FB11365422 on 25 Aug. No response yet.

ScrollViewProxy.scrollTo is broken on iOS 16
 
 
Q