diff --git a/SDWebImage/SDAnimatedImageView.m b/SDWebImage/SDAnimatedImageView.m index 0e6c52fd..9c7d4595 100644 --- a/SDWebImage/SDAnimatedImageView.m +++ b/SDWebImage/SDAnimatedImageView.m @@ -689,8 +689,10 @@ static NSUInteger SDDeviceFreeMemory() { // Update the current frame UIImage *currentFrame; + UIImage *fetchFrame; LOCKBLOCK({ currentFrame = self.frameBuffer[@(currentFrameIndex)]; + fetchFrame = currentFrame ? self.frameBuffer[@(nextFrameIndex)] : nil; }); BOOL bufferFull = NO; if (currentFrame) { @@ -744,11 +746,6 @@ static NSUInteger SDDeviceFreeMemory() { fetchFrameIndex = nextFrameIndex; } - UIImage *fetchFrame; - LOCKBLOCK({ - fetchFrame = self.frameBuffer[@(fetchFrameIndex)]; - }); - if (!fetchFrame && !bufferFull && self.fetchQueue.operationCount == 0) { // Prefetch next frame in background queue UIImage *animatedImage = self.animatedImage;