rounak / RJImageLoader

A recreation of the image loader animation created by Michael Villar for iOS
MIT License
833 stars 89 forks source link

Bugs #7

Open pronebird opened 9 years ago

pronebird commented 9 years ago
  1. pod try RJImageLoader opens broken project.
  2. trying out pod in app, animation runs once, then on second run it is inversed and finally after that it's completely gone.

I made a small video: http://cl.ly/1y0G1p050o0M. I think the problem is in SDWebImage:

    self.photoImageView.image = nil;

    [self.photoImageView startLoaderWithTintColor:[UIColor blueColor]];
    NSLog(@"Start loader");

    __weak typeof(self) weakSelf = self;
    [self.photoImageView sd_setImageWithURL:url
                           placeholderImage:nil
                                    options:SDWebImageRetryFailed | SDWebImageRefreshCached
                                   progress:^(NSInteger receivedSize, NSInteger expectedSize) {
                                       dispatch_async(dispatch_get_main_queue(), ^{
                                           CGFloat percent = (CGFloat)receivedSize / expectedSize;
                                           [weakSelf.photoImageView updateImageDownloadProgress:percent];
                                           NSLog(@"Update progress = %f", percent);
                                       });
                                   }
                                  completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
                                    [weakSelf.photoImageView reveal];
                                    NSLog(@"Reveal loader");
                                  }];

I posted couple of issues in SDWebImage related to this problem. https://github.com/rs/SDWebImage/issues/1090

Since SDWebImage is a wreck, we can avoid completion handler and run all animations in progress block:

    self.photoImageView.image = nil;

    [self.photoImageView startLoaderWithTintColor:[UIColor blueColor]];
    NSLog(@"Start loader");

    __weak typeof(self) weakSelf = self;
    [self.photoImageView sd_setImageWithURL:url
                           placeholderImage:nil
                                    options:SDWebImageRetryFailed | SDWebImageRefreshCached
                                   progress:^(NSInteger receivedSize, NSInteger expectedSize) {
                                       dispatch_async(dispatch_get_main_queue(), ^{
                                           CGFloat percent = (CGFloat)receivedSize / expectedSize;
                                           [weakSelf.photoImageView updateImageDownloadProgress:percent];
                                           NSLog(@"Update progress = %f", percent);

                                           if(receivedSize == expectedSize) {
                                               [weakSelf.photoImageView reveal];
                                           }
                                       });
                                   }
                                  completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
                                  }];

But then it's all broken after I run it twice, see video: http://cl.ly/2U192i321D1N

rounak commented 9 years ago

This is very weird. By second run, do you mean a build and run second time, or something else?

pronebird commented 9 years ago

By second run I meant as if I ran the same start/update/reveal cycle once again on the same image view.

rounak commented 9 years ago

Ah, ok. Got it. I think we can fix this by doing some more cleanup at the end of reveal. (Resetting progress back to 0, possibly removing from superview) I'll take a look at this over the weekend.

pronebird commented 9 years ago

@rounak thank you! I had something like that in mind and I tried to remove view from superview but I guess it needs more thorough clean up.

LiuSky commented 9 years ago

There are still similar problems in the list when multiplexing

cyril94440 commented 8 years ago

I have the same issue, what is the workaround?

chinnuios commented 8 years ago

@pronebird I have the same issue, what is the workaround?

hyunwoo3008 commented 8 years ago

I have the same issue,,

chinnuios commented 8 years ago

@rounak @hyunwoo3008 did you resolved this issue ?? if yes, please tell me