-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Description
In our live app, our top crash used to happen when our UnityPlayerActivity would receive onResume. (call stack will be shown below).
Looking at the code of AppStartTrace.java at line 355 (at revision a350561 on April 25th, 2024 ), the line is:
353 if (isExperimentTTIDEnabled) {
354 View rootView = activity.findViewById(android.R.id.content);
355 rootView.getViewTreeObserver().addOnDrawListener(onDrawCounterListener); // crash happens here
It is unclear why, in certain cases, line 354 would return null.
The crash disappeared when we disabled ExperimentTTID by adding
<meta-data android:name="experiment_app_start_ttid" android:value="false" />
to our AndroidManifest.xml
We have never reproduced the issue internally, or never noticed that it happened.
It seems to happen on Android 12 and above.
Would a null check against rootView resolve the issue? Or is there a deeper reason and that value should never be null?
Since our app is large, maybe the view hasn't finished initialization at that point? (Google Play vitals has flagged our Warm app start metric as problematic, if that helps.)
Reproducing the issue
No known reproduction steps.
Firebase Unity SDK Version
11.7.0
Unity editor version
2022.3.27f1
Installation Method
Unity Package Manager
Problematic Firebase Component(s)
Performance
Other Firebase Component(s) in use
Analytics, Crashlytics, DynamicLinks, Messaging
Additional SDKs you are using
- Google Play (Play Games, App Update, App Bundle)
- Tapjoy
- Unity Ads
- Adjust
- Airship
- Helpshift
- Ironsource
- Applovin
Targeted Platform(s)
Android
Unity editor platform
Mac, Windows
Scripting Runtime
IL2CPP
Release Distribution Type
Pre-built SDK from https://firebase.google.com/download/unity
Relevant Log Output
truncated call stack of crash:
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewTreeObserver android.view.View.getViewTreeObserver()' on a null object reference
at com.google.firebase.perf.metrics.AppStartTrace.onActivityResumed(AppStartTrace.java:355)
at android.app.Application.dispatchActivityResumed(Application.java:436)
at android.app.Activity.dispatchActivityResumed(Activity.java:1489)
at android.app.Activity.onResume(Activity.java:2081)
at com.unity3d.player.UnityPlayerActivity.onResume(UnityPlayerActivity.java:97)If using CocoaPods for Apple platforms, the project's Podfile.lock
Expand Podfile.lock snippet
👀 Replace this line with the contents of your Podfile.lock!