pinterest / PINRemoteImage

A thread safe, performant, feature rich image fetcher
Apache License 2.0
4.01k stars 511 forks source link

Three UX issues with PINAnimatedImageView & GIFs #536

Open Jarred-Sumner opened 5 years ago

Jarred-Sumner commented 5 years ago

I'm rendering several PINAnimatedImageView in a UIScrollView. As the user scrolls, it sets isPlaybackPaused to true when shown on screen and false when off screen. Overall, I really like this library. The performance of my app is meaningfully better than the other two libraries I integrated before this.

There are three UX issues that I'd like to report.

1. When PINAnimatedImageView is initially paused, it does not display the cover image

When/how is the cover image displayed?

I've noticed that whenever isPlaybackPaused is set to true before the image loads, the coverImage is never displayed, so the user sees an empty UIView and its sad.

Expected behavior: Even while paused, render the cover image once the image loads.

2. Pausing playback makes the PINAnimatedImageView display nothing

Currently, when isPlaybackPaused is false, the PINAnimatedImageView displays nothing. If there's any delay between pausing and unpausing (such as, the JS bridge when using this library in a React Native app), there are brief moments of black nothingness where the most recently played frame is supposed to go.

Expected behavior: Display the last image rendered before the animation was paused (maybe not setting frameImage to nil would work?)

I spent a couple of hours investigating this today. I think the image frame is being released here:

https://github.com/pinterest/PINRemoteImage/blob/5e51b816a5c7f2ba877250f3fdf3f441cec2dc9d/Source/Classes/AnimatedImages/PINAnimatedImageView.m#L237

3. isPlaybackPaused stops instead of pauses

stopAnimating, (which isPlaybackPaused calls) causes the PINCachedAnimatedImage to start over from the first frame the next time startAnimating is called. This appears to be a deliberate implementation detail. Is resume a thing other people care about too or is it just me?

Its quite likely that 1 and 2 are the same issue.