firebase-unity-sdk: [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
	    }

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 24 (4 by maintainers)

Most upvoted comments

@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!

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?

I can try reproduce tomorrow on my personal Samsung A52 and attach more info