Skip to content

Commit

Permalink
Add checking availability for webp animation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gmary95 committed Jun 7, 2024
1 parent e711bb7 commit 95708c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MMMLoadable.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
7 changes: 5 additions & 2 deletions Sources/MMMLoadableObjC/MMMLoadableImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit 95708c9

Please sign in to comment.