Firestore .get .(addOnCompleteListener) not receiveing response in firestore sdk 21.4.3 or newer

  • Android Studio version: 4.1.1
  • Firebase Component: Firestore
  • Component version: 21.4.3 or higher

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

I’m having issue with firestore Android sdk. We were using firestore sdk 22.0.0 but we found an issue with our application, that in some cases, data wouldn’t load successfully. After investigation, we figured out that the issue was happening when user had closed application and when there was big number of changes happening, first try to load the data was not successful. If you closed and opened application again (called .addOnCompleteListener again) the data was loaded ok, so the issue is only when you call listener for the first time since there were a lot of changes made to the documents. The strange thing is that in this .get() none of the listeners got a response (neither addOnCompleteListener, addOnFailureListener or addOnCanceledListener). I tried to wait for hours (8 documents in this collection collection, but in other collections there were hundreds of changes if not thousands).

private fun getAssignmentConsumptions() { Log.d("firestoreService", "firestoreService: getAssignmentConsumptions, started") getFacilityDocumentRef(facilityId).collection(AssignmentConsumption.COLLECTION).get().addOnCompleteListener { snapshots -> assignmentConsumptionsList = snapshots.result?.documents?.toModels<AssignmentConsumption>()?.toMutableList() ?: mutableListOf() Log.d("firestoreService", "firestoreService: getAssignmentConsumptions, done") assignmentConsumptionsListBehaviourRelay.accept(assignmentConsumptionsList.toList()) }.addOnFailureListener { Log.d("firestoreService", "firestoreService: getAssignmentConsumptions, onFailure") }.addOnCanceledListener { Log.d("firestoreService", "firestoreService: getAssignmentConsumptions, onCanceled") } }

Then I tried to use firestore 19.0.0 version. And it worked as it should. Then I decided that I would figure out when was this “issue” introduced into firestore project. The last version that works OK for us is the 21.4.2 version, anything above this version, this .get() call gets 0 response.

In documentation for version 21.4.3 it says this:

Cloud Firestore version 21.4.3 Cloud Firestore now limits the number of concurrent document lookups it will perform when resolving inconsistencies in the local cache.

As we can see there were some changes done for local cache, but it seems that this broke loading/resolving local data with new changes, where we don’t get response about what is happening.

I cannot make a sample where this is reproduceable , but in our case it’s reproduceable 100%% of the time. To reproduce this, we delete all collections and documents of this data set and populate it with the same again (our backend does this). First loading is not successful, the second one is. And this issue only occurs from version 21.4.2 onwards.

1 possible answer(s) on “Firestore .get .(addOnCompleteListener) not receiveing response in firestore sdk 21.4.3 or newer

  1. Update: This fix did not get merged in time for the next release, but will be part of the release following the next release, which is expected (but not guaranteed!) to be near the end of this month (Feb 2021).