firebase-android-sdk: 160996413: Firebase IAM(In-App Messaging) Crash 💣 BUG

Basic info:

  • Android Studio version: 4.0
  • Firebase Component: In-App Messaging
  • Component version: 19.0.7

Describe the problem

We created a new campaign and for some of the users, the application failed during the showing In-App Message.

Here is the crash from crashlytics:

Fatal Exception: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
       at android.view.ViewRootImpl.setView(ViewRootImpl.java:1000)
       at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:428)
       at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:118)
       at com.google.firebase.inappmessaging.display.internal.FiamWindowManager.show(FiamWindowManager.java:28)
       at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay$4$4.run(FirebaseInAppMessagingDisplay.java:14)
       at android.app.Activity.runOnUiThread(Activity.java:7178)
       at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay$4.onSuccess(FirebaseInAppMessagingDisplay.java:89)
       at com.squareup.picasso.ImageViewAction.a(ImageViewAction.java:31)
       at com.squareup.picasso.Picasso.a(Picasso.java:28)
       at com.squareup.picasso.Picasso.a(Picasso.java:50)
       at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:81)
       at android.os.Handler.dispatchMessage(Handler.java:107)
       at android.os.Looper.loop(Looper.java:213)
       at android.app.ActivityThread.main(ActivityThread.java:8178)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

Steps to reproduce:

I can give you all devices which were affected, and maybe it can be helpful for you: 33% - Galaxy S10e 17% - Galaxy S20 Ultra 5G 17% - Galaxy S20 17% - P30 Pro 16% - HUAWEI P smart 2019

Relevant Code:

Nothing to share, it was implemented according to your documentation.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 22 (7 by maintainers)

Most upvoted comments

It seems that this issue is fixed in 19.1.5 as mentioned here : https://firebase.google.com/support/release-notes/android#inappmessaging_v19-1-5

@premacck Thank you for notice, I already reacted there.

@JasonAHeron For the last months we weren’t face with this issue again, nevertheless as I see from the comments above and also duplicating issues such as #1808, probably the bug is still exist. By start of the year we are planing several campaigns which will use the IAM, and the campaigns will be on the big audience, based on those data I will be able to tell you if this bug is still actual for me or not.

Thank you in advance see you next year.

Merry Christmas & Happy New Year to all 🎊.

I have this issue as well. It started to show up recently (June 26th):

Fatal Exception: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
       at android.view.ViewRootImpl.setView(ViewRootImpl.java:1069)
       at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:381)
       at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
       at com.google.firebase.inappmessaging.display.internal.FiamWindowManager.show(FiamWindowManager.java:62)
       at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay$4$4.run(FirebaseInAppMessagingDisplay.java:428)
       at android.app.Activity.runOnUiThread(Activity.java:6406)
       at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay$4.onSuccess(FirebaseInAppMessagingDisplay.java:424)
       at com.squareup.picasso.RequestCreator.into(RequestCreator.java:721)
       at com.google.firebase.inappmessaging.display.internal.FiamImageLoader$FiamImageRequestCreator.into(FiamImageLoader.java:65)
       at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay.loadNullableImage(FirebaseInAppMessagingDisplay.java:506)
       at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay.inflateBinding(FirebaseInAppMessagingDisplay.java:362)
       at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay.access$000(FirebaseInAppMessagingDisplay.java:83)
       at com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay$1.run(FirebaseInAppMessagingDisplay.java:298)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:7156)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

I’m using InAppMessaging library version 19.0.6. And it happens on different devices such as:

37% samsung
21% Xiaomi
9% motorola
9% HUAWEI
24% Other

I have a single activity app so it’s a bit weird.

Hey, so by trigger FIAM I mean trigger via any mechanism. It sounds like you’re triggering via Firebase Analytics. So what you can do is rather than trigger based on an analytics event that you fire right before killing your activity you can trigger from an event when you start the activity that you’re going to.

This is my understanding if your current setup.

Activity 1: 0. starts up and does work,

  1. triggers analytics event (that fiam is listening for)
  2. immediately kills itself and switches to another activity

Activity 2: 0. starts up and tries to display fiam from activity 1, crashes

you can solve this by triggering fiam from activity 2 when it starts rather than from activity 1 when it dies. Does that make sense?

Also we are aware of this and we are working on it but unfortunately I don’t always have the time to update this bug with my progress. Thank you for the detailed report though and we are indeed working on it.