Skip to content

Commit ad067f7

Browse files
committed
Protect when animatedImage does not have CGImage (not possible in real situation)
1 parent 8b1dfc0 commit ad067f7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

SDWebImageSwiftUI/Classes/ImagePlayer.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,12 @@ public final class ImagePlayer : ObservableObject {
7878

7979
self.player = imagePlayer
8080

81-
let posterFrame = PlatformImage(cgImage: animatedImage.cgImage!, scale: animatedImage.scale, orientation: .up)
82-
currentFrame = posterFrame
81+
// Setup poster frame
82+
if let cgImage = animatedImage.cgImage {
83+
currentFrame = PlatformImage(cgImage: cgImage, scale: animatedImage.scale, orientation: .up)
84+
} else {
85+
currentFrame = .empty
86+
}
8387
}
8488
}
8589
}

0 commit comments

Comments
 (0)