firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.23k stars 564 forks source link

FirebaseMessaging : Disable retry Topic operation upon connection without internet #5980

Open haizadvnet opened 1 month ago

haizadvnet commented 1 month ago

Our app users have reported an issue where the app is slow to start, sometimes taking around 1 minute to fully load. This problem occurs when their devices have no data left, even though mobile data is turned on. Interestingly, this issue does not happen when mobile data is turned off.

The app is built using Flutter. We suspect that this issue is caused by the Firebase Messaging SDK on Android, which assumes the connection will recover soon and thus runs a retry operation. This retry operation appears to occur after Firebase.initializeApp is called:

FirebaseApp firebaseApp = await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
);

The log message after opening the app is as follows:

Topic operation failed: SERVICE_NOT_AVAILABLE. Will retry Topic operation.

We want to disable the retry operation because we don't want the user to wait too long for the app to start. How can we achieve this?

google-oss-bot commented 1 month ago

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

lehcar09 commented 1 month ago

Hi @haizadvnet, thank you for reaching out. For context, SERVICE_NOT_AVAILABLE means one of the following issues:

  1. The phone is offline.
  2. The phone is online but it cannot reach Google servers.
  3. The firebase messaging servers are temporarily unavailable.
  4. Google Play services are not installed on the phone.
  5. Google Play services are in an extremely bad state.

Currently, there is no way to disable the topic sync retry operation. Disabling topic synchronization means that your app will not receive updates to topics or topic subscriptions from the Firebase backend that might affect the apps that relies on topic-based messaging.

I'll mark this as a feature request to keep this under our radar. However, we can’t provide any timeline for this.

For folks who find this useful, adding an emoji thumbs up on the original post can help us prioritize adding this to the roadmap.