-
Notifications
You must be signed in to change notification settings - Fork 4k
🐛 [cloud_firestore] Streambuilder very slow to update from Cloud Firestore when Android app resumes after long period of inactivity #4305
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 didn't see any delay after waiting for 30 minutes on the latest master flutter doctor -v
|
I forgot to mention that the issue doesn't occur if the phone is connected
to my computer via ADB while waiting the 30 minutes.
Also, the issue doesn't occur every time I wait 30 minutes. I would say it
happens ~50% of the time.
Thanks
…On Thu., Dec. 3, 2020, 5:26 a.m. Markus Aksli, ***@***.***> wrote:
I didn't see any delay after waiting for 30 minutes on the latest master
1.25.0-5.0.pre.45.
flutter doctor -v
[√] Flutter (Channel master, 1.25.0-5.0.pre.45, on Microsoft Windows [Version 10.0.19041.630], locale et-EE)
• Flutter version 1.25.0-5.0.pre.45 at C:\Development\flutter_master
• Framework revision 81e1f7d1ed (5 hours ago), 2020-12-02 17:19:57 -0800
• Engine revision 20caf54969
• Dart version 2.12.0 (build 2.12.0-76.0.dev)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\marku\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6953283\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.7.30621.155
• Windows 10 SDK version 10.0.18362.0
[√] Android Studio (version 4.1.0)
• Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6953283
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] Connected device (4 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19041.630]
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.88
• Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.47
• No issues found!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4305 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJ662AAGMU6PSETTJHLNPNTSS6GZFANCNFSM4ULRZ2MA>
.
|
A couple more points to note:
- I have observed this issue when testing with a Pixel 3XL (Android 11) and a Samsung
Galaxy A50 (Android 10)
- When the problem occurs I seem to be able to force the phone out of the
bad state by turning airplane mode on and then off again. The data will
then appear in less than 1 second.
…On Thu., Dec. 3, 2020, 8:51 a.m. Jim Cicalo, ***@***.***> wrote:
I forgot to mention that the issue doesn't occur if the phone is connected
to my computer via ADB while waiting the 30 minutes.
Also, the issue doesn't occur every time I wait 30 minutes. I would say
it happens ~50% of the time.
Thanks
On Thu., Dec. 3, 2020, 5:26 a.m. Markus Aksli, ***@***.***>
wrote:
> I didn't see any delay after waiting for 30 minutes on the latest master
> 1.25.0-5.0.pre.45.
> flutter doctor -v
>
> [√] Flutter (Channel master, 1.25.0-5.0.pre.45, on Microsoft Windows [Version 10.0.19041.630], locale et-EE)
>
> • Flutter version 1.25.0-5.0.pre.45 at C:\Development\flutter_master
>
> • Framework revision 81e1f7d1ed (5 hours ago), 2020-12-02 17:19:57 -0800
>
> • Engine revision 20caf54969
>
> • Dart version 2.12.0 (build 2.12.0-76.0.dev)
>
>
>
> [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
>
> • Android SDK at C:\Users\marku\AppData\Local\Android\sdk
>
> • Platform android-30, build-tools 30.0.2
>
> • Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6953283\jre\bin\java
>
> • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
>
> • All Android licenses accepted.
>
>
>
> [√] Chrome - develop for the web
>
> • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
>
>
>
> [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
>
> • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
>
> • Visual Studio Community 2019 version 16.7.30621.155
>
> • Windows 10 SDK version 10.0.18362.0
>
>
>
> [√] Android Studio (version 4.1.0)
>
> • Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6953283
>
> • Flutter plugin can be installed from:
>
> https://plugins.jetbrains.com/plugin/9212-flutter
>
> • Dart plugin can be installed from:
>
> https://plugins.jetbrains.com/plugin/6351-dart
>
> • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
>
>
>
> [√] Connected device (4 available)
>
> • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19041.630]
>
> • Web Server (web) • web-server • web-javascript • Flutter Tools
>
> • Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.88
>
> • Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.47
>
>
>
> • No issues found!
>
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#4305 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AJ662AAGMU6PSETTJHLNPNTSS6GZFANCNFSM4ULRZ2MA>
> .
>
|
same issue observed here! |
Same exact problem with a Galaxy S10 (Android 10). |
Hi @markusaksli-nc any luck reproducing the issue when your phone is not connected to your computer via ADB? This is key to reproducing the issue, as the problem won't occur when your device is connected via ADB. This bug is a serious issue for me as many users of our app are complaining about "missing" chat messages due to this issue.... and as a result they often decide to delete our app as they view it to be unreliable. Your help is appreciated here. Thanks |
I'm seeing the exact same issue here but in the native android sdk. Exactly the same behavior, happens after app is backgrounded 1-2 hours, reconnects after 1 minute then works fine. Switching from wifi to LTE triggers an update immediately. Has anyone been able to find a solution? Thanks |
Hi @jorgegil96 unfortunately I haven't found a solution and this issue doesn't seem to be getting any attention from the flutterfire team. I've tried the latest versions of the flutterfire packages and the issue still remains: firebase_core: 0.7.0 It looks like once the "Needs Attention" label is removed from an issue there is no further follow-up. At this point the only path to resolving this issue that I can see is to file a new bug report. Have you tried submitting a bug report for the android SDK? https://github.com/firebase/firebase-android-sdk/issues |
I was able to reproduce this again with a release build without ADB on the latest master flutter doctor -v[√] Flutter (Channel master, 1.26.0-13.0.pre.179, on Microsoft Windows [Version 10.0.19041.746], locale et-EE)
• Flutter version 1.26.0-13.0.pre.179 at C:\Development\flutter_master
• Framework revision fc9addb88b (7 hours ago), 2021-01-26 03:24:03 -0500
• Engine revision f47ab4434d
• Dart version 2.12.0 (build 2.12.0-257.0.dev)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\marku\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.7042882\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.7.30621.155
• Windows 10 SDK version 10.0.18362.0
[√] Android Studio (version 4.1.0)
• Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.7042882
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] Connected device (4 available)
• SM G950F (mobile) • ce12171c51cc001c03 • android-arm64 • Android 9 (API 28)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19041.746]
• Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.141
• Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.75
• No issues found! You can somewhat force this behavior with @ratherNotB FYI the |
Thank you @markusaksli-nc for investigating this issue further. Very excited to hear that you were able to reproduce it! |
Exactly the same issue for me on a pixel 3a and Android 11 😤 |
Please thumbs up the original issue comment if you have the same issue, that way we can track how many are facing the problem. |
Regarding how long this issue has existed, I've found a SO question from Aug 2020 (Flutter 1.20.2) that I believe describes this same issue: |
Hello, |
Hello, Nobody with a workaround ? |
I too am seeing this with a release version of Android on my Galaxy Note 10. When the app is resumed from the background after a long time (could be many hours later) then the first query will take 60-90 seconds to complete. This is a blocker since the nature of the app will have people coming in after some time of inactivity then want to save/query data in the moment. Waiting this long will be a massive fail in experience and distrust in the app. |
Has anybody found a way around this? This is resulting in presentation of incorrect data to my users. Please @markusaksli-nc, do we have this on the priority list since you were already able to reproduce the issue. |
Unfortunately I haven't found a workaround and am still waiting for a fix for this highly disruptive bug. Hi @markusaksli-nc, @kroikie; can one of you please advise as to when we can have a rough timeline for a fix? Can we expect a fix in the next 2-3 months for example? It's been almost 5 months since I filed this bug report. If a decision has been made to not fix this bug then please let us know asap so we can plan accordingly. Thanks |
Same problem here: it takes good 20 - 50 seconds for firestore streams to 'catch up' with the data on resume. I'm considering restarting the whole app every time it gets active, but this workaround is far from optimal due to launch time and additional charges for new data downloads. Looking forward to better ideas or fix to this problem. |
Individually you can restart the app and get the latest data, but how do you explain that to the user? This is not a good user experience, in fact, it really makes the application look really average. @markusaksli-nc , @kroikie : Can you point me to the code that may be causing the problem.. If you don't have time, at least direct the community to fix the issue for you please 👍 |
I think this is an underlying SDK issue, which also is confirmed with this comment:
FlutterFire is just wrapping the native Firebase SDKs - when a query event is sent from native we relay it to Dart land via a stream. If something is taking a long time to fire an event, then either the Android SDK has an issue or Flutter isn't letting Android know about the reconnection. |
Yeah I saw that, however actually having a project to run would be super helpful. |
Unfortunately, I am not a native developer so I might not be able to submit a small reproducible project. @jorgegil96 could you please help us on this please? On the other note, can you please verify this issue on Firebase Android SDK repo: firebase/firebase-android-sdk#1258. It seems like that a similar problem was reported last year (although they could only restore connection after 18 minutes, we can recover connection within 30-60 seconds). Issue suggests a following workaround:
Is there a way to call these methods from flutter firestore/firebase wrapper? I want to try it out. |
It took a bit but I found a way to reliably reproduce this with a sample small project (native SDK, not flutter). You'll find a small project and the logs + repro steps in this drive folder. Copying repro steps here:
I feel that being backgrounded should not count as a connection error that triggers exponential backoff strategy. Or at least,
I think I tried that a while ago and did not work. Only thing that works is killing and restarting the app. That workaround is from an issue in the real-time database, not firestore, so I guess it's not the same underlying issue. The only real workaround I can think of is to migrate back to real-time db :( |
Thanks a ton, @jorgegil96 . @Ehesp , I hope this should be sufficient to raise an issue with SDK team and perhaps, prioritize? Performance is a key element of any application, and I believe, looking at a number of people experiencing this issue, I suggest this should be no less than a P2. |
Thanks very much for the details and repro. I'll flag this up, however keep in mind I am not a Googler so how it's dealt with and the speed/priority is not something I can comment on. |
Closing this as we can now track over on firebase/firebase-android-sdk#2637 |
Hello @Ehesp , could we please release a new version of cloud_firestore and relevant libraries with the latest changes made for firebase/firebase-android-sdk#2637. Thank you. |
@frankyvij we need it to become available as a Firebase release first - we've got an internal ticket to keep an eye on that and create a new release when we can. |
Thanks @Ehesp , I can only request to prioritize the release. Hope we will see a release in the next couple of days. |
A Firebase release is outside of our control I'm afraid. Once it lands we'll make sure it's a priority on FlutterFire. |
Hi @Ehesp , it seems that the fix has been released in firebase android SDK. Could we please plan the release for cloud_firestore with the latest SDK. Please! Thank you! |
Hi, I am also the one who waiting for this problem to be fixed. I hope to see an update to new firebase BoM soon. Thanks for all of your effort |
I have created a fork and upgraded the firebase_core to use the latest SDK: 28.1.0. Those who just want to test in their dev environments can use this in their pubspec.yaml.
|
@frankyvij does it work for you? Did you experienced any improvement? |
I have been using my version of firebase core for about a day now and not even once I had to restart my app. I have never been so happy before. HAHA. |
This was published in cloud_firestore: ^2.2.2 |
I'm using 2.2.2 and the issue is not resolved for me |
Same here (with the native SDK) - I just posted about it in firebase/firebase-android-sdk#2637 |
Same here with 2.2.2 - which I'd expect if it's not resolved in the native SDK. But I'm also observing that if the first firestore call after the connection timeout and the app brought back to foreground is a 'get()' on a doc that doesn't exist, for example I have a call as follows: (await noteMatchDocRef.get()).exists; it indefinitely hangs and never returns. not sure if anyone else has noticed that? In any case, we really need to have these firestore db streams re-established after they shutdown when the app returns and in-use again - it doesn't seem to be an issue with my realtime db streams, they look ok after the same delay in app use. |
In cloud_firestore: ^2.3.0 problem still persists. |
The PR with the new fix has only recently been merged into Android SDK repo, we're still waiting on a Firebase release. |
Bug report
I have observed instances where a Streambuilder takes 60-90 seconds to rebuild the UI with current Cloud Firestore data. This can occur when an Android phone running a Flutter app is locked and left inactive for a period of time... 30 minutes for example. When the phone is unlocked and the Flutter app resumed, any data written to Cloud Firestore while the phone was locked can take 60-90 seconds to appear in the app when being read via a Streambuilder.
I have tried to reproduce this issue on iOS but have been unsuccessful.
Some other noteworthy points:
I have a chat app written in Flutter that uses Cloud Firestore. It's very confusing to users when they tap on a new message notification and the app opens but they don't see the new message in their chat screen for > 60 seconds.
Steps to reproduce
Please use the sample code attached below to reproduce the issue.
/demo/demoData/
Expected behavior
I would expect the data from Cloud Firestore to update within the time it takes to perform a cold start... which I believe is ~10 seconds for Cloud Firestore.
Additional context
Sample app to reproduce the issue. Tapping the FAB increments the "count" field in Cloud Firestore.
main.dart
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
The text was updated successfully, but these errors were encountered: