firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.72k stars 3.97k forks source link

🐛[FLTDocumentSnapshotStreamHandler onListenWithArguments:eventSink:] FIRIllegalStateException - The client has already been terminated. #10504

Closed TiagoAraujo54 closed 1 year ago

TiagoAraujo54 commented 1 year ago

Bug report

Describe the bug Flutter IOS crashes mid app usage.

Steps to reproduce

Cannot reproduce behaviour on my iPhone 8, have multiple issues in crashlytics with multiple phones and iOS versions ranging from 15.5.0 to 16.3.0

Click To Expand ``` Fatal Exception: FIRIllegalStateException 0 CoreFoundation 0x119180 __exceptionPreprocess 1 libobjc.A.dylib 0x59f8 objc_exception_throw 2 FirebaseFirestore 0x46838 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 3 FirebaseFirestore 0x463b4 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 4 FirebaseFirestore 0x587ec (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 5 FirebaseFirestore 0x69da0 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 6 FirebaseFirestore 0x36430 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 7 FirebaseFirestore 0x53fb8 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 8 FirebaseFirestore 0x53f68 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 9 Runner 0x6cfc00 -[FLTDocumentSnapshotStreamHandler onListenWithArguments:eventSink:] + 46 (FLTDocumentSnapshotStreamHandler.m:46) 10 Flutter 0x57822c (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 11 Flutter 0x43de4 (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 12 libdispatch.dylib 0x5fa38 _dispatch_call_block_and_release 13 libdispatch.dylib 0x607d4 _dispatch_client_callout 14 libdispatch.dylib 0xe008 _dispatch_main_queue_callback_4CF$VARIANT$mp 15 CoreFoundation 0xaab20 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 16 CoreFoundation 0xa5a58 __CFRunLoopRun 17 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific 18 GraphicsServices 0xa79c GSEventRunModal 19 UIKitCore 0x8bcc38 UIApplicationMain 20 Runner 0x45fc main + 7 (main.m:7) 21 libdyld.dylib 0x18e0 start ```

Sample project

Cannot provide example as app is too extensive and don't know where the issue stems from.


Additional context

issue that might be associated : #10503

full crash dump

Click To Expand ``` # Crashlytics - Stack trace Fatal Exception: FIRIllegalStateException 0 CoreFoundation 0x119180 __exceptionPreprocess 1 libobjc.A.dylib 0x59f8 objc_exception_throw 2 FirebaseFirestore 0x46838 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 3 FirebaseFirestore 0x463b4 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 4 FirebaseFirestore 0x587ec (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 5 FirebaseFirestore 0x69da0 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 6 FirebaseFirestore 0x36430 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 7 FirebaseFirestore 0x53fb8 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 8 FirebaseFirestore 0x53f68 (Missing UUID d06aedb3f3673b07b56bcc9587ba2c32) 9 Runner 0x6cfc00 -[FLTDocumentSnapshotStreamHandler onListenWithArguments:eventSink:] + 46 (FLTDocumentSnapshotStreamHandler.m:46) 10 Flutter 0x57822c (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 11 Flutter 0x43de4 (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 12 libdispatch.dylib 0x5fa38 _dispatch_call_block_and_release 13 libdispatch.dylib 0x607d4 _dispatch_client_callout 14 libdispatch.dylib 0xe008 _dispatch_main_queue_callback_4CF$VARIANT$mp 15 CoreFoundation 0xaab20 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 16 CoreFoundation 0xa5a58 __CFRunLoopRun 17 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific 18 GraphicsServices 0xa79c GSEventRunModal 19 UIKitCore 0x8bcc38 UIApplicationMain 20 Runner 0x45fc main + 7 (main.m:7) 21 libdyld.dylib 0x18e0 start Crashed: com.google.firebase.crashlytics.ios.exception 0 FirebaseCrashlytics 0x222ec FIRCLSProcessRecordAllThreads + 184 1 FirebaseCrashlytics 0x226cc FIRCLSProcessRecordAllThreads + 1176 2 FirebaseCrashlytics 0x1869c FIRCLSHandler + 48 3 FirebaseCrashlytics 0x128c4 __FIRCLSExceptionRecord_block_invoke + 92 4 libdispatch.dylib 0x607d4 _dispatch_client_callout + 16 5 libdispatch.dylib 0xec1c _dispatch_lane_barrier_sync_invoke_and_complete + 56 6 FirebaseCrashlytics 0x116a4 FIRCLSExceptionRecord + 204 7 FirebaseCrashlytics 0x1236c FIRCLSExceptionRecordNSException + 556 8 FirebaseCrashlytics 0x112a4 FIRCLSTerminateHandler() + 404 9 libc++abi.dylib 0xd838 std::__terminate(void (*)()) + 16 10 libc++abi.dylib 0xd8c4 std::terminate() + 84 11 libobjc.A.dylib 0x5d5c _destroyAltHandlerList + 10 12 libdispatch.dylib 0x607e8 _dispatch_client_callout + 36 13 libdispatch.dylib 0xe008 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1068 14 CoreFoundation 0xaab20 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 15 CoreFoundation 0xa5a58 __CFRunLoopRun + 1924 16 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 17 GraphicsServices 0xa79c GSEventRunModal + 104 18 UIKitCore 0x8bcc38 UIApplicationMain + 212 19 Runner 0x45fc main + 7 (main.m:7) 20 libdyld.dylib 0x18e0 start + 4 Thread 0 libsystem_pthread.dylib 0xecd0 + 190 com.apple.uikit.eventfetch-thread 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 CoreFoundation 0xaa914 __CFRunLoopServiceMachPort + 236 3 CoreFoundation 0xa5824 __CFRunLoopRun + 1360 4 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 5 Foundation 0x795c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300 6 Foundation 0x77ec -[NSRunLoop(NSRunLoop) runUntilDate:] + 96 7 UIKitCore 0x9a2754 -[UIEventFetcher threadMain] + 136 8 Foundation 0x1344a0 __NSThread__start__ + 984 9 libsystem_pthread.dylib 0xb2c0 + 128 10 libsystem_pthread.dylib 0xb220 _pthread_start + 44 11 libsystem_pthread.dylib 0xecdc thread_start + 4 io.flutter.1.ui 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 CoreFoundation 0xaa914 __CFRunLoopServiceMachPort + 236 3 CoreFoundation 0xa5824 __CFRunLoopRun + 1360 4 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 5 Flutter 0x2f90cc (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 6 Flutter 0x2f8acc (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 7 libsystem_pthread.dylib 0xb2c0 + 128 8 libsystem_pthread.dylib 0xb220 _pthread_start + 44 9 libsystem_pthread.dylib 0xecdc thread_start + 4 io.flutter.1.raster 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 CoreFoundation 0xaa914 __CFRunLoopServiceMachPort + 236 3 CoreFoundation 0xa5824 __CFRunLoopRun + 1360 4 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 5 Flutter 0x2f90cc (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 6 Flutter 0x2f8acc (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 7 libsystem_pthread.dylib 0xb2c0 + 128 8 libsystem_pthread.dylib 0xb220 _pthread_start + 44 9 libsystem_pthread.dylib 0xecdc thread_start + 4 io.flutter.1.io 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 CoreFoundation 0xaa914 __CFRunLoopServiceMachPort + 236 3 CoreFoundation 0xa5824 __CFRunLoopRun + 1360 4 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 5 Flutter 0x2f90cc (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 6 Flutter 0x2f8acc (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 7 libsystem_pthread.dylib 0xb2c0 + 128 8 libsystem_pthread.dylib 0xb220 _pthread_start + 44 9 libsystem_pthread.dylib 0xecdc thread_start + 4 io.worker.1 0 libsystem_kernel.dylib 0x22ee4 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x3cf8 + 636 2 libc++.1.dylib 0x8090 std::__1::condition_variable::wait(std::__1::unique_lock&) + 24 3 Flutter 0x2f3840 (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 4 libsystem_pthread.dylib 0xb2c0 + 128 5 libsystem_pthread.dylib 0xb220 _pthread_start + 44 6 libsystem_pthread.dylib 0xecdc thread_start + 4 io.worker.2 0 libsystem_kernel.dylib 0x22ee4 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x3cf8 + 636 2 libc++.1.dylib 0x8090 std::__1::condition_variable::wait(std::__1::unique_lock&) + 24 3 Flutter 0x2f3840 (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 4 libsystem_pthread.dylib 0xb2c0 + 128 5 libsystem_pthread.dylib 0xb220 _pthread_start + 44 6 libsystem_pthread.dylib 0xecdc thread_start + 4 dart:io EventHandler 0 libsystem_kernel.dylib 0x248f4 kevent + 8 1 Flutter 0x4e432c (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 2 Flutter 0x513414 (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 3 libsystem_pthread.dylib 0xb2c0 + 128 4 libsystem_pthread.dylib 0xb220 _pthread_start + 44 5 libsystem_pthread.dylib 0xecdc thread_start + 4 AVAudioSession Notify Thread 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 CoreFoundation 0xaa914 __CFRunLoopServiceMachPort + 236 3 CoreFoundation 0xa5824 __CFRunLoopRun + 1360 4 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 5 AVFAudio 0x8c334 GenericRunLoopThread::Entry(void*) + 156 6 AVFAudio 0xb6c60 CAPThread::Entry(CAPThread*) + 88 7 libsystem_pthread.dylib 0xb2c0 + 128 8 libsystem_pthread.dylib 0xb220 _pthread_start + 44 9 libsystem_pthread.dylib 0xecdc thread_start + 4 com.google.firebase.crashlytics.MachExceptionServer 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 FirebaseCrashlytics 0x1b004 FIRCLSMachExceptionServer + 108 3 libsystem_pthread.dylib 0xb2c0 + 128 4 libsystem_pthread.dylib 0xb220 _pthread_start + 44 5 libsystem_pthread.dylib 0xecdc thread_start + 4 com.apple.root.default-qos 0 libsystem_kernel.dylib 0x18148 semaphore_timedwait_trap + 8 1 libdispatch.dylib 0x2888 _dispatch_sema4_timedwait$VARIANT$mp + 64 2 libdispatch.dylib 0x31dc _dispatch_semaphore_wait_slow + 72 3 ffmpegkit 0x8f0c callbackBlockFunction + 444 4 libdispatch.dylib 0x5fa38 _dispatch_call_block_and_release + 24 5 libdispatch.dylib 0x607d4 _dispatch_client_callout + 16 6 libdispatch.dylib 0x4c80 _dispatch_queue_override_invoke + 684 7 libdispatch.dylib 0x11030 _dispatch_root_queue_drain + 372 8 libdispatch.dylib 0x118d4 _dispatch_worker_thread2 + 128 9 libsystem_pthread.dylib 0xc1b4 _pthread_wqthread + 464 10 libsystem_pthread.dylib 0xecd4 start_wqthread + 4 AXSpeech 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 CoreFoundation 0xaa914 __CFRunLoopServiceMachPort + 236 3 CoreFoundation 0xa5824 __CFRunLoopRun + 1360 4 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 5 Foundation 0x795c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300 6 libAXSpeechManager.dylib 0x794c -[AXSpeechThread main] + 264 7 Foundation 0x1344a0 __NSThread__start__ + 984 8 libsystem_pthread.dylib 0xb2c0 + 128 9 libsystem_pthread.dylib 0xb220 _pthread_start + 44 10 libsystem_pthread.dylib 0xecdc thread_start + 4 com.apple.NSURLConnectionLoader 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 CoreFoundation 0xaa914 __CFRunLoopServiceMachPort + 236 3 CoreFoundation 0xa5824 __CFRunLoopRun + 1360 4 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 5 CFNetwork 0x174c -[__CoreSchedulingSetRunnable runForever] + 216 6 Foundation 0x1344a0 __NSThread__start__ + 984 7 libsystem_pthread.dylib 0xb2c0 + 128 8 libsystem_pthread.dylib 0xb220 _pthread_start + 44 9 libsystem_pthread.dylib 0xecdc thread_start + 4 com.squareup.SocketRocket.NetworkThread 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 CoreFoundation 0xaa914 __CFRunLoopServiceMachPort + 236 3 CoreFoundation 0xa5824 __CFRunLoopRun + 1360 4 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 5 Foundation 0x795c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300 6 FirebaseDatabase 0x52f44 -[_FSRRunLoopThread main] + 252 7 Foundation 0x1344a0 __NSThread__start__ + 984 8 libsystem_pthread.dylib 0xb2c0 + 128 9 libsystem_pthread.dylib 0xb220 _pthread_start + 44 10 libsystem_pthread.dylib 0xecdc thread_start + 4 com.apple.CFSocket.private 0 libsystem_kernel.dylib 0x23328 __select + 8 1 CoreFoundation 0xb35f8 __CFSocketManager + 620 2 libsystem_pthread.dylib 0xb2c0 + 128 3 libsystem_pthread.dylib 0xb220 _pthread_start + 44 4 libsystem_pthread.dylib 0xecdc thread_start + 4 com.apple.CoreMotion.MotionThread 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 CoreFoundation 0xaa914 __CFRunLoopServiceMachPort + 236 3 CoreFoundation 0xa5824 __CFRunLoopRun + 1360 4 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 5 CoreFoundation 0xa5d10 CFRunLoopRun + 80 6 CoreMotion 0x74be8 (Missing UUID 6844e1347736340e90d826bc503c0b2c) 7 libsystem_pthread.dylib 0xb2c0 + 128 8 libsystem_pthread.dylib 0xb220 _pthread_start + 44 9 libsystem_pthread.dylib 0xecdc thread_start + 4 Thread 0 libsystem_kernel.dylib 0x180f4 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x175a0 mach_msg + 72 2 CoreFoundation 0xaa914 __CFRunLoopServiceMachPort + 236 3 CoreFoundation 0xa5824 __CFRunLoopRun + 1360 4 CoreFoundation 0xa4fb4 CFRunLoopRunSpecific + 436 5 TTSSpeechBundle 0x229e4 TTSSpeechServerCopyVoiceNamesForLanguage + 15328 6 libsystem_pthread.dylib 0xb2c0 + 128 7 libsystem_pthread.dylib 0xb220 _pthread_start + 44 8 libsystem_pthread.dylib 0xecdc thread_start + 4 com.google.fira.worker 0 libsystem_kernel.dylib 0x24408 fsync + 8 1 libsqlite3.dylib 0x6e3ec sqlite3_free_table + 67964 2 libsqlite3.dylib 0x78e2c sqlite3_randomness + 2284 3 libsqlite3.dylib 0x6dcf8 sqlite3_free_table + 66184 4 libsqlite3.dylib 0x58154 sqlite3_value_text + 23708 5 libsqlite3.dylib 0x23df4 sqlite3_finalize + 3636 6 libsqlite3.dylib 0x50b00 sqlite3_step + 65916 7 libsqlite3.dylib 0x40b40 sqlite3_step + 444 8 Runner 0xafe0c -[APMSqliteStore executeSQLStatement:error:] + 4295966220 9 Runner 0xae364 -[APMSqliteStore upsertRecord:inTableWithName:error:] + 4295959396 10 Runner 0x2aff4 -[APMDatabase upsertDataType:inTableWithName:columnName:columnValue:tableLimit:error:] + 4295421940 11 Runner 0x244e4 -[APMDatabase updateUserAttribute:error:] + 4295394532 12 Runner 0x543fc -[APMMeasurement setUserPropertyInDatabaseOnWorkerQueue:] + 4295590908 13 Runner 0x53e78 -[APMMeasurement setUserAttributeOnWorkerQueue:] + 4295589496 14 Runner 0x53e14 __35-[APMMeasurement setUserAttribute:]_block_invoke + 4295589396 15 Runner 0xa4ce4 __51-[APMScheduler scheduleOnWorkerQueueBlockID:block:]_block_invoke + 4295920868 16 libdispatch.dylib 0x5fa38 _dispatch_call_block_and_release + 24 17 libdispatch.dylib 0x607d4 _dispatch_client_callout + 16 18 libdispatch.dylib 0x9324 _dispatch_lane_serial_drain$VARIANT$mp + 592 19 libdispatch.dylib 0x9e40 _dispatch_lane_invoke$VARIANT$mp + 428 20 libdispatch.dylib 0x124ac _dispatch_workloop_worker_thread + 596 21 libsystem_pthread.dylib 0xc114 _pthread_wqthread + 304 22 libsystem_pthread.dylib 0xecd4 start_wqthread + 4 Thread 0 libsystem_pthread.dylib 0xecd0 + 190 Thread 0 libsystem_pthread.dylib 0xecd0 + 190 Thread 0 libsystem_pthread.dylib 0xecd0 + 190 Thread 0 libsystem_kernel.dylib 0x23b74 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0xc138 _pthread_wqthread + 340 2 libsystem_pthread.dylib 0xecd4 start_wqthread + 4 com.mixpanel.90bfb063754562d343006498d215c000.tracking) 0 libsystem_kernel.dylib 0x247f8 guarded_close_np + 8 1 libsqlite3.dylib 0x79468 sqlite3_randomness + 3880 2 libsqlite3.dylib 0x58ba4 sqlite3_value_text + 26348 3 libsqlite3.dylib 0x58580 sqlite3_value_text + 24776 4 libsqlite3.dylib 0x23e30 sqlite3_finalize + 3696 5 libsqlite3.dylib 0x50b00 sqlite3_step + 65916 6 libsqlite3.dylib 0x40b40 sqlite3_step + 444 7 Mixpanel 0x39bbc $s8Mixpanel4MPDBC9insertRow_4data4flagyAA15PersistenceTypeO_10Foundation4DataVSbtFySWXEfU_ + 488 8 Mixpanel 0x39984 $s8Mixpanel4MPDBC9insertRow_4data4flagyAA15PersistenceTypeO_10Foundation4DataVSbtF + 800 9 Mixpanel 0x42474 $s8Mixpanel5TrackC5track5event10properties11timedEvents15superProperties16mixpanelIdentity13epochIntervalSDySSypGSSSg_SDySSAA0A4Type_pGSgA2kA0aK0VSdtF + 2892 10 Mixpanel 0x26cd4 $s8Mixpanel0A8InstanceC5track5event10propertiesySSSg_SDySSAA0A4Type_pGSgtFyycfU_ + 624 11 Mixpanel 0x1f374 $sIeg_IeyB_TR + 28 12 libdispatch.dylib 0x5fa38 _dispatch_call_block_and_release + 24 13 libdispatch.dylib 0x607d4 _dispatch_client_callout + 16 14 libdispatch.dylib 0x9324 _dispatch_lane_serial_drain$VARIANT$mp + 592 15 libdispatch.dylib 0x9e40 _dispatch_lane_invoke$VARIANT$mp + 428 16 libdispatch.dylib 0x124ac _dispatch_workloop_worker_thread + 596 17 libsystem_pthread.dylib 0xc114 _pthread_wqthread + 304 18 libsystem_pthread.dylib 0xecd4 start_wqthread + 4 Thread 0 libsystem_pthread.dylib 0xecd0 + 190 Thread 0 libsystem_kernel.dylib 0x18148 semaphore_timedwait_trap + 8 1 libdispatch.dylib 0x2888 _dispatch_sema4_timedwait$VARIANT$mp + 64 2 libdispatch.dylib 0x31dc _dispatch_semaphore_wait_slow + 72 3 libdispatch.dylib 0x10df8 _dispatch_worker_thread + 352 4 libsystem_pthread.dylib 0xb2c0 + 128 5 libsystem_pthread.dylib 0xb220 _pthread_start + 44 6 libsystem_pthread.dylib 0xecdc thread_start + 4 Thread 0 libsystem_kernel.dylib 0x18148 semaphore_timedwait_trap + 8 1 libdispatch.dylib 0x2888 _dispatch_sema4_timedwait$VARIANT$mp + 64 2 libdispatch.dylib 0x31dc _dispatch_semaphore_wait_slow + 72 3 libdispatch.dylib 0x10df8 _dispatch_worker_thread + 352 4 libsystem_pthread.dylib 0xb2c0 + 128 5 libsystem_pthread.dylib 0xb220 _pthread_start + 44 6 libsystem_pthread.dylib 0xecdc thread_start + 4 Thread 0 libsystem_kernel.dylib 0x23b74 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0xc138 _pthread_wqthread + 340 2 libsystem_pthread.dylib 0xecd4 start_wqthread + 4 DartWorker 0 libsystem_kernel.dylib 0x22ee4 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x3d2c + 688 2 Flutter 0x62a8fc (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 3 Flutter 0x66b9a0 (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 4 Flutter 0x62a224 (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 5 libsystem_pthread.dylib 0xb2c0 + 128 6 libsystem_pthread.dylib 0xb220 _pthread_start + 44 7 libsystem_pthread.dylib 0xecdc thread_start + 4 DartWorker 0 libsystem_kernel.dylib 0x22ee4 __psynch_cvwait + 8 1 libsystem_pthread.dylib 0x3d2c + 688 2 Flutter 0x62a8fc (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 3 Flutter 0x66b9a0 (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 4 Flutter 0x62a224 (Missing UUID c5b43c20360b3122a6e867c5a3fd398d) 5 libsystem_pthread.dylib 0xb2c0 + 128 6 libsystem_pthread.dylib 0xb220 _pthread_start + 44 7 libsystem_pthread.dylib 0xecdc thread_start + 4 Thread 0 libsystem_kernel.dylib 0x18148 semaphore_timedwait_trap + 8 1 libdispatch.dylib 0x2888 _dispatch_sema4_timedwait$VARIANT$mp + 64 2 libdispatch.dylib 0x31dc _dispatch_semaphore_wait_slow + 72 3 libdispatch.dylib 0x10df8 _dispatch_worker_thread + 352 4 libsystem_pthread.dylib 0xb2c0 + 128 5 libsystem_pthread.dylib 0xb220 _pthread_start + 44 6 libsystem_pthread.dylib 0xecdc thread_start + 4 Thread 0 libsystem_kernel.dylib 0x23b74 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0xc1f8 _pthread_wqthread + 532 2 libsystem_pthread.dylib 0xecd4 start_wqthread + 4 Thread 0 libsystem_kernel.dylib 0x23b74 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0xc138 _pthread_wqthread + 340 2 libsystem_pthread.dylib 0xecd4 start_wqthread + 4 Thread 0 libsystem_kernel.dylib 0x23b74 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0xc138 _pthread_wqthread + 340 2 libsystem_pthread.dylib 0xecd4 start_wqthread + 4 Thread 0 libsystem_kernel.dylib 0x23b74 __workq_kernreturn + 8 1 libsystem_pthread.dylib 0xc138 _pthread_wqthread + 340 2 libsystem_pthread.dylib 0xecd4 start_wqthread + 4 ```

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.3.9, on macOS 12.6 21G115 darwin-arm, locale en-PT) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] VS Code (version 1.71.0) [✓] VS Code (version 1.70.2) [✓] Connected device (3 available) [✓] HTTP Host Availability • No issues found! ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 2.18.5 Flutter SDK 3.3.9 dependencies: - animations 2.0.3 [flutter] - async 2.9.0 [collection meta] - auto_size_text 3.0.0 [flutter] - bubble_tab_indicator 0.1.6 [flutter] - cached_network_image 3.2.3 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - chewie 1.0.0 [cupertino_icons flutter video_player wakelock] - clipboard 0.1.3 [flutter] - cloud_firestore 4.3.1 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - cloud_functions 4.0.7 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter] - collection 1.16.0 - connectivity_plus 2.2.2 [flutter connectivity_plus_platform_interface connectivity_plus_linux connectivity_plus_macos connectivity_plus_web connectivity_plus_windows] - device_info_plus 8.0.0 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32] - device_preview 1.1.0 [flutter flutter_localizations provider device_frame freezed_annotation json_annotation shared_preferences collection] - disk_space 0.2.1 [flutter] - dropdown_search 5.0.2 [flutter] - ffmpeg_kit_flutter_min_gpl 4.5.1 [ffmpeg_kit_flutter_platform_interface flutter] - firebase_analytics 10.1.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.2.5 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.4.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.0.11 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_database 10.0.9 [firebase_core firebase_core_platform_interface firebase_database_platform_interface firebase_database_web flutter] - firebase_dynamic_links 5.0.11 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_messaging 14.2.1 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_remote_config 3.0.9 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter] - firebase_storage 11.0.10 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - fl_chart 0.55.1 [flutter equatable] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] - flutter_facebook_auth 4.4.1 [flutter flutter_facebook_auth_platform_interface flutter_facebook_auth_web] - flutter_holo_date_picker 1.0.1 [flutter auto_size_text] - flutter_isolate 2.0.4 [flutter uuid] - flutter_local_notifications 9.9.1 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math] - flutter_native_timezone 2.0.0 [flutter_web_plugins flutter js] - flutter_rating_bar 4.0.0 [flutter] - flutter_slidable 0.6.0 [flutter] - flutter_spinkit 5.1.0 [flutter] - flutter_svg 1.1.6 [flutter meta path_drawing vector_math xml] - flutter_tts 3.6.3 [flutter flutter_web_plugins] - flutter_typeahead 4.0.0 [flutter flutter_keyboard_visibility] - flutterfire_ui 0.4.3+20 [cloud_firestore collection crypto desktop_webview_auth email_validator firebase_auth firebase_core firebase_database firebase_dynamic_links flutter flutter_facebook_auth flutter_localizations flutter_svg google_sign_in sign_in_with_apple twitter_login] - font_awesome_flutter 9.2.0 [flutter] - google_api_availability 3.0.1 [flutter meta] - google_sign_in 5.4.1 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web] - http 0.13.5 [async http_parser meta path] - image_cropper 3.0.0 [flutter image_cropper_platform_interface image_cropper_for_web] - image_picker 0.8.6 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface] - implicitly_animated_reorderable_list 0.4.2 [flutter async meta] - in_app_review 2.0.6 [flutter in_app_review_platform_interface] - in_app_update 3.0.0 [flutter] - intl 0.17.0 [clock path] - ios_volume_checker 0.0.1 [flutter] - just_audio 0.9.28 [just_audio_platform_interface just_audio_web audio_session rxdart path path_provider async uuid crypto meta flutter] - lint 1.5.3 - mixpanel_flutter 1.6.0 [flutter flutter_web_plugins js] - package_info_plus 3.0.1 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - path_provider 2.0.12 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - percent_indicator 4.2.2 [flutter] - permission_handler 7.2.0 [flutter meta permission_handler_platform_interface] - preload_page_view 0.1.6 [flutter] - provider 6.0.3 [collection flutter nested] - purchases_flutter 4.3.0 [flutter freezed_annotation json_annotation] - readmore 2.2.0 [flutter] - rxdart 0.27.3 - sensors 2.0.3 [flutter] - share_plus 3.0.4 [meta mime flutter share_plus_platform_interface share_plus_linux share_plus_macos share_plus_windows share_plus_web] - shared_preferences 2.0.5 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows] - shimmer 2.0.0 [flutter] - showcaseview 1.1.5 [flutter] - sign_in_with_apple 3.3.0 [flutter meta sign_in_with_apple_platform_interface sign_in_with_apple_web] - sliding_sheet 0.5.2 [flutter] - sliver_tools 0.2.5 [flutter] - universal_io 2.0.4 [collection crypto meta typed_data] - upgrader 5.1.0 [flutter device_info_plus html http os_detect package_info_plus shared_preferences url_launcher version xml] - url_launcher 6.1.6 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - version 3.0.2 - video_player 2.4.2 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web] - video_player_web_hls 0.1.11+4 [flutter flutter_web_plugins http meta video_player_platform_interface js] - visibility_detector 0.3.3 [flutter] - volume_control 0.1.5 [flutter] - wakelock 0.5.0+2 [flutter meta wakelock_macos wakelock_windows wakelock_platform_interface wakelock_web] - webview_flutter 2.0.7 [flutter] dev dependencies: - flutter_driver 0.0.0 [file flutter flutter_test fuchsia_remote_debug_protocol path meta vm_service webdriver archive async boolean_selector characters clock collection crypto matcher material_color_utilities platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - pedantic 1.11.1 dependency overrides: - provider 6.0.3 [collection flutter nested] - shared_preferences 2.0.5 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows] - wakelock 0.5.0+2 [flutter meta wakelock_macos wakelock_windows wakelock_platform_interface wakelock_web] transitive dependencies: - _flutterfire_internals 1.0.12 [collection firebase_core firebase_core_platform_interface flutter meta] - archive 3.3.0 [crypto path] - args 2.3.1 - audio_session 0.1.10 [flutter flutter_web_plugins rxdart meta] - boolean_selector 2.1.0 [source_span string_scanner] - cached_network_image_platform_interface 2.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.0.2 [flutter flutter_cache_manager cached_network_image_platform_interface] - characters 1.2.1 - clock 1.1.1 - cloud_firestore_platform_interface 5.10.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.2.1 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - cloud_functions_platform_interface 5.1.26 [firebase_core flutter meta plugin_platform_interface] - cloud_functions_web 4.3.15 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - connectivity_plus_linux 1.3.1 [flutter connectivity_plus_platform_interface meta nm] - connectivity_plus_macos 1.2.4 [connectivity_plus_platform_interface flutter] - connectivity_plus_platform_interface 1.2.1 [flutter meta plugin_platform_interface] - connectivity_plus_web 1.2.3 [connectivity_plus_platform_interface flutter_web_plugins flutter] - connectivity_plus_windows 1.2.2 [connectivity_plus_platform_interface flutter] - cross_file 0.3.3+2 [js meta] - crypto 3.0.2 [typed_data] - csslib 0.17.2 [source_span] - cupertino_icons 1.0.5 - dbus 0.7.8 [args ffi meta xml] - desktop_webview_auth 0.0.9 [crypto flutter http] - device_frame 1.1.0 [freezed_annotation flutter] - device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface] - email_validator 2.1.17 - equatable 2.0.5 [collection meta] - fake_async 1.3.1 [clock collection] - ffi 2.0.1 - ffmpeg_kit_flutter_platform_interface 0.2.1 [flutter plugin_platform_interface] - file 6.1.2 [meta path] - firebase_analytics_platform_interface 3.3.17 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.1+8 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 6.11.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.2.4 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.5.2 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.3.11 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_database_platform_interface 0.2.2+17 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_database_web 0.2.1+19 [firebase_core firebase_core_web firebase_database_platform_interface flutter flutter_web_plugins js] - firebase_dynamic_links_platform_interface 0.2.3+26 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 4.2.10 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.2.11 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_remote_config_platform_interface 1.1.29 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_remote_config_web 1.1.18 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins js] - firebase_storage_platform_interface 4.1.26 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.3.19 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - flutter_blurhash 0.7.0 [flutter] - flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_facebook_auth_platform_interface 3.2.0 [flutter plugin_platform_interface] - flutter_facebook_auth_web 3.2.0 [flutter flutter_web_plugins js flutter_facebook_auth_platform_interface] - flutter_keyboard_visibility 5.3.0 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_web flutter] - flutter_keyboard_visibility_platform_interface 2.0.0 [flutter meta plugin_platform_interface] - flutter_keyboard_visibility_web 2.0.0 [flutter_keyboard_visibility_platform_interface flutter_web_plugins flutter] - flutter_local_notifications_linux 0.5.1 [flutter flutter_local_notifications_platform_interface dbus path xdg_directories] - flutter_local_notifications_platform_interface 5.0.0 [flutter plugin_platform_interface] - flutter_plugin_android_lifecycle 2.0.7 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - freezed_annotation 2.1.0 [collection json_annotation meta] - fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform] - google_sign_in_android 6.1.1 [flutter google_sign_in_platform_interface] - google_sign_in_ios 5.5.0 [flutter google_sign_in_platform_interface] - google_sign_in_platform_interface 2.3.0 [flutter plugin_platform_interface quiver] - google_sign_in_web 0.10.2 [flutter flutter_web_plugins google_sign_in_platform_interface js] - html 0.15.1 [csslib source_span] - http_parser 4.0.1 [collection source_span string_scanner typed_data] - image_cropper_for_web 1.0.2 [flutter flutter_web_plugins image_cropper_platform_interface js] - image_cropper_platform_interface 3.0.2 [flutter plugin_platform_interface http] - image_picker_android 0.8.5+3 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 2.1.8 [flutter flutter_web_plugins image_picker_platform_interface] - image_picker_ios 0.8.6+1 [flutter image_picker_platform_interface] - image_picker_platform_interface 2.6.1 [cross_file flutter http plugin_platform_interface] - in_app_review_platform_interface 2.0.4 [flutter url_launcher plugin_platform_interface platform] - js 0.6.4 - json_annotation 4.6.0 [meta] - just_audio_platform_interface 4.2.0 [flutter plugin_platform_interface] - just_audio_web 0.4.7 [just_audio_platform_interface flutter flutter_web_plugins] - matcher 0.12.12 [stack_trace] - material_color_utilities 0.1.5 - meta 1.8.0 - mime 1.0.2 - nested 1.0.0 [flutter] - nm 0.5.0 [dbus] - octo_image 1.0.2 [flutter flutter_blurhash] - os_detect 2.0.1 - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path 1.8.2 - path_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [vector_math meta] - path_provider_android 2.0.20 [flutter path_provider_platform_interface] - path_provider_foundation 2.1.1 [flutter path_provider_platform_interface] - path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.0.4 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.3 [ffi flutter path path_provider_platform_interface win32] - permission_handler_platform_interface 3.7.0 [flutter meta plugin_platform_interface] - petitparser 5.0.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.1.3 [meta] - process 4.2.4 [file path platform] - quiver 3.1.0 [matcher] - share_plus_linux 2.0.4 [share_plus_platform_interface file flutter meta url_launcher] - share_plus_macos 2.1.0 [share_plus_platform_interface flutter] - share_plus_platform_interface 2.1.0 [flutter meta mime plugin_platform_interface] - share_plus_web 2.0.4 [share_plus_platform_interface url_launcher flutter flutter_web_plugins meta] - share_plus_windows 2.0.3 [share_plus_platform_interface flutter meta url_launcher] - shared_preferences_linux 2.1.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_macos 2.0.4 [flutter shared_preferences_platform_interface] - shared_preferences_platform_interface 2.1.0 [flutter plugin_platform_interface] - shared_preferences_web 2.0.4 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.1.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - sign_in_with_apple_platform_interface 1.0.0 [flutter plugin_platform_interface meta] - sign_in_with_apple_web 1.0.1 [flutter flutter_web_plugins sign_in_with_apple_platform_interface js] - sky_engine 0.0.99 - source_span 1.9.0 [collection path term_glyph] - sqflite 2.0.3+1 [flutter sqflite_common path] - sqflite_common 2.2.1+1 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.1 [source_span] - sync_http 0.3.1 - synchronized 3.0.0+3 - term_glyph 1.2.1 - test_api 0.4.12 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.8.0 [path] - twitter_login 4.2.3 [flutter crypto http] - typed_data 1.3.1 [collection] - url_launcher_android 6.0.19 [flutter url_launcher_platform_interface] - url_launcher_ios 6.0.17 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.1 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.0 [flutter plugin_platform_interface] - url_launcher_web 2.0.13 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface] - uuid 3.0.6 [crypto] - vector_math 2.1.2 - video_player_android 2.3.9 [flutter video_player_platform_interface] - video_player_avfoundation 2.3.5 [flutter video_player_platform_interface] - video_player_platform_interface 5.1.4 [flutter plugin_platform_interface] - video_player_web 2.0.12 [flutter flutter_web_plugins video_player_platform_interface] - vm_service 9.0.0 - wakelock_macos 0.1.0+3 [flutter flutter_web_plugins wakelock_platform_interface] - wakelock_platform_interface 0.2.1+3 [flutter meta] - wakelock_web 0.2.0+3 [flutter flutter_web_plugins js wakelock_platform_interface] - wakelock_windows 0.1.0+2 [flutter wakelock_platform_interface win32] - webdriver 3.0.0 [archive matcher path stack_trace sync_http] - win32 2.7.0 [ffi] - xdg_directories 0.2.0+2 [meta path process] - xml 6.1.0 [collection meta petitparser] ```

darshankawar commented 1 year ago

For this issue:

[FLTDocumentSnapshotStreamHandler onListenWithArguments:eventSink:] + 46 (FLTDocumentSnapshotStreamHandler.m:46)

Which is different from https://github.com/firebase/flutterfire/issues/10503, so keeping this issue open for team's attention.

russellwheatley commented 1 year ago

Hey @TiagoAraujo54, we're going to need more information than what you've provided. This is coming from the native side. My guess is you're trying to initialise Firestore again somewhere, or even trying to call Firestore from native code, not Flutter. Hard to tell without further information so please eliminate anything I've already mentioned and try to provide some form of reproduction. Thanks.

RobertOdrowaz commented 1 year ago

I believe I've encountered the same issue. It seems to be caused by premature termination of firestore for all threads when any of them is terminated.

In iOS implementation detachFromEngineForRegistrar callback calls a cleanupWithCompletion method and this method terminates firestore for all apps

NSUInteger numberOfApps = [[FIRApp allApps] count];
  void (^firestoreTerminateInstanceCompletion)(NSError *) = ^void(NSError *error) {
    instancesTerminated++;
    if (instancesTerminated == numberOfApps && completion != nil) {
      completion();
    }
  };

  if (numberOfApps > 0) {
    for (NSString *appName in [FIRApp allApps]) {
      FIRApp *app = [FIRApp appNamed:appName];
      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
        [[FIRFirestore firestoreForApp:app] terminateWithCompletion:^(NSError *error) {
          [FLTFirebaseFirestoreUtils destroyCachedFIRFirestoreInstanceForKey:appName];
          firestoreTerminateInstanceCompletion(error);
        }];
      });
    }
  } else {
    if (completion != nil) completion();
  }

In contrast in android implementation onDetachedFromEngine calls removeEventListeners which is equivalent to first part of cleanupWithCompletion on iOS. The firestore termination across all apps is only done in didReinitializeFirebaseCore

TaskCompletionSource<Void> taskCompletionSource = new TaskCompletionSource<>();

    cachedThreadPool.execute(
        () -> {
          try {
            // Context is ignored by API so we don't send it over even though annotated non-null.

            for (FirebaseApp app : FirebaseApp.getApps(null)) {
              FirebaseFirestore firestore = FirebaseFirestore.getInstance(app);
              Tasks.await(firestore.terminate());
              FlutterFirebaseFirestorePlugin.destroyCachedFirebaseFirestoreInstanceForKey(
                  app.getName());
            }

            removeEventListeners();

            taskCompletionSource.setResult(null);
          } catch (Exception e) {
            taskCompletionSource.setException(e);
          }
        });

    return taskCompletionSource.getTask();

Here is a workaround in which number of attached plugins is tracked and firestore for all apps is terminated only after last plugin has been detached. Probably the android implementation is correct and the apps don't need to be terminated at on plugin detach at all but I don't have time to get into it deep enough to be sure.

russellwheatley commented 1 year ago

Hey @RobertOdrowaz, thanks for the insight 👍. I've made a PR based on your observation and my own checks. I'd be grateful for you to take a look and see if it aligns with your experience. Thanks.

RobertOdrowaz commented 1 year ago

Yep, separating the cleanup like this should resolve the issue

google-oss-bot commented 1 year ago

Hey @TiagoAraujo54. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

TiagoAraujo54 commented 1 year ago

Any updates on this?