From 40729dbdd216adc6bfb197abba8b2ef45923bb39 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 31 May 2018 10:31:53 -0400 Subject: [PATCH] Use background task while downloading profile avatar. --- SignalMessaging/profiles/OWSProfileManager.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SignalMessaging/profiles/OWSProfileManager.m b/SignalMessaging/profiles/OWSProfileManager.m index 3f3a2822e..72bcd180c 100644 --- a/SignalMessaging/profiles/OWSProfileManager.m +++ b/SignalMessaging/profiles/OWSProfileManager.m @@ -801,6 +801,8 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640; { OWSAssert(userProfile); + __block OWSBackgroundTask *backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__]; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ if (userProfile.avatarUrlPath.length < 1) { OWSFail(@"%@ Malformed avatar URL: %@", self.logTag, userProfile.avatarUrlPath); @@ -884,6 +886,9 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640; [localUserProfile updateWithAvatarFileName:fileName dbConnection:self.dbConnection completion:nil]; [self updateProfileAvatarCache:image filename:fileName]; } + + OWSAssert(backgroundTask); + backgroundTask = nil; }); };