I am experiencing this crash on one specific line of code, in one specific method, within the first 2 seconds of the app openning.
This crash occurs randomly on my users devices and never on mine so I cannot reproduce it. I just have what Firebase Crashlytics provides.
Some extra details about the code:
This query is run in ViewDidLoad on the first page the user sees when they open the app
This query is run in a background thread
This query is run concurrently with 6 other queries each on their own background thread
This crash only occurs in this specific query in this specific line
This crash usually occurs on the first iteration of FIRDocumentSnapshot but occasionally occurs after multiple iterations
Some solutions I've already tried:
I've tried allowing this query to finish before running any other queries
I've tried running this query last, after all other queries have finished
I've tried adding NULL checks to snapshot, doc, and doc.data
I've tried checking for an NSError
I've tried running it on the main thread
Crash occurs on this line when accessing doc.data
NSLog(@"Test %@", doc.data);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
FIRFirestore *defaultFirestore = [FIRFirestore firestore];
[[[[defaultFirestore collectionWithPath:@"Homes"] documentWithPath:homeID] collectionWithPath:collection] getDocumentsWithCompletion:^(FIRQuerySnapshot * _Nullable snapshot, NSError * _Nullable error) {
if (error == nil) {
for (FIRDocumentSnapshot *doc in snapshot.documents) {
if (doc != nil) {
NSLog(@"Test %@", doc.data);
}
}
}
}];
});