Authored by 孙凯

crash 保护 review by hongmo

... ... @@ -52,8 +52,15 @@
completed:(SDWebImageCompletionWithFinishedBlock)completedBlock
{
@try {
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
[[YH_EventCollector sharedInstance] timeEventStartWithWebImageDownloadURL:url.absoluteString];
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,14 +69,15 @@
return [self yher_downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
@try {
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
if (cacheType == SDImageCacheTypeNone) {//暂时只去下载的图片的时间,过滤掉读缓存的时间
if (error) {
[[YH_EventCollector sharedInstance] timeEventEndWithWebImageDownloadURL:url.absoluteString status:YHEventLoadStatusFailed];
}else{
[[YH_EventCollector sharedInstance] timeEventEndWithWebImageDownloadURL:url.absoluteString status:YHEventLoadStatusSuc];
}
if ([url isKindOfClass:NSURL.class]) {
if ([YHEventReport sharedInstance].isPerformanceTrackEnabled && [YHEventReport sharedInstance].isImagePerformanceTrackEnable){
if (cacheType == SDImageCacheTypeNone) {//暂时只去下载的图片的时间,过滤掉读缓存的时间
if (error) {
[[YH_EventCollector sharedInstance] timeEventEndWithWebImageDownloadURL:url.absoluteString status:YHEventLoadStatusFailed];
}else{
[[YH_EventCollector sharedInstance] timeEventEndWithWebImageDownloadURL:url.absoluteString status:YHEventLoadStatusSuc];
}
}
}
}
} @catch (NSException *exception) {
... ...