firebase-unity-sdk
firebase-unity-sdk copied to clipboard
[Bug] Crashlytics Crash
[REQUIRED] Please fill in the following fields:
- Unity editor version: 2020.3.34f1
- Firebase Unity SDK version: 9.4.0
- Source you installed the SDK: unitypackage
- Problematic Firebase Component: Crashlytics
- Other Firebase Components in use: Crashlytics, Installations, DynamicLinks
- Additional SDKs you are using: Google Mobile Ads v7.1.0, GooglePlayGames 0.10.06
- Platform you are using the Unity editor on: Windows
- Platform you are targeting:Android
- Scripting Runtime: IL2CPP
- Pre-built SDK from the website or open-source from this repo: repo
[REQUIRED] Please describe the issue here:
2022-08-17 01:31:08.869 4696-4738/com.playflock.family.hotel.story.home.mansion.puzzle.garden.decoration A/rden.decoratio: runtime.cc:675] at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:278)
runtime.cc:675] at com.google.firebase.crashlytics.internal.common.Utils.awaitEvenIfOnMainThread(Utils.java:124)
runtime.cc:675] at com.google.firebase.crashlytics.internal.common.CrashlyticsCore.checkForPreviousCrash(CrashlyticsCore.java:485)
runtime.cc:675] at com.google.firebase.crashlytics.internal.common.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:184)
runtime.cc:675] at com.google.firebase.crashlytics.FirebaseCrashlytics.init(FirebaseCrashlytics.java:149)
runtime.cc:675] at com.google.firebase.crashlytics.CrashlyticsRegistrar.buildCrashlytics(CrashlyticsRegistrar.java:57)
runtime.cc:675] at com.google.firebase.crashlytics.CrashlyticsRegistrar.lambda$Pfd5XmDCFzNyAT9o9H6rDnTBQE4(unavailable:0)
runtime.cc:675] at com.google.firebase.crashlytics.-$$Lambda$CrashlyticsRegistrar$Pfd5XmDCFzNyAT9o9H6rDnTBQE4.create(unavailable:2)
runtime.cc:675] at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0$ComponentRuntime(ComponentRuntime.java:132)
runtime.cc:675] at com.google.firebase.components.-$$Lambda$ComponentRuntime$4FqOW9eOQsvFYo-HpMfxCOnPQr0.get(unavailable:4)
runtime.cc:675] at com.google.firebase.components.Lazy.get(Lazy.java:53)
runtime.cc:675] - locked <0x0ca76207> (a com.google.firebase.components.Lazy)
runtime.cc:675] at com.google.firebase.components.ComponentRuntime.doInitializeEagerComponents(ComponentRuntime.java:291)
runtime.cc:675] at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(ComponentRuntime.java:281)
runtime.cc:675] at com.google.firebase.FirebaseApp.initializeAllApis(FirebaseApp.java:594)
runtime.cc:675] at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:305)
runtime.cc:675] at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:269)
runtime.cc:675] at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:254)
runtime.cc:675] - locked <0x0b8d0f34> (a java.lang.Object)
runtime.cc:675] at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
runtime.cc:675] at android.content.ContentProvider.attachInfo(ContentProvider.java:2516)
runtime.cc:675] at android.content.ContentProvider.attachInfo(ContentProvider.java:2486)
runtime.cc:675] at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
runtime.cc:675] at android.app.ActivityThread.installProvider(ActivityThread.java:8226)
runtime.cc:675] at android.app.ActivityThread.installContentProviders(ActivityThread.java:7728)
runtime.cc:675] at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7482)
runtime.cc:675] at android.app.ActivityThread.access$1600(ActivityThread.java:310)
runtime.cc:675] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2281)
runtime.cc:675] at android.os.Handler.dispatchMessage(Handler.java:106)
runtime.cc:675] at android.os.Looper.loopOnce(Looper.java:226)
runtime.cc:675] at android.os.Looper.loop(Looper.java:313)
runtime.cc:675] at android.app.ActivityThread.main(ActivityThread.java:8669)
runtime.cc:675] at java.lang.reflect.Method.invoke(Native method)
runtime.cc:675] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
runtime.cc:675] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
runtime.cc:675]
runtime.cc:675] "Runtime worker thread 1" prio=10 tid=2 Native (still starting up)
runtime.cc:675] | group="" sCount=1 ucsCount=0 flags=1 obj=0x0 self=0xf316f000
runtime.cc:675] | sysTid=4699 nice=-20 cgrp=default sched=0/0 handle=0xf33741c0
runtime.cc:675] | state=S schedstat=( 652186 0 6 ) utm=0 stm=0 core=4 HZ=100
runtime.cc:675] | stack=0xf3365000-0xf3367000 stackSize=60KB
runtime.cc:675] | held mutexes=
runtime.cc:675] native: #00 pc 0005c0ac /apex/com.android.runtime/lib/bionic/libc.so (syscall+28) (BuildId: c58c6e54c8fe595d7265cec136b3efd7)
2022-08-17 01:31:08.869 4696-4738/com.playflock.family.hotel.story.home.mansion.puzzle.garden.decoration A/rden.decoratio: runtime.cc:675] native: #01 pc 0023ceb7 /apex/com.android.art/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+78) (BuildId: dc0300bc7e69bff6ae7e34bc89549396)
runtime.cc:675] native: #02 pc 0050ad75 /apex/com.android.art/lib/libart.so (art::ThreadPool::GetTask(art::Thread*)+128) (BuildId: dc0300bc7e69bff6ae7e34bc89549396)
runtime.cc:675] native: #03 pc 0050a8b9 /apex/com.android.art/lib/libart.so (art::ThreadPoolWorker::Run()+36) (BuildId: dc0300bc7e69bff6ae7e34bc89549396)
runtime.cc:675] native: #04 pc 002c4137 /apex/com.android.art/lib/libart.so (art::ThreadPoolWorker::Callback(void*)+94) (BuildId: dc0300bc7e69bff6ae7e34bc89549396)
runtime.cc:675] native: #05 pc 000a92a7 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+40) (BuildId: c58c6e54c8fe595d7265cec136b3efd7)
runtime.cc:675] native: #06 pc 00062043 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: c58c6e54c8fe595d7265cec136b3efd7)
runtime.cc:675] (no managed stack frames)
Steps to reproduce:
Frequently reproduced on Samsung A51 or 52 devices, app always crash on restart. On first launch and Firebase initialization all ok
Relevant Code:
public override void Initialize()
{
Debug.Log("Initialize FirebaseAnalyticsService");
#if UNITY_EDITOR
return;
#endif
#if UNITY_ANDROID || UNITY_IOS
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
{
var dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available)
{
// Create and hold a reference to your FirebaseApp,
// where app is a Firebase.FirebaseApp property of your application class.
// Crashlytics will use the DefaultInstance, as well;
// this ensures that Crashlytics is initialized.
var app = FirebaseApp.DefaultInstance;
FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
Crashlytics.IsCrashlyticsCollectionEnabled = true;
InitializeFcm();
if (Debug.isDebugBuild)
{
FirebaseApp.LogLevel = LogLevel.Verbose;
}
_initializeDirtyFlag = true;
_initializeDirtyFlagStatic = true;
}
else
{
Debug.LogError("Could not resolve all Firebase dependencies : " + dependencyStatus);
}
});
#endif
}
and in some game places we call methods
public static void SetUserMetadata(string key, string value)
{
if(!_initializeDirtyFlagStatic)
return;
if(string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value))
return;
#if UNITY_ANDROID || UNITY_IOS
Crashlytics.SetCustomKey(key, value);
#endif
}
public static void SetMetadata_UserId(string id)
{
if(!_initializeDirtyFlagStatic)
return;
#if UNITY_ANDROID || UNITY_IOS
Crashlytics.SetUserId(id);
#endif
}
Hi @dreamcodestudio,
Thanks for reporting this issue. In order to identify what's causing the crash, could you provide a minimal, reproducible example of your implementation? Based on the code you initially provided, it doesn't seem like there's anything out of the ordinary happening.
Hi @dreamcodestudio,
Thanks for reporting this issue. In order to identify what's causing the crash, could you provide a minimal, reproducible example of your implementation? Based on the code you initially provided, it doesn't seem like there's anything out of the ordinary happening.
We use only this code nothing more
I attached full stack trace firebaseStack.txt
Our QA says that it more reproduce in mono build then IL2CPP can it affected? Last prod build without crashes used Firebase Unity 8.10.1
Hi @dreamcodestudio,
I've used the code you provided, but I haven't encountered any crashes. Does the issue occur with just the Firebase SDK in your implementation?
It would be great if you provide a sample project that reproduces the issue so that we can analyze what's causing this behavior.
i can't send you source project, it's published copyright version, nowadays deleted crashlytics module, i can try downdrade to 8.10.1 and send you result
yeap downgrade to 8.10.1 work fine, i try isolate problem with 9.4.0 version and send more info, if find it
I reproduced it on quickstart-unity project(only on Mono script backend, IL2CPP work fine), on crashlytics section, attached sample project on Unity 2020.3.34 and Firebase 9.4.0 by link I just changed source code of "Throw Exception" GUI button tos imulate gameObj NullRef
public void ThrowUncaughtException()
{
GameObject test = null;
test.SetActive(false);
}
After execute NullRef exception, i restart app and it always freeze on start Samsung A52 Android 12 One UI 4.1, restart freeze log firebaseTest_freeze.txt
Hi @dreamcodestudio,
Thanks for the additional information. I've followed these steps, and I haven't encountered the app freezing on start so far. I've used an Android 13 and an Android 12 device. What's the issue repro rate of this behavior on your device (eg 100%, 1/5 etc)? Does the behavior you're facing persist on any other devices or emulators?
Hi @dreamcodestudio,
Thanks for the additional information. I've followed these steps, and I haven't encountered the app freezing on start so far. I've used an Android 13 and an Android 12 device. What's the issue repro rate of this behavior on your device (eg 100%, 1/5 etc)? Does the behavior you're facing persist on any other devices or emulators?
it's 100% rate on Samsung device and Mono builds Task on our QA created, they collect info about device manufacturers
I attached apk, which freeze on restart game https://drive.google.com/file/d/1HPyG3L8Gn-KLa7gY-oyBexkR966k7NjK/view?usp=sharing
Video showcase
https://user-images.githubusercontent.com/7010398/186407100-ff551e39-899f-4ec7-8f5e-f22b16d23f9c.mp4
fast QA test
Thanks for the additional information, @dreamcodestudio. I'd like to ask for more information related to the issue.
- Do all the problem devices exhibit an issue rate of 100%?
- Does this behavior persist using Android virtual devices?
- Is your Optimized Frame Pacing (In Player Settings) enabled? If so, disabling it may resolve the issue.
Feel free to add more information that you may find useful.
- Devices from list above with tag "Crash" - 100% issue rate
- Not reproduces on virtual devices
- Optimized Frame Pacing flag disabled on our projects
Hi. I was looking into this issue after seeing it reported in Firebase Crashlytics. I'm an Android developer who uses the native development platform (Android Studio) to create apps, and one of our apps has started reporting this issue in large amounts. Seems very much like a Firebase bug. Something to note, according to Google, this isn't a crash. It's an ANR event.
Please specify a version that this problem does not occur for native Android. a lot of ANR events were reported!
Hi @dreamcodestudio, thanks for your patience here. I've been looking into this and I'm seeing a similar stack trace on a Pixel 5a using your precompiled APK from the Aug 24 comment, on launch after a crash. Though my error is a crash, not an ANR. Also, when I build it myself using the zipped project file from the previous day (or a fresh quickstart clone), I cannot reproduce it, despite ensuring they are Mono builds. So it isn't clear exactly what's happening.
I'm trying to get my hands on one of the Samsung devices that you said was problematic. In the meantime, does the behavior change at all if you remove the code that sets Crashlytics metadata? Also, can you provide the full logcat output (not just tombstone) for a clean launch + crash + restart for the FirebaseCrashlytics
and libcrashlytics
logcat tags on VERBOSE
?
Hi @dreamcodestudio, thanks for your patience here. I've been looking into this and I'm seeing a similar stack trace on a Pixel 5a using your precompiled APK from the Aug 24 comment, on launch after a crash. Though my error is a crash, not an ANR. Also, when I build it myself using the zipped project file from the previous day (or a fresh quickstart clone), I cannot reproduce it, despite ensuring they are Mono builds. So it isn't clear exactly what's happening.
I'm trying to get my hands on one of the Samsung devices that you said was problematic. In the meantime, does the behavior change at all if you remove the code that sets Crashlytics metadata? Also, can you provide the full logcat output (not just tombstone) for a clean launch + crash + restart for the
FirebaseCrashlytics
andlibcrashlytics
logcat tags onVERBOSE
?
I can try reproduce tomorrow on my personal Samsung A52 and attach more info
Metadata no matter, i just call only one method to reproduce it
public void ThrowUncaughtException()
{
GameObject test = null;
test.SetActive(false);
//DebugLog("Causing a platform crash.");
//throw new InvalidOperationException("Uncaught exception created from UI.");
}
Logs by tags tag:libcrashlytics tag:FirebaseCrashlytics level:verbose
FirebaseCrashlytics_libcrashlytics_verbose.txt But they not contains errors just infinity loop of call Initializing Firebase Crashlytics 18.2.12 Builded from Unity project https://drive.google.com/file/d/1ZmpVsIsneBFoO5TEhmYATd43BxxU7wFU/view
Log by package name and firebase filter package_name_firebase.txt Log contains errors It's not ANR or crash, but apps freeze on Unity logo and firebase logs infinity spam, they not stopped after time Builded from Unity project https://drive.google.com/file/d/1ZmpVsIsneBFoO5TEhmYATd43BxxU7wFU/view
Now i try it on Firebase Unity SDK version: 9.6.0 and on last version bug not reproduced on same device
@dreamcodestudio I'm glad the issue is not persisting on the latest version of the Firebase Unity SDK. Though from looking at the Crashlytics source changes, it isn't clear to me which change could have resolved the issue. The repeated logs of "Initializing Firebase Crashlytics 18.2.12..." is very strange, though it makes sense that repeatedly attempts to initialize the SDK would cause the app to crash / misbehave. My best guess at this point is there was some obscure conflict between the Firebase SDK's C# code and the underlying Crashlytics Android SDK that would only manifest on certain devices.
I'm going to close this GitHub issue since it seems to be resolved for you, but I'm continuing to track this investigation internally in case similar situations arise that we can reproduce locally. Thanks for the bug report and please let us know ASAP if the issue returns!