Skip to content

[cloud_firestore]: iOS app crash #13515

@Ovidiu-S

Description

@Ovidiu-S

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Other

Which platforms are affected?

iOS

Description

We have a Firestore collection that updates often.
After upgrading our build server to iOS 18 we started getting random crash reports from different users, all related to firestore and memory

Reproducing the issue

Stream<List<ItemResponse>> getItemsStream() async* {
    try {
      final stream = _fireStoreInstance.collection(ItemsCollection).snapshots();
      await for (final snapshot in stream) {
        if (_isAppPaused) {
          break;
        }
        final docChanges = snapshot.docChanges;
        final List<ItemResponse> Items = [];
        for (final documentChange in docChanges) {
          final data = documentChange.doc.data();
          if (data != null) {
            try {
              final Map<String, dynamic> json = data;
              final ItemResponse Item = ItemResponse.fromJson(json);
              Items.add(Item);
            } catch (e, s) {
              ErrorLogger.logError(
                e,
                s,
                reason:
                    'Item not added from firebase stream due to parsing error: $data',
              );
            }
          }
        }
        yield Items;
      }
    } catch (e, s) {
      throw ErrorLogger.logError(
        e,
        s,
        reason: 'Getting Items stream from Firestore failed.',
      );
    }
  }

Firebase Core version

3.6.0

Flutter Version

3.24.3

Relevant Log Output

Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0xc2ec __pthread_kill + 8
1  libsystem_pthread.dylib        0x7c0c pthread_kill + 268
2  libsystem_c.dylib              0x75ba0 abort + 180
3  libsystem_malloc.dylib         0x9588 malloc_vreport + 896
4  libsystem_malloc.dylib         0x6430 malloc_zone_error + 104
5  libsystem_malloc.dylib         0x20a80 free_list_checksum_botch + 40
6  libsystem_malloc.dylib         0xc47c small_free_list_remove_ptr_no_clear + 960
7  libsystem_malloc.dylib         0xc7a8 free_small + 604
8  FirebaseFirestoreInternal      0x3c6b0 std::__1::deque<firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty> const*, std::__1::allocator<firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty> const*>>::~deque[abi:ne180100]() + 569 (deque:569)
9  FirebaseFirestoreInternal      0x3c908 firebase::firestore::util::iterator_first<firebase::firestore::immutable::impl::SortedMapIterator<std::__1::pair<firebase::firestore::model::Document, firebase::firestore::util::Empty>, std::__1::pair<firebase::firestore::model::Document, firebase::firestore::util::Empty> const*, firebase::firestore::immutable::impl::LlrbNodeIterator<firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty>>>>::iterator_first(firebase::firestore::immutable::impl::SortedMapIterator<std::__1::pair<firebase::firestore::model::Document, firebase::firestore::util::Empty>, std::__1::pair<firebase::firestore::model::Document, firebase::firestore::util::Empty> const*, firebase::firestore::immutable::impl::LlrbNodeIterator<firebase::firestore::immutable::impl::LlrbNode<firebase::firestore::model::Document, firebase::firestore::util::Empty>>>) + 564 (deque:564)
10 FirebaseFirestoreInternal      0x3e894 firebase::firestore::immutable::SortedSet<firebase::firestore::model::Document, firebase::firestore::model::DocumentComparator>::begin() const + 75 (sorted_map_iterator.h:75)
11 FirebaseFirestoreInternal      0x10f9a0 firebase::firestore::api::QuerySnapshot::ForEachDocument(std::__1::function<void (firebase::firestore::api::DocumentSnapshot)> const&) const + 89 (document_set.h:89)
12 FirebaseFirestoreInternal      0x838c4 -[FIRQuerySnapshot documents] + 112 (FIRQuerySnapshot.mm:112)
13 Runner                         0xaaf114 __65-[FLTQuerySnapshotStreamHandler onListenWithArguments:eventSink:]_block_invoke.11 + 67 (FLTQuerySnapshotStreamHandler.m:67)
14 libdispatch.dylib              0x213c _dispatch_call_block_and_release + 32
15 libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
16 libdispatch.dylib              0x125a4 _dispatch_main_queue_drain + 988
17 libdispatch.dylib              0x121b8 _dispatch_main_queue_callback_4CF + 44
18 CoreFoundation                 0x56710 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
19 CoreFoundation                 0x53914 __CFRunLoopRun + 1996
20 CoreFoundation                 0x52cd8 CFRunLoopRunSpecific + 608
21 GraphicsServices               0x11a8 GSEventRunModal + 164
22 UIKitCore                      0x40aae8 -[UIApplication _run] + 888
23 UIKitCore                      0x4bed98 UIApplicationMain + 340
24 UIKitCore                      0x638504 keypath_get_selector_hoverStyle + 11024
25 Runner                         0x8a90 main + 4308650640 (AppDelegate.swift:4308650640)
26 ???                            0x1bceb3154 (Missing)

Flutter dependencies

Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.

Additional context and comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions