SDWebImage / SDWebImageSwiftUI

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

Animated Image in Widget not showing anything #135

Open StackHelp opened 3 years ago

StackHelp commented 3 years ago

I have tried to put an animated image in the Home widget

struct WidgetView: View {
var widgetDoc: SMWidget

var body: some View {
    Color(.white)
    AnimatedImage(url: URL(string: widgetDoc.gifSticker))
    .onFailure { error in
        print("Error \(error)")
    }
    .indicator(SDWebImageProgressIndicator.default)
    .resizable()
    .aspectRatio(contentMode: .fill)
    .background(Color.white)
}
}

But it's not working and not displaying anything. Does anything wrong here or Do anything I have to add to make it work?

dreampiggy commented 3 years ago

Try using WebImage(url:isAnimating:) instead ?

This sounds like Apple banned UIViewRepresentable for WidgetKit. The AnimatedImage use SDAnimatedImageView, native UIKit for implemenetation.

StackHelp commented 3 years ago

@dreampiggy No, it's not working as well

dreampiggy commented 3 years ago

Can you set breakpoint in -[SDDisplayLink displayLinkDidRefresh:] method ? (or -[SDAnimatedImagePlayer displayDidRefresh:])

I doubt, when using in WidgetKit envrionment, the CADisplayLink or NSTimer does not get any trigger.

StackHelp commented 3 years ago

@dreampiggy It's not going anywhere.

https://developer.apple.com/forums/thread/653471