Skip to content

[Bug] Native crash in libFirebaseCppApp #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Jack37 opened this issue Nov 2, 2021 · 29 comments
Closed

[Bug] Native crash in libFirebaseCppApp #1170

Jack37 opened this issue Nov 2, 2021 · 29 comments
Labels
api: core closed-by-bot needs-info Need information for the developer stale Don't have recent activity type: question

Comments

@Jack37
Copy link

Jack37 commented Nov 2, 2021

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.3.21f1
  • Firebase Unity SDK version: 8.5.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: libFirebaseCppApp
  • Other Firebase Components in use: Analytics, Firestore, Messaging
  • Additional SDKs you are using: IronSource, PlayFab, Photon, Facebook, AppsFlyer, GooglePlayPlugins, GoogleSignIn, AppleSignIn
  • Platform you are using the Unity editor on: Mac
  • Platform you are targeting: Android, iOS
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the issue here:

Our Unity console is full of these crashes. However it doesn't happen on my end, so I wasn't able to reproduce this issue yet.

Native StackTrace:

Thread 0 (crashed)
0   libc.so                            0x0000007bd196b0f8 <symbols missing for uuid: e885d38d9727779a38ff50505627faac> 
1   libFirebaseCppApp-8_5_0.so         0x00000079663b9c24 <symbols missing for uuid: 75c537d8a20bc56fceb35ccb80f6344f> 
2   libFirebaseCppApp-8_5_0.so         0x00000079663bf4e8 <symbols missing for uuid: 75c537d8a20bc56fceb35ccb80f6344f> 
3   libFirebaseCppApp-8_5_0.so         0x00000079663bf49c <symbols missing for uuid: 75c537d8a20bc56fceb35ccb80f6344f> 
4   libFirebaseCppApp-8_5_0.so         0x000000796642d100 <symbols missing for uuid: 75c537d8a20bc56fceb35ccb80f6344f> 
5   libFirebaseCppApp-8_5_0.so         0x00000079664434c8 <symbols missing for uuid: 75c537d8a20bc56fceb35ccb80f6344f> 
6   libart.so                          0x0000007b4cf42350 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
7   libart.so                          0x0000007b4cf39334 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
8   libart.so                          0x0000007b4cf480ac <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
9   libart.so                          0x0000007b4d0e5678 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
10  libart.so                          0x0000007b4d0e1770 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
11  libart.so                          0x0000007b4d3a9290 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
12  libart.so                          0x0000007b4cf33c14 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
13  libart.so                          0x0000007b4d3a41f0 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
14  libart.so                          0x0000007b4cf33814 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
15  libart.so                          0x0000007b4d0b5fa8 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
16  libart.so                          0x0000007b4d395378 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
17  libart.so                          0x0000007b4cf42468 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
18  libart.so                          0x0000007b4cf39334 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
19  libart.so                          0x0000007b4cf480ac <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
20  libart.so                          0x0000007b4d2b4430 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
21  libart.so                          0x0000007b4d2b57a0 <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
22  libart.so                          0x0000007b4d19affc <symbols missing for uuid: 222a416b24ff8da5f3346cc682a2c2fb> 
23  libFirebaseCppApp-8_5_0.so         0x00000079663beb58 <symbols missing for uuid: 75c537d8a20bc56fceb35ccb80f6344f> 
24  libFirebaseCppApp-8_5_0.so         0x000000796644162c <symbols missing for uuid: 75c537d8a20bc56fceb35ccb80f6344f> 
25  libFirebaseCppApp-8_5_0.so         0x00000079664412b4 <symbols missing for uuid: 75c537d8a20bc56fceb35ccb80f6344f> 
26  libFirebaseCppApp-8_5_0.so         0x000000796647aaf8 <symbols missing for uuid: 75c537d8a20bc56fceb35ccb80f6344f> 
27  libFirebaseCppApp-8_5_0.so         0x00000079663badd0 <symbols missing for uuid: 75c537d8a20bc56fceb35ccb80f6344f> 
28  libil2cpp.so                       0x0000007ac4301b08 AppUtilPINVOKE_FirebaseApp_ReleaseReferenceInternal_m83E641C7626685F4E5018D332B214A4497F4437C (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Firebase.App.cpp:6916)
29  libil2cpp.so                       0x0000007ac4303e94 FirebaseApp_ReleaseReferenceInternal_m251EC6B33F516335E844BC8CBC7531205D41C934 (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Firebase.App.cpp:10169)
30  libil2cpp.so                       0x0000007ac43027b4 FirebaseApp_RemoveReference_mF1E15EE01A41D7674FAFDAB777CF637071F907E0 (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Firebase.App.cpp:8150)
31  libil2cpp.so                       0x0000007ac4305ad8 FirebaseApp_CheckDependenciesInternal_m3C1FA1603F994655D1C49443FFF8053420F98509 (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Firebase.App.cpp:9776)
32  libil2cpp.so                       0x0000007ac4309790 U3CCheckDependenciesU3Ec__AnonStorey2_U3CU3Em__0_mECC3E61E5A6E1E53D59A57324902DABE019526D2 (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Firebase.App.cpp:13554)
33  libil2cpp.so                       0x0000007ac3c98e50 Action_Invoke_m3FFA5BE3D64F0FF8E1E1CB6F953913FADB5EB89E (/Applications/Unity/Hub/Editor/2020.3.21f1/Unity.app/Contents/il2cpp/libil2cpp/vm/ClassInlines.h:0)
34  libil2cpp.so                       0x0000007ac43028e4 FirebaseApp_TranslateDllNotFoundException_m7AA751F31022C03AA209E73B99646C4D0A17A90D (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Firebase.App.cpp:7669)
35  libil2cpp.so                       0x0000007ac4305a00 FirebaseApp_CheckDependencies_mCD719D29867B855EBA5F74102286BB9A44FCB946 (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Firebase.App.cpp:9656)
36  libil2cpp.so                       0x0000007ac430615c FirebaseApp_U3CCheckDependenciesAsyncU3Em__2_m7418E08620989B76203932B94ED9C94E3C928ACF (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Firebase.App.cpp:10336)
37  libil2cpp.so                       0x0000007ac40172e8 Func_1_Invoke_mE30C1A875EF0B23CF6994EB0F0010292C886106D_gshared (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Generics12.cpp:31406)
38  libil2cpp.so                       0x0000007ac3f86abc Task_1_InnerInvoke_mB52092E4E9AC61B6E83BCD7AAA6B804D9A4AC66D_gshared (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Generics24.cpp:16892)
39  libil2cpp.so                       0x0000007ac3deb33c Task_Execute_m35673A0487248C5577449A4A3FBDF7FD3B6BA086 (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/mscorlib17.cpp:65)
40  libil2cpp.so                       0x0000007ac3940f18 ContextCallback_Invoke_mF4F8496213E8F0925947DD8994A477AE2E54EFDF (/Applications/Unity/Hub/Editor/2020.3.21f1/Unity.app/Contents/il2cpp/libil2cpp/vm/ClassInlines.h:0)
41  libil2cpp.so                       0x0000007ac3b6f268 ExecutionContext_RunInternal_mC5D58D6EDE270B4CDA05181E9064E040D6692B2B (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/mscorlib7.cpp:27806)
42  libil2cpp.so                       0x0000007ac3deba24 Task_ExecuteWithThreadLocal_m25476BDF5AAFF102A95E92CB1E0989DFF72408A8 (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/mscorlib17.cpp:28637)
43  libil2cpp.so                       0x0000007ac3deb83c Task_ExecuteEntry_m55634616576BB085EF3CEDB04801C4183FE1B053 (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/mscorlib17.cpp:28501)
44  libil2cpp.so                       0x0000007ac3cc9580 ThreadPoolWorkQueue_Dispatch_mCC5743D99870EC7844CAB3FF3FA7D23A44A4A984 (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/mscorlib18.cpp:110)
45  libil2cpp.so                       0x0000007ac34ecda8 RuntimeInvoker_FalseSByte_t928712DD662DC29BA4FAAE8CE2230AFB23447F0B(void (*)(), MethodInfo const*, void*, void**) (/Users/username/Documents/gamename/Library/Il2cppBuildCache/Android/armeabi-v7a/il2cppOutput/Il2CppInvokerTable.cpp:70158)
46  libil2cpp.so                       0x0000007ac3608a20 worker_thread(void*) (/Applications/Unity/Hub/Editor/2020.3.21f1/Unity.app/Contents/il2cpp/libil2cpp/mono/ThreadPool/ThreadPoolWorkerThread.cpp:250)
47  libil2cpp.so                       0x0000007ac35d2298 il2cpp::vm::ThreadStart(void*) (/Applications/Unity/Hub/Editor/2020.3.21f1/Unity.app/Contents/il2cpp/libil2cpp/vm/Thread.cpp:708)
48  libil2cpp.so                       0x0000007ac359e550 il2cpp::os::Thread::RunWrapper(void*) (/Applications/Unity/Hub/Editor/2020.3.21f1/Unity.app/Contents/il2cpp/libil2cpp/os/Thread.cpp:183)
49  libil2cpp.so                       0x0000007ac359ced4 il2cpp::os::ThreadImpl::ThreadStartWrapper(void*) (/Applications/Unity/Hub/Editor/2020.3.21f1/Unity.app/Contents/il2cpp/libil2cpp/os/Posix/ThreadImpl.cpp:125)
50  libc.so                            0x0000007bd196a614 <symbols missing for uuid: e885d38d9727779a38ff50505627faac> 
51  libc.so                            0x0000007bd190be98 <symbols missing for uuid: e885d38d9727779a38ff50505627faac> 

Here is my Firebase code:

public void Awake()
{  
#if UNITY_ANDROID
    FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
    {
        if (task.Result == DependencyStatus.Available)
            FirebaseInitialized();
    });
#else
    FirebaseInitialized();
#endif
}

private void FirebaseInitialized()
{
    SetupFirestore();
    SetupMessaging();
}        

private void SetupFirestore() 
{
    FirebaseFirestore db = FirebaseFirestore.DefaultInstance;
    db.Collection("matches").WhereEqualTo("player_id", Login.Self.PlayerID).Listen(LoadMatch);
}

private void SetupMessaging() 
{
    FirebaseMessaging.GetTokenAsync().ContinueWith(token => Register(token.Result));
}
@tiennguyenlastmile
Copy link

I don't why google developers release this bugs?
I lost many many users from upgrade this release

@paulinon paulinon removed the new New issue. label Nov 2, 2021
@paulinon
Copy link
Contributor

paulinon commented Nov 2, 2021

Hi @Jack37,

After building an app based on the information you provided, I haven't been able to replicate the issue so far as my app didn't crash.

Could you provide a minimal, reproducible example so that we can analyze what's causing this? Could you also confirm if there are additional steps necessary to be able to generate logs similar to what you provided?

@paulinon paulinon added the needs-info Need information for the developer label Nov 2, 2021
@aroman
Copy link

aroman commented Nov 4, 2021

I also have this issue on Android after upgrading to 8.5.0. Here is a more symbolicated stack trace than what OP provided:

Caused by java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Version '2021.2.0f1 (4bf1ec4b23c9)', Build type 'Development', Scripting Backend 'il2cpp', CPU 'armeabi-v7a'
Build fingerprint: 'samsung/a10eue/a10e:10/QP1A.190711.020/A102U1UESBBUF2:user/release-keys'
Revision: '4'
ABI: 'arm'
Timestamp: 2021-11-03 23:15:36-0700
pid: 21139, tid: 21353, name: Thread-15  >>> com.MagicCircleStudio.TruffleHogs <<<
uid: 10276
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4
Cause: null pointer dereference
    r0  00000004  r1  96d5a3c8  r2  00000004  r3  96d5a411
    r4  00000000  r5  96d5a3c8  r6  96d5a3c8  r7  00000004
    r8  96d5a411  r9  98e7bd58  r10 00000004  r11 00000000
    ip  91b36c68  sp  96d5a358  lr  91a6394f  pc  e673fe0a

backtrace:
      #00 pc 000a7e0a  /apex/com.android.runtime/lib/bionic/libc.so (pthread_mutex_lock+6) (BuildId: 320fbdc2a1289fadd7dacae7f2eb77a3)
      #01 pc 0015f94b  /data/app/com.MagicCircleStudio.TruffleHogs-ZWUDVnBgrHj8iKRum2bfaQ==/lib/arm/libFirebaseCppApp-8_5_0.so (firebase::Mutex::Acquire()+2) (BuildId: ebcd73edf267d0b16d817bd2da9d3b78)
      #02 pc 0016310d  /data/app/com.MagicCircleStudio.TruffleHogs-ZWUDVnBgrHj8iKRum2bfaQ==/lib/arm/libFirebaseCppApp-8_5_0.so (void firebase::ReferenceCountedFutureImpl::CompleteInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)::'lambda'(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >*)>(firebase::FutureHandle const&, int, char const*, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle co<truncated: 10026 chars>
       at libc.pthread_mutex_lock(pthread_mutex_lock:6)
       at libFirebaseCppApp-8_5_0.firebase::Mutex::Acquire()(Acquire:2)
       at libFirebaseCppApp-8_5_0.void firebase::ReferenceCountedFutureImpl::CompleteInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)::'lambda'(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >*)>(firebase::FutureHandle const&, int, char const*, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)::'lambda'(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >*) const&)(allocator<char> > >:16)
       at libFirebaseCppApp-8_5_0.void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)(allocator<char> > >:32)
       at libFirebaseCppApp-8_5_0.firebase::messaging::CompleteStringCallback(_JNIEnv*, _jobject*, firebase::util::FutureResult, char const*, void*)(CompleteStringCallback:96)
       at libFirebaseCppApp-8_5_0.firebase::util::JniResultCallback_nativeOnResult(_JNIEnv*, _jobject*, _jobject*, unsigned char, unsigned char, _jstring*, long long, long long)(JniResultCallback_nativeOnResult:116)
       at libart.art_quick_generic_jni_trampoline(art_quick_generic_jni_trampoline:40)
       at libart.art_quick_invoke_stub_internal(art_quick_invoke_stub_internal:68)
       at libart.art_quick_invoke_stub(art_quick_invoke_stub:250)
       at libart.art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)(Invoke:174)
       at libart.art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)(ArtInterpreterToCompiledCodeBridge:280)
       at libart.bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)(DoCall<true, false>:524)
       at libart.MterpInvokeDirectRange(MterpInvokeDirectRange:240)
       at libart.mterp_op_invoke_direct_range(mterp_op_invoke_direct_range:20)
       at libart.MterpInvokeVirtual(MterpInvokeVirtual:1148)
       at libart.mterp_op_invoke_virtual(mterp_op_invoke_virtual:20)
       at libart.art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.17081802220158389190)(Execute:192)
       at libart.art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)(EnterInterpreterFromEntryPoint:124)
       at libart.artQuickToInterpreterBridge(artQuickToInterpreterBridge:808)
       at libart.art_quick_to_interpreter_bridge(art_quick_to_interpreter_bridge:32)
       at libart.art_quick_invoke_stub_internal(art_quick_invoke_stub_internal:68)
       at libart.art_quick_invoke_stub(art_quick_invoke_stub:250)
       at libart.art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)(Invoke:174)
       at libart.art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)(:54)
       at libart.art::InvokeVirtualOrInterfaceWithVarArgs(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)(InvokeVirtualOrInterfaceWithVarArgs:304)
       at libart.art::JNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)(CallVoidMethodV:480)
       at libart.art::(anonymous namespace)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType)(:1694)
       at libart.art::(anonymous namespace)::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)(:44)
       at libFirebaseCppApp-8_5_0._JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)(CallVoidMethod:16)
       at libFirebaseCppApp-8_5_0.firebase::util::CancelCallbacks(_JNIEnv*, char const*)(CancelCallbacks:120)
       at libFirebaseCppApp-8_5_0.firebase::util::Terminate(_JNIEnv*)(Terminate:40)
       at libFirebaseCppApp-8_5_0.firebase::App::~App()(~App:52)

@aroman
Copy link

aroman commented Nov 4, 2021

Aha! I found a clue. It turns out the issue comes with calling MobileAds.Initialize() from the AdMob Unity SDK around the same time as FirebaseApp.CheckAndFixDependenciesAsync(). Removing either one of those calls reliably fixes the crash for me. This is still in my main project, let me see about a minimal test project to prove my hunch now...

@aroman
Copy link

aroman commented Nov 4, 2021

Okay, I can confirm that I can repro in a blank Unity project. Here are the steps for minimal repro @paulinon:

  1. Create a new blank project in Unity (I chose 2D template). I used Unity 2021.2, but other versions may be affected.
  2. Import GoogleMobileAds-v6.1.2.unitypackage (latest stable at time of writing)
  3. Import latest stable FirebaseAnalytics.unitypackage. Presumably any Firebase package would work; we just need the core library after all.
  4. Create this script (below) and add it to the scene
  5. Supply an AdMob app ID in the admob config ScriptableObject. Any string should work.
  6. Switch build target to Android and build & run to device
  7. It should crash
using Firebase;
using Firebase.Extensions;
using GoogleMobileAds.Api;
using GoogleMobileAds.Common;
using UnityEngine;

public class ReproductionTest : MonoBehaviour
{
    private void Start()
    {
        MobileAds.Initialize(_ => MobileAdsEventExecutor.ExecuteInUpdate(() => Debug.Log("admob done")));
        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(_ => Debug.Log("firebase done"));
    }
}

I haven't attempted a workaround (I should sleep) but I wonder if forcing these libraries to initialize in serial (one to wait for the other before loading) would work.

@Jack37
Copy link
Author

Jack37 commented Nov 4, 2021

Great find! So far I can confirm that I am using AdMob, which I removed from latest release, to see if crashes will go away. However I am using AdMob mediation adapter for IronSource instead of plain AdMob SDK.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Nov 4, 2021
@aroman
Copy link

aroman commented Nov 4, 2021

Ahhh, my minimal repro attempt is flawed — I was getting a crash for a different reason, which is that if your AdMob App ID is invalid, your app will hard crash (terrible behavior in its own right). So, while this doesn't explain why removing MobileAds.Initialize in my actual project fixes the crash, it does mean that my explanation might not be correct.

@paulinon
Copy link
Contributor

paulinon commented Nov 4, 2021

Thanks for the additional information, @aroman and @Jack37. Given that you make use of AdMob, could you confirm if removing this from your implementation makes a difference? If it doesn't, a minimal, reproducible example of your project would come in handy so that we can analyze this behavior.

@paulinon paulinon added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels Nov 4, 2021
@aroman
Copy link

aroman commented Nov 5, 2021

@paulinon as you requested, I have created a repo of a minimal reproducible example demonstrating this issue:

https://github.com/aroman/TestFirebaseCrash

Removing AdMob does seem to make a difference; there seems to be an interaction between multiple Google libraries going on here. My minimal reproducible repo contains only Google plugins — AdMob for Unity and Firebase for Unity.

@Jack37
Copy link
Author

Jack37 commented Nov 5, 2021

Removing AdMob adapter did not help for me. But I still have other Google libraries that may cause this.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Nov 5, 2021
@paulinon paulinon added type: bug and removed type: question needs-attention Need Googler's attention labels Nov 5, 2021
@kolobokspb
Copy link

kolobokspb commented Nov 8, 2021

@paulinon, @aroman

*Unity editor version: 2021.2.1f1previous 2021.1.13f1

*Source you installed the SDK: .unitypackage
Firebase Unity SDK version: 8.5.0 previous 8.1.0

*GoogleMobileAds 6.0.2, GooglePlayGames 0.10.12

*Platform you are using the Unity editor on: Win
*Platform you are targeting: Android
*Scripting Runtime: IL2CPP

java.lang.Error: FATAL EXCEPTION [UnityMain]
Unity version     : 2021.2.1f1
Device model      : Xiaomi Redmi Note 5
Device fingerprint: xiaomi/whyred/whyred:9/PKQ1.180904.001/V11.0.3.0.PEIMIXM:user/release-keys
Build Type        : Release
Scripting Backend : IL2CPP
ABI               : arm64-v8a
Strip Engine Code : true

Caused by: java.lang.Error: * * * * * * * * * * * * * * * *
Version '2021.2.1f1 (c20c6d589440)', Build type 'Release', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
Build fingerprint: 'xiaomi/whyred/whyred:9/PKQ1.180904.001/V11.0.3.0.PEIMIXM:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2021-11-09 01:51:45+0300
pid: 31876, tid: 32026, name: Thread-45  >>> com.WiB.LiveFactory <<<
uid: 10205
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
Cause: null pointer dereference
    x0  0000000000000008  x1  00000072003c7e20  x2  0000000000000004  x3  00000072003c7e99
    x4  00000072003c7dd8  x5  0000000000000000  x6  455e5e6472606164  x7  7f7f7f7f7f7f7f7f
    x8  0000000000000000  x9  00000072003c7e99  x10 000000723a61f1e0  x11 0000000000000000
    x12 0000000000000001  x13 0000000000000010  x14 0000000000000000  x15 0000000000000000
    x16 00000072007ef748  x17 00000072c32a9de8  x18 0000000000000000  x19 0000000000000000
    x20 00000072003c7e20  x21 00000072003c7dd8  x22 0000000000000000  x23 00000072003c7e99
    x24 0000000000000004  x25 0000000000000008  x26 00000072003c7e98  x27 0000000000000001
    x28 0000000000000000  x29 00000072003c8008
    sp  00000072003c7d80  lr  00000072006bec28  pc  00000072c32a9de8

backtrace:
      #00 pc 0000000000090de8  /system/lib64/libc.so (pthread_mutex_lock) (BuildId: f82474d2188d0c21e110184220b5e386)
      #01 pc 00000000001f6c24  /data/app/com.WiB.LiveFactory-wAioSMLjDP7D477SIRbjpA==/lib/arm64/libFirebaseCppApp-8_5_0.so (firebase::Mutex::Acquire()+4) (BuildId: 75c537d8a20bc56fceb35ccb80f6344f)
      #02 pc 00000000001fc4e8  /data/app/com.WiB.LiveFactory-wAioSMLjDP7D477SIRbjpA==/lib/arm64/libFirebaseCppApp-8_5_0.so (void firebase::ReferenceCountedFutureImpl::CompleteInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)::'lambda'(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >*)>(firebase::FutureHandle const&, int, char const*, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::ch...
      #03 pc 00000000001fc49c  /data/app/com.WiB.LiveFactory-wAioSMLjDP7D477SIRbjpA==/lib/arm64/libFirebaseCppApp-8_5_0.so (void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+64) (BuildId: 75c537d8a20bc56fceb35ccb80f6344f)
      #04 pc 000000000026a100  /data/app/com.WiB.LiveFactory-wAioSMLjDP7D477SIRbjpA==/lib/arm64/libFirebaseCppApp-8_5_0.so (firebase::messaging::CompleteStringCallback(_JNIEnv*, _jobject*, firebase::util::FutureResult, char const*, void*)+136) (BuildId: 75c537d8a20bc56fceb35ccb80f6344f)
      #05 pc 00000000002804c8  /data/app/com.WiB.LiveFactory-wAioSMLjDP7D477SIRbjpA==/lib/arm64/libFirebaseCppApp-8_5_0.so (firebase::util::JniResultCallback_nativeOnResult(_JNIEnv*, _jobject*, _jobject*, unsigned char, unsigned char, _jstring*, long, long)+172) (BuildId: 75c537d8a20bc56fceb35ccb80f6344f)
      #06 pc 0000000000002214  /data/data/com.WiB.LiveFactory/cache/oat/arm64/app_resources_lib.odex

 at libc.pthread_mutex_lock(pthread_mutex_lock:0)
 at libFirebaseCppApp-8_5_0.firebase::Mutex::Acquire()(Acquire:4)
 at libFirebaseCppApp-8_5_0.void firebase::ReferenceCountedFutureImpl::CompleteInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)::'lambda'(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >*)>(firebase::FutureHandle const&, int, char const*, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)::'lambda'(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >*) const&)(allocator<char> > >:44)
 at libFirebaseCppApp-8_5_0.void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)(allocator<char> > >:64)
 at libFirebaseCppApp-8_5_0.firebase::messaging::CompleteStringCallback(_JNIEnv*, _jobject*, firebase::util::FutureResult, char const*, void*)(CompleteStringCallback:136)
 at libFirebaseCppApp-8_5_0.firebase::util::JniResultCallback_nativeOnResult(_JNIEnv*, _jobject*, _jobject*, unsigned char, unsigned char, _jstring*, long, long)(JniResultCallback_nativeOnResult:172)
 at app_resources_lib.0x2214(Native Method)

@chkuang-g
Copy link
Contributor

Hi folks,

If you see firebase::messaging::CompleteStringCallback in the callstack, this very likely fits this profile #1160 (comment)

Please upgrade to the latest Firebase and see if that resolves your issue.

@Jack37
I cannot tell if this is your case from your callstack. Could you:

  1. Try to upgrade Firebase SDK and see if that fixes your issue.
  2. Confirm if this happens on Android, iOS or Unity editor.

Thank you

@chkuang-g chkuang-g added needs-info Need information for the developer and removed type: bug labels Nov 11, 2021
@aroman
Copy link

aroman commented Nov 11, 2021

I have updated all firebase pacakges in my project 8.6.1 and I can confirm that I'm still seeing this crash. It doesn't happen 100% of the time, but >50% of the time on my test device (Samsung A10). The errors I'm seeing are coming from the device itself via ADB, and unfortunately the stack trace stops about where @kolobokspb's does.

@kolobokspb
Copy link

@chkuang-g , @aroman

*Unity editor version: 2021.2.1f1

*Source you installed the SDK: .unitypackage
Firebase Unity SDK version: 8.6.1

*GoogleMobileAds 6.0.2, GooglePlayGames 0.10.12

*Platform you are using the Unity editor on: Win
*Platform you are targeting: Android
*Scripting Runtime: IL2CPP

java.lang.Error: FATAL EXCEPTION [UnityMain]
Unity version     : 2021.2.1f1
Device model      : Xiaomi Redmi Note 5
Device fingerprint: xiaomi/whyred/whyred:9/PKQ1.180904.001/V11.0.3.0.PEIMIXM:user/release-keys
Build Type        : Development
Scripting Backend : IL2CPP
ABI               : arm64-v8a
Strip Engine Code : true

Caused by: java.lang.Error: * * * * * * * * * * * * * * * *
Version '2021.2.1f1 (c20c6d589440)', Build type 'Development', Scripting Backend 'il2cpp', CPU 'arm64-v8a'
Build fingerprint: 'xiaomi/whyred/whyred:9/PKQ1.180904.001/V11.0.3.0.PEIMIXM:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2021-11-11 16:28:45+0300
pid: 11323, tid: 11471, name: Thread-45  >>> com.WiB.LiveFactory <<<
uid: 10207
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
Cause: null pointer dereference
    x0  0000000000000008  x1  00000072129028d0  x2  0000000000000004  x3  0000007212902949
    x4  0000007212902888  x5  0000000000000000  x6  455e5e6472606164  x7  7f7f7f7f7f7f7f7f
    x8  0000000000000000  x9  0000007212902949  x10 000000723a61d960  x11 0000000000000000
    x12 0000000000000001  x13 0000000000000010  x14 0000000000000000  x15 aaaaaaaaaaaaaaab
    x16 0000007212d2b778  x17 00000072c32a9de8  x18 0000000000000000  x19 0000000000000000
    x20 00000072129028d0  x21 0000007212902888  x22 0000000000000000  x23 0000007212902949
    x24 0000000000000004  x25 0000000000000008  x26 0000007212902948  x27 0000000000000001
    x28 0000000000000000  x29 0000007212902ab8
    sp  0000007212902830  lr  0000007212bfa630  pc  00000072c32a9de8

backtrace:
      #00 pc 0000000000090de8  /system/lib64/libc.so (pthread_mutex_lock) (BuildId: f82474d2188d0c21e110184220b5e386)
      #01 pc 00000000001f762c  /data/app/com.WiB.LiveFactory-_XugJDcINxh04YwqEf8TTg==/lib/arm64/libFirebaseCppApp-8_6_1.so (firebase::Mutex::Acquire()+4) (BuildId: 2e9fce08b1290e3363802b8715260d2a)
      #02 pc 00000000001fcef0  /data/app/com.WiB.LiveFactory-_XugJDcINxh04YwqEf8TTg==/lib/arm64/libFirebaseCppApp-8_6_1.so (void firebase::ReferenceCountedFutureImpl::CompleteInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)::'lambda'(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >*)>(firebase::FutureHandle const&, int, char const*, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::ch...
      #03 pc 00000000001fcea4  /data/app/com.WiB.LiveFactory-_XugJDcINxh04YwqEf8TTg==/lib/arm64/libFirebaseCppApp-8_6_1.so (void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+64) (BuildId: 2e9fce08b1290e3363802b8715260d2a)
      #04 pc 000000000026ad08  /data/app/com.WiB.LiveFactory-_XugJDcINxh04YwqEf8TTg==/lib/arm64/libFirebaseCppApp-8_6_1.so (firebase::messaging::CompleteStringCallback(_JNIEnv*, _jobject*, firebase::util::FutureResult, char const*, void*)+136) (BuildId: 2e9fce08b1290e3363802b8715260d2a)
      #05 pc 00000000002810d0  /data/app/com.WiB.LiveFactory-_XugJDcINxh04YwqEf8TTg==/lib/arm64/libFirebaseCppApp-8_6_1.so (firebase::util::JniResultCallback_nativeOnResult(_JNIEnv*, _jobject*, _jobject*, unsigned char, unsigned char, _jstring*, long, long)+172) (BuildId: 2e9fce08b1290e3363802b8715260d2a)
     #06 pc 0000000000002214  /data/data/com.WiB.LiveFactory/cache/oat/arm64/app_resources_lib.odex

 at libc.pthread_mutex_lock(pthread_mutex_lock:0)
 at libFirebaseCppApp-8_6_1.firebase::Mutex::Acquire()(Acquire:4)
 at libFirebaseCppApp-8_6_1.void firebase::ReferenceCountedFutureImpl::CompleteInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)::'lambda'(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >*)>(firebase::FutureHandle const&, int, char const*, void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)::'lambda'(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >*) const&)(allocator<char> > >:44)
 at libFirebaseCppApp-8_6_1.void firebase::ReferenceCountedFutureImpl::CompleteWithResultInternal<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > >(firebase::FutureHandle const&, int, char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)(allocator<char> > >:64)
 at libFirebaseCppApp-8_6_1.firebase::messaging::CompleteStringCallback(_JNIEnv*, _jobject*, firebase::util::FutureResult, char const*, void*)(CompleteStringCallback:136)
 at libFirebaseCppApp-8_6_1.firebase::util::JniResultCallback_nativeOnResult(_JNIEnv*, _jobject*, _jobject*, unsigned char, unsigned char, _jstring*, long, long)(JniResultCallback_nativeOnResult:172)
 at app_resources_lib.0x2214(Native Method)

@ghost
Copy link

ghost commented Nov 11, 2021

I'm getting same error with @aroman

@TBarendt
Copy link

firebase/firebase-cpp-sdk#745 there was one more edge case for this during shutdown

@devup1225
Copy link

