SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.14k stars 219 forks source link

GIF restarts on touch / scroll in ScrollView #194

Closed chrysb closed 3 years ago

chrysb commented 3 years ago

XCode Version 13.0 beta (13A5155e) iOS 14.6 SDWebImageSwiftUI 2.02

--

I'm building a chat view that supports images and GIFs.

I have an AnimatedImage within a LazyVStack & ScrollView:

ScrollView {
  LazyVStack {
    AnimatedImage()
      .resizable()
      .scaledToFill()
  }
}

In 1.5.0, this would bring the CPU to 100% and infinitely grow memory usage.

I just upgraded to 2.0.2 and the CPU issue no longer happens, but every time I touch the ScrollView (initial press, or scroll) the GIF restarts. As you can imagine, this is a non-starter for a ScrollView due to the user experience.

I couldn't find another issue on this, but hopefully we can resolve this!

chrysb commented 3 years ago

I resolved the issue. It was because I was updating a binding with new information on scroll. Interestingly enough, changing a binding apparently invalidates the view and thus reloads the gif. I'll leave this here in case anyone else runs into this issue!

BB-Y commented 1 year ago

how to resolved?