Skip to content
This repository

RKHTTPRequestOperation Error when fetching images with SDWebImage (-999 cancelled) #1285

Closed
sprynmr opened this Issue · 6 comments

3 participants

Bob Spryn Dmitry Shevchenko Blake Watters
Bob Spryn

So I'm not sure if this is a bug with RestKit, SDWebImage, or I'm somehow doing something very wrong. I have a table view loading in images to cells via the UIImageView+WebCache category. I keep getting this error, and I'm unsure why RestKit is even in the mix in this situation:

E restkit.network:RKHTTPRequestOperation.m:175 GET 'http://s3-media2.ak.yelpcdn.com/bphoto/k0AgUkAZS3r9KlTlP55kmQ/ms.jpg' (0) [0.0394 s]: Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x12a99620 {NSErrorFailingURLKey=http://s3-media2.ak.yelpcdn.com/bphoto/k0AgUkAZS3r9KlTlP55kmQ/ms.jpg}

Why is SDWebImage going through RKHTTPRequestOperation somehow? Then of course, why is it canceling the download?

If you think this is actually a restkit issue, let me know if you need more data.

Dmitry Shevchenko
Bob Spryn

Sure.

[self.thumbnailImageView setImageWithURL:[NSURL URLWithString:object.imageUrl]];

Where object.imageUrl is obviously the url I'm seeing in the error logs. Not specific to one image, or even one image source (yelp cdn vs google images).

Dmitry Shevchenko

Ok, so AFNetworking (which is part of RestKit) has the same category methods as SDWebImage defined on UIImageView. Therefore, it's unknown which one will be called, in your case AFNetworking clearly wins.

Now, RKHTTPRequestOperation subscribes to NSNotification from AFNetworking operations, which is why you're seeing this log message.

This analysis could be too shallow, but I'm sure the problem arises from colliding categories.
I do not know of a way to resolve such a collision (maybe exclude UIImageView+AFNetworking from imports somehow), so I would recommend to replicate what setImageWithURL does in your own code.

Bob Spryn
Dmitry Shevchenko

I can't close the issue :)
It's an interesting one though for sure, I wonder if passing object:nil here
https://github.com/RestKit/RestKit/blob/development/Code/Network/RKHTTPRequestOperation.m#L118

could lead to more subtle bugs, @blakewatters ?

Dmitry Shevchenko dmishe referenced this issue in AFNetworking/AFNetworking
Closed

Category methods collision #859

Blake Watters
Owner

@dmishe The line you are referencing is in the RKHTTPRequestOperationLogger class, which observes all AFNetworking operations started within the application and emits logging information. That object:nil argument just tells the observation center that we want to watch any networking, rather than ones emitted by a particular objects.

This definitely is a conflict between AFN and SDWebImage. My recommendation would be to split the UIImage category into a subspec that would allow users to opt-in to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.