Skip to content

Commit d6fd783

Browse files
authored
[LP-11199] Fixing background deadlock (#350)
* Synchronize access to callbacks * Fixing deadlock
1 parent e668478 commit d6fd783

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Leanplum-SDK/Classes/Internal/Leanplum.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,11 +1192,13 @@ + (void)pause
11921192

11931193
// Block that finish task.
11941194
void (^finishTaskHandler)(void) = ^(){
1195-
// Make sure all database operations are done before ending the background task.
1196-
[[LPOperationQueue serialQueue] waitUntilAllOperationsAreFinished];
1195+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
1196+
// Make sure all database operations are done before ending the background task.
1197+
[[LPOperationQueue serialQueue] waitUntilAllOperationsAreFinished];
11971198

1198-
[application endBackgroundTask:backgroundTask];
1199-
backgroundTask = UIBackgroundTaskInvalid;
1199+
[application endBackgroundTask:backgroundTask];
1200+
backgroundTask = UIBackgroundTaskInvalid;
1201+
});
12001202
};
12011203

12021204
// Start background task to make sure it runs when the app is in background.

0 commit comments

Comments
 (0)