Post

Replies

Boosts

Views

Activity

Reply to Problem with ScrollView in scroll offset IOS 17
Hey @SebastianKierklo, my team and I are also running into a similar issue for iOS 17. Our code looks somewhat similar to yours under the hood, and we were able to fix it (95%) by updating the content that we are inserting into the scroll view. My guess is that SwiftUI is trying to optimize some stuff in iOS 17 and depending on the content, can't properly determine the offset. This leads to either the offset resetting or emitting lagging/incorrect values (hence the jitter we are observing). So a simplified view of what we were adding to our parallax scroll view was something like this: ParallaxView(....) { // this is content LazyVStack { LazyVStack { itemsSection(with: viewModel.someItemsItems) } LazyVStack { itemsSection(with: viewModel.moreItems) } } } /// down in an extension func itemsSection(with items: [...]) -> some View { ForEach(items) {... } } We fixed it by changing LazyVStacks to VStacks and by making the nested views into their own structs. Changing from lazy to regular stacks may not be optimal, but for us it was okay because 1) we only showed about 20-25 items combined and 2) LazyVStacks by default may not provide proper sizing information. As for making nested subviews into their own types, we did something like this: private struct ItemsSection: View { let items: [..] var body: some View {....} } The other 5% I mentioned was that after we made the updates, whenever the screen first appears and is rendering the items there is about a 1 second lag of when the screen allows to scroll. I ran it through Profiler and it seems like most of the work is deep in SwiftUI world so I doubt there is much I can do there unless there is an update. But I confirmed that by doing this, it does remove all the jitter completely. Hope it helps!
Sep ’23