From 17aa1e320e75393d46a54ec0fee8b068eeef142f Mon Sep 17 00:00:00 2001 From: Brandon Baumgarten Date: Thu, 21 Jan 2021 10:53:07 -0800 Subject: [PATCH] Fix image loop counter on iOS 14 (#30744) Summary: Animated gifs, which do not loop, currently animate twice on iOS 14. See: https://github.com/facebook/react-native/issues/30147 ## Changelog [iOS] [Fixed] - Animated images without loop no longer animate twice Pull Request resolved: https://github.com/facebook/react-native/pull/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 --- Libraries/Image/RCTAnimatedImage.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Libraries/Image/RCTAnimatedImage.m b/Libraries/Image/RCTAnimatedImage.m index 978fc2e905d7c3..85bf09e05d37c2 100644 --- a/Libraries/Image/RCTAnimatedImage.m +++ b/Libraries/Image/RCTAnimatedImage.m @@ -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++; + } } } }