firebase-ios-sdk
firebase-ios-sdk copied to clipboard
Firestore Snapshot Listener executes too much work on main thread
[REQUIRED] Step 1: Describe your environment
- Xcode version: 12.4
- Firebase SDK version: 6.34.0
- Installation method: CocoaPods
- Firebase Component: Firestore
[REQUIRED] Step 2: Describe the problem
Snapshot listener executes large tasks on the main thread and makes the app extremely laggy. I was wondering if the code can be optimized to perform the work on a background thread
Steps to reproduce:
- Have an active snapshot listener (listening to 10 documents)
- Perform large number of writes (this can be a cloud function updating the documents, 10-20 updates in a second)
I don't see this issue on the Android client
What happened? How can we make the problem occur? This could be a description, log/console output, etc.
If you have a downloadable sample project that reproduces the bug you're reporting, you will likely receive a faster response on your issue.
Relevant Code:
@aryaxt have you tried setting the callback queue to a background queue?
Can you also share the code of you listeners and approximate the number of documents in each snapshot? Raising the snapshot should not put a lot of work on the main queue, but accessing the document data inside of the snapshot may kick off expensive operations.
Hey @aryaxt. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Thanks, I'll try the callback queue and report back
I'm setting the callback queue to a background queue, but doing this makes the listeners sometimes don't send any response. Tried using concurrent and serial queues, for now, I'm keeping the main queue to avoid this kind of issue.
I'm using now Firebase 9.4.1, but it's also happening on version 9.5.0. Xcode 14b6, iOS 16 beta.