Description
[REQUIRED] Step 2: Describe your environment
- Android Studio version: Android Studio Koala | 2024.1.1
- Firebase Component: Firestore
- Component version: BoM 33.9.0 (Firestore 25.1.2)
[REQUIRED] Step 3: Describe the problem
When upgrading the SDK BoM from 33.8.0 to a higher version, we're seeing a performance/speed impact in Firestore when subscribed to a large collection in Android.
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, BoM 33.8.0 (Firestore 25.1.1) detects changes at a rate of ~11ms per update, while BoM 33.9.0 (Firestore 25.1.2) is more like ~115ms per update. I also tried on BoM 33.11.0 (Firestore 25.1.3) which is better but still not as fast as 33.8.0 (it's ~60ms per update).
Steps to reproduce:
- 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-bom version - changing the version in build.gradle.kts dependencies.
Logcat outputs from example project:
implementation(platform("com.google.firebase:firebase-bom:33.8.0")):
2025-06-20 13:46:18.345 13505-13505 Firestore com.example.myapplication D CHANGE: MODIFIED item90 49 TimeSinceLastChange: 12 ms
2025-06-20 13:46:18.356 13505-13505 Firestore com.example.myapplication D CHANGE: MODIFIED item91 49 TimeSinceLastChange: 11 ms
2025-06-20 13:46:18.367 13505-13505 Firestore com.example.myapplication D CHANGE: MODIFIED item92 49 TimeSinceLastChange: 11 ms
2025-06-20 13:46:18.378 13505-13505 Firestore com.example.myapplication D CHANGE: MODIFIED item93 49 TimeSinceLastChange: 10 ms
2025-06-20 13:46:18.389 13505-13505 Firestore com.example.myapplication D CHANGE: MODIFIED item94 49 TimeSinceLastChange: 11 ms
2025-06-20 13:46:18.400 13505-13505 Firestore com.example.myapplication D CHANGE: MODIFIED item95 49 TimeSinceLastChange: 11 ms
2025-06-20 13:46:18.411 13505-13505 Firestore com.example.myapplication D CHANGE: MODIFIED item96 49 TimeSinceLastChange: 11 ms
2025-06-20 13:46:18.422 13505-13505 Firestore com.example.myapplication D CHANGE: MODIFIED item97 49 TimeSinceLastChange: 11 ms
2025-06-20 13:46:18.433 13505-13505 Firestore com.example.myapplication D CHANGE: MODIFIED item98 49 TimeSinceLastChange: 11 ms
2025-06-20 13:46:18.444 13505-13505 Firestore com.example.myapplication D CHANGE: MODIFIED item99 49 TimeSinceLastChange: 12 ms
implementation(platform("com.google.firebase:firebase-bom:33.9.0")):
2025-06-20 13:43:27.985 13283-13283 Firestore com.example.myapplication D CHANGE: MODIFIED item90 38 TimeSinceLastChange: 117 ms
2025-06-20 13:43:28.099 13283-13283 Firestore com.example.myapplication D CHANGE: MODIFIED item91 38 TimeSinceLastChange: 114 ms
2025-06-20 13:43:28.216 13283-13283 Firestore com.example.myapplication D CHANGE: MODIFIED item92 38 TimeSinceLastChange: 118 ms
2025-06-20 13:43:28.331 13283-13283 Firestore com.example.myapplication D CHANGE: MODIFIED item93 38 TimeSinceLastChange: 115 ms
2025-06-20 13:43:28.452 13283-13283 Firestore com.example.myapplication D CHANGE: MODIFIED item94 38 TimeSinceLastChange: 121 ms
2025-06-20 13:43:28.555 13283-13283 Firestore com.example.myapplication D CHANGE: MODIFIED item95 38 TimeSinceLastChange: 103 ms
2025-06-20 13:43:28.672 13283-13283 Firestore com.example.myapplication D CHANGE: MODIFIED item96 38 TimeSinceLastChange: 117 ms
2025-06-20 13:43:28.788 13283-13283 Firestore com.example.myapplication D CHANGE: MODIFIED item97 38 TimeSinceLastChange: 115 ms
2025-06-20 13:43:28.906 13283-13283 Firestore com.example.myapplication D CHANGE: MODIFIED item98 38 TimeSinceLastChange: 118 ms
2025-06-20 13:43:29.024 13283-13283 Firestore com.example.myapplication D CHANGE: MODIFIED item99 38 TimeSinceLastChange: 118 ms
implementation(platform("com.google.firebase:firebase-bom:33.11.0")):
2025-06-20 13:54:45.841 13774-13774 Firestore com.example.myapplication D CHANGE: MODIFIED item90 85 TimeSinceLastChange: 60 ms
2025-06-20 13:54:45.901 13774-13774 Firestore com.example.myapplication D CHANGE: MODIFIED item91 85 TimeSinceLastChange: 59 ms
2025-06-20 13:54:45.960 13774-13774 Firestore com.example.myapplication D CHANGE: MODIFIED item92 85 TimeSinceLastChange: 59 ms
2025-06-20 13:54:46.023 13774-13774 Firestore com.example.myapplication D CHANGE: MODIFIED item93 85 TimeSinceLastChange: 64 ms
2025-06-20 13:54:46.087 13774-13774 Firestore com.example.myapplication D CHANGE: MODIFIED item94 85 TimeSinceLastChange: 63 ms
2025-06-20 13:54:46.146 13774-13774 Firestore com.example.myapplication D CHANGE: MODIFIED item95 85 TimeSinceLastChange: 59 ms
2025-06-20 13:54:46.207 13774-13774 Firestore com.example.myapplication D CHANGE: MODIFIED item96 85 TimeSinceLastChange: 62 ms
2025-06-20 13:54:46.265 13774-13774 Firestore com.example.myapplication D CHANGE: MODIFIED item97 85 TimeSinceLastChange: 58 ms
2025-06-20 13:54:46.324 13774-13774 Firestore com.example.myapplication D CHANGE: MODIFIED item98 85 TimeSinceLastChange: 58 ms
2025-06-20 13:54:46.383 13774-13774 Firestore com.example.myapplication D CHANGE: MODIFIED item99 85 TimeSinceLastChange: 59 ms
implementation(platform("com.google.firebase:firebase-bom:33.15.0")):
2025-06-20 13:57:02.593 13986-13986 Firestore com.example.myapplication D CHANGE: MODIFIED item90 26 TimeSinceLastChange: 58 ms
2025-06-20 13:57:02.652 13986-13986 Firestore com.example.myapplication D CHANGE: MODIFIED item91 26 TimeSinceLastChange: 58 ms
2025-06-20 13:57:02.716 13986-13986 Firestore com.example.myapplication D CHANGE: MODIFIED item92 26 TimeSinceLastChange: 64 ms
2025-06-20 13:57:02.778 13986-13986 Firestore com.example.myapplication D CHANGE: MODIFIED item93 26 TimeSinceLastChange: 63 ms
2025-06-20 13:57:02.843 13986-13986 Firestore com.example.myapplication D CHANGE: MODIFIED item94 26 TimeSinceLastChange: 64 ms
2025-06-20 13:57:02.906 13986-13986 Firestore com.example.myapplication D CHANGE: MODIFIED item95 26 TimeSinceLastChange: 64 ms
2025-06-20 13:57:02.965 13986-13986 Firestore com.example.myapplication D CHANGE: MODIFIED item96 26 TimeSinceLastChange: 58 ms
2025-06-20 13:57:03.024 13986-13986 Firestore com.example.myapplication D CHANGE: MODIFIED item97 26 TimeSinceLastChange: 60 ms
2025-06-20 13:57:03.088 13986-13986 Firestore com.example.myapplication D CHANGE: MODIFIED item98 26 TimeSinceLastChange: 63 ms
2025-06-20 13:57:03.147 13986-13986 Firestore com.example.myapplication D CHANGE: MODIFIED item99 26 TimeSinceLastChange: 59 ms
Relevant Code:
Repro Project (Writes the 2000 docs on first open. Press the fab to initiate 100 doc field writes with a random value):
https://github.com/AlexWestNT/android-firestore-repro
Needs FirebaseOptions info inserting into onCreate in of MainActivity.