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

Crash when calling cancelCurrentImageLoad on UIIMageView #785

Closed
Kry256 opened this issue Jun 27, 2014 · 17 comments
Closed

Crash when calling cancelCurrentImageLoad on UIIMageView #785

Kry256 opened this issue Jun 27, 2014 · 17 comments
Assignees
Milestone

Comments

@Kry256
Copy link

Kry256 commented Jun 27, 2014

From the last update, when I call cancelCurrentImageLoad from my UIIMageView the app crashes with this message
-[UIImageView sd_cancelImageLoadOperationWithKey:]: unrecognized selector sent to instance 0x172490b0
Also this metho seems to be deprecated, but SDWebImage suggest me to replace as follows
cancelCurrentImageLoad' is deprecated: Use cancelCurrentImageLoad.
Think this one is only a typing error.

@valentinradu
Copy link

I'm having the exact same problem here.

@mythodeia
Copy link
Contributor

@Kry256
its a typo mistake like you said...
it should say "Use sd_cancelCurrentImageLoad" instead

however i do not get the crash you suggested.

@bpoplauschi bpoplauschi added this to the 3.7.0 milestone Jun 27, 2014
@bpoplauschi bpoplauschi self-assigned this Jun 27, 2014
@brynbodayle
Copy link
Contributor

In order to resolve this crash, you need to import the newly added files:

UIView+WebCacheOperation.h
UIView+WebCacheOperation.m
UIImageView+HighlightedWebCache.h
UIImageView+HighlightedWebCache.m

@bpoplauschi
Copy link
Member

I can't reproduce the crash using the demo project. I don't see why a crash because of missing imports. Could you provide more details? Does your copy of SDWebImage contain the UIView+WebCacheOperation class?

@bpoplauschi
Copy link
Member

BTW, fixed the deprecated misspell with 30e034d

@dezinezync
Copy link

I can confirm that this only occurs when the UIView+WebCacheOperation.{h,m} are not included in the project. Works perfectly fine when they are included.

@Kry256
Copy link
Author

Kry256 commented Jul 1, 2014

I have tried it inside a clean project. I have all the new classes correctly imported. Basically it happens that when I try to load an image using:
[imageView sd_setImageWithURL:__MyURL__ placeholderImage:[UIImage imageNamed:@"placeholder.png"] options:SDWebImageRetryFailed];

Then it will jump inside

- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {

And as the first instruction of the method it calls

[self sd_cancelCurrentImageLoad];

The call make SDWebImage jumps into

- (void)sd_cancelCurrentImageLoad { [self sd_cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"]; }

And here the crash happens with this message

-[UIImageView sd_cancelImageLoadOperationWithKey:]: unrecognized selector sent
to instance 0x1780ade0
Terminating app due to uncaught exception 'NSInvalidArgumentException'
reason: '-[UIImageView sd_cancelImageLoadOperationWithKey:]: unrecognized selector sent to instance 0x1780ade0'
First throw call stack:
(0x2d49af0b 0x37c31ce7 0x2d49e837 0x2d49d137 0x2d3ec098 0x41a0e7 0x418097 0x417d9f 0xf7c9d 0x2fd2ae15 0x2fd29651 0x2fd257a3 0x2fcca305 0x2f94631b 0x2f941b3f 0x2f9419d1 0x2f9413e5 0x2f9411f7 0x2f93af1d 0x2d466039 0x2d4639c7 0x2d463d13 0x2d3ce769 0x2d3ce54b 0x3233b6d3 0x2fd2d891 0xfefc1 0x3812fab7)
libc++abi.dylib: terminating with uncaught exception of type NSException

@mythodeia
Copy link
Contributor

@Kry256 the demo project has a scenario like that. when you go into the details view it loads the image by calling the sd_setImageWithURL which in turns calls sd_cancelCurrentImageLoad which successfully cals the sd_cancelImageLoadOperationWithKey inside the UIView+WebCacheOperation.m file.
no crash for me with the demo.
can you replicate it there?

@bpoplauschi
Copy link
Member

There must be an issue with your project (either doesn't properly include the UIView+WebCacheOperation files or it has an issue loading categories (might be missing force_load or load_all flags)). Please try using our demo project. Also, on the clean project you set up, check if the UIView+WebCacheOperation files exist.

@bpoplauschi
Copy link
Member

I just created a test single-view project where I installed SDWebImage via cocoapods

platform :ios, '6.1'
pod 'SDWebImage', :head

Ran sd_setImageWithUrl: and everything went smoothly.

@Kry256
Copy link
Author

Kry256 commented Jul 14, 2014

Sorry for the late in answer. In the sample project I wasn't able to reproduce this issue, however with the last commit cd4b925 everything came back to work well

@bpoplauschi
Copy link
Member

Ok @Kry256, thanks for checking. Will close this one. Please reopen if you still encounter this issue.

@valentinradu
Copy link

Sorry for the extra late reply. I can confirm, my problem was the fact that after pulling the new version I didn't imported the right categories. Thanks for this cool class. (As a side question, why did you prefixed your methods with sd_? Just curious.)

@bpoplauschi
Copy link
Member

@valentinradu we prefixed with sd_ to avoid naming collisions with libraries like AFNetworking (which also has an UIImageView category with imageWithURL:... methods. It's kind off having a namespace, since Obj-C doesn't support one built-in.

@ymakin
Copy link

ymakin commented Sep 1, 2014

@bpoplauschi Sorry, but i still have this problem.

@coryhymel
Copy link

I am having this issue again as well. I installed using cocoapods and the methods show up as valid but when running I get unrecognized selector . These items are included in the pod file so everything should be there.

UIView+WebCacheOperation.h
UIView+WebCacheOperation.m
UIImageView+HighlightedWebCache.h
UIImageView+HighlightedWebCache.m

The only thing that may be causing this is that I had SDWebImage added originally by dragging the files in and setup the project environment for it. I removed all the old files, removed the other linker flags then ran the pod install. Any suggestions?

Also, that is weird is that setImageWithURL works fine??

@qiang437587687
Copy link

Just as @brynbodaylee and @coryhymel said check your SDWebImage include it or not ?? UIView+WebCacheOperation.h
UIView+WebCacheOperation.m
UIImageView+HighlightedWebCache.h
UIImageView+HighlightedWebCache.m
I slove this Issue add it to the progect!.

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

9 participants