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

PINAnimatedImageView bug when loading two or more gifs with the same url #517

Open
hovox opened this issue Jul 10, 2019 · 2 comments
Open

Comments

@hovox
Copy link
Contributor

hovox commented Jul 10, 2019

Let's say we have a two PINAnimatedImageView instances, if we load same gif url simultaneously for those two image views, only one of them will work. Another one will not load anything.

By simultaneously I mean something like this:

NSURL *url = [NSURL URLWithString:@"google.com"];
[imageView1 pin_setImageFromURL:url];
[imageView2 pin_setImageFromURL:url];

Issue happens because only one PINAnimatedCachedImage instance is created for those two image views so those two views use same PINAnimatedCachedImage instance.
PINAnimatedCachedImage has coverImageReadyCallback and playbackReadyCallback properties which seems not designed to work right in this case. What happens is one image view sets coverImageReadyCallback and playbackReadyCallback properties and another one is overriding them.

@iwheelbuy
Copy link

iwheelbuy commented Jan 16, 2020

Have the same issue with two images applied simultaneously.

if let object = result.alternativeRepresentation as? PINCachedAnimatedImage {
    // set image
}

We receive one instance of the image for both views:

<PINCachedAnimatedImage: 0x281911d80>
<PINCachedAnimatedImage: 0x281911d80>

I believe there is an easy work around

if let object = result.alternativeRepresentation as? PINCachedAnimatedImage {
    let object: PINCachedAnimatedImage = {
        guard let data = object.data else {
            return object
        }
        return PINCachedAnimatedImage(animatedImageData: data) ?? object
    }()
    // set image
}

It might not work in all situations, but it works for me and as a result I get different instances of one image.

<PINCachedAnimatedImage: 0x2837dd100>
<PINCachedAnimatedImage: 0x2837e6380>

@alex-vasenin
Copy link

We also have the same issue

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

3 participants