Quickstart-unity: FCM IllegalStateException crash in onTokenRefresh, Android 8 only

Created on 26 May 2018  路  7Comments  路  Source: firebase/quickstart-unity

I'm getting a lot of crash reports with Firebase Cloud Messaging related to onTokenRefresh. So far it has only occurred on Android 8.0/8.1 devices, on many different Android devices. I don't have an Android 8 test device, but I tried it in an Android 8 emulator and couldn't reproduce the crash. Here's one of the crash reports on the Google Play dashboard:

Samsung Galaxy Note8 (greatqlte), 6144MB RAM, Android 8.0
Report 2

java.lang.IllegalStateException: 
  at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1538)
  at android.app.ContextImpl.startService (ContextImpl.java:1484)
  at android.content.ContextWrapper.startService (ContextWrapper.java:663)
  at com.google.firebase.messaging.cpp.FcmInstanceIDListenerService.onTokenRefresh (FcmInstanceIDListenerService.java:24)
  at com.google.firebase.iid.FirebaseInstanceIdService.handleIntent (Unknown Source:12)
  at com.google.firebase.iid.zzg.run (Unknown Source:26)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
  at java.lang.Thread.run (Thread.java:764)

bug

Most helpful comment

We have a fix checked in and it should land in a release next week.

All 7 comments

Our crash rate go to 4% because of that error

capture png

I took a look into this issue and it looks like we're firing an Intent from FcmInstanceIDListenerService an Intent service to get the Intent service to get the most recent IID token and queue it for forwarding to the application. This does not work in Android 8.x (https://developer.android.com/about/versions/oreo/background) as the background service FcmInstanceIDListenerService can't start other services while the application is in the background. We have lined up a patch that should resolve this by moving the token refresh logic from the Intent service to FcmInstanceIDListenerService.

The problem is pretty hard to reproduce as far as I can tell since it will only happen if the IID token changes while the app is in the background or closed.

We have a fix checked in and it should land in a release next week.

is this fixed in 5.0.0?

The 5.1.0 release of the Firebase Unity SDK resolves this issue:
Release notes: https://firebase.google.com/support/release-notes/unity#5.1.0
Download: https://firebase.google.com/docs/unity/setup

Hi ,this issue also happened on firebase unitysdk 5.4.0

We see the same error in Unitysdk 5.4.3. Does 5.5.0 have a fix, or should we downgrade to 5.3?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SeanLangre picture SeanLangre  路  3Comments

v-sag picture v-sag  路  6Comments

kantagara picture kantagara  路  5Comments

exzizt picture exzizt  路  4Comments

Crashthatch picture Crashthatch  路  5Comments