Description
Is there an existing issue for this?
- I have searched the existing issues.
Which plugins are affected?
Core
Which platforms are affected?
Android
Description
When upgrading firebase_core from 3.11.0 to a higher version, we're seeing a performance/speed impact in Firestore when subscribed to a large collection in Android. Web does not appear to be affected in any way.
It seems to manifest in a number of ways but the simplest demonstration of the impact is just to subscribe to the large collection (e.g. 2000 items) and then loop through a large number of writes (e.g. 100).
When doing this, core 3.11.0 detects changes at a rate of ~40ms per update, while 3.12.0 is more like ~115ms per update. I also tried on core 3.14.0 which is better but still not as fast as 3.11.0 (~65ms per update).
Only the firebase_core version in pubspec.yaml was changed in between these tests.
Changing the cloud_firestore pubspec package version doesn't seem to have an effect. Examples all used 5.6.3.
While the effect seems a bit worse while online, this issue also happens the same way when the device is completely offline and using the cache.
Reproducing the issue
- Subscribe to a large collection (the performance loss per update read appears to be multiplicatively worse depending on the size of the collection) - 2000 is used in the repro project.
- Write a set of documents all at once (100 used in the repro project).
- Observe the delay between each document update being detected on each firebase_core version.
Repro Project (Writes the 2000 docs on first open. Press + floating button to initiate 100 doc field writes with the counter value):
https://github.com/AlexWestNT/core-firestore-repro
Needs FirebaseOptions info inserting into top of main.dart.
Firebase Core version
3.12.0
Flutter Version
3.29.3
Relevant Log Output
firebase_core: 3.11.0:
I/flutter ( 3558): CHANGE: item30 2 TimeSinceLastChange: 51 ms
I/flutter ( 3558): CHANGE: item31 2 TimeSinceLastChange: 43 ms
I/flutter ( 3558): CHANGE: item32 2 TimeSinceLastChange: 40 ms
I/flutter ( 3558): CHANGE: item33 2 TimeSinceLastChange: 41 ms
I/flutter ( 3558): CHANGE: item34 2 TimeSinceLastChange: 40 ms
I/flutter ( 3558): CHANGE: item35 2 TimeSinceLastChange: 40 ms
I/flutter ( 3558): CHANGE: item36 2 TimeSinceLastChange: 40 ms
I/flutter ( 3558): CHANGE: item37 2 TimeSinceLastChange: 40 ms
I/flutter ( 3558): CHANGE: item38 2 TimeSinceLastChange: 40 ms
I/flutter ( 3558): CHANGE: item39 2 TimeSinceLastChange: 45 ms
I/flutter ( 3558): CHANGE: item40 2 TimeSinceLastChange: 40 ms
firebase_core 3.12.0:
I/flutter ( 5941): CHANGE: item54 1 TimeSinceLastChange: 104 ms
I/flutter ( 5941): CHANGE: item56 1 TimeSinceLastChange: 113 ms
I/flutter ( 5941): CHANGE: item55 1 TimeSinceLastChange: 114 ms
I/flutter ( 5941): CHANGE: item58 1 TimeSinceLastChange: 118 ms
I/flutter ( 5941): CHANGE: item60 1 TimeSinceLastChange: 113 ms
I/flutter ( 5941): CHANGE: item61 1 TimeSinceLastChange: 117 ms
I/flutter ( 5941): CHANGE: item59 1 TimeSinceLastChange: 115 ms
I/flutter ( 5941): CHANGE: item62 1 TimeSinceLastChange: 116 ms
I/flutter ( 5941): CHANGE: item65 1 TimeSinceLastChange: 113 ms
I/flutter ( 5941): CHANGE: item63 1 TimeSinceLastChange: 115 ms
firebase_core 3.14.0:
I/flutter ( 6467): CHANGE: item52 3 TimeSinceLastChange: 64 ms
I/flutter ( 6467): CHANGE: item51 3 TimeSinceLastChange: 67 ms
I/flutter ( 6467): CHANGE: item50 3 TimeSinceLastChange: 67 ms
I/flutter ( 6467): CHANGE: item53 3 TimeSinceLastChange: 66 ms
I/flutter ( 6467): CHANGE: item57 3 TimeSinceLastChange: 68 ms
I/flutter ( 6467): CHANGE: item54 3 TimeSinceLastChange: 63 ms
I/flutter ( 6467): CHANGE: item55 3 TimeSinceLastChange: 66 ms
I/flutter ( 6467): CHANGE: item58 3 TimeSinceLastChange: 66 ms
I/flutter ( 6467): CHANGE: item59 3 TimeSinceLastChange: 64 ms
I/flutter ( 6467): CHANGE: item60 3 TimeSinceLastChange: 64 ms
Flutter dependencies
Expand Flutter dependencies
snippet
Dart SDK 3.7.2
Flutter SDK 3.29.3
firestore_minimal_repro 1.0.0+1
dependencies:
- cloud_firestore 5.6.3 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- cupertino_icons 1.0.8
- firebase_core 3.12.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
dev dependencies:
- flutter_lints 5.0.0 [lints]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]
transitive dependencies:
- _flutterfire_internals 1.3.51 [collection firebase_core firebase_core_platform_interface flutter meta]
- async 2.12.0 [collection meta]
- boolean_selector 2.1.2 [source_span string_scanner]
- characters 1.4.0
- clock 1.1.2
- cloud_firestore_platform_interface 6.6.3 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 4.4.3 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins]
- collection 1.19.1
- fake_async 1.3.2 [clock collection]
- firebase_core_platform_interface 5.4.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.23.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- leak_tracker 10.0.8 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.9 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- lints 5.1.1
- matcher 0.12.17 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.11.1 [collection]
- meta 1.16.0
- path 1.9.1
- plugin_platform_interface 2.1.8 [meta]
- sky_engine 0.0.0
- source_span 1.10.1 [collection path term_glyph]
- stack_trace 1.12.1 [path]
- stream_channel 2.1.4 [async]
- string_scanner 1.4.1 [source_span]
- term_glyph 1.2.2
- test_api 0.7.4 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- vector_math 2.1.4
- vm_service 14.3.1
- web 1.1.1
Additional context and comments
No response