Skip to content

[Bug] Crashes on get FirebaseAuth.CurrentUser.UserId #733

Description

@amoswazana

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2021.3.25f1
  • Firebase Unity SDK version: 11.0.0
  • Source you installed the SDK: .unityPackage
  • Problematic Firebase Component: Auth
  • Other Firebase Components in use: Auth, Firestore, DynamicLinks, Analytics, Crashlytics, Functions, Messaging
  • Additional SDKs you are using: Admob, Admob mediation (Unity, AdColony, AppLovin, InMobi), Photon, Unity Purchasing
  • Platform you are using the Unity editor on: Mac
  • Platform you are targeting: iOS, Android, WebGL
  • Scripting Runtime: IL2CPP
  • Pre-built SDK from the website or open-source from this repo: pre-built

[REQUIRED] Please describe the issue here:

We have noticed a new crash in our app, caused by the line auth.CurrentUser.UserId.
Relevant crash logs from Google Play Console (replaced our app name with com.appname):

backtrace:
  #00  pc 0x00000000002ba7b4  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libFirebaseCppApp-11_0_0.so (firebase::auth::User::is_valid() const+8)
  #01  pc 0x00000000001fc600  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libFirebaseCppApp-11_0_0.so (Firebase_Auth_CSharp_FirebaseUser_IsValid+12)
  #02  pc 0x0000000000851ee4  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libil2cpp.so (AuthUtilPINVOKE_FirebaseUser_IsValid_m8506CC0BE369BBEFD83BBC02F1777C140A16299F)
  #03  pc 0x0000000000851e10  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libil2cpp.so (FirebaseUser_IsValid_m745FA6B0AF38AF4988B188E019F0621C27DED2DA)
  #04  pc 0x000000000085415c  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libil2cpp.so (FirebaseAuth_UpdateCurrentUser_m8C0906D45788F454E7E19A8C929FEBA42792A06B)
  #05  pc 0x00000000015f77cc  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libil2cpp.so (FirebaseAsyncOperationsLayer_get_CurrentUserID_m3803590513CE5532AE611E61B67A55578DEBE52A)
  #06  pc 0x0000000001609f88  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libil2cpp.so (LoginMaster_LoginComplete_mC3FEC58E92D4595BD52CE71AE0E2608565311617)
  #07  pc 0x0000000001676c48  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libil2cpp.so (BaseFirebaseManager_Update_mA0BD31D4C48A63E7226E28F3BFD84F645A35D022)
  #08  pc 0x0000000000708d40  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libil2cpp.so (il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**))
  #09  pc 0x0000000000708bb4  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libil2cpp.so (il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**))
  #10  pc 0x00000000002a314c  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libunity.so (scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool))
  #11  pc 0x00000000002b1c4c  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libunity.so (ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool))
  #12  pc 0x00000000002bf644  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libunity.so (MonoBehaviour::CallUpdateMethod(int))
  #13  pc 0x000000000015af40  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libunity.so (void BaseBehaviourManager::CommonUpdate<BehaviourManager>())
  #14  pc 0x00000000001efc80  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libunity.so (ExecutePlayerLoop(NativePlayerLoopSystem*))
  #15  pc 0x00000000001efcc0  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libunity.so (ExecutePlayerLoop(NativePlayerLoopSystem*))
  #16  pc 0x00000000001efef8  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libunity.so (PlayerLoop())
  #17  pc 0x000000000032d1c0  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libunity.so (UnityPlayerLoop())
  #18  pc 0x00000000003437f4  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/lib/arm64/libunity.so (nativeRender(_JNIEnv*, _jobject*))
  #19  pc 0x00000000000b7b4c  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/oat/arm64/base.odex (art_jni_trampoline+124)
  #20  pc 0x000000000019f19c  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/oat/arm64/base.odex (com.unity3d.player.UnityPlayer$e$1.handleMessage+972)
  #21  pc 0x0000000000649ee8  /system/framework/arm64/boot-framework.oat (android.os.Handler.dispatchMessage+136)
  #22  pc 0x000000000064d560  /system/framework/arm64/boot-framework.oat (android.os.Looper.loop+1696)
  #23  pc 0x000000000019fda8  /data/app/~~mEbfahJdQHVXzJfHkmJ1sQ==/com.appname-QNl3qhFgfFnaksjT2yAViQ==/oat/arm64/base.odex (com.unity3d.player.UnityPlayer$e.run+216)
  #24  pc 0x0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548)
  #25  pc 0x00000000001a8a78  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
  #26  pc 0x0000000000554e34  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+460)
  #27  pc 0x00000000005a41d0  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1308)
  #28  pc 0x00000000000eb968  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64)
  #29  pc 0x000000000008bb88  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)

Steps to reproduce:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?
No. We currently do not have a device that can reproduce this issue.
What's the issue repro rate?
We currently have 500+ users that have experienced this crash.

What happened? How can we make the problem occur?
The crash happens when we call auth.CurrentUser.UserId.

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:

    // example flow
    using Firebase;
    using Firebase.Auth;

    private FirebaseAuth auth;
    private IEnumerator FirebaseAuthFlow(string email, string password) {
        bool isReadyForFirebaseOperations = false;
        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available) {
                auth = FirebaseAuth.DefaultInstance;
                isReadyForFirebaseOperations = true;
            } else {
                Debug.Log($"Could not resolve all Firebase dependencies: {dependencyStatus}");
            }
        });

        while (isReadyForFirebaseOperations) {
            yield return null;
        }

        bool success = false;
        bool signInRunning = true;

        auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith((t) => {
            if (t.IsFaulted || t.IsCanceled) {
                Debug.Log($"EmailLogin faulted or canceled. faulted: {t.IsFaulted}, canceled: {t.IsCanceled}, message: {t.Exception}");
            } else {
                success = true;
            }
            signInRunning = false;
        });

        while(signInRunning) {
            yield return null;
        }

        if(success) {
            // This crashes the app on certain devices
            Debug.Log(auth.CurrentUser.UserId);
        }
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions