Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single-frame GIF has rendering issues on iOS 14 #248

Open
zisulu opened this issue Mar 17, 2021 · 2 comments
Open

Single-frame GIF has rendering issues on iOS 14 #248

zisulu opened this issue Mar 17, 2021 · 2 comments

Comments

@zisulu
Copy link

zisulu commented Mar 17, 2021

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...

@zisulu
Copy link
Author

zisulu commented Jul 26, 2021

@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
Copy link

denty commented Aug 17, 2022

@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;
          }
    

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants