-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Is there an existing issue for this?
- I have searched the existing issues.
Which plugins are affected?
Messaging
Which platforms are affected?
Android, iOS
Description
I have got complains that the Flutter app never starts on different locations and phones.
After some research some users have blocked their analytics servers on their wifi.
I develop on a mac and have tested this issue using the "Network Link Conditioner" using 100% loss.
In the call: await FirebaseMessaging.instance.subscribeToTopic("mychannel"); it will stop totally and never snatch the errors from underlaying processes.
Here is the errors I got:
I/FLTFireMsgService( 3823): FlutterFirebaseMessagingBackgroundService started!
W/FLTFireMsgService( 3823): Attempted to start a duplicate background isolate. Returning...
E/FirebaseMessaging( 3823): Failed to get FIS auth token
E/FirebaseMessaging( 3823): java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseMessaging( 3823): at com.google.android.gms.tasks.Tasks.zza(com.google.android.gms:play-services-tasks@@18.1.0:5)
E/FirebaseMessaging( 3823): at com.google.android.gms.tasks.Tasks.await(com.google.android.gms:play-services-tasks@@18.1.0:9)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.GmsRpc.setDefaultAttributesToBundle(GmsRpc.java:283)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.GmsRpc.startRpc(GmsRpc.java:245)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.GmsRpc.getToken(GmsRpc.java:195)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.FirebaseMessaging.lambda$blockingGetToken$14$com-google-firebase-messaging-FirebaseMessaging(FirebaseMessaging.java:650)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.FirebaseMessaging$$ExternalSyntheticLambda14.start(D8$$SyntheticClass:0)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.RequestDeduplicator.getOrStartGetTokenRequest(RequestDeduplicator.java:67)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.FirebaseMessaging.blockingGetToken(FirebaseMessaging.java:646)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.TopicsSubscriber.blockingSubscribeToTopic(TopicsSubscriber.java:275)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.TopicsSubscriber.performTopicOperation(TopicsSubscriber.java:234)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.TopicsSubscriber.syncTopics(TopicsSubscriber.java:188)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.TopicsSyncTask.run(TopicsSyncTask.java:101)
E/FirebaseMessaging( 3823): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
E/FirebaseMessaging( 3823): at java.util.concurrent.FutureTask.run(FutureTask.java:264)
E/FirebaseMessaging( 3823): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
E/FirebaseMessaging( 3823): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/FirebaseMessaging( 3823): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/FirebaseMessaging( 3823): at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.3.0:2)
E/FirebaseMessaging( 3823): at java.lang.Thread.run(Thread.java:1012)
E/FirebaseMessaging( 3823): Caused by: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseMessaging( 3823): at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.createFirebaseInstallation(FirebaseInstallationServiceClient.java:209)
E/FirebaseMessaging( 3823): at com.google.firebase.installations.FirebaseInstallations.registerFidWithServer(FirebaseInstallations.java:533)
E/FirebaseMessaging( 3823): at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:387)
E/FirebaseMessaging( 3823): at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationOrRefresh$3$com-google-firebase-installations-FirebaseInstallations(FirebaseInstallations.java:372)
E/FirebaseMessaging( 3823): at com.google.firebase.installations.FirebaseInstallations$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
E/FirebaseMessaging( 3823): at com.google.firebase.concurrent.SequentialExecutor$1.run(SequentialExecutor.java:117)
E/FirebaseMessaging( 3823): at com.google.firebase.concurrent.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:229)
E/FirebaseMessaging( 3823): at com.google.firebase.concurrent.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:174)
E/FirebaseMessaging( 3823): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/FirebaseMessaging( 3823): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/FirebaseMessaging( 3823): at com.google.firebase.concurrent.CustomThreadFactory.lambda$newThread$0$com-google-firebase-concurrent-CustomThreadFactory(CustomThreadFactory.java:47)
E/FirebaseMessaging( 3823): at com.google.firebase.concurrent.CustomThreadFactory$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
E/FirebaseMessaging( 3823): ... 1 more
E/FirebaseMessaging( 3823): Failed to sync topics. Won't retry sync. java.util.concurrent.ExecutionException: java.io.IOException: SERVICE_NOT_AVAILABLE
I would like to be able to catch these errors on the try/catch-block and continue starting my app, or try to present a toast-message or equal. Now it just stands in "splashscreen mode" until forever.
Edit:
I made a work-around calling the subscribeToTopic() in a async Task during startup and a Timer check status. An local array was used to see if there where channels added with a call after the subscribe. It works, but not a nice solution in my opinion.
Also recalled the subscribeToTopic() if channels are empty but get this error directly:
Failed to sync topics. Won't retry sync. "java.util.concurrent.ExecutionException: java.io.IOException: SERVICE_NOT_AVAILABLE".
Restoring Wifi/Internet will make no difference (has to be tested with a clean file/cache on app).
Edit2:
If the firebase message has been been connected once before, it shows this error:
Topic operation failed: SERVICE_NOT_AVAILABLE. Will retry Topic operation.
Firebase takes 10-120 seconds or so to get online. Then the registration is done.
If the exception could be thrown, it would be possible to handle this much better.
Reproducing the issue
void main() async {
WidgetsFlutterBinding.ensureInitialized();
//Early init to get Firebase Crashlytics to trigger
await Firebase.initializeApp();
FirebaseAnalytics analytics = FirebaseAnalytics.instance;
//Only non debug uses the crash
await FirebaseCrashlytics.instance
.setCrashlyticsCollectionEnabled(!kDebugMode);
//Error handling of Flutter
FlutterError.onError = (FlutterErrorDetails details) async {
FlutterError.dumpErrorToConsole(details);
// Custom error handling logic
if (!kDebugMode) {
await FirebaseCrashlytics.instance
.recordFlutterError(details);
} else {
print(details.toString());
}
};
//Crash here from logcat, flutter never continue
await FirebaseMessaging.instance.subscribeToTopic("somechannel").then((t) {
//Will not be triggered on first time registration at all
//If app has been registered once, it will trigger after a retry internally in firebas-api
print("Firebase finished");
});
print("not getting here at all...");
//runApp(const MyApp());
}Also my app is running on runZonedGuarded() which makes no difference.
Firebase Core version
3.10.0
Flutter Version
3.27.2 (Channel stable) on macOS 15.2 24C101 darwin-arm64
Relevant Log Output
I/FLTFireMsgService( 3823): FlutterFirebaseMessagingBackgroundService started!
W/FLTFireMsgService( 3823): Attempted to start a duplicate background isolate. Returning...
E/FirebaseMessaging( 3823): Failed to get FIS auth token
E/FirebaseMessaging( 3823): java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseMessaging( 3823): at com.google.android.gms.tasks.Tasks.zza(com.google.android.gms:play-services-tasks@@18.1.0:5)
E/FirebaseMessaging( 3823): at com.google.android.gms.tasks.Tasks.await(com.google.android.gms:play-services-tasks@@18.1.0:9)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.GmsRpc.setDefaultAttributesToBundle(GmsRpc.java:283)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.GmsRpc.startRpc(GmsRpc.java:245)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.GmsRpc.getToken(GmsRpc.java:195)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.FirebaseMessaging.lambda$blockingGetToken$14$com-google-firebase-messaging-FirebaseMessaging(FirebaseMessaging.java:650)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.FirebaseMessaging$$ExternalSyntheticLambda14.start(D8$$SyntheticClass:0)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.RequestDeduplicator.getOrStartGetTokenRequest(RequestDeduplicator.java:67)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.FirebaseMessaging.blockingGetToken(FirebaseMessaging.java:646)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.TopicsSubscriber.blockingSubscribeToTopic(TopicsSubscriber.java:275)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.TopicsSubscriber.performTopicOperation(TopicsSubscriber.java:234)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.TopicsSubscriber.syncTopics(TopicsSubscriber.java:188)
E/FirebaseMessaging( 3823): at com.google.firebase.messaging.TopicsSyncTask.run(TopicsSyncTask.java:101)
E/FirebaseMessaging( 3823): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
E/FirebaseMessaging( 3823): at java.util.concurrent.FutureTask.run(FutureTask.java:264)
E/FirebaseMessaging( 3823): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
E/FirebaseMessaging( 3823): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/FirebaseMessaging( 3823): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/FirebaseMessaging( 3823): at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.3.0:2)
E/FirebaseMessaging( 3823): at java.lang.Thread.run(Thread.java:1012)
E/FirebaseMessaging( 3823): Caused by: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
E/FirebaseMessaging( 3823): at com.google.firebase.installations.remote.FirebaseInstallationServiceClient.createFirebaseInstallation(FirebaseInstallationServiceClient.java:209)
E/FirebaseMessaging( 3823): at com.google.firebase.installations.FirebaseInstallations.registerFidWithServer(FirebaseInstallations.java:533)
E/FirebaseMessaging( 3823): at com.google.firebase.installations.FirebaseInstallations.doNetworkCallIfNecessary(FirebaseInstallations.java:387)
E/FirebaseMessaging( 3823): at com.google.firebase.installations.FirebaseInstallations.lambda$doRegistrationOrRefresh$3$com-google-firebase-installations-FirebaseInstallations(FirebaseInstallations.java:372)
E/FirebaseMessaging( 3823): at com.google.firebase.installations.FirebaseInstallations$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
E/FirebaseMessaging( 3823): at com.google.firebase.concurrent.SequentialExecutor$1.run(SequentialExecutor.java:117)
E/FirebaseMessaging( 3823): at com.google.firebase.concurrent.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:229)
E/FirebaseMessaging( 3823): at com.google.firebase.concurrent.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:174)
E/FirebaseMessaging( 3823): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/FirebaseMessaging( 3823): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/FirebaseMessaging( 3823): at com.google.firebase.concurrent.CustomThreadFactory.lambda$newThread$0$com-google-firebase-concurrent-CustomThreadFactory(CustomThreadFactory.java:47)
E/FirebaseMessaging( 3823): at com.google.firebase.concurrent.CustomThreadFactory$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
E/FirebaseMessaging( 3823): ... 1 more
E/FirebaseMessaging( 3823): Failed to sync topics. Won't retry sync. java.util.concurrent.ExecutionException: java.io.IOException: SERVICE_NOT_AVAILABLEFlutter dependencies
firebase_analytics: ^11.4.0
firebase_crashlytics: ^4.3.0
firebase_messaging: ^15.2.0
firebase_core: ^3.10.0
flutter_local_notifications: ^18.0.1Additional context and comments
Tested on Android & iOS emulator on my Mac
Tested on real life app, debug or release it will do the same.