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.71k stars 3.97k forks source link

🐛 [cloud_firestore] Data loading issue in cloud_firestore dependancy #11935

Closed sumittiware closed 11 months ago

sumittiware commented 11 months ago

Bug report

Describe the bug We have noticed a strange bug in cloud_firestore dependency, we have created an in-house chat community using cloud_firestore, now if the user has an app installed for long time(i.e. if they didn't uninstall or clear app data for long time), then loading data from cloud_firestore takes long time, we have already tested the network it was woking fine as other api's apart from the firestore once are fast. But when we asked user to clear app data and then open the app again, then the data was loaded quickly. Not sure if this is some kind if cache issue in the dependency, also clearing app cache didn't work. We have to either clear data or completely uninstall the app.

Please need help here!

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [✓] Flutter (Channel stable, 3.10.5, on macOS 14.1.1 23B81 darwin-arm64, locale en-IN) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] VS Code (version 1.84.2) [✓] Connected device (2 available) [✓] Network resources • No issues found! ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 3.0.5 Flutter SDK 3.10.5 app 4.6.8+291 dependencies: - android_path_provider 0.3.0 [flutter] - any_link_preview 3.0.0 [flutter html http shared_preferences string_validator url_launcher] - audio_session 0.1.13 [flutter flutter_web_plugins rxdart meta] - cached_network_image 3.3.0 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image] - camera 0.10.3+2 [camera_android camera_avfoundation camera_platform_interface camera_web flutter flutter_plugin_android_lifecycle quiver] - carousel_slider 4.2.1 [flutter] - clippy_flutter 2.0.0-nullsafety.1 [flutter] - cloud_firestore 4.9.3 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - collection 1.17.1 - confetti 0.7.0 [flutter vector_math] - connectivity_plus 2.3.9 [flutter connectivity_plus_platform_interface connectivity_plus_linux connectivity_plus_macos connectivity_plus_web connectivity_plus_windows] - country_code_picker 3.0.0 [flutter collection] - crypto 3.0.3 [typed_data] - dartz 0.10.1 - debounce_throttle 2.0.0 [meta simple_observable] - device_info_plus 8.1.0 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32] - dio 4.0.6 [http_parser path] - dots_indicator 2.1.0 [flutter] - emoji_picker_flutter 1.5.2 [flutter flutter_web_plugins plugin_platform_interface shared_preferences] - equatable 2.0.5 [collection meta] - expandable_text 2.3.0 [flutter] - facebook_app_events 0.13.5 [flutter] - figma_squircle 0.5.3 [vector_math flutter] - file_picker 5.3.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32] - firebase_analytics 10.1.5 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_core 2.17.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.3.7 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_dynamic_links 5.0.16 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_messaging 14.6.9 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_storage 11.2.8 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flick_video_player 0.5.0 [flutter video_player provider wakelock_plus universal_html dio path_provider] - flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine] - flutter_cache_manager 3.3.1 [clock collection file flutter http path path_provider rxdart sqflite uuid] - flutter_cached_pdfview 0.4.2 [flutter flutter_pdfview flutter_cache_manager path_provider path] - flutter_dotenv 5.0.2 [flutter] - flutter_downloader 1.10.4 [flutter] - flutter_inappwebview 5.7.2+3 [flutter] - flutter_local_notifications 9.7.0 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math] - flutter_mobx 2.0.6+5 [flutter mobx] - flutter_modular 5.0.3 [flutter_modular_annotations modular_core meta flutter] - flutter_parsed_text 2.2.1 [flutter] - flutter_rating_bar 4.0.1 [flutter] - flutter_screenutil 5.7.0 [flutter] - flutter_sound 9.2.13 [path_provider recase uuid provider path synchronized logger flutter flutter_sound_platform_interface flutter_sound_web] - flutter_svg 1.1.6 [flutter meta path_drawing vector_math xml] - freezed_annotation 2.2.0 [collection json_annotation meta] - gallery_saver 2.3.2 [flutter path_provider http path] - get_it 7.2.0 [async collection] - growthbook_sdk_flutter 2.1.0+0 [dio flutter json_annotation tuple] - image_picker 0.8.7 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface] - in_app_purchase 3.1.5 [flutter in_app_purchase_android in_app_purchase_platform_interface in_app_purchase_storekit] - in_app_update 4.0.1 [flutter] - injectable 1.5.4 [get_it] - intl 0.18.0 [clock meta path] - json_annotation 4.7.0 [meta] - liquid_swipe 3.0.0 [flutter provider] - logging 1.1.0 - lottie 2.5.0 [archive flutter path vector_math] - media_info 0.11.0 [mime flutter] - mime 1.0.4 - mobx 2.2.0 [meta] - nb_utils 4.6.21 [flutter shared_preferences fluttertoast connectivity_plus] - ntp 2.0.0 - open_filex 4.3.2 [flutter ffi] - package_info_plus 4.2.0 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - path_provider 2.0.13 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - percent_indicator 4.2.3 [flutter] - permission_handler 10.2.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - photo_view 0.14.0 [flutter] - provider 6.0.5 [collection flutter nested] - razorpay_flutter 1.3.5 [flutter eventify fluttertoast package_info_plus] - receive_sharing_intent 1.4.5 [flutter] - rich_text_controller 1.4.2 [flutter] - scrollable_positioned_list 0.3.8 [flutter collection] - share_plus 7.0.0 [cross_file meta mime flutter flutter_web_plugins share_plus_platform_interface file url_launcher_web url_launcher_windows url_launcher_linux url_launcher_platform_interface ffi win32] - sliver_tools 0.2.12 [flutter] - sms_autofill 2.3.0 [pin_input_text_field flutter] - sticky_headers 0.3.0+2 [flutter] - swipe_plus 0.8.1 [flutter] - synchronized 3.0.0+3 - upgrader 6.5.0 [flutter device_info_plus html http os_detect package_info_plus shared_preferences url_launcher version xml] - url_launcher 6.1.10 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - uuid 3.0.7 [crypto] - video_compress 3.1.1 [flutter] - video_thumbnail 0.5.3 [flutter] - visibility_detector 0.3.3 [flutter] - webengage_flutter 1.2.4 [flutter] - win32 4.1.4 [ffi] dev dependencies: - analyzer 5.13.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - build_runner 2.3.3 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - cloud_firestore_odm_generator 1.0.0-dev.45 [analyzer build build_config cloud_firestore_odm collection freezed_annotation json_annotation meta recase source_gen] - dart_code_metrics 5.7.5 [analyzer analyzer_plugin ansicolor args collection crypto dart_code_metrics_presets file glob html http meta path platform pub_updater source_span uuid xml yaml] - dependency_validator 3.2.2 [args build_config checked_yaml glob io json_annotation logging package_config path pub_semver pubspec_parse yaml] - flutter_launcher_icons 0.11.0 [args checked_yaml cli_util image json_annotation path yaml] - flutter_lints 2.0.1 [lints] - flutter_native_splash 2.2.9 [args flutter flutter_web_plugins html image js lint meta path universal_io xml yaml] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - freezed 2.2.0 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation] - injectable_generator 1.5.5 [build source_gen path glob analyzer code_builder dart_style injectable collection] - json_serializable 6.5.4 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper] - mobx_codegen 2.1.1 [analyzer build build_resolvers meta mobx path source_gen] - modular_test 2.0.0 [modular_core] - translations_cleaner 0.0.5 [args glob] dependency overrides: - fluttertoast 8.0.9 [flutter flutter_web_plugins] - modal_bottom_sheet 3.0.0-pre [flutter] transitive dependencies: - _fe_analyzer_shared 61.0.0 [meta] - _flutterfire_internals 1.3.7 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer_plugin 0.11.2 [analyzer collection dart_style pub_semver yaml] - ansicolor 2.0.1 - archive 3.3.6 [crypto path pointycastle] - args 2.3.1 - async 2.11.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - build 2.3.1 [analyzer async convert crypto glob logging meta path] - build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 3.1.1 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.10 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.7 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.4.4 [built_collection collection fixnum meta] - cached_network_image_platform_interface 3.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.1.0 [cached_network_image_platform_interface flutter flutter_cache_manager] - camera_android 0.10.7 [camera_platform_interface flutter flutter_plugin_android_lifecycle stream_transform] - camera_avfoundation 0.9.11+1 [camera_platform_interface flutter stream_transform] - camera_platform_interface 2.5.0 [cross_file flutter plugin_platform_interface stream_transform] - camera_web 0.3.1+3 [camera_platform_interface flutter flutter_web_plugins stream_transform] - characters 1.3.0 - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - cli_util 0.3.5 [meta path] - clock 1.1.1 - cloud_firestore_odm 1.0.0-dev.51 [cloud_firestore flutter json_annotation meta] - cloud_firestore_platform_interface 5.16.2 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.7.2 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.4.0 [built_collection built_value collection matcher meta] - connectivity_plus_linux 1.3.1 [flutter connectivity_plus_platform_interface meta nm] - connectivity_plus_macos 1.2.6 [connectivity_plus_platform_interface flutter] - connectivity_plus_platform_interface 1.2.4 [flutter meta plugin_platform_interface] - connectivity_plus_web 1.2.5 [connectivity_plus_platform_interface flutter_web_plugins flutter js] - connectivity_plus_windows 1.2.2 [connectivity_plus_platform_interface flutter] - convert 3.1.0 [typed_data] - cross_file 0.3.3+4 [js meta] - csslib 0.17.2 [source_span] - dart_code_metrics_presets 1.8.0 - dart_style 2.2.4 [analyzer args path pub_semver source_span] - dbus 0.7.8 [args ffi meta xml] - device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface] - eventify 1.0.1 - fake_async 1.3.1 [clock collection] - ffi 2.0.1 - file 6.1.4 [meta path] - firebase_analytics_platform_interface 3.3.22 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.1+13 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.8.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.6.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_dynamic_links_platform_interface 0.2.3+31 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 4.5.8 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.5.8 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 4.4.7 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.6.8 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 1.0.1 - 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_modular_annotations 0.0.2 [flutter] - flutter_pdfview 1.2.5 [flutter] - flutter_plugin_android_lifecycle 2.0.9 [flutter] - flutter_sound_platform_interface 9.2.13 [flutter meta plugin_platform_interface logger] - flutter_sound_web 9.2.13 [flutter_sound_platform_interface flutter logger flutter_web_plugins meta js] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - frontend_server_client 3.2.0 [async path] - glob 2.1.1 [async collection file path string_scanner] - graphs 2.2.0 [collection] - html 0.15.2 [csslib source_span] - http 0.13.5 [async http_parser meta path] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image 3.3.0 [archive meta xml] - image_picker_android 0.8.6+1 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 2.1.12 [flutter flutter_web_plugins image_picker_platform_interface] - image_picker_ios 0.8.6+9 [flutter image_picker_platform_interface] - image_picker_platform_interface 2.6.3 [cross_file flutter http plugin_platform_interface] - in_app_purchase_android 0.2.4+3 [collection flutter in_app_purchase_platform_interface json_annotation] - in_app_purchase_platform_interface 1.3.3 [flutter plugin_platform_interface] - in_app_purchase_storekit 0.3.5+2 [collection flutter in_app_purchase_platform_interface json_annotation] - io 1.0.4 [meta path string_scanner] - js 0.6.7 [meta] - lint 1.10.0 - lints 2.0.1 - logger 1.3.0 - matcher 0.12.15 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.2.0 - meta 1.9.1 - modular_core 2.0.3+1 [characters meta modular_interfaces] - modular_interfaces 2.0.2 - nested 1.0.0 [flutter] - nm 0.5.0 [dbus] - octo_image 2.0.0 [flutter] - os_detect 2.0.1 - package_config 2.1.0 [path] - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path 1.8.3 - path_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [vector_math meta] - path_provider_android 2.0.24 [flutter path_provider_platform_interface] - path_provider_foundation 2.1.3 [flutter path_provider_platform_interface] - path_provider_linux 2.1.10 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.0.6 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.7 [ffi flutter path path_provider_platform_interface win32] - permission_handler_android 10.2.0 [flutter permission_handler_platform_interface] - permission_handler_apple 9.0.7 [flutter permission_handler_platform_interface] - permission_handler_platform_interface 3.9.0 [flutter meta plugin_platform_interface] - permission_handler_windows 0.1.2 [flutter permission_handler_platform_interface] - petitparser 5.0.0 [meta] - pin_input_text_field 4.4.1 [flutter] - platform 3.1.0 - plugin_platform_interface 2.1.4 [meta] - pointycastle 3.6.2 [collection convert js] - pool 1.5.1 [async stack_trace] - process 4.2.4 [file path platform] - pub_semver 2.1.3 [collection meta] - pub_updater 0.3.0 [http json_annotation process pub_semver] - pubspec_parse 1.2.1 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.2.1 [matcher] - recase 4.1.0 - rxdart 0.27.7 - share_plus_platform_interface 3.2.1 [cross_file flutter meta mime plugin_platform_interface path_provider uuid] - shared_preferences 2.0.18 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - shared_preferences_android 2.0.17 [flutter shared_preferences_platform_interface] - shared_preferences_foundation 2.1.5 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.1.5 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_platform_interface 2.1.1 [flutter plugin_platform_interface] - shared_preferences_web 2.0.6 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.1.5 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.4.0 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.3 [shelf stream_channel web_socket_channel] - simple_observable 2.0.0 [meta] - sky_engine 0.0.99 - source_gen 1.2.6 [analyzer async build dart_style glob meta path source_span yaml] - source_helper 1.3.3 [analyzer collection source_gen] - source_span 1.9.1 [collection path term_glyph] - sqflite 2.3.0 [flutter sqflite_common path] - sqflite_common 2.5.0 [synchronized path meta] - stack_trace 1.11.0 [path] - stream_channel 2.1.1 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - string_validator 0.3.0 - term_glyph 1.2.1 - test_api 0.5.1 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.8.0 [path] - timing 1.0.1 [json_annotation] - tuple 2.0.1 - typed_data 1.3.1 [collection] - universal_html 2.2.1 [async csslib charcode collection html meta source_span typed_data universal_io] - universal_io 2.2.0 [collection meta typed_data] - url_launcher_android 6.0.25 [flutter url_launcher_platform_interface] - url_launcher_ios 6.0.18 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.6 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.4 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.2 [flutter plugin_platform_interface] - url_launcher_web 2.0.16 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.8 [flutter url_launcher_platform_interface] - vector_math 2.1.4 - version 3.0.2 - video_player 2.6.0 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web] - video_player_android 2.4.1 [flutter video_player_platform_interface] - video_player_avfoundation 2.3.9 [flutter video_player_platform_interface] - video_player_platform_interface 6.0.2 [flutter plugin_platform_interface] - video_player_web 2.0.15 [flutter flutter_web_plugins video_player_platform_interface] - wakelock_plus 1.1.3 [flutter flutter_web_plugins meta wakelock_plus_platform_interface win32 dbus package_info_plus js] - wakelock_plus_platform_interface 1.1.0 [flutter plugin_platform_interface meta] - watcher 1.0.2 [async path] - web_socket_channel 2.3.0 [async crypto stream_channel] - xdg_directories 0.2.0+3 [meta path process] - xml 6.1.0 [collection meta petitparser] - yaml 3.1.1 [collection source_span string_scanner] ```

danagbemava-nc commented 11 months ago

Hi @sumittiware, can you try upgrading to the latest version of `cloud_firestore to see if you still have this issue?

Also, is this only on android or is iOS affected as well?

Do you have any cache settings enabled in your project?

How are you loading your data? In batches or all at once?

Can you also see https://stackoverflow.com/a/72393014 for some tips that might help?

sumittiware commented 11 months ago

Hi @danagbemava-nc thank you for the response!

Sure will try updating the dependency, but I couldn’t find anything that can be related to this in the change-log. For now we have noticed this only with the Android. Persistance settings are by default enables in the android and IOS projects, I haven't changed that. So it should be enable. We are loading our data in batches.

sumittiware commented 11 months ago
static Query<MessageEntity> getAllGroupChatMessagesQuery(String groupId) {
    final SharedPreferenceHelper sharedPreferenceHelper =
        GetIt.I.get<SharedPreferenceHelper>();
    final String currentUserId = sharedPreferenceHelper.userId;
    return FirebaseFirestore.instance
        .collection(DbPaths.collectiongroups)
        .doc(groupId)
        .collection(DbPaths.subCollectionGroupChats)
        .where(DbKeys.recipientList, arrayContainsAny: [
      "0",
      currentUserId
    ]).withConverter<MessageEntity>(
      fromFirestore: (DocumentSnapshot<Map<String, dynamic>> doc,
          SnapshotOptions? options) {
        try {
          MessageEntity.fromJson(doc.data() ?? {});
        } catch (error, stackTrace) {
          FirebaseCrashlytics.instance
              .recordError(error, stackTrace, reason: "${doc.data() ?? {}}");
        }
        return MessageEntity.fromJson(doc.data() ?? {})
            .copyWith(messageId: doc.id);
      },
      toFirestore: (MessageEntity value, SetOptions? options) => value.toJson(),
    );
  }

@danagbemava-nc this is the query we are using to fetch the data. but this is a batched query.

danagbemava-nc commented 11 months ago

Hi @sumittiware, how long does it usually take before you start experiencing this issue? And approximately, how many items are loaded from cloud_firestore when the bug starts appearing?

Also, can you share the structure of the messages? Is it deeply nested or not?

sumittiware commented 11 months ago

Hi @danagbemava-nc, It is noticeable if the users is having the app from more than 15-20 days, to fetching chats we also have some index in firestore.

image

And the structure of our message object looks like this


@firestoreSerializable
class MessageEntity {
  MessageEntity({
    this.content = '',
    this.contentV2,
    this.contentV3,
    this.type = MessageType.unsupported,
    this.typeV2 = MessageType.unsupported,
    this.status,
    this.timestamp = 0,
    this.senderName = '',
    this.isDeleted = false,
    this.isForwarded = false,
    this.isRepliedMessage = false,
    this.repliedMessage,
    this.groupName,
    this.groupId,
    this.groupIdFiltered = '',
    this.senderUserId,
    this.senderPhNo,
    this.caption,
    this.localpath,
    this.messageId,
    this.messageAttachment,
    this.isRemoved = false,
    this.recipients = const <String>['0'],
    this.shouldShowPrivate = true,
    this.senderRole = UserRole.NON_ADMIN,
    this.minRequiredVersion,
    this.supportedBackwardCompatibilityVersion,
    this.pinned = false,
    this.pinnedBy,
    this.pinnedAt,
    this.templateName,
    this.videoPlaybackTime,
    this.isChapter = false,
    this.chapterName,
    this.sessionLogBusinessType,
    this.sessionLogBusinessPayload,
    this.deviceInfo,
  });

  factory MessageEntity.fromJson(Map<String, dynamic> json) =>
      _$MessageEntityFromJson(json);
  final String content;
  final String? contentV2;
  @MessageContentV3Converter()
  MessageContentV3? contentV3;
  final bool isDeleted;
  final int timestamp;
  @MessageTypeConverter()
  final MessageType type;
  @MessageTypeConverter()
  final MessageType typeV2;
  @MessageStatusConverter()
  final MessageStatus? status;
  @JsonKey(name: 'name')
  final String? groupName;
  @JsonKey(name: 'id')
  final String? groupId;
  @JsonKey(name: 'sname')
  final String senderName;
  @JsonKey(name: 'iDfltrd')
  final String groupIdFiltered;
  @JsonKey(name: 'isReply')
  final bool isRepliedMessage;
  final bool isForwarded;
  @JsonKey(name: 'replyToMsgDoc')
  @MessageEntityConverter()
  MessageEntity? repliedMessage;
  final String? senderUserId;
  @JsonKey(name: 'sendby')
  final String? senderPhNo;
  final UserRole senderRole;
  final String? caption;
  final String? localpath;
  String? messageId;
  bool isRemoved;
  @JsonKey(name: 'attachment')
  @MessageAttachmentConverter()
  final MessageAttachment? messageAttachment;
  List<String> recipients;
  bool shouldShowPrivate;
  final int? minRequiredVersion;
  final int? supportedBackwardCompatibilityVersion;
  final bool pinned;
  final String? pinnedBy;
  final int? pinnedAt;
  final String? templateName;
  final double? videoPlaybackTime;
  final bool isChapter;
  final String? chapterName;
  final String? sessionLogBusinessType;
  final String? sessionLogBusinessPayload;
  final SenderDeviceInfo? deviceInfo;

