简体   繁体   中英

Flutter iOS Release Crash: Firebase FireStore Util

I have been trying to debug this issue for almost 8 days now. Tried everything I can find on the inte.net / stack overflow / github and still on the same problem. I have done all the basic troubleshooting (cleaning, deintegrating pods, etc.) and even adding the GoogleService-info.plist through Xcode.

There is no problem on debug modes and on android release mode. It only occurs on iOS release mode on test flight and on app store connect but works on the emulator / debug mode. Below is the stack trace:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Application Specific Information:
abort() called

Last Exception Backtrace:
0   CoreFoundation                         0x1c8b25e88 __exceptionPreprocess + 164
1   libobjc.A.dylib                        0x1c1e538d8 objc_exception_throw + 60
2   FirebaseFirestore                      0x102f1bc08 firebase::firestore::util::ObjcThrowHandler(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 112
3   FirebaseFirestore                      0x102f1b78c firebase::firestore::util::Throw(firebase::firestore::util::ExceptionType, char const*, char const*, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 20
4   FirebaseFirestore                      0x102f2284c void firebase::firestore::util::ThrowInvalidArgument<>(char const*) + 56
5   FirebaseFirestore                      0x102f4d3b4 -[FIRFirestore documentWithPath:] + 308
6   Runner                                 0x1023730c4 -[FLTFirebaseFirestoreReader readValueOfType:] + 2339012 (FLTFirebaseFirestoreReader.m:38)
7   Flutter                                0x10576d9c0 0x1051f4000 + 5740992
8   Runner                                 0x102373040 -[FLTFirebaseFirestoreReader readValueOfType:] + 2338880 (FLTFirebaseFirestoreReader.m:79)
9   Flutter                                0x10576ee54 0x1051f4000 + 5746260
10  Flutter                                0x10576bc8c 0x1051f4000 + 5733516
11  Flutter                                0x105237de4 0x1051f4000 + 277988
12  libdispatch.dylib                      0x1d00f44b4 _dispatch_call_block_and_release + 32
13  libdispatch.dylib                      0x1d00f5fdc _dispatch_client_callout + 20
14  libdispatch.dylib                      0x1d01047f4 _dispatch_main_queue_drain + 928
15  libdispatch.dylib                      0x1d0104444 _dispatch_main_queue_callback_4CF + 44
16  CoreFoundation                         0x1c8bb66f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
17  CoreFoundation                         0x1c8b98058 __CFRunLoopRun + 2036
18  CoreFoundation                         0x1c8b9ced4 CFRunLoopRunSpecific + 612
19  GraphicsServices                       0x201e9a368 GSEventRunModal + 164
20  UIKitCore                              0x1cb07b3d0 -[UIApplication _run] + 888
21  UIKitCore                              0x1cb07b034 UIApplicationMain + 340
22  Runner                                 0x10213dbe0 main + 23520 (AppDelegate.swift:5)
23  dyld                                   0x1e7204960 start + 2528

Thread 0 name:   Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib                 0x205720200 __pthread_kill + 8
1   libsystem_pthread.dylib                0x215b821ac pthread_kill + 268
2   libsystem_c.dylib                      0x1d01b13e4 __abort + 128
3   libsystem_c.dylib                      0x1d0159c98 abort + 192
4   libc++abi.dylib                        0x215ac2b8c abort_message + 132
5   libc++abi.dylib                        0x215ab2a80 demangling_terminate_handler() + 336
6   libobjc.A.dylib                        0x1c1e59d3c _objc_terminate() + 144
7   libc++abi.dylib                        0x215ac1f28 std::__terminate(void (*)()) + 20
8   libc++abi.dylib                        0x215ac1ec4 std::terminate() + 56
9   libdispatch.dylib                      0x1d00f5ff0 _dispatch_client_callout + 40
10  libdispatch.dylib                      0x1d01047f4 _dispatch_main_queue_drain + 928
11  libdispatch.dylib                      0x1d0104444 _dispatch_main_queue_callback_4CF + 44
12  CoreFoundation                         0x1c8bb66f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
13  CoreFoundation                         0x1c8b98058 __CFRunLoopRun + 2036
14  CoreFoundation                         0x1c8b9ced4 CFRunLoopRunSpecific + 612
15  GraphicsServices                       0x201e9a368 GSEventRunModal + 164
16  UIKitCore                              0x1cb07b3d0 -[UIApplication _run] + 888
17  UIKitCore                              0x1cb07b034 UIApplicationMain + 340
18  Runner                                 0x10213dbe0 main + 23520 (AppDelegate.swift:5)
19  dyld                                   0x1e7204960 start + 2528

Below will also be the code that is affected. I tried to pinpoint the problem and when I comment docRef.get() method, it doesn't crash on test flight anymore:

Future<List<dbResults>> results({
  required String collectionKey,
  required String documentKey,
  required int count,
}) async {
  FirebaseFirestore firestore = FirebaseFirestore.instance;
  DocumentReference docRef =
      firestore.collection(collectionKey).doc(documentKey);
  List<dbResults> databaseResults = [];

  await docRef.get().then((datasnapshot) {
    if (datasnapshot.exists) {
      try {
        datbaseResults = datasnapshot.get('results');
        // Additional Logic Here which won't even matter as
        // it throws on docRef.get() itself (tried and tested)
        }
      } catch (_) {
        if (kDebugMode) {
          print("Error fetching game database results.");
        }
      }
    }
  });

  return databaseResults;
}

Flutter: 3.3.9

Pubspec:

Cloud Firestore : 4.1.0
Firebase Core: 2.3.0

Any help would be appreciated!

I have exhausted the resources online and submitted +30 builds just to address the issue.

I managed to fix it by adding a conditional check on the parameters being passed to the function if they are not empty before performing the query.

Just a bit weird because the above function isn't even being called on app start and it seems that Swift is trying to call the function on app start and crash but on Android Release and both debug modes, everything is normal.

For all the other devs out there that is on the same boat, please learn from my mistake

Thank you Ali Nabel for helping too!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM