firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

With a large amount of pending deletes, newly added snapshot listeners stop being called

Open sjudd opened this issue 1 year ago • 4 comments

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • For general Firebase discussion, use the firebase-talk google group.
  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version:

Android Studio Koala | 2024.1.1 Patch 1 Build #AI-241.18034.62.2411.12071903, built on July 10, 2024 Runtime version: 17.0.11+0-17.0.11b1207.24-11852314 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 14.1 GC: G1 Young Generation, G1 Old Generation Memory: 8192M Cores: 12 Metal Rendering is ON Registry: debugger.new.tool.window.layout=true ide.experimental.ui=true Non-Bundled Plugins: de.santiv.fastscrolling (1.2) IdeaVIM (2.16.0)

  • Firebase Component: firebase-firestore
  • Component version: :33.1.2

[REQUIRED] Step 3: Describe the problem

With a large number of pending deletes, if I remove and add a few listeners (symmetrically), eventually newly added listeners are never notified of changes until I kill and restart the app.

I do not see this with a smaller number of documents (~50) added and removed in the same pattern.

Steps to reproduce:

I'm able to reproduce this reliably by following the steps listed here https://github.com/firebase/firebase-ios-sdk/issues/13883. I open the app, add a listener, then add 2500 documents and then delete them via the admin sdk as described. While firestore is processing the deletes on the client, I switch between two screens where one observes firestore and the other doesn't. Usually the first or second time I do this, I stop receiving updates in the newly added listeners. I've confirmed with logging that the listener is added.

I have two listeners, the first queries a collection, the second uses the output from the first query to observe a second collection. I've observed that even the first query with no other dependencies does not receive updates even though it is registered.

Relevant Code:

sjudd avatar Oct 14 '24 05:10 sjudd

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Oct 14 '24 05:10 google-oss-bot

@sjudd,

I switch between two screens where one observes firestore and the other doesn't.

When you switch between screens, are you removing and re-adding the listener?

ListenerRegistration registration = collection.addSnapshotListener(...);

// on switch to different screen
registration.remove();

// on switch back to screen using the listener, re-add the listener
registration = collection.addSnapshotListener(...);

I stop receiving updates in the newly added listeners

Are you stating that the listener will not produce any more snapshots for that collection? If your server app then adds a new document to the collection, is a new snapshot raised?

I think some code to demonstrate what your app is doing would be helpful. An MCVE would likely help us resolve the issue faster.

MarkDuckworth avatar Oct 15 '24 20:10 MarkDuckworth

Yes, going from screen A -> B, the listener is removed. Then going from B -> A, the listener is added again. It's at this point that the listener seems to stop receiving snapshots. If I add or delete new items in the collection no new snapshot is received.

I do wonder if this is just another symptom of Firestore being overloaded by https://github.com/firebase/firebase-ios-sdk/issues/13883. I've reported this issue here because I could only reproduce it on Android, not on iOS. I did not try waiting for the several minutes required for all of the deletes to be processed.

I've provided the listener example in the other issue, as well as the code used to add and remove documents.

sjudd avatar Oct 15 '24 21:10 sjudd

@sjudd, having logs from the SDK may also be useful in this case. Or we can try to focus on the iOS issue you reported first.

You can enable logging for the SDK with the instructions here: https://gist.github.com/katowulf/0475fb7a5907ed757f687aab6ed15878

To securely share a log, one way is to submit a firebase support case and attach the generate log in a file. Please reference internal bug b/373388444, so the team can route the log to the correct place. Thanks!

MarkDuckworth avatar Oct 16 '24 20:10 MarkDuckworth

Hi @sjudd, as mentioned by Mark it would help us a lot to investigate the issue if you can share the logs from the SDK. You can share this log by reaching out to the Firebase Support team and share the internal bug or this Github issue so the team can route the details accordingly.

That said, I'll be closing this issue for now to streamline the communication. Let me know if there's any misunderstanding or you have additional details so we can reopen this issue. Thanks!

lehcar09 avatar Nov 13 '24 14:11 lehcar09

I've provided logs for the other issue and haven't heard back. Once I hear back from there I'd be happy to reproduce this again and provide another set.

sjudd avatar Nov 14 '24 00:11 sjudd