Migration from GCM to FCM

182 views
Skip to first unread message

Pavel Seleznev

unread,
May 18, 2021, 8:54:52 AM5/18/21
to Chromium-dev

Hello,

I have applied my changes on Chromium 90.0.4430.210 for Android and found that I can't send test notification from Firebase Console even the token value is the same as for Chromium 89.0.4389.105.

I checked the migration commit
https://chromium.googlesource.com/chromium/src/+/a59edbdba691e190d696eda5aaaea0eccc7d3eea
but did not find something that can break notifications

I would really appreciate any hints on how to debug this issue.

Regards,
Pavel

Pavel Seleznev

unread,
May 25, 2021, 8:24:58 AM5/25/21
to Chromium-dev, Pavel Seleznev
So,

When I send test event from FirebaseConsole I get the log below for active mobile browser
(for background I got nothing)


AndroidRuntime: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.thidparty.mobilebrowser. Make sure to call FirebaseApp.initializeApp(Context) first.
AndroidRuntime:   at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:183)
AndroidRuntime:   at com.google.firebase.messaging.MessagingAnalytics.logToScion(com.google.firebase:firebase-messaging@@21.0.1:27)
AndroidRuntime:   at com.google.firebase.messaging.MessagingAnalytics.logNotificationReceived(com.google.firebase:firebase-messaging@@21.0.1:2)
AndroidRuntime:   at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(com.google.firebase:firebase-messaging@@21.0.1:7)
AndroidRuntime:   at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(com.google.firebase:firebase-messaging@@21.0.1:3)
AndroidRuntime:   at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(com.google.firebase:firebase-messaging@@21.0.1:3)
AndroidRuntime:   at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$EnhancedIntentService(Unknown Source:1)
AndroidRuntime:   at com.google.firebase.messaging.EnhancedIntentService$$Lambda$0.run(Unknown Source:6)
AndroidRuntime:   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
AndroidRuntime:   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
AndroidRuntime:   at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@17.5.0:6)
AndroidRuntime:   at java.lang.Thread.run(Thread.java:764)

Can anybody suggest how can I fix it?

- is this happen because of special build of Firebase Java Library?
- is this happen because I missconfigured InstanceId/authorized_entity? I have specified them only during receiving token
- I putted values from google-services.json into values.xml but without any effect
- may be I should use FirebaseInitProvider

Regards,
Pavel

вторник, 18 мая 2021 г. в 15:54:52 UTC+3, Pavel Seleznev:

Peter Beverloo

unread,
May 25, 2021, 8:36:57 AM5/25/21
to pavel.s...@gmail.com, Chromium-dev
Hi Pavel,

There is a lot of functionality in Chromium that depends on specific details of the GCM configuration we have in place, so swapping it out with Firebase directly isn't straightforward, and actually is something that we've been working on for a couple of months & isn't due to complete until next year.

If your use-case allows for breaking Web Notifications, Sync, Enterprise provisioning & a slew of other things, you could start by removing all functionality from the InstanceIDBridge, then removing the actual dependency on GCM/FCM that already exists, then re-adding your own behaviour on top. You'd be making some significant forks here, and maintenance will be an issue—particularly as we're working in this area as well.

Thanks,
Peter


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/28b9a465-5202-4486-a7ed-8556ba786687n%40chromium.org.

Pavel Seleznev

unread,
May 25, 2021, 10:22:02 AM5/25/21
to Chromium-dev, Peter Beverloo, Chromium-dev, Pavel Seleznev

Hi Peter,

Thank you for clarifications.

One more question - are there any guidelines/references for proper Firebase initialization?

Regards,
Pavel

вторник, 25 мая 2021 г. в 15:36:57 UTC+3, Peter Beverloo:

Peter Beverloo

unread,
May 25, 2021, 11:00:29 AM5/25/21
to Pavel Seleznev, Chromium-dev
Please refer to the Firebase documentation for that, the exception you're getting is fairly explanatory:

Make sure to call FirebaseApp.initializeApp(Context) first.

In other words, make sure you call that function before using any of the individual Firebase APIs. If you see this message on the receive path, you'd probably have to add it to ChromeGcmListenerServiceImpl.

Thanks,
Peter

Pavel Seleznev

unread,
May 25, 2021, 11:19:27 AM5/25/21
to Chromium-dev, Peter Beverloo, Chromium-dev, Pavel Seleznev

> In other words, make sure you call that function before using any of the individual Firebase APIs.
>If you see this message on the receive path, you'd probably have to add it to ChromeGcmListenerServiceImpl.

I am working on it. Current question for me is how to write firebaseapp dependency in BUILD.gn

this variant didn't work
"//third_party/android_deps:com_google_firebase_firebase_common",

>>>
The item //chrome/android:chrome_java
can not depend on //third_party/android_deps:google_firebase_firebase_common_java
because it is not in //third_party/android_deps:google_firebase_firebase_common_java's visibility list: [
  //third_party/android_deps:*
  //third_party/androidx:*
<<<

and I am looking of how visibility list is organized, but may be I should add some new line in build.gradle file

Regards,
Pavel
вторник, 25 мая 2021 г. в 18:00:29 UTC+3, Peter Beverloo:

Pavel Seleznev

unread,
May 31, 2021, 4:14:13 PM5/31/21
to Chromium-dev, Pavel Seleznev, Peter Beverloo, Chromium-dev
Hi Peter and everyone,

I am a little bit confused about the points where I should put the code
FirebaseApp.initializeApp(ContextUtils.getApplicationContext());
Log.e(TAG, "FIREBASE APP INITIALIZED");

I have used the code above in 2 places
1) in method performPreInflationStartup of ChromeActivity class (suppose it is main thread)
2) in method onCreate of ChromeGcmListenerService class (suppose it is thread created by android)

and still get the exception

12274 12274 E cr_chromium: FIREBASE APP INITIALIZED
12274 12466 E AndroidRuntime: FATAL EXCEPTION: Firebase-Messaging-Intent-Handle
12274 12466 E AndroidRuntime: Process: global.netbox.mobilebrowser, PID: 12274

According to the log the exception happens in a thread which is not the one that I use to do the initialization,
but I didn't see the proper point to put initialization code (tried onNewIntent, but without success)

Can anyone advice me on that please?

Regards,
Pavel

вторник, 25 мая 2021 г. в 18:19:27 UTC+3, Pavel Seleznev:

Peter Beverloo

unread,
May 31, 2021, 6:07:17 PM5/31/21
to Pavel Seleznev, Chromium-dev
Hi Pavel,

What the appropriate place is depends entirely on the call path towards the exception. Interaction with InstanceID is done on a handler thread, so you'd have to do it right before usage. (Which the API mandates anyway, I believe.) I would suggest looking at the call stack to see the latest point in Chromium code prior to the exception being thrown, and starting there. When there is none, I'd suggest mimicking what the Firebase Cloud Messaging examples do.

Thanks,
Peter

Pavel Seleznev

unread,
Jun 2, 2021, 3:16:24 AM6/2/21
to Chromium-dev, Peter Beverloo, Chromium-dev, Pavel Seleznev
Hello Peter,

My mistake that I didn't provided full log in previous email, see it below

06-01 16:53:15.412 26793 26970 E AndroidRuntime: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.thirdparty.browser. Make sure to call FirebaseApp.initializeApp(Context) first.
06-01 16:53:15.412 26793 26970 E AndroidRuntime:   at o20.b(chromium-ChromePublic.apk-stable-11:5)
06-01 16:53:15.412 26793 26970 E AndroidRuntime:   at Xz0.b(chromium-ChromePublic.apk-stable-11:28)
06-01 16:53:15.412 26793 26970 E AndroidRuntime:   at com.google.firebase.messaging.FirebaseMessagingService.b(chromium-ChromePublic.apk-stable-11:28)
06-01 16:53:15.412 26793 26970 E AndroidRuntime:   at EV.run(chromium-ChromePublic.apk-stable-11:1)
06-01 16:53:15.412 26793 26970 E AndroidRuntime:   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
06-01 16:53:15.412 26793 26970 E AndroidRuntime:   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
06-01 16:53:15.412 26793 26970 E AndroidRuntime:   at W22.run(chromium-ChromePublic.apk-stable-11:2)
06-01 16:53:15.412 26793 26970 E AndroidRuntime:   at java.lang.Thread.run(Thread.java:764)

This log is for release-x86 version and it didn't contains usefull information for me and I decided to get log for
debug-x86 version. I have been surpised that in debug-x86 version I have got the notification for closed browser
and no crash for open browser.

GN args differences are
* is_debug          = true/false
* sumbol_level      = 2/1
* is_official_build = false/true
* is_component_build= true/false

May be somewhere the "is_official_build" flag has an impact over the build process,
but I didn't see any condition flags in //components/gcm_driver sources.

Regards,
Pavel

вторник, 1 июня 2021 г. в 01:07:17 UTC+3, Peter Beverloo:
Reply all
Reply to author
Forward
0 new messages