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

Regression - Image disappears once full resolution is loaded #309

Open
StainlessStlRat opened this issue Apr 6, 2020 · 7 comments
Open

Comments

@StainlessStlRat
Copy link

I was really excited to see that NYTPhotoViewer had finally gotten an update. Unfortunately, there's been a regression.

I have an object derived from NYTPhoto that pulls the "placeholder" image from cache if available. In my case, the placeholder is basically a thumbnail. When "image" is called, I kick off an asynchronous web fetch, that once finished will call updatePhoto:photo on the photosviewcontroller.

This works fine on 2.0 but when the "image" is updated, it clears the image and doesn't load the new one unless you touch the screen/begin to slide.

It appears to get chugged up somewhere on the new Pinterest image stuff that replaced FLAnimatedImage. While debugging, the whole system freezes on me making it difficult to see what's actually happening, but it appears basically stuck after this:

// Animated Image can take a while to dealloc, let's try and do it off main.
__block PINCachedAnimatedImage *strongAnimatedImage = previousAnimatedImage;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
strongAnimatedImage = nil;
});

If I never call update, the view never gets blanked (but I also don't get my fullscreen image).

Another interesting facet of this bug is that it only happens on the first view if it's a series of images. The second, third, etc... all load up fine (first with thumb, then with full image).

See linked video here: https://imgur.com/a/VgwkEwz

@StainlessStlRat
Copy link
Author

Anyone looked at this? Any new information needed?

@mr-fixit
Copy link
Contributor

do you have a sample project i can look at?

@sohail-niazi
Copy link

I am facing the same problem. When I load multiple images in NYTPhotoViewerController , at first all images all loaded. And I can swipe to all images perfectly fine. Once all images are loaded, on image change screen turns black, in my debugging I can see the proper image with size is return but as soon as photoViewController.update(photo) is called, The screen goes black and so on.

mr-fixit pushed a commit that referenced this issue Nov 22, 2020
@mr-fixit
Copy link
Contributor

Sorry for the delay. Does this reproduce in either Example apps?

I tried, (see branch issue-309), and though i can simulate the 'goes to blank' issue by calling 'updatePhoto:photo' when image is still nil, I couldn't repo the behavior of it being okay if I left and came back.

@rpendleton
Copy link

rpendleton commented Dec 8, 2020

I don't know if it's the same root cause, but I'm able to reproduce this consistently whenever the placeholder image is the same size as the full image, and the full image is loaded after the placeholder has been displayed. This is easy to reproduce using the example Swift app if you make the following change:

diff --git a/Examples/Sources/Swift/PhotoBox.swift b/Examples/Sources/Swift/PhotoBox.swift
index ff42727..cf9f719 100644
--- a/Examples/Sources/Swift/PhotoBox.swift
+++ b/Examples/Sources/Swift/PhotoBox.swift
@@ -22,7 +22,9 @@ final class NYTPhotoBox: NSObject, NYTPhoto {

     var image: UIImage?
     var imageData: Data?
-    var placeholderImage: UIImage?
+    var placeholderImage: UIImage? {
+        return UIImage(named: value.name)
+    }

     var isPhoto: Bool {
         return value.itemType == .image

And just to verify that it's not an issue with the images being the same reference (which they would be in my example modification above), here's a snippet of a debugging session in my app:

(lldb) po self?.placeholderImage == self?.image
false

(lldb) po self?.placeholderImage?.size == self?.image?.size
true

(lldb) print self?.image?.size
(CGSize?) $R34 = (width = 94.5, height = 126)

@mr-fixit
Copy link
Contributor

mr-fixit commented Dec 8, 2020

thanks, i'll give this a try (in the next day or two)

@mr-fixit
Copy link
Contributor

mr-fixit commented Dec 9, 2020

I reproduced the issue, thanks for the how-to.

I think this is a manifestation of this issue pinterest/PINRemoteImage#591.

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

4 participants