From 9cc5ba7c0eb7b447a2687cd27d04384046c5a5b3 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 17 Jun 2022 15:43:12 -0700 Subject: [PATCH] [Crashlytics] Enable much earlier sending reports Sending reports is now handled synchronously on the startup path, so that unsent reports can be sent before a startup crash causes further crashes to occur. This is apparently needed to help one particular user catch whatever is causing the app to crash for them. Signed-off-by: Christopher Snowhill --- Application/AppController.m | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Application/AppController.m b/Application/AppController.m index 3362b5ae2..827f8f0a8 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -146,6 +146,26 @@ void *kAppControllerContext = &kAppControllerContext; [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"NSApplicationCrashOnExceptions": @(YES) }]; [FIRApp configure]; + /* Evil startup synchronous crash log submitter, because apparently, there + * are some startup crashes that need diagnosing, and they're not getting + * sent, because the asynchronous defaults are not kicking in before the + * ensuing startup crash that happens somewhere later in this function. */ + __block BOOL submitCompleted = NO; + ALog(@"Checking for unsent reports..."); + [[FIRCrashlytics crashlytics] checkForUnsentReportsWithCompletion:^(BOOL hasReports) { + if(hasReports) { + ALog(@"Unsent reports found, sending..."); + [[FIRCrashlytics crashlytics] sendUnsentReports]; + ALog(@"Reports sent, continuing..."); + } else { + ALog(@"No reports found, continuing..."); + } + submitCompleted = YES; + }]; + while(!submitCompleted) { + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]]; + } + #ifdef DEBUG // Prevent updates automatically in debug builds [updater setAutomaticallyChecksForUpdates:NO];