From 7928162cb2a88cee049bbb902a9b5dff73e1b2e8 Mon Sep 17 00:00:00 2001 From: Garrett Moon Date: Fri, 2 Aug 2019 14:22:37 -0700 Subject: [PATCH] Removes the optimization to reduce the display links frame interval The idea behind this optimization was to reduce the number of calls the display link would need for animated images which didn't draw every frame. But this has resulted in frames being dropped in certain cases where frameInterval isn't respected (see https://i.pinimg.com/originals/58/9c/e8/589ce828d2ef0797da0e85b1c6d2f2b3.gif) Since the the display link fire method continues if we detect we're at the same image index as before, let's just remove this optimization. --- Source/Classes/AnimatedImages/PINAnimatedImageView.m | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/Classes/AnimatedImages/PINAnimatedImageView.m b/Source/Classes/AnimatedImages/PINAnimatedImageView.m index 8ef426fc..a4a69df1 100644 --- a/Source/Classes/AnimatedImages/PINAnimatedImageView.m +++ b/Source/Classes/AnimatedImages/PINAnimatedImageView.m @@ -211,14 +211,10 @@ - (void)startAnimating if ([self canBeVisible] == NO) { return; } - - // Get frame interval before holding display link lock to avoid deadlock - NSUInteger frameInterval = self.animatedImage.frameInterval; if (_displayLink == nil) { _playHead = 0; _displayLink = [PINDisplayLink displayLinkWithTarget:[PINRemoteWeakProxy weakProxyWithTarget:self] selector:@selector(displayLinkFired:)]; - _displayLink.frameInterval = frameInterval; _lastSuccessfulFrameIndex = NSUIntegerMax; [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:self.animatedImageRunLoopMode]; @@ -361,7 +357,7 @@ - (void)displayLinkFired:(PINDisplayLink *)displayLink _playHead = 0; _playedLoops++; } - + if (self.animatedImage.loopCount > 0 && _playedLoops >= self.animatedImage.loopCount) { [self stopAnimating]; return;