Skip to content

Commit

Permalink
Fix image loop counter on iOS 14 (#30744)
Browse files Browse the repository at this point in the history
Summary:
Animated gifs, which do not loop, currently animate twice on iOS 14.
See: #30147

## Changelog

[iOS] [Fixed] - Animated images without loop no longer animate twice

Pull Request resolved: #30744

Test Plan:
Run the example app with any animated gif. I attached a gif, which is affected.

![checkmark](https://user-images.githubusercontent.com/54310840/104746529-b2e02900-574f-11eb-9870-0c03c769c990.gif)

Reviewed By: sammy-SC

Differential Revision: D25977626

Pulled By: PeteTheHeat

fbshipit-source-id: 889d4a7bed8f7a7be6a9a427501d0071b7c02b8c
  • Loading branch information
comvenger-brandon authored and facebook-github-bot committed Jan 21, 2021
1 parent 768ecc2 commit 17aa1e3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Libraries/Image/RCTAnimatedImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ - (NSUInteger)imageLoopCountWithSource:(CGImageSourceRef)source
NSNumber *gifLoopCount = gifProperties[(__bridge NSString *)kCGImagePropertyGIFLoopCount];
if (gifLoopCount != nil) {
loopCount = gifLoopCount.unsignedIntegerValue;
// A loop count of 1 means it should repeat twice, 2 means, thrice, etc.
if (loopCount != 0) {
loopCount++;
if (@available(iOS 14, *)) {
} else {
// A loop count of 1 means it should animate twice, 2 means, thrice, etc.
if (loopCount != 0) {
loopCount++;
}
}
}
}
Expand Down

0 comments on commit 17aa1e3

Please sign in to comment.