-
Notifications
You must be signed in to change notification settings - Fork 102
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
🐛 FirestoreListView renders (incomplete) local cache before remote db result #238
Comments
Labeling based on the report above, I keep hitting #239 |
Scratched my head on this issue for a while, it turns out, this appears to be a bug in the firebase-js-sdk. I will open a bug report on that repo and link to this issue 👍 |
Opened issue here if you wish to track: firebase/firebase-js-sdk#8004 |
Hi. Do you have any updates on this? I am utilizing a The JS sdk isue got closed as it was concluded that the issue wasn't there. What's the issue exactly? And is there an interim solution in the meantime? |
the interim solution is to update your cache settings so persistenceEnabled is set to FirebaseFirestore.instance.settings = const Settings(
persistenceEnabled: true,
); I'm trying to figure out the optimal solution to this problem in the underlying implementation. |
@sinnaj-r - I actually think the solution to this problem is to set persistence: FirebaseFirestore.instance.settings = const Settings(
persistenceEnabled: true,
); That way, you're matching the persistence that you see on the native SDKs which have persistence enabled by default. FlutteFire has also fixed the hot restart bug so it no longer crashes. |
Thank you for the response; unfortunately, at least in our use case, activating persistence is not something we can do because our application is used by many "office"-type PCs with very limited resources that can not deal with the app taking up several hundreds of megabytes (or more) of RAM -- which is what we observed after enabling persistence. |
Have you tried limiting cache size: FirebaseFirestore.instance.settings = const Settings(
persistenceEnabled: true,
// Limit cache size to whatever you want
cacheSizeBytes: 10000,
);
|
Hello 👋, to help manage issues we automatically close stale issues. This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require attention?
Thank you for your contributions. |
I experimented with various ways to limit the cache size, but the RAM usage remains too high, as shown in the images below. As @sinnaj-r mentioned, enabling persistence is not a viable option, and setting cacheByteSize has no significant impact. Does anyone have suggestions for alternative approaches? Images: The screenshots are in German, but they all display "Arbeitsspeichernutzung" (RAM usage). For example, "Arbeitsspeichernutzung: 279 MB" translates to "RAM usage: 279 MB." Disabled caching: My machine: MacBook Air M3 2024 |
Is there an existing issue for this?
What plugin is this bug for?
Firebase UI Firestore
What platform(s) does this bug affect?
Web
List of dependencies used.
flutter pub deps -s list
Steps to reproduce
.snapshots()
-Stream on a single firestore document (lets call it docA ); Render this document e.g. with a StreamBuilder.FirestoreListView
to render a list of documents (including docA ). The database should contain enough documents, to allow for multiple pages.FirestoreListView
to trigger the "fetch more" functionality.Expected Behavior
I would expect the List not jumping. And thereby, as far as I understood the bug, I would expect the list not rendering a single cached item inbetween list fetches. I would also be fine with disabling any caching behavior on web, if there's a way to do that.
Actual Behavior
(see steps to reproduce)
Additional Information
I briefly looked into the
FirestoreListView
code (packages/firebase_ui_firestore/lib/src/query_builder.dart
) . If I'm not mistaken, the problems lies in thequery.snapshots().listen()
-Callback in lines 176 et seq. Here any data is "rendered", as long as its smaller thenexpectedDocsCount
, which of course includes the one item eagerly returned by the cache.The text was updated successfully, but these errors were encountered: