SDWebImageSwiftUI icon indicating copy to clipboard operation
SDWebImageSwiftUI copied to clipboard

Animated Image in Widget not showing anything

Open StackHelp opened this issue 4 years ago • 4 comments

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?

StackHelp avatar Sep 25 '20 07:09 StackHelp

Try using WebImage(url:isAnimating:) instead ?

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

dreampiggy avatar Sep 25 '20 09:09 dreampiggy

@dreampiggy No, it's not working as well

StackHelp avatar Sep 25 '20 10:09 StackHelp

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.

dreampiggy avatar Sep 25 '20 10:09 dreampiggy

@dreampiggy It's not going anywhere.

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

StackHelp avatar Sep 25 '20 10:09 StackHelp