-
Notifications
You must be signed in to change notification settings - Fork 615
Firestore .get .(addOnCompleteListener) not receiveing response in firestore sdk 21.4.3 or newer #2311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I found a few problems with this issue:
|
Hi @markic22. I'm sorry that this issue is affecting you. Thank you for the detailed bug report. I'm not sure what's happening but it does sound like something is not right. The update in 21.4.3 that you've referred to ("Cloud Firestore now limits the number of concurrent document lookups it will perform when resolving inconsistencies in the local cache") is #1374. Your mentions that "there was big number of changes happening" and "we delete all collections and documents of this data set and populate it with the same again (our backend does this)" seem to suggest that this could indeed be related to the feature added in that PR. Could you reproduce the issue with logging enabled and post the logs? The logs could prove to be very helpful if I am unable to reproduce the issue. To enable logging, call FirebaseFirestore.setLoggingEnabled(true). In the meantime, I'll see if I can reproduce the issue. |
Oh, and I'd like to confirm: When you say "not successful" do you mean that the listeners specified to |
Hi @dconeybe , thanks for your time and quick response.
.get() gets called, but neither of listeners gets any response (neither addOnCompleteListener, addOnFailureListener or addOnCanceledListenel receives any feedback). Ok, i uploaded couple of scenarios for you, with logging enabled. First load with 22.0.0 version: Load after changes with 22.0.o version: (it doesn't load): And now the same with the last working version 21.4.2 And the issue is with only one of the collection (assignment_consumptions). Only this listener "gets stuck". Really appriciate the time and help. tip: you can use "firestoreService" string to search if listeners got a response or not. |
@dconeybe Did you have any breaktrough? This is a big issue for us, since we cannot user newer version of firestore in our live app. Is there anything I can do? Anybody else I can contact regarding this? Please let me know. |
Hi @markic22. My apologies for the delay in my reply. I realize that this is a frustrating issue for you and as of yesterday my time has freed up to invest more time in the investigation. I spent some time setting up a reproduction app yesterday and I am going to continue today. I have not had any breakthroughs and the logs did not, unfortunately, point to anything obvious. Thank you for your patience. This could be a tricky one to get to the bottom of but I'll keep you posted with updates. |
@markic22 Reading the logs has not pointed to an obvious problem; however, I do see that there are 10 documents in the I do, however, have a few hypotheses that I'd like to test out. If I were to provide you with a custom Firestore SDK build and instructions for modifying your app to use it, would you be willing to reproduce the issue with that custom build? Basically, I want to add some additional logging to try and figure out what's going on. We would probably need to do 5 or 6 iterations of this as the log output sends the investigation in different directions. |
@dconeybe I'm willing to try anything, i'm trying to find what exactly causes the issue for about 2 weeks now and trying to reproduce in demo app for you, but no success. It seems to be specific situation. If you would agree, we could even have "Live" session, where I would share my screen and detail and show our issue to you exactly. |
Are you, by any chance, able to share your entire app with me so that I can reproduce (as opposed to an isolated demo app)? Me being able to set breakpoints and debug locally would dramatically speed up this investigation. But I totally understand if that's not feasible, in which case we can go down this debugging-via-logging method. |
Ok I have a build for you to try. I've included instructions for you to build it by yourself since that will be the easiest way for us to iterate on this. Also, I'd personally be wary about executing opaque binary artifacts that someone sent me on GitHub, so I don't want to do that to you either :) Anyways, here are the steps:
With these changes, please rebuild your app, reproduce the bug, and post the logs in a GitHub Gist. I'm specifically interested in the log lines with "zzyzx" as their tag, so feel free to filter out the rest. |
@dconeybe I tried to build snapshot, but I got some issues. First it was ndk issue, which I resolved with using older version (newest doesn't have platform folder). But now I'm stuck. `* What went wrong:
i tried to comment those licence files in projects, but in the end, the same error comes for build/m2repository... something like that. I'm still trying to solve this issue with illegal character, but if you have any idea how I could fix this, it would be great help. |
Hmmm I'm not familiar with that error. It could be a Windows specific thing. Let me try to reproduce on my end. I use Mac and Linux but not typically Windows so it's possible that I've been fortunate enough to simply not run into this issue. |
Ok. I've pushed 017ca0d to the branch to work around the "Illegal character in authority at index 7" build error. Please do a Sorry this took so long to reply. I spent a good part of my day getting my Windows machine set up for building! Also, which version of the NDK did you install to work around the missing "platforms" directory issue? I have 28.0.3 and 30.0.3 (according to Android Studio) and I'm still seeing the issue. |
Thanks for the detailed steps! I was able to work around the NDK "platforms" directory issue and fix the other "Illegal character in authority at index 7" with 9c6168f. Please |
@dconeybe Ok, we are moving forward :D. I have successfully build snapshot now and used it in my app. Now I have an issue when I set this snapshot as library. At compiling I get this error
Do I need to build snapshot of those "missing" libraries also? for example for |
Yes, you're right. You will need to publish firestore's dependencies as well. I tried running If you by any chance have access to a Mac or Linux machine to do this work then that will likely greatly reduce this sort of friction. Otherwise, I'll keep digging. I have another commitment today so I won't have an update until tomorrow, unfortunately. |
Hm... I guess I can make dual boot into linux, if we cannot figure out the issue, I will do that. I have managed to build all dependencies, and my application builds successfully with this snapshot now. The problem is that sdk crashes when being used in our application.
Does this have something to do with proguard? (in our project it's disabled) |
Hmm it does look like it's proguard related; however, if you aren't using proguard then it must be something else. Sigh. Sorry this is so difficult. I'll investigate and reply tomorrow. |
Update: I've finally gotten myself to the point where I am also experiencing the |
Ok, I think I've gotten it figured out. Try adding these deps to your app's
I also pushed up some fixes to the
again to make sure that we're on the same page. |
Thank you for your time and effort on this. I added those dependencies, and generated new snapshots. |
Thank you for providing these logs. Something is suspicious for sure. From the logs I can see that the call to To test this hypothesis I've added some more logging and reduced the maximum number of concurrent limbo resolutions from 100 to 10. This will likely cause the bug to be reproduced much more easily on your end and will also help limit the sheer amount of log output that would be introduced by my new logging. So please |
Here are the new logs. I used the same "stress test" as before, so not sure yet if it's now more easy to reproduce. |
OK, now it goes through 🍾 , but I wanna run some more tests tomorrow (to check if it's actually new data loaded, not previous and some other cases). Can you maybe explain to me why did it cause issue in our case, and why it was so difficulty to reproduce? I saw the change you made, but I don't fully understand "limbo" state of document. I want to understand it more, to maybe avoid or improve our usage of firestore. Here are logs of successfully loaded data. Really appreciate your help and time!! :) |
That's great news! To be honest, I don't fully understand why the query started by A "limbo" document is a document that is stored in the local cache is known to be out of sync with the server. The concept of "limbo documents" is internal to the SDK and that's why it is not discussed in public documentation. When a document goes into "limbo" the client issues a request to get the latest version to update the local cache. I can explain the gory details, if desired, but there is also a pretty good explanation in the bug report that brought about the throttling of limbo resolutions: firebase/firebase-js-sdk#2683. As it turns out, this is a bug in the web and iOS SDKs as well so I'm going to work on a fix for all repositories. |
Great to hear this is being fixed, thank you, @dconeybe ! Been struggling with this for a couple of weeks as well! I noticed this in my Flutter app too, but only on Android, and this seems to be the exact issue I'm having. A strange workaround that worked in my case (again, I'm on Flutter so there may be other things at play here), was to add a |
@dconeybe Please wait a little bit with a fix, I think that this doesn't fully resolve the issue and there are some "side effects". I'm still testing and trying to figure out what exactly is going on, but I think that limbo resolution is not working correctly, there are still some data that should be there. |
@red42 That's interesting to know that others are facing this issue as well. Thanks for the extra info. Adding a limit to your query shouldn't change limbo resolution, but limits to involve extra logic and introduce new cases where documents can go into limbo so it's entirely possible that adding a limit could help the situation serendipitously. @markic22 I've updated the |
@dconeybe Ok, after some further tests, it seems that everything is okay. We had one internal bug, which I mistaken for issue with limbo resolution. It all looks good to me. |
@markic22 Thank you for confirming. I'll get the fix merged and included in the next Android release. |
The fix has been merged in c9fefbe and will be included in the next release of the Android SDK. @markic22 Thank you for all of the time you spent going back and forth with me debugging, including the up-front investigation you did to find the release in which this bug was introduced. I'm sorry for how this bug has been affecting you and costing you precious time. I'm glad that we could get it resolved. Thank you for using Firestore! |
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). |
Update: The fix for this bug was included in the Firestore Android SDK release 22.1.1 on March 01, 2021. For some reason it was excluded from the release notes. I'll see if I can fix that. https://firebase.google.com/support/release-notes/android#firestore_v22-1-1 Update: The release notes at the link above have been updated to include this bug fix. |
Hello, Denver, Just wandering is there a plan to fix this |
@ywmei-brt1 I have no plans to fix the "Illegal character in authority at index 7" issue. It's outside of the purview of Firestore and was tangential to this issue so I just worked around it. If this bug concerns you, feel free to open a new GitHub issue for it and perhaps the team responsible will get it fixed. Thanks! |
[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:
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.
The text was updated successfully, but these errors were encountered: