Flipboard/FLAnimatedImage

Single-frame GIF has rendering issues on iOS 14

zisulu opened this issue · 2 comments

This problem occurs when loading a single-frame GIF, the rest is unclear...

  • didMoveToWindow will be triggered when we switch viewControllers,
    but self.layer.contents may be nil, causing the FLAnimatedImageView to display blank.
    I have solved it through hook -didMoveToWindow temporarily. I hope the official can provide the correct solution as soon as possible, please...
- (void)xxxx_didMoveToWindow
{
    [self xxxx_didMoveToWindow];
    if (self.window && self.image && ([self.image sd_imageFormat] == SDImageFormatGIF) && self.animatedImage && self.animatedImage.frameCount == 1 && !self.layer.contents) {
        /// Single-frame GIF, which is not displayed when we switch viewControllers, needs to call setNeedsDisplay again to trigger the -displayLayer
        [self.layer setNeedsDisplay];
    }
}

single_frame_test.gif.zip
Sorry for my English...

@raphaelschaad Is there anyone who can solve this problem, or at least pay attention.
My solution can be used, but not including some special cases, such as using UIPopoverPresentationController, still can cause it to become nil, I can't figure out the reason...)

denty commented

@zisulu
maybe is Apple bugs system api in -[UIImageView _setImageViewContents:] () will set layer.contents into nil
you can add this code to refresh with displayLink callback

`

  • (void)displayDidRefresh:(CADisplayLink *)displayLink
    {
          if (self.needsDisplayWhenImageBecomesAvailable || self.layer.contents == nil) {
              [self.layer setNeedsDisplay];
              self.needsDisplayWhenImageBecomesAvailable = NO;
          }
    

`