devup1225 commented Nov 13, 2021

Make sure the Firebase and Unity Ads initialization order is guaranteed.
After I guaranteed the initialization order, the problem was solved.

Conflicts were resolved by ensuring Firebase initialization and Unity Ads initialization order.

### 2021-11-12 15:42:21.139 3899-3993/? D/UnityAds: com.unity3d.services.UnityServices.initialize() (line:1) :: ENTERED METHOD
2021-11-12 15:42:21.261 3899-3993/? I/Unity: Firebase Analytics API Initializing

    UnityEngine.Logger:Log(LogType, Object)

2021-11-12 15:42:21.262 3899-3993/? I/Unity: analytics API Initialized

    UnityEngine.Logger:Log(LogType, Object)

2021-11-12 15:42:21.263 3899-3993/? I/Unity: Firebase Cloud Messaging API Initialized

    UnityEngine.Logger:Log(LogType, Object)

2021-11-12 15:42:22.746 3899-4224/? I/UnityAds: com.unity3d.services.core.configuration.InitializeThread$InitializeStateConfig.execute() (line:1) :: Unity Ads init: load configuration from
2021-11-12 15:42:23.085 3899-4224/? I/UnityAds: com.unity3d.services.core.configuration.InitializeThread$InitializeStateLoadCache.execute() (line:6) :: Unity Ads init: webapp loaded from local cache

@Jack37
Copy link
Author

Jack37 commented Nov 15, 2021

@chkuang-g This is probably my case too, as there seem to be two callstacks. This one is same as mine, on a 8.6.1 version #1169 (comment). This happens on Android.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Nov 15, 2021
@a-maurice
Copy link
Contributor

We haven't been able to completely reproduce the problem on our end, but we just released 8.6.2, which contains a potential fix for the issue.

@naklow12
Copy link

naklow12 commented Nov 22, 2021

We haven't been able to completely reproduce the problem on our end, but we just released 8.6.2, which contains a potential fix for the issue.

In my case, I was using Firebase 8.1 and I updated to 8.6.1 for adding message service. Then this problem occured and I'm using Admob, Facebook, Adjust, UnityAds, Applovin etc SDKs. I didn't notice the error, Google Play Console did it on the release. I will try 8.6.2 now.

@snorrsi
Copy link

snorrsi commented Nov 22, 2021

@naklow12 Are you able to reproduce this problem easily? Did you see any improvements with 8.6.2 ?

@naklow12
Copy link

Yes it's solved.

@paulinon
Copy link
Contributor

Hey @Jack37, could you try out version 8.6.2 of the SDK and see if the issue persists? I tested this with @aroman's sample project, and the error messages don't appear anymore.

@paulinon paulinon added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels Nov 24, 2021
@iningwei
Copy link

I am sure it is the same as this bug which i have metioned 1-2month ago (i used firebase sdk v-8.3.0).
The first time you launched app after installation, the crash is caused by fcm auto init,if you have no internet connect or can not connect to google,it will crash.
In the link above i have made some rectify buy @Otarius0 's suggestion.It works a lot,but still have chance to crash.

@TBarendt
Copy link

TBarendt commented Nov 25, 2021

@iningwei the bug fix was for shutting down messaging. Yours looks like during startup? I had a quick look at the code and I think there might be an issue there as well. I had put in a pull request to see what the devs thinks. firebase/firebase-cpp-sdk#760

@kolobokspb
Copy link

kolobokspb commented Nov 27, 2021

@paulinon , @TBarendt , @snorrsi
8.1.0 - ок
8.5.0 - crashing
8.6.1 - crashing
8.6.2 - the application stopped crashing

@kolobokspb
Copy link

@paulinon , @TBarendt , @snorrsi
I was not happy for long.

After upgrading to version 8.6.2, my app stopped crashing. )
But GooglePlayGames v0.10.12 stopped working. (

Only after updating GooglePlayGames to version v0.10.13 did it work.

That's not all, after installing the plugin GooglePlayGames and ExternalDependencyManage v0.10.13 Unity began to crash due to ExternalDependencyManage when installing the plugin and every time Unity was loaded. So I took the ExternalDependencyManager that comes with Firebase.

@google-oss-bot google-oss-bot added the stale Don't have recent activity label Dec 6, 2021
@google-oss-bot
Copy link

Hey @Jack37. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link

Since there haven't been any recent updates here, I am going to close this issue.

@Jack37 if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@firebase firebase locked and limited conversation to collaborators Jan 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: core closed-by-bot needs-info Need information for the developer stale Don't have recent activity type: question
Projects
None yet
Development

No branches or pull requests