firebase / firebase-android-sdk

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

[Bug] InAppMessaging ArrayIndexOutOfBoundsException #2509

Closed Nyankoo closed 4 weeks ago

Nyankoo commented 3 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

Some of our users getting crashes caused by the InAppMessaging package. When this is happening is currently unknown to us, as we can't replicate this on our end.

The devices the crashes happen on are:

Steps to reproduce:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?

What happened? How can we make the problem occur?

If you have a downloadable sample project that reproduces the bug you're reporting, you will likely receive a faster response on your issue.

Relevant Code:

Caused by java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
       at com.google.protobuf.MessageSchema.newSchemaForRawMessageInfo(MessageSchema.java:507)
       at com.google.protobuf.MessageSchema.newSchema(MessageSchema.java:227)
       at com.google.protobuf.ManifestSchemaFactory.newSchema(ManifestSchemaFactory.java:77)
       at com.google.protobuf.ManifestSchemaFactory.createSchema(ManifestSchemaFactory.java:71)
       at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:90)
       at com.google.protobuf.Protobuf.schemaFor(Protobuf.java:104)
       at com.google.protobuf.GeneratedMessageLite.makeImmutable(GeneratedMessageLite.java:175)
       at com.google.protobuf.GeneratedMessageLite$Builder.buildPartial(GeneratedMessageLite.java:395)
       at com.google.protobuf.GeneratedMessageLite$Builder.build(GeneratedMessageLite.java:403)
       at com.google.firebase.inappmessaging.CampaignAnalytics$Builder.setClientApp(CampaignAnalytics.java:1049)
       at com.google.firebase.inappmessaging.internal.MetricsLoggerClient.createCampaignAnalyticsBuilder(MetricsLoggerClient.java:193)
       at com.google.firebase.inappmessaging.internal.MetricsLoggerClient.createEventEntry(MetricsLoggerClient.java:170)
       at com.google.firebase.inappmessaging.internal.MetricsLoggerClient.lambda$logMessageClick$1(MetricsLoggerClient.java:126)
       at com.google.firebase.inappmessaging.internal.MetricsLoggerClient$$Lambda$2.onSuccess(:6)
       at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@17.2.1:1)
       at android.os.Handler.handleCallback(Handler.java:808)
       at android.os.Handler.dispatchMessage(Handler.java:101)
       at android.os.Looper.loop(Looper.java:166)
       at android.app.ActivityThread.main(ActivityThread.java:7529)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Nyankoo commented 3 years ago

Possibly related to this? https://github.com/firebase/firebase-android-sdk/issues/2158#issuecomment-732989095

chkuang-g commented 3 years ago

@Nyankoo

This is odd. I don't think we provide InAppMessaging API in our Firebase Unity SDK. Are you using InAppMessaging in your app? If so, is your project directly use native Android SDK?

If not, the only possible reason is that one of those Firebase product you used, a.k.a Firestore, Analytics, Crashlytics, Remote Config, is calling InAppMessaging API internally. Or perhaps Admob is using it. From the functionality of those products and InAppMessaging, it does not make too much sense though.

https://github.com/firebase/firebase-android-sdk/issues/2158#issuecomment-732989095 looks like an issue for Firebase Performance, which is not available in Unity SDK either. Also that is not related to InAppMessaging.

Could you provide a bit more information about how InAppMessaging got into your app?

Shawn

Nyankoo commented 3 years ago

@chkuang-g Yes, we're using the native Android SDK directly by adding the correct dependencies through the External Dependency Manager.

chkuang-g commented 3 years ago

@Nyankoo

Ah I see.
Currently Firebase Unity SDK does not fully support this use-case, that is mixed use of Android native SDK and Unity SDK. We do not test Unity SDK for such use at all so we cannot guarantee it works perfectly. Also it is hard for me to tell if this is an Android SDK issue or something related to the whole C++/Unity architecture. I'm most concerned about the life-cycle of the FirebaseApp instance from Android.

However, I recognize that some team would do so to access Firebase products which is not available in Unity SDK yet. I appreciate the enthusiasm! However, the safest way is to file a feature request ticket to Unity SDK team to properly support InAppMessaging. But I digress.

Let clarify several things first

Also, I would recommend you to open a ticket at firebase-android-sdk repo and point to this issue as a reference.

Nyankoo commented 3 years ago

@chkuang-g Thank you for the detailed explanation!

Do I file a feature request directly here in this repo, or somewhere else?

About your questions:

Another note that could be important is that we're getting the same debug output ("Starting InAppMessaging runtime...") on our test devices as mentioned in the Android documentation here: https://firebase.google.com/docs/in-app-messaging/get-started?authuser=0&platform=android#get_your_apps

chkuang-g commented 3 years ago

Thank you for the information.

I'll forward this to the team.

vimanyu commented 3 years ago

Hi @Nyankoo, Do you know if your application is directly or transitively pulling in a version of protobuf libraries (protobuf-javalite or any other protobuf libraries) that is different from Firebase protobuf library version?

For FIAM 19.1.4, we are using 3.14.0.

|    |    +--- com.google.firebase:protolite-well-known-types:17.1.1
|    |    |    \--- com.google.protobuf:protobuf-javalite:3.14.0
Nyankoo commented 3 years ago

@vimanyu Is there a way to check this somewhere in the final .aab file (or somewhere else)?

vimanyu commented 3 years ago

If you are using gradle for your application, you could run the following to get list of dependencies.

# assuming app is the name of the project
./gradlew app:dependencies
Nyankoo commented 3 years ago

@vimanyu These are the dependencies I could find, added by the Firestore and In-App Messaging plugins:

com.google.protobuf:protobuf-javalite:3.14.0
io.grpc:grpc-protobuf-lite:1.28.0
com.google.protobuf:protobuf-javalite:3.11.0 -> 3.14.0
io.grpc:grpc-protobuf-lite:1.28.0 (*)
vimanyu commented 3 years ago

Great. So if you export your project to Android Studio project (using MainTemplate gradle) from Unity, you should be able to query all the dependencies being pulled in by the application. We are trying to see if there is any non-compatible version of protobuf libraries being introduced by any other package.

Nyankoo commented 3 years ago

@vimanyu The above dependencies are the only ones I can see in the dependency tree after exporting to Android Studio.

vimanyu commented 3 years ago

Thanks for confirming. It does seem like something tried to get javalite 3.11.0 but was bumped up to 3.14.0. Another clarification, is the error 100% reproducible on the devices listed in the original post?

Nyankoo commented 3 years ago

@vimanyu We sadly don't have any of the listed devices on hand to test this. The list comes directly from Crashlytics (user devices).

google-oss-bot commented 3 years ago

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

vimanyu commented 3 years ago

Moving this issue to firebase-android-sdk as this seems like something not caused by the C++/Unity layer. We haven't been able to reproduce this issue locally but we should keep an eye out for this just incase there are more occurrences. User pointed out it could be related to https://github.com/firebase/firebase-android-sdk/issues/2158 and I have confirmed that we are using the libraries with versions which should have the fix for that issue.

Something that could be related as per internal discussions is, b/169066309

Nyankoo commented 3 years ago

Any update on this?

Nyankoo commented 3 years ago

@vimanyu @aguatno

vimanyu commented 3 years ago

Hi @Nyankoo, unfortunately since it is not reproducible, it hasn't been prioritized yet. Are you running into it often? @var-const, have we seen this error being reported by users of Android SDK before?

var-const commented 3 years ago

@vimanyu I don't think we've seen this in Firestore -- adding @schmidt-sebastian Sebastian to confirm.

Nyankoo commented 3 years ago

@vimanyu @var-const This happened to a majority of our users and we needed to pull the plug by disabling all In-App Messaging setups in the Firebase Dashboard. Since then, we didn't try again.

schmidt-sebastian commented 3 years ago

cc @gesly who works on In App Messaging

Nyankoo commented 3 years ago

@vimanyu @var-const @schmidt-sebastian Any update on this?