diff --git a/SDWebImage/Core/SDAnimatedImagePlayer.m b/SDWebImage/Core/SDAnimatedImagePlayer.m index 31cbcb67..efb6f9b8 100644 --- a/SDWebImage/Core/SDAnimatedImagePlayer.m +++ b/SDWebImage/Core/SDAnimatedImagePlayer.m @@ -145,18 +145,18 @@ if (!self.currentFrame && [self.animatedProvider isKindOfClass:[UIImage class]]) { UIImage *image = (UIImage *)self.animatedProvider; - // Use the poster image if available + // Cache the poster image if available, but should not callback to avoid caller thread issues #if SD_MAC UIImage *posterFrame = [[NSImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:kCGImagePropertyOrientationUp]; #else UIImage *posterFrame = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:image.imageOrientation]; #endif if (posterFrame) { - self.currentFrame = posterFrame; + // HACK: The first frame should not check duration and immediately display + self.needsDisplayWhenImageBecomesAvailable = YES; SD_LOCK(self->_lock); - self.frameBuffer[@(self.currentFrameIndex)] = self.currentFrame; + self.frameBuffer[@(self.currentFrameIndex)] = posterFrame; SD_UNLOCK(self->_lock); - [self handleFrameChange]; } }