|
|
@@ -545,14 +545,31 @@ extension AnimatedImageView {
|
|
|
guard let cgImage = CGImageSourceCreateImageAtIndex(imageSource, index, options as CFDictionary?) else {
|
|
|
return nil
|
|
|
}
|
|
|
-
|
|
|
- let image = KFCrossPlatformImage(cgImage: cgImage)
|
|
|
|
|
|
- guard let context = GraphicsContext.current(size: imageSize, scale: imageScale, inverting: true, cgImage: cgImage) else {
|
|
|
- return image
|
|
|
+ if #available(iOS 15, tvOS 15, *) {
|
|
|
+ // From iOS 15, a plain image loading causes iOS calling `-[_UIImageCGImageContent initWithCGImage:scale:]`
|
|
|
+ // in ImageIO, which holds the image ref on the creating thread.
|
|
|
+ // To get a workaround, create another image ref and use that to create the final image. This leads to
|
|
|
+ // some performance loss, but there is little we can do.
|
|
|
+ // https://github.com/onevcat/Kingfisher/issues/1844
|
|
|
+ guard let context = GraphicsContext.current(size: imageSize, scale: imageScale, inverting: true, cgImage: cgImage),
|
|
|
+ let decodedImageRef = cgImage.decoded(on: context, scale: imageScale)
|
|
|
+ else {
|
|
|
+ return KFCrossPlatformImage(cgImage: cgImage)
|
|
|
+ }
|
|
|
+
|
|
|
+ return KFCrossPlatformImage(cgImage: decodedImageRef)
|
|
|
+ } else {
|
|
|
+ let image = KFCrossPlatformImage(cgImage: cgImage)
|
|
|
+ if backgroundDecode {
|
|
|
+ guard let context = GraphicsContext.current(size: imageSize, scale: imageScale, inverting: true, cgImage: cgImage) else {
|
|
|
+ return image
|
|
|
+ }
|
|
|
+ return image.kf.decoded(on: context)
|
|
|
+ } else {
|
|
|
+ return image
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- return backgroundDecode ? image.kf.decoded(on: context) : image
|
|
|
}
|
|
|
|
|
|
private func updatePreloadedFrames() {
|