firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.63k stars 3.95k forks source link

πŸ› [cloud_firestore] After some time, Cloud Firestore sync stops working #6749

Closed wujek-srujek closed 2 years ago

wujek-srujek commented 3 years ago

Bug report

Both on Android and iOS, the sync works fine when the application starts and keeps working for some time. However, after some time (not sure how much) sync stops working - sending doesn't work, and receiving in another instance of the app doesn't receive changes (I can see this by changing data directly in the console). When the application is force-stopped and restarted, it starts working again immediately. This behavior is 100% consistent between Android and iOS.

I started having the issue only recently, maybe 2-3 weeks ago. Before this, this application and Firestore integration had been working flawlessly for months and there have been no code changes at all since May 19, and no code changes to anything related to Firebase or Firestore for half a year (except for version updates).

Has anything changed in your backend, and is some change in code required for it to start working without issues again?

I upgraded everything about a week ago but it didn't help.

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [βœ“] Flutter (Channel unknown, 2.2.3, on macOS 11.5.1 20G80 darwin-x64, locale en-DE) [βœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [βœ“] Xcode - develop for iOS and macOS [βœ“] Chrome - develop for the web [!] Android Studio (version 2020.3) βœ— Unable to find bundled Java version. [βœ“] IntelliJ IDEA Ultimate Edition (version 2021.2) [βœ“] VS Code (version 1.58.2) [βœ“] Connected device (2 available) ! Doctor found issues in 1 category. ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 2.13.4 Flutter SDK 2.2.3 mu_project 1.2.0-dev dependencies: - blocs 0.0.0 [bloc equatable flutter google_sign_in meta model repository rxdart] - cloud_firestore 2.4.0 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta] - firebase_crashlytics 2.1.1 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_bloc 7.0.1 [flutter bloc provider] - flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math] - flutter_slidable 0.6.0 [flutter] - flutter_svg 0.22.0 [flutter meta path_drawing vector_math xml] - googleapis 4.0.0 [_discoveryapis_commons http] - http 0.13.3 [async http_parser meta path pedantic] - hydrated_bloc 7.0.1 [bloc hive meta synchronized] - intl 0.17.0 [clock path] - json_annotation 4.0.1 - meta 1.3.0 - model 0.0.0 [equatable meta] - package_info_plus 1.0.4 [flutter package_info_plus_platform_interface package_info_plus_linux package_info_plus_macos package_info_plus_windows package_info_plus_web] - path_provider 2.0.2 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - provider 5.0.0 [collection flutter nested] - repository 0.0.0 [cloud_firestore firebase_auth flutter google_sign_in googleapis http json_annotation meta rxdart] - wakelock 0.5.2 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows] dev dependencies: - build_runner 2.0.6 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - flutter_launcher_icons 0.9.1 [args image path yaml] - json_serializable 4.1.4 [analyzer build build_config collection json_annotation meta path source_gen] transitive dependencies: - _discoveryapis_commons 1.0.1 [http http_parser meta] - _fe_analyzer_shared 22.0.0 [meta] - analyzer 1.7.1 [_fe_analyzer_shared cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml pedantic] - archive 3.1.2 [crypto path] - args 2.2.0 - async 2.8.1 [collection meta] - bloc 7.0.0 [meta] - build 2.0.3 [analyzer async convert crypto glob logging meta path] - build_config 1.0.0 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 3.0.0 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.4 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.0.1 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pedantic pool timing watcher yaml] - built_collection 5.1.0 - built_value 8.1.1 [built_collection collection fixnum meta] - characters 1.1.0 - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - cli_util 0.3.3 [meta path] - clock 1.1.0 - cloud_firestore_platform_interface 5.3.0 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.3.0 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.1.0 [built_collection built_value collection matcher meta] - collection 1.15.0 - convert 3.0.1 [typed_data] - crypto 3.0.1 [collection typed_data] - dart_style 2.0.3 [analyzer args path pub_semver source_span] - equatable 2.0.3 [collection meta] - ffi 1.1.2 - file 6.1.2 [meta path] - firebase_auth 3.0.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_auth_platform_interface 6.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 3.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core 1.4.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.1.0 [collection firebase_core flutter meta plugin_platform_interface] - fixnum 1.0.0 - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - frontend_server_client 2.1.0 [async path] - glob 2.0.1 [async collection file path pedantic string_scanner] - google_sign_in 5.0.5 [flutter google_sign_in_platform_interface google_sign_in_web meta] - google_sign_in_platform_interface 2.0.1 [flutter meta quiver] - google_sign_in_web 0.10.0 [google_sign_in_platform_interface flutter flutter_web_plugins meta js] - graphs 2.0.0 - hive 2.0.4 [meta crypto] - http_multi_server 3.0.1 [async] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image 3.0.2 [archive meta xml] - io 1.0.3 [meta path string_scanner] - js 0.6.3 - logging 1.0.1 - matcher 0.12.10 [stack_trace] - mime 1.0.0 - nested 1.0.0 [flutter] - package_config 2.0.0 [path] - package_info_plus_linux 1.0.3 [package_info_plus_platform_interface flutter path] - package_info_plus_macos 1.1.1 [flutter] - package_info_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface] - package_info_plus_web 1.0.3 [flutter flutter_web_plugins http meta package_info_plus_platform_interface] - package_info_plus_windows 1.0.3 [package_info_plus_platform_interface ffi flutter win32] - path 1.8.0 - path_drawing 0.5.1 [vector_math meta path_parsing flutter] - path_parsing 0.2.1 [vector_math meta] - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 2.0.0 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.11.1 - petitparser 4.1.0 [meta] - platform 3.0.0 - plugin_platform_interface 2.0.1 [meta] - pool 1.5.0 [async stack_trace] - process 4.2.3 [file path platform] - pub_semver 2.0.0 [collection] - pubspec_parse 1.0.0 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.0.1 [matcher] - rxdart 0.27.1 - shelf 1.2.0 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.1 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_gen 1.0.3 [analyzer async build dart_style glob meta path pedantic source_span yaml] - source_span 1.8.1 [collection path term_glyph] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.0 [charcode source_span] - synchronized 3.0.0 - term_glyph 1.2.0 - timing 1.0.0 [json_annotation] - typed_data 1.3.0 [collection] - vector_math 2.1.0 - wakelock_macos 0.1.0+1 [flutter flutter_web_plugins wakelock_platform_interface] - wakelock_platform_interface 0.2.1+1 [flutter meta] - wakelock_web 0.2.0+1 [flutter flutter_web_plugins js wakelock_platform_interface] - wakelock_windows 0.1.0 [flutter wakelock_platform_interface win32] - watcher 1.0.0 [async path pedantic] - web_socket_channel 2.1.0 [async crypto stream_channel] - win32 2.2.5 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.1.2 [collection meta petitparser] - yaml 3.1.0 [collection source_span string_scanner] ```

markusaksli-nc commented 3 years ago

Hi @wujek-srujek Could you provide a minimal complete reproducible code sample to demonstrate the behavior? Thank you

wujek-srujek commented 3 years ago

Hi @markusaksli-nc No, I can't because there isn't anything special what I'm doing. Here is the code for listening:

FirebaseFirestore.instance.collection('items').snapshots().map(
          (querySnapshot) => querySnapshot.docs.map(_mapDocumentSnapshot),
        );

_mapDocumentSnapshot is just a mapping function that internally uses code generated by json_serializable. Here is my initialization code:

Future<void> main() async {
  await runZonedGuarded<Future<void>>(() async {
    WidgetsFlutterBinding.ensureInitialized();

    await SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);

    await Firebase.initializeApp();

    if (kDebugMode) {
      // Report crashes in release mode only.
      await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(false);
    }
    FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;

    runApp(MyApp());
  }, (error, stack) => FirebaseCrashlytics.instance.recordError(error, stack));
}

Pretty standard code, I would say.

As I mentioned before, it all works fine for some time after starting the app, and before my issues started, it had worked fine for months no matter how much time the app was open.

markusaksli-nc commented 3 years ago

Roughly how long does it take for it to stop working? Are there no errors/warnings in the logs?

You're saying this reproduces consistently with multiple devices?

wujek-srujek commented 3 years ago

I have just tested this using the iOS simulator (debug mode) and simultaneously on an Android device (release mode). Here are the observations:

  1. Once the app started, sync worked correctly on both devices: I could change a value using the web console and the changes were visible on both devices. Changes made on one device also synced with the console and the other device.
  2. I let the application just sit doing nothing for about 1.5 h: on the iOS simulator the app was in the foreground the whole time; I moved the app to the background on the Android device.
  3. After 1.5 h I brought the Android instance to the foreground and changed a value using the web console. Neither of the app (running on iOS simulator or the Android device) reflected the changes, they didn't sync.
  4. Similarly, changing values using the either app didn't sync with the web console, nor did it sync with the other device.
  5. There are no logs whatsoever in the 'debug console' of VS Code (used to start the app on the simulator).
  6. I restarted the app on Android, finished the debug session on the simulator and just started the debug application again right away - syncing from any device to any other device (including the web console) worked immediately in any direction and combination without any issues.

The good thing is I can reproduce the issue in debug mode using the simulator, which should make troubleshooting easier. The bad thing is: I'm at a loss how I can even debug this, there are no logs at all and I see nothing wrong - no connection errors, no timeouts, nothing. Is there some kind of 'debug' or 'verbose' mode I could turn on?

You will have noticed from my snippets above that I'm also using Crashlytics - which doesn't show any issues either.

I will try to narrow the time window down by decreasing the time after which I perform the sync test, maybe 1.5 h is not necessary.

markusaksli-nc commented 3 years ago

I wasn't able to reproduce this but I'll label it based on the report. You should probably also contact https://firebase.google.com/support

The android side sounds familiar to https://github.com/FirebaseExtended/flutterfire/issues/4305. What android device did you test this with?

wujek-srujek commented 3 years ago

Pixel 3XL. I also have an iPhone XS device whose behavior is 100% consistent, i.e. also stops syncing after some time. I'll take a look at the issue you linked.

wujek-srujek commented 3 years ago

The issue seems to be very similar, it might be the same one - the next time I can reproduce the issue I will wait for a few minutes to see if the data is synced with a delay, or never. So far, I never waited so long and simply assumed the data will never arrive. Will comment when I know more.

However, I have the same issue on iOS...

wujek-srujek commented 3 years ago

Seems to be a different issue for me - once sync stopped working (changing in web console didn't get propagated to the app on Android) I waited for 5 minutes with a timer, but the update never came. Turning airplane mode off and on doesn't help in my case either.

larssn commented 3 years ago

Just to chime in: We're getting similar reports from our users. Seems to be handheld devices primarily, which often goes into standby.

wujek-srujek commented 3 years ago

Hi, it's been a while, are there any news on this issue? The problem still occurs, 100% reproducible when the phones are left for about an hour without doing anything (get locked etc.). This basically prevents my app from being released.

markusaksli-nc commented 3 years ago

I can't really offer an update. Since I wasn't able to reproduce it and we're not seeing many reports of this (well https://github.com/FirebaseExtended/flutterfire/issues/4305 sounded similar I suppose) it's hard to immediately fix anything here without some digging. I can try bringing this up to see if anyone has some ideas.

larssn commented 3 years ago

I'll help creating a repro when I have time. I don't know if it happens on iOS, but it definitely happens on Android.

The easiest way is to run it in debug mode via Wifi:

If you have the firestore console open, you should see nothing happen there yet.

After a while it will show up, which could be a few minutes, or never (the "never" is harder to reproduce, but it does also happens for our clients).

A bit of info: From what the console spits out, it seems the device has trouble detecting when Wifi is available again. I see numerous errors relating to resolving the url firestore.googleapis.com long after Wifi is back (@wujek-srujek can you confirm this?).

Could also be related to https://github.com/FirebaseExtended/flutterfire/issues/6736 which outputs similar errors. https://github.com/FirebaseExtended/flutterfire/issues/6736 is being investigated in the Android repo here https://github.com/firebase/firebase-android-sdk/issues/2877 but there hasn't been any real traction yet.

wujek-srujek commented 3 years ago

I redid the steps and I'm seeing a lot of log entries like this one:

W/Firestore(30441): (23.0.1) [WatchStream]: (d7e5263) Stream closed with status: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname
W/Firestore(30441):     at io.grpc.internal.DnsNameResolver.resolveAll(DnsNameResolver.java:436)
W/Firestore(30441):     at io.grpc.internal.DnsNameResolver$Resolve.resolveInternal(DnsNameResolver.java:272)
W/Firestore(30441):     at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:228)
W/Firestore(30441):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/Firestore(30441):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/Firestore(30441):     at java.lang.Thread.run(Thread.java:923)
W/Firestore(30441): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname
W/Firestore(30441):     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156)
W/Firestore(30441):     at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
W/Firestore(30441):     at java.net.InetAddress.getAllByName(InetAddress.java:1152)
W/Firestore(30441):     at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:646)
W/Firestore(30441):     at io.grpc.internal.DnsNameResolver.resolveAll(DnsNameResolver.java:404)
W/Firestore(30441):     ... 5 more
W/Firestore(30441): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
W/Firestore(30441):     at libcore.io.Linux.android_getaddrinfo(Native Method)
W/Firestore(30441):     at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73)
W/Firestore(30441):     at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202)
W/Firestore(30441):     at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73)
W/Firestore(30441):     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135)
W/Firestore(30441):     ... 9 more
W/Firestore(30441): }.

This happens to me even before I wake up the device, i.e. it happens as soon as it Wifi is shut down - my device is still in standby mode but my console already shows a lot of them. I'll update this comment once I test what happens when I wake up the device (~1.5 hrs from now).

Update: upon waking the device I immediately got many exceptions like the one above. When I tried to add a document I got even more of the same, and the document didn't show up in Firestore. After waiting a few minutes I started getting:

W/Firestore(30441): (23.0.1) [FirestoreCallCredentials]: Failed to get token: com.google.firebase.FirebaseException: An internal error has occurred. [ Requests to this API securetoken.googleapis.com method google.identity.securetoken.v1.SecureToken.GrantToken are blocked. ].
W/Firestore(30441): (23.0.1) [WriteStream]: (ab8ed95) Stream closed with status: Status{code=UNAUTHENTICATED, description=null, cause=com.google.firebase.FirebaseException: An internal error has occurred. [ Requests to this API securetoken.googleapis.com method google.identity.securetoken.v1.SecureToken.GrantToken are blocked. ]
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zzto.zza(com.google.firebase:firebase-auth@@21.0.1:4)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zzuw.zza(com.google.firebase:firebase-auth@@21.0.1:9)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zzux.zzl(com.google.firebase:firebase-auth@@21.0.1:1)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zzuu.zzk(com.google.firebase:firebase-auth@@21.0.1:25)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zztl.zzh(com.google.firebase:firebase-auth@@21.0.1:1)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zzom.zza(com.google.firebase:firebase-auth@@21.0.1:2)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zzvb.zza(com.google.firebase:firebase-auth@@21.0.1:23)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zzul.zzf(com.google.firebase:firebase-auth@@21.0.1:4)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zzpt.zzp(com.google.firebase:firebase-auth@@21.0.1:4)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zztp.zzk(com.google.firebase:firebase-auth@@21.0.1:5)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zzqr.zzd(com.google.firebase:firebase-auth@@21.0.1:3)
W/Firestore(30441):     at com.google.android.gms.internal.firebase-auth-api.zzqq.accept(Unknown Source:6)
W/Firestore(30441):     at com.google.android.gms.common.api.internal.zacj.doExecute(com.google.android.gms:play-services-base@@17.1.0:2)
W/Firestore(30441):     at com.google.android.gms.common.api.internal.zaf.zac(com.google.android.gms:play-services-base@@17.1.0:6)
W/Firestore(30441):     at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zac(com.google.android.gms:play-services-base@@17.1.0:167)
W/Firestore(30441):     at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zab(com.google.android.gms:play-services-base@@17.1.0:139)
W/Firestore(30441):     at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zaa(com.google.android.gms:play-services-base@@17.1.0:105)
W/Firestore(30441):     at com.google.android.gms.common.api.internal.GoogleApiManager.handleMessage(com.google.android.gms:play-services-base@@17.1.0:145)
W/Firestore(30441):     at android.os.Handler.dispatchMessage(Handler.java:102)
W/Firestore(30441):     at com.google.android.gms.internal.base.zar.dispatchMessage(com.google.android.gms:play-services-base@@17.1.0:8)
W/Firestore(30441):     at android.os.Looper.loop(Looper.java:223)
W/Firestore(30441):     at android.os.HandlerThread.run(HandlerThread.java:67)
W/Firestore(30441): }.

I'm testing with my real app which does require authentication, but I was logged in and adding the document worked initially. After some time I killed the app and started it again, and added a few documents and they showed up in Firestore Web Console immediately, without any auth errors - which means the auth part works fine, right?

So yeah, I can confirm the steps by @larssn work to reproduce the issue, but in my case I got even more errors (as auth is involved).

larssn commented 3 years ago

which means the auth part works fine, right?

Yeah sounds like it. Auth should be completely transparent once logged in.

I have a feeling the error might be really far downstream; maybe the problem is all the way down in the GRPC layer, since io.grpc.internal.DnsNameResolver seems to be the one that can't resolve the address.

Think we need more eyes on this one. @markusaksli-nc Thoughts?

Ps. I should stress that this issue could be considered critical, since you could easily (on some devices) end up in situations where data is never sent to firestore, which could cause havoc if that data is mission critical.

markusaksli-nc commented 3 years ago

@larssn Are you on the latest version of the plugin? The behavior you described sounds a lot like something that should have been fixed in a previous firebase release which should be picked up in the latest cloud_firestore: ^2.5.1

larssn commented 3 years ago

Hey, thanks for replying! πŸ˜„

I'm on the latest version, and yes, I know about that issue. It was me that made the PR to bump the internal versions, hoping it would fix the problem: it did not, sadly.

@wujek-srujek Could you try ^2.5.1 to see if it changes anything for you? Just so we have more eyes on this.

wujek-srujek commented 3 years ago

@larssn Yes I will try it out over the weekend.

wujek-srujek commented 3 years ago

Hi, I tried 2.5.1 and nothing changed, I still get the same exceptions in the log console and the sync stops working.

wujek-srujek commented 3 years ago

Is there any workaround?

larssn commented 3 years ago

Not that I know of. I've tried running disableNetwork/enableNetwork hoping it would reset something internally, but it didn't work.

AydinBK commented 3 years ago

Hey guys, any news regarding this issue?

It's getting pretty critical since our app relies on this core feature to work consistently and as @wujek-srujek said it used to work flawlessly before.

davidgalarza commented 3 years ago

Any update? I'm facing the same issue.

wujek-srujek commented 3 years ago

Out of curiosity, does anybody facing the issue also face it on iOS, like I do? There has been a lot of talk about Android-specific bugs in the native SDK, but I have the feeling the issue might be somewhere else: infrastructure or in the Dart code, since it is 100% consistent and reproducible on both platforms for me.

AydinBK commented 3 years ago

@wujek-srujek Most of our users are using Android and therefore the reports we have are Android related. We have tried to reproduce the issue on iOS but here it seems to work fine.

wujek-srujek commented 2 years ago

It's been 2 months since the original filing of the issue, any updates?

park1120 commented 2 years ago

I also have been facing this issue for the very long time(#4305). I really wished this could be solved, but I am pretty sure that the problem still exists and it is critical. At least, I hope there is an API as an alternative for checking firestore daemon health status and restarting it without restarting app. So the company can handle it from the perspective of user experience design.

wujek-srujek commented 2 years ago

The issue still persists. Any news?

larssn commented 2 years ago

Here's a reproduction of the issue in Flutter: link

I wrote to firebase support, but they didn't wanna help without a reproduction in native Android/iOS, so I'm gonna make one in Android at the least.

larssn commented 2 years ago

Here's a reproduction in pure Android: link

I CANNOT reproduce the issue in pure Android, but I'd like some more eyes on it. @wujek-srujek Do you have time to verify this?

Basically the instructions from https://github.com/FirebaseExtended/flutterfire/issues/6749#issuecomment-904406020 still applies, with the only difference being that you run it from Android Studio instead.

You can check the logcat for what is outputted. I output all info at the error-level, so it's easier to spot.

The thing to look for is the difference in the local timestamp, and the server timestamp, which is what I log.

wujek-srujek commented 2 years ago

@larssn I will try to do it this week, but it's not high on my priority list I'm afraid, I have long given up on Firestore.

AydinBK commented 2 years ago

With the projects that @larssn have made it looks like the issue is related to FlutterFire only and not Firestore.

Do we all need to give up or can you @markusaksli-nc please pull some strings and give this critical issue some attention?

larssn commented 2 years ago

Not sure if I should make a new issue since the topic has diverged from "stops working", to "coming out of standby, firestore is very slow to start sync'ing data".

And again to stress: This only seems to happen with the Flutter version for yet undiscernible reasons.

@markusaksli-nc Thoughts?

markusaksli-nc commented 2 years ago

I haven't been on FlutterFire issue triage for a while so I'm not sure what the status here is, from what I remember the team should be aware of this issue. @larssn what do you mean by "only seems to happen with the Flutter version"?

cc @darshankawar

larssn commented 2 years ago

@markusaksli-nc Thanks for replying! Just to bring you up to speed:

This is in stark contrast to the Flutter version where it takes one whole minute for data to arrive.

The two POCs are very simple and pretty much identical in implementation.

But in case I'm missing something here, I'd like some more eyes on it.

larssn commented 2 years ago

Found this: https://groups.google.com/g/firebase-talk/c/9D9rXvhBmUM/m/wFBVapeGAwAJ

Mike from 4 years ago is describing the issue exactly... 😞

Wonder why my Android POC didn't show the problem then.

darshankawar commented 2 years ago

I'll make the team aware about this issue.

larssn commented 2 years ago

Follow-up research

I've been doing some research on this issue, and here's what I've found: (The tests were done using the master branch of flutterfire, and turning on logging with FirebaseFirestore.setLoggingEnabled(true);)

It seems this issue is related to Android's "Doze mode", which allows apps to go into various levels of sleep.

Here's my observations/log from using the flutter reproduction app and playing around with Doze mode.

The device is unplugged from charging, and the screen is turned off. (The log can be found below.)

Things start to go wrong when GRPC reports a TRANSIENT_FAILURE, which, so far, only happens in Flutter, and not native Android (AFAIK).

I turn on the screen on this line: I/Firestore(18202): (24.0.1) [AndroidConnectivityMonitor]: App has entered the foreground. (At this point, I know the device is connected correctly to Wifi.)

Notice that after this line, the SDK attempts to write to the backend. This fails, and it starts doing exponential backoff which makes things worse in this case. Also notice all the DNS resolution errors that happens in spite of having internet access again.

When the line I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Current gRPC connectivity state: READY appears, this is when the SDK can actually connect to the backend, however depending on how long the exponential backoff has been running, this can take a while.

All in all, it can take minutes to get to a working state again.

Full log ``` ************************SCREEN IS TURNED OFF************************ I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Current gRPC connectivity state: CONNECTING I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Setting the connectivityAttemptTimer I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: Collect garbage I/Firestore(18202): (24.0.1) [LruGarbageCollector]: Garbage collection skipped; Cache size 118784 is lower than threshold 104857600 I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds I/Firestore(18202): I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [GrpcCallProvider]: connectivityAttemptTimer elapsed. Resetting the channel. I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Clearing the connectivityAttemptTimer I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Current gRPC connectivity state: SHUTDOWN I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Channel shutdownNow invoked, cause=null} I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 0 ms (base delay: 1000 ms, delay with jitter: 1242 ms, last attempt: 15054 ms ago) I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Channel successfully reset. I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Current gRPC connectivity state: IDLE I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Current gRPC connectivity state: TRANSIENT_FAILURE I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) I/Firestore(18202): at java.lang.Thread.run(Thread.java:923) I/Firestore(18202): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) I/Firestore(18202): at java.net.InetAddress.getAllByName(InetAddress.java:1152) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219) I/Firestore(18202): ... 5 more I/Firestore(18202): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) I/Firestore(18202): at libcore.io.Linux.android_getaddrinfo(Native Method) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) I/Firestore(18202): ... 9 more I/Firestore(18202): } I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 1275 ms (base delay: 1500 ms, delay with jitter: 1370 ms, last attempt: 95 ms ago) I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) I/Firestore(18202): at java.lang.Thread.run(Thread.java:923) I/Firestore(18202): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:124) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) I/Firestore(18202): at java.net.InetAddress.getAllByName(InetAddress.java:1152) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219) I/Firestore(18202): ... 5 more I/Firestore(18202): } I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 1335 ms (base delay: 2250 ms, delay with jitter: 1367 ms, last attempt: 32 ms ago) I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) I/Firestore(18202): at java.lang.Thread.run(Thread.java:923) I/Firestore(18202): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) I/Firestore(18202): at java.net.InetAddress.getAllByName(InetAddress.java:1152) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219) I/Firestore(18202): ... 5 more I/Firestore(18202): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) I/Firestore(18202): at libcore.io.Linux.android_getaddrinfo(Native Method) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) I/Firestore(18202): ... 9 more I/Firestore(18202): } I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 4929 ms (base delay: 3375 ms, delay with jitter: 4964 ms, last attempt: 35 ms ago) I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) I/Firestore(18202): at java.lang.Thread.run(Thread.java:923) I/Firestore(18202): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) I/Firestore(18202): at java.net.InetAddress.getAllByName(InetAddress.java:1152) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219) I/Firestore(18202): ... 5 more I/Firestore(18202): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) I/Firestore(18202): at libcore.io.Linux.android_getaddrinfo(Native Method) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) I/Firestore(18202): ... 9 more I/Firestore(18202): } I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 4384 ms (base delay: 5062 ms, delay with jitter: 4419 ms, last attempt: 35 ms ago) I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) I/Firestore(18202): at java.lang.Thread.run(Thread.java:923) I/Firestore(18202): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) I/Firestore(18202): at java.net.InetAddress.getAllByName(InetAddress.java:1152) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219) I/Firestore(18202): ... 5 more I/Firestore(18202): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) I/Firestore(18202): at libcore.io.Linux.android_getaddrinfo(Native Method) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) I/Firestore(18202): ... 9 more I/Firestore(18202): } I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 8995 ms (base delay: 7593 ms, delay with jitter: 9028 ms, last attempt: 33 ms ago) I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) I/Firestore(18202): at java.lang.Thread.run(Thread.java:923) I/Firestore(18202): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) I/Firestore(18202): at java.net.InetAddress.getAllByName(InetAddress.java:1152) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219) I/Firestore(18202): ... 5 more I/Firestore(18202): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) I/Firestore(18202): at libcore.io.Linux.android_getaddrinfo(Native Method) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) I/Firestore(18202): ... 9 more I/Firestore(18202): } I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 10547 ms (base delay: 11389 ms, delay with jitter: 10575 ms, last attempt: 28 ms ago) I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) I/Firestore(18202): at java.lang.Thread.run(Thread.java:923) I/Firestore(18202): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) I/Firestore(18202): at java.net.InetAddress.getAllByName(InetAddress.java:1152) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219) I/Firestore(18202): ... 5 more I/Firestore(18202): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) I/Firestore(18202): at libcore.io.Linux.android_getaddrinfo(Native Method) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) I/Firestore(18202): ... 9 more I/Firestore(18202): } I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 22317 ms (base delay: 17083 ms, delay with jitter: 22350 ms, last attempt: 33 ms ago) I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) I/Firestore(18202): at java.lang.Thread.run(Thread.java:923) I/Firestore(18202): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) I/Firestore(18202): at java.net.InetAddress.getAllByName(InetAddress.java:1152) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219) I/Firestore(18202): ... 5 more I/Firestore(18202): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) I/Firestore(18202): at libcore.io.Linux.android_getaddrinfo(Native Method) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) I/Firestore(18202): ... 9 more I/Firestore(18202): } I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 24081 ms (base delay: 25624 ms, delay with jitter: 24099 ms, last attempt: 18 ms ago) I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) I/Firestore(18202): at java.lang.Thread.run(Thread.java:923) I/Firestore(18202): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) I/Firestore(18202): at java.net.InetAddress.getAllByName(InetAddress.java:1152) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219) I/Firestore(18202): ... 5 more I/Firestore(18202): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) I/Firestore(18202): at libcore.io.Linux.android_getaddrinfo(Native Method) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) I/Firestore(18202): ... 9 more I/Firestore(18202): } I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 43636 ms (base delay: 38436 ms, delay with jitter: 43652 ms, last attempt: 16 ms ago) I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:223) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.doResolve(DnsNameResolver.java:282) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:318) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) I/Firestore(18202): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) I/Firestore(18202): at java.lang.Thread.run(Thread.java:923) I/Firestore(18202): Caused by: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) I/Firestore(18202): at java.net.InetAddress.getAllByName(InetAddress.java:1152) I/Firestore(18202): at io.grpc.internal.DnsNameResolver$JdkAddressResolver.resolveAddress(DnsNameResolver.java:631) I/Firestore(18202): at io.grpc.internal.DnsNameResolver.resolveAddresses(DnsNameResolver.java:219) I/Firestore(18202): ... 5 more I/Firestore(18202): Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) I/Firestore(18202): at libcore.io.Linux.android_getaddrinfo(Native Method) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202) I/Firestore(18202): at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73) I/Firestore(18202): at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135) I/Firestore(18202): ... 9 more I/Firestore(18202): } I/Firestore(18202): This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend. I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 79004 ms (base delay: 57654 ms, delay with jitter: 79035 ms, last attempt: 31 ms ago) ************************SCREEN IS TURNED ON************************ I/Firestore(18202): (24.0.1) [AndroidConnectivityMonitor]: App has entered the foreground. I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: Locally write mutations I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: notifyLocalViewChanges I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 639 ms (base delay: 1000 ms, delay with jitter: 646 ms, last attempt: 7 ms ago) I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 766 ms (base delay: 1500 ms, delay with jitter: 773 ms, last attempt: 7 ms ago) I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 2995 ms (base delay: 2250 ms, delay with jitter: 3009 ms, last attempt: 14 ms ago) I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 3665 ms (base delay: 3375 ms, delay with jitter: 3687 ms, last attempt: 22 ms ago) I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 2569 ms (base delay: 5062 ms, delay with jitter: 2590 ms, last attempt: 21 ms ago) I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 6645 ms (base delay: 7593 ms, delay with jitter: 6666 ms, last attempt: 21 ms ago) I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 13580 ms (base delay: 11389 ms, delay with jitter: 13604 ms, last attempt: 24 ms ago) I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 22328 ms (base delay: 17083 ms, delay with jitter: 22351 ms, last attempt: 23 ms ago) I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [ExponentialBackoff]: Backing off for 33634 ms (base delay: 25624 ms, delay with jitter: 33655 ms, last attempt: 21 ms ago) I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Current gRPC connectivity state: CONNECTING I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Setting the connectivityAttemptTimer I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Current gRPC connectivity state: READY I/Firestore(18202): (24.0.1) [GrpcCallProvider]: Clearing the connectivityAttemptTimer I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream is open I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream sending: # com.google.firestore.v1.ListenRequest@e0553caa I/Firestore(18202): add_target { I/Firestore(18202): documents { I/Firestore(18202): documents: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): target_id: 2 I/Firestore(18202): } I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [FirestoreCallCredentials]: Successfully fetched auth token. I/Firestore(18202): (24.0.1) [FirestoreCallCredentials]: Firebase AppCheck API not available. I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream received headers: {date=Fri, 28 Jan 2022 12:26:37 GMT} I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream received: # com.google.firestore.v1.ListenResponse@72b7dc77 I/Firestore(18202): target_change { I/Firestore(18202): target_change_type: ADD I/Firestore(18202): target_change_type_value: 1 I/Firestore(18202): target_ids: 2 I/Firestore(18202): } I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream received: # com.google.firestore.v1.ListenResponse@1df5afea I/Firestore(18202): target_change { I/Firestore(18202): read_time { I/Firestore(18202): nanos: 921246000 I/Firestore(18202): seconds: 1643372563 I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\336\362\237\357\267\324\365\002" I/Firestore(18202): } I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: Apply remote event I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: notifyLocalViewChanges I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream received: # com.google.firestore.v1.ListenResponse@5266c08a I/Firestore(18202): target_change { I/Firestore(18202): read_time { I/Firestore(18202): nanos: 439481000 I/Firestore(18202): seconds: 1643372797 I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\371\333\314\336\270\324\365\002" I/Firestore(18202): target_change_type: CURRENT I/Firestore(18202): target_change_type_value: 3 I/Firestore(18202): target_ids: 2 I/Firestore(18202): } I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream received: # com.google.firestore.v1.ListenResponse@b975ccef I/Firestore(18202): target_change { I/Firestore(18202): read_time { I/Firestore(18202): nanos: 439481000 I/Firestore(18202): seconds: 1643372797 I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\371\333\314\336\270\324\365\002" I/Firestore(18202): } I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: Apply remote event I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: notifyLocalViewChanges I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream is open I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@8c63ad3a I/Firestore(18202): database: "projects/tillty-repros/databases/(default)" I/Firestore(18202): (24.0.1) [FirestoreCallCredentials]: Successfully fetched auth token. I/Firestore(18202): (24.0.1) [FirestoreCallCredentials]: Firebase AppCheck API not available. I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream received headers: {date=Fri, 28 Jan 2022 12:26:51 GMT} I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream received: # com.google.firestore.v1.WriteResponse@cac5c480 I/Firestore(18202): stream_id: "0" I/Firestore(18202): stream_token: "\031\020hB\002\201\364\265\265" I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: Set stream token I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@692c5a5c I/Firestore(18202): stream_token: "\031\020hB\002\201\364\265\265" I/Firestore(18202): writes { I/Firestore(18202): update { I/Firestore(18202): fields { I/Firestore(18202): key: "local_timestamp" I/Firestore(18202): value { I/Firestore(18202): integer_value: 0 I/Firestore(18202): timestamp_value { I/Firestore(18202): nanos: 359211000 I/Firestore(18202): seconds: 1643372726 I/Firestore(18202): } I/Firestore(18202): } I/Firestore(18202): } I/Firestore(18202): name: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): } I/Firestore(18202): update_transforms { I/Firestore(18202): field_path: "server_timestamp" I/Firestore(18202): set_to_server_value: REQUEST_TIME I/Firestore(18202): set_to_server_value_value: 1 I/Firestore(18202): } I/Firestore(18202): } I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream received: # com.google.firestore.v1.WriteResponse@8504e8f I/Firestore(18202): commit_time { I/Firestore(18202): nanos: 23504000 I/Firestore(18202): seconds: 1643372812 I/Firestore(18202): } I/Firestore(18202): stream_token: "\020\001\031\020hB\002\201\364\265\265" I/Firestore(18202): write_results { I/Firestore(18202): transform_results { I/Firestore(18202): integer_value: 0 I/Firestore(18202): timestamp_value { I/Firestore(18202): nanos: 958000000 I/Firestore(18202): seconds: 1643372811 I/Firestore(18202): } I/Firestore(18202): } I/Firestore(18202): update_time { I/Firestore(18202): nanos: 23504000 I/Firestore(18202): seconds: 1643372812 I/Firestore(18202): } I/Firestore(18202): } I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: Acknowledge batch I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: notifyLocalViewChanges I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream received: # com.google.firestore.v1.ListenResponse@117cbec9 I/Firestore(18202): document_change { I/Firestore(18202): document { I/Firestore(18202): create_time { I/Firestore(18202): nanos: 145467000 I/Firestore(18202): seconds: 1642076333 I/Firestore(18202): } I/Firestore(18202): fields { I/Firestore(18202): key: "local_timestamp" I/Firestore(18202): value { I/Firestore(18202): integer_value: 0 I/Firestore(18202): timestamp_value { I/Firestore(18202): nanos: 359211000 I/Firestore(18202): seconds: 1643372726 I/Firestore(18202): } I/Firestore(18202): } I/Firestore(18202): } I/Firestore(18202): fields { I/Firestore(18202): key: "server_timestamp" I/Firestore(18202): value { I/Firestore(18202): integer_value: 0 I/Firestore(18202): timestamp_value { I/Firestore(18202): nanos: 958000000 I/Firestore(18202): seconds: 1643372811 I/Firestore(18202): } I/Firestore(18202): } I/Firestore(18202): } I/Firestore(18202): name: "projects/tillty-repros/databases/(default)/documents/issues/6749" I/Firestore(18202): update_time { I/Firestore(18202): nanos: 23504000 I/Firestore(18202): seconds: 1643372812 I/Firestore(18202): } I/Firestore(18202): } I/Firestore(18202): target_ids: 2 I/Firestore(18202): } I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream received: # com.google.firestore.v1.ListenResponse@bb6b294e I/Firestore(18202): target_change { I/Firestore(18202): read_time { I/Firestore(18202): nanos: 23504000 I/Firestore(18202): seconds: 1643372812 I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\320\355\306\345\270\324\365\002" I/Firestore(18202): } I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: Apply remote event I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: notifyLocalViewChanges I/Firestore(18202): (24.0.1) [WatchStream]: (5c49860) Stream received: # com.google.firestore.v1.ListenResponse@189b08c2 I/Firestore(18202): target_change { I/Firestore(18202): read_time { I/Firestore(18202): nanos: 34237000 I/Firestore(18202): seconds: 1643372857 I/Firestore(18202): } I/Firestore(18202): resume_token: "\n\t\b\375\213\202\373\270\324\365\002" I/Firestore(18202): } I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: Apply remote event I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: notifyLocalViewChanges I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Performing stream teardown I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Stream sending: # com.google.firestore.v1.WriteRequest@a9bc0ee4 I/Firestore(18202): stream_token: "\020\001\031\020hB\002\201\364\265\265" I/Firestore(18202): (24.0.1) [WriteStream]: (4f533ba) Closing stream client-side I/Firestore(18202): (24.0.1) [WriteStream]: stream callback skipped by CloseGuardedRunner. I/Firestore(18202): (24.0.1) [Persistence]: Starting transaction: Collect garbage I/Firestore(18202): (24.0.1) [LruGarbageCollector]: Garbage collection skipped; Cache size 118784 is lower than threshold 104857600 ```

Turning off doze mode

You can use the command adb shell dumpsys deviceidle disable to turn off doze mode. When turned off, the above never happens, as the device has a continuous connection to the backend.

To turn doze mode back on, use the command adb shell dumpsys deviceidle enable.

There's a section on exemptions from doze mode, which might be a valid workaround for some people, which can be found here: https://developer.android.com/training/monitoring-device-state/doze-standby

Summary

So this seems to be an unhealthy cocktail of Flutter+gRPC+Doze that causes this issue. I'm not convinced there isn't an issue with gRPC, since we're seeing those DNS resolution errors when coming out of sleep, which might compound the problem.

I'm not sure where to begin fixing this, but I hope some of these observations are helpful and can give a clue to what is happening.

Other issues

This is one of those issues that has been reported many times, fixed many times, but apparently not good enough yet. Here's some other issues that all point to the same thing: https://github.com/FirebaseExtended/flutterfire/issues/6355 https://github.com/FirebaseExtended/flutterfire/issues/4305 - This issue claims it should have been fixed in https://github.com/firebase/firebase-android-sdk/pull/2763 https://github.com/firebase/firebase-android-sdk/issues/2637 https://github.com/firebase/firebase-android-sdk/issues/3302 gRPC issues that seem VERY related: https://github.com/grpc/grpc-java/issues/5610 https://github.com/grpc/grpc-java/issues/4028 https://github.com/grpc/grpc-java/issues/8860

SO: https://stackoverflow.com/questions/67877284/firebase-unable-to-reconnect-after-exiting-doze-mode https://stackoverflow.com/questions/53313824/not-receiving-document-updates-on-network-disconnect-and-reconnect-in-firestore

Other: https://groups.google.com/g/firebase-talk/c/9D9rXvhBmUM/m/wFBVapeGAwAJ

cc @darshankawar

larssn commented 2 years ago

This PR upstream is of interest IMO: https://github.com/grpc/grpc-java/pull/8855

wujek-srujek commented 2 years ago

@larssn Sorry for taking so much time with it. I can't reproduce the issue on native Android either, still have issues on Flutter, though, no change here.

larssn commented 2 years ago

@darshankawar This is fixed in Firebase BoM 29.2.0 which contains GRPC 1.44.1

larssn commented 2 years ago

You can try the version if you're impatient by adding the following to android/app/build.gradle:

rootProject.ext {
  set('FlutterFire', [
    FirebaseSDKVersion: '29.2.0'
  ])
}
wujek-srujek commented 2 years ago

I updated to everything latest (Flutter 2.10.4, all the dependencies including FlutterFire etc., forced FirebaseSDKVersion to 29.3.0 on Android and to 8.14.0 (as described here: https://firebase.flutter.dev/docs/manual-installation/#overriding-firebase-sdk-versions) and verified that these are indeed the versions used) and the problem still occurs for my app, both on Android and on iOS.

Behavior:

I have no idea what is going on, but the summary is:

This issue should not be closed.

larssn commented 2 years ago

I updated to everything latest (Flutter 2.10.4, all the dependencies including FlutterFire etc., forced FirebaseSDKVersion to 29.3.0 on Android and to 8.14.0 (as described here: https://firebase.flutter.dev/docs/manual-installation/#overriding-firebase-sdk-versions) and verified that these are indeed the versions used) and the problem still occurs for my app, both on Android and on iOS.

Behavior:

  • I start the apps on a Pixel 3XL and iPhone XS and change some data on Android - changes almost immediately visible on the iPhone.
  • I then change data on the iPhone - changes almost immediately visible on Android.
  • I lock bock devices and go for a walk.
  • Come back after half an hour, unlock both devices.
  • Change data on Android - no change on iPhone.
  • Change data on iPhone - no change on Android.
  • Change data in the web console - no change on any of the apps.
  • I force kill the apps and restart them.
  • Sync works again.

I have no idea what is going on, but the summary is:

  • Initially, up until about 9 months ago, it all worked.
  • Then it stopped working and has been broken for me ever since.
  • The problem I'm having is on both Android and iOS, while the comments in this issue tend to mention Android only.

This issue should not be closed.

I'd try to make a simple reproduction of it: Make a new Flutter project and keep everything as minimalistic as possible, and see if you can still reproduce the bug.

Thats what I did above, which convinced me that the problem was not a bug in my end. πŸ™‚

wujek-srujek commented 2 years ago

What I did instead is I created a completely new Firebase project (I wanted to change the packageName and bundleId anyway), regenerated the whole project (i.e. the android, ios etc. folders) with Flutter 2.10.4, updated to everything latest etc. Basically I redid everything around the code and assets, and now sync works fine. When I test with the old Firebase project and older Flutter (but latest package versions), it doesn't work on either platform. I have no idea what was wrong with the 'old' Firebase project configuration and why it spontaneously broke at some point. What I also don't know is whether I was really having problems with the issue described here (with grpc etc.) or something different, as it also breaks iOS. If anybody from Firebase would like access to the old project to check the config, let me know.