Authored by 孙凯

crash 保护 review by hongmo

... ... @@ -52,9 +52,16 @@
completed:(SDWebImageCompletionWithFinishedBlock)completedBlock
{
@try {
if ([url isKindOfClass:NSString.class]) {
url = [NSURL URLWithString:(NSString *)url];
}
// Prevents app crashing on argument type error like sending NSNull instead of NSURL
if ([url isKindOfClass:NSURL.class]) {
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
[[YH_EventCollector sharedInstance] timeEventStartWithWebImageDownloadURL:url.absoluteString];
}
}
} @catch (NSException *exception) {
YHLog(@"%@ error: %@", self, exception);
}
... ... @@ -62,7 +69,7 @@
return [self yher_downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
@try {
if ([url isKindOfClass:NSURL.class]) {
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
if (cacheType == SDImageCacheTypeNone) {//暂时只去下载的图片的时间,过滤掉读缓存的时间
if (error) {
... ... @@ -72,6 +79,7 @@
}
}
}
}
} @catch (NSException *exception) {
YHLog(@"%@ error: %@", self, exception);
}
... ...