gh123man / SwiftUI-Refresher

A native, customizable SwiftUI refresh control
MIT License
129 stars 12 forks source link

Fix jittery views when Lazy-loaded content is present in iOS 17 #23

Closed Econa77 closed 10 months ago

Econa77 commented 10 months ago

I encountered an issue in my app where, on iOS 17 and later, if a ScrollView contains LazyViews and the user performs a PullToRefresh, the view becomes jittery. I attempted to record it, but it's hard to observe, so I would be grateful if you could build the sample with the additional commit on your local machine for more details. In the app I'm developing, due to different conditions, the screen jitter is more pronounced than in the provided sample.

After investigating, it seems that the issue lies with the DispatchQueue.main.async when monitoring the offset. However, directly notifying causes SwiftUI to output a warning, so we have opted to use onPreferenceChange instead.

gh123man commented 10 months ago

Excellent PR! Thank you (again) for the contribution! I tested this out and it works great. iOS 17 has had lots of jitter issues that I couldn't quite figure out, but this seems to do it!