Skip to content

Commit 3ca9dca

Browse files
authored
Twitter dont block main on file ops (#7298)
* Remove sync wait on filesystem from main queue On initialization, a promise is created that synchronously waits on an NSOperationQueue with file ops in it. Re-work this so that the promise is asynchronously fulfilled with an operation that is inserted into the queue, and then dispatched back to the main queue when finished.
1 parent 199ef50 commit 3ca9dca

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Crashlytics/Crashlytics/Controllers/FIRCLSReportManager.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,18 @@ - (FBLPromise *)deleteUnsentReports {
410410
NSOperationQueue *__weak queue = _operationQueue;
411411
FBLPromise *__weak unsentReportsHandled = _unsentReportsHandled;
412412
promise = [promise then:^id _Nullable(NSNumber *_Nullable value) {
413-
[queue waitUntilAllOperationsAreFinished];
414-
// Signal that to callers of processReports that everything is finished.
415-
[unsentReportsHandled fulfill:nil];
416-
return value;
413+
FBLPromise *allOpsFinished = [FBLPromise pendingPromise];
414+
[queue addOperationWithBlock:^{
415+
[allOpsFinished fulfill:nil];
416+
}];
417+
418+
return [allOpsFinished onQueue:dispatch_get_main_queue()
419+
then:^id _Nullable(id _Nullable allOpsFinishedValue) {
420+
// Signal that to callers of processReports that everything is
421+
// finished.
422+
[unsentReportsHandled fulfill:nil];
423+
return value;
424+
}];
417425
}];
418426

419427
return promise;

0 commit comments

Comments
 (0)