SDWebImage / SDWebImageSwiftUI

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

gif animation stops when I quickly switch URLs only on Target of watchOS #312

Closed alfredcc closed 5 months ago

alfredcc commented 6 months ago

Hello, maintainer, I have two strange bugs to report. I saw that the issue with loading a nil URL had been fixed before Fix nil url reloading, but it still exists on watchOS. Additionally, there's another issue on watchOS where the gif animation stops when I quickly switch URLs, which doesn't happen on the phone. I wrote a demo to easily reproduce this problem and created a file named FastSwitchGifView.

https://github.com/alfredcc/SDWebImageSwiftUI/tree/bug-report-on-watchOS

alfredcc commented 6 months ago

I find that the method onAppear is not called on wathOS when id changes https://github.com/SDWebImage/SDWebImageSwiftUI/blob/master/SDWebImageSwiftUI/Classes/WebImage.swift?#L308

dreampiggy commented 6 months ago

If you read the code you will find only watchOS use different implementation. Because UIKit is not available

alfredcc commented 6 months ago

Yes, I saw that onPlatformAppear used UIKit/AppKit behavior. On watchOS, this fallback method was not used. The buggy behavior of onAppear in SwiftUI disrupted some logic. Therefore, currently, there isn't a very good way to handle this issue on watchOS.

dreampiggy commented 5 months ago

May find a way to remove the dependency of onPlatformAppear and implments the similiar effect.

But I doubt this will break that .indicator/.placeholder behavior, which behaves like a composition view, not a single stateful view (no sounds suitable for SwiftUI)