Flutter iOS发布崩溃:Firebase FireStore Util



我已经试着调试这个问题近8天了。尝试了我在互联网/堆栈溢出/github上能找到的一切,仍然在同样的问题上。我已经完成了所有基本的故障排除(清洁,分解pod等),甚至添加了googleservice信息。

在调试模式和android发布模式下没有问题。它只出现在iOS发布模式下的测试飞行和应用商店连接,但在模拟器/调试模式下工作。下面是堆栈跟踪:

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

下面也将是受影响的代码。我试图找出问题,当我评论docRef.get()方法时,它不再在试飞中崩溃了:

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;
}

颤振:3.3.9

Pubspec:

Cloud Firestore : 4.1.0
Firebase Core: 2.3.0

任何帮助将不胜感激!

我已经用尽了在线资源,提交了+30个构建只是为了解决这个问题。

我设法通过在执行查询之前对传递给函数的参数添加条件检查来修复它,如果它们不是空的。

只是有点奇怪,因为上面的函数甚至没有在应用程序启动时被调用,似乎Swift试图在应用程序启动和崩溃时调用该函数,但在Android发布和调试模式下,一切都是正常的。

对于所有和我在同一条船上的其他开发者,请从我的错误中吸取教训

也感谢Ali Nabel的帮助!

相关内容

  • 没有找到相关文章

最新更新