  void refreshMessageState() {
    isRemoved = true;
  }

  void setReplyDoc(MessageEntity? newDoc) {
    repliedMessage = newDoc;
  }

  Map<String, dynamic> toJson() => _$MessageEntityToJson(this);

  MessageEntity copyWith(
      {String? content,
      String? contentV2,
      MessageContentV3? contentV3,
      bool? isDeleted,
      int? timestamp,
      MessageType? type,
      MessageType? typeV2,
      MessageStatus? status,
      String? groupName,
      String? groupId,
      String? senderName,
      String? groupIdFiltered,
      bool? isRepliedMessage,
      bool? isForwarded,
      MessageEntity? repliedMessage,
      String? senderUserId,
      String? senderPhNo,
      UserRole? senderRole,
      String? caption,
      String? localpath,
      String? messageId,
      bool? isRemoved,
      MessageAttachment? messageAttachment,
      List<String>? recipients,
      bool? shouldShowPrivate,
      int? minRequiredVersion,
      int? supportedBackwardCompatibilityVersion,
      bool? pinned,
      String? pinnedBy,
      int? pinnedAt,
      String? templateName,
      double? videoPlaybackTime,
      bool? isChapter,
      String? chapterName,
      SenderDeviceInfo? deviceInfo}) {
    return MessageEntity(
      content: content ?? this.content,
      contentV2: contentV2 ?? this.contentV2,
      contentV3: contentV3 ?? this.contentV3,
      isDeleted: isDeleted ?? this.isDeleted,
      timestamp: timestamp ?? this.timestamp,
      type: type ?? this.type,
      typeV2: typeV2 ?? this.typeV2,
      status: status ?? this.status,
      groupName: groupName ?? this.groupName,
      groupId: groupId ?? this.groupId,
      senderName: senderName ?? this.senderName,
      groupIdFiltered: groupIdFiltered ?? this.groupIdFiltered,
      isRepliedMessage: isRepliedMessage ?? this.isRepliedMessage,
      isForwarded: isForwarded ?? this.isForwarded,
      repliedMessage: repliedMessage ?? this.repliedMessage,
      senderUserId: senderUserId ?? this.senderUserId,
      senderPhNo: senderPhNo ?? this.senderPhNo,
      senderRole: senderRole ?? this.senderRole,
      caption: caption ?? this.caption,
      localpath: localpath ?? this.localpath,
      messageId: messageId ?? this.messageId,
      isRemoved: isRemoved ?? this.isRemoved,
      messageAttachment: messageAttachment ?? this.messageAttachment,
      recipients: recipients ?? this.recipients,
      shouldShowPrivate: shouldShowPrivate ?? this.shouldShowPrivate,
      minRequiredVersion: minRequiredVersion ?? this.minRequiredVersion,
      supportedBackwardCompatibilityVersion:
          supportedBackwardCompatibilityVersion ??
              this.supportedBackwardCompatibilityVersion,
      pinned: pinned ?? this.pinned,
      pinnedBy: pinnedBy ?? this.pinnedBy,
      pinnedAt: pinnedAt ?? this.pinnedAt,
      templateName: templateName ?? this.templateName,
      videoPlaybackTime: videoPlaybackTime ?? this.videoPlaybackTime,
      isChapter: isChapter ?? this.isChapter,
      chapterName: chapterName ?? this.chapterName,
      deviceInfo: deviceInfo ?? this.deviceInfo,
    );
  }
}

@firestoreSerializable
class MessageEntity {
  MessageEntity({
    this.content = '',
    this.contentV2,
    this.contentV3,
    this.type = MessageType.unsupported,
    this.typeV2 = MessageType.unsupported,
    this.status,
    this.timestamp = 0,
    this.senderName = '',
    this.isDeleted = false,
    this.isForwarded = false,
    this.isRepliedMessage = false,
    this.repliedMessage,
    this.groupName,
    this.groupId,
    this.groupIdFiltered = '',
    this.senderUserId,
    this.senderPhNo,
    this.caption,
    this.localpath,
    this.messageId,
    this.messageAttachment,
    this.isRemoved = false,
    this.recipients = const <String>['0'],
    this.shouldShowPrivate = true,
    this.senderRole = UserRole.NON_ADMIN,
    this.minRequiredVersion,
    this.supportedBackwardCompatibilityVersion,
    this.pinned = false,
    this.pinnedBy,
    this.pinnedAt,
    this.templateName,
    this.videoPlaybackTime,
    this.isChapter = false,
    this.chapterName,
    this.sessionLogBusinessType,
    this.sessionLogBusinessPayload,
    this.deviceInfo,
  });
  MessageAttachment({
    this.id,
    this.mediaUrl,
    this.fileLocalPath,
    this.fileName,
    this.fileSize,
    this.fileMetaData,
    this.thumbnailMetaData,
    this.thumbnailUrl,
    this.thumbnailLocalPath,
    this.compressedFileSize,
    this.thumbnailMetaDataV2,
    this.type = AttachmentType.DOC,
    this.isCapturedFromThisDevice = false,
  });
class SenderDeviceInfo {
  const SenderDeviceInfo({
    this.appVersion,
    this.buildNo,
    this.platform,
    this.deviceId,
  });

  factory SenderDeviceInfo.fromJson(Map<String, dynamic> json) =>
      _$SenderDeviceInfoFromJson(json);

  final String? appVersion;
  final String? buildNo;
  final String? platform;
  final String? deviceId;

  Map<String, dynamic> toJson() => _$SenderDeviceInfoToJson(this);
}
danagbemava-nc commented 11 months ago

Hi @sumittiware, thanks for the details.

Does this bug reproduce in debug mode as well?

And what is the average load time for the messages when the crash is cleared vs when the bug occurs?

google-oss-bot commented 11 months ago

Hey @sumittiware. 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!

google-oss-bot commented 11 months ago

Since there haven't been any recent updates here, I am going to close this issue.

@sumittiware if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.