Skip to content
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

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

Open
sjudd opened this issue Oct 14, 2024 · 4 comments
Assignees

Comments

@sjudd
Copy link

sjudd commented Oct 14, 2024

[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 firebase/firebase-ios-sdk#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:

@google-oss-bot
Copy link
Contributor

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

@MarkDuckworth
Copy link
Contributor

@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.

@sjudd
Copy link
Author

sjudd commented Oct 15, 2024

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 firebase/firebase-ios-sdk#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.

@MarkDuckworth
Copy link
Contributor

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants