Tuesday, 10 September 2013

SDWebImage operations not being canceled

SDWebImage operations not being canceled

I have a table view that includes several feed cells that each have a few
images a piece. I'm loading in the images like this:
[timeLineCell.avatar setImageWithURL:[NSURL URLWithString:[feedAccount
accountAvatarUrl]] placeholderImage:avatarPlaceholderImage
options:SDWebImageRetryFailed];
This works fine, but on slow connections the operations tend to just climb
instead of removing old operations for the same images. That is -- if I
scroll down and back up through the same cells, it adds the same images
into the operation queue for a second time.
I'm also attempting to remove images from the download queue when the cell
gets reused like this in cellForRow:
- (void)prepareForReuse {
[super prepareForReuse];
[self.avatar cancelCurrentImageLoad];
}
But it seems like the operation doesn't match anything in the operation
queue in SDWebImage's methods, so it doesn't actually cancel anything. If
I run cancelAll on the shared manager it works, but it's obviously not
ideal.
I'm aware I'm only showing one image on this cell, but I have commented
out everything except for this image loading and the problem persists. It
also persists if I comment out the avatar image and allow a different
image (loaded similarly) to download instead.
Anyone have any tips on this?
P.S. I've tried changing the options from SDWebImageRetryFailed to other
things including no options at all, but it made no difference.

No comments:

Post a Comment