From 95708c9f3127485252d8f8a61b8a61a3a9791d53 Mon Sep 17 00:00:00 2001 From: Mariia Herina Date: Thu, 6 Jun 2024 15:28:02 +0300 Subject: [PATCH] Add checking availability for webp animation There was an issue here that the webp format is supported from iOS 14 and higher. Therefore, a runtime error could appear if you run the code on iOS 13 and lower. Also along the way, the minimum FPS was increased to 25, since some animations had it and looked very slow using previous value. --- MMMLoadable.podspec | 2 +- Sources/MMMLoadableObjC/MMMLoadableImage.m | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/MMMLoadable.podspec b/MMMLoadable.podspec index 73096b4..198e905 100644 --- a/MMMLoadable.podspec +++ b/MMMLoadable.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.name = "MMMLoadable" - s.version = "2.2.1" + s.version = "2.2.2" s.summary = "A simple model for async calculations" s.description = "#{s.summary}." s.homepage = "https://github.com/mediamonks/#{s.name}" diff --git a/Sources/MMMLoadableObjC/MMMLoadableImage.m b/Sources/MMMLoadableObjC/MMMLoadableImage.m index 422fb7e..5aaaf36 100644 --- a/Sources/MMMLoadableObjC/MMMLoadableImage.m +++ b/Sources/MMMLoadableObjC/MMMLoadableImage.m @@ -224,7 +224,10 @@ - (NSNumber *)imageAnimationDelayTime:(CGImageSourceRef)source { return nil; } NSDictionary *gifProps = (__bridge NSDictionary *)(CFDictionaryRef)CFDictionaryGetValue(props, kCGImagePropertyGIFDictionary); - NSDictionary *webpProps = (__bridge NSDictionary *)(CFDictionaryRef)CFDictionaryGetValue(props, kCGImagePropertyWebPDictionary); + NSDictionary *webpProps = nil; + if (@available(iOS 14.0, *)) { + webpProps = (__bridge NSDictionary *)(CFDictionaryRef)CFDictionaryGetValue(props, kCGImagePropertyWebPDictionary); + } CFRelease(props); if (gifProps) { return (NSNumber *)gifProps[(NSString *)kCGImagePropertyGIFDelayTime]; @@ -270,7 +273,7 @@ - (UIImage *)imageWithData:(NSData *)data { [images addObject:image]; } - NSTimeInterval delayTime = MAX([delayTimeNum doubleValue], 0.1); + NSTimeInterval delayTime = MAX([delayTimeNum doubleValue], 0.04); UIImage *result = [UIImage animatedImageWithImages:images duration:delayTime * count];