mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
#1697 (clean scroll stutter on iPhone)
- Heaviest activity was scaling story thumbnails on the main thread; moved to a background thread. - No more heavy activity when scrolling shown in Instruments.
This commit is contained in:
parent
5e0d037db5
commit
fe1e81ef90
1 changed files with 20 additions and 15 deletions
|
@ -709,20 +709,25 @@ typedef NS_ENUM(NSUInteger, MarkReadShowMenu)
|
||||||
for (NSString *storyImageUrl in storyImageUrls) {
|
for (NSString *storyImageUrl in storyImageUrls) {
|
||||||
// NSLog(@"Fetching image: %@", storyImageUrl);
|
// NSLog(@"Fetching image: %@", storyImageUrl);
|
||||||
[manager GET:storyImageUrl parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
[manager GET:storyImageUrl parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||||
UIImage *image = (UIImage *)responseObject;
|
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0ul);
|
||||||
|
dispatch_async(queue, ^{
|
||||||
if (!image || image.size.height < 50 || image.size.width < 50) {
|
UIImage *image = (UIImage *)responseObject;
|
||||||
[self.appDelegate.cachedStoryImages setObject:[NSNull null]
|
|
||||||
|
if (!image || image.size.height < 50 || image.size.width < 50) {
|
||||||
|
[self.appDelegate.cachedStoryImages setObject:[NSNull null]
|
||||||
|
forKey:storyImageUrl];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGSize maxImageSize = CGSizeMake(300, 300);
|
||||||
|
image = [image imageByScalingAndCroppingForSize:maxImageSize];
|
||||||
|
[self.appDelegate.cachedStoryImages setObject:image
|
||||||
forKey:storyImageUrl];
|
forKey:storyImageUrl];
|
||||||
return;
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
}
|
[self.appDelegate.feedDetailViewController
|
||||||
|
showStoryImage:storyImageUrl];
|
||||||
CGSize maxImageSize = CGSizeMake(300, 300);
|
});
|
||||||
image = [image imageByScalingAndCroppingForSize:maxImageSize];
|
});
|
||||||
[self.appDelegate.cachedStoryImages setObject:image
|
|
||||||
forKey:storyImageUrl];
|
|
||||||
[self.appDelegate.feedDetailViewController
|
|
||||||
showStoryImage:storyImageUrl];
|
|
||||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
@ -1328,9 +1333,9 @@ typedef NS_ENUM(NSUInteger, MarkReadShowMenu)
|
||||||
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
|
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0ul);
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC),
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC),
|
||||||
dispatch_get_main_queue(), ^(void) {
|
queue, ^(void) {
|
||||||
[self cacheStoryImages:storyImageUrls];
|
[self cacheStoryImages:storyImageUrls];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue