Skip to content

[Bug] FirebaseAuth anonymous sign-in fails after Application.Unload() on Android #1417

@NicolasDebeurme

Description

@NicolasDebeurme

Description

Description:
After signing in anonymously and querying Firestore, calling Application.Unload() prevents subsequent sign-ins.

Expected vs Actual:
Expected: sign in successfully after unload.
Actual: user stays nul

What i've tried:
Calling Dispose() on FirebaseApp or FirebaseAuth before Application.Unload() does not allow a successful re-sign-in.

Reproducing the issue

Sign In Anonymously → works.
Query Firestore Document → works.
Application.Unload().
ReOpen the app.
Try Sign In Anonymously again → user remains null (stuck in the Task & no error thrown)

Firebase Unity SDK Version

Tested on 13.9.0 and 12.10.1

Unity editor version

6000.0.59f2

Installation Method

.unitypackage

Problematic Firebase Component(s)

Authentication

Other Firebase Component(s) in use

Firestore

Additional SDKs you are using

I am using the .tgz files.

Targeted Platform(s)

Android

Unity editor platform

Windows

Scripting Runtime

IL2CPP

Release Distribution Type

Open-source from this repo

Relevant Log Output

16:39:41.878  I  [FIREBASE_DEBUG] Start() - Firebase will not sign in automatically.
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
16:39:44.958  I  [FIREBASE_DEBUG] Button: Sign In
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:OnGUI()
16:39:44.958  W  [FIREBASE_DEBUG] Auth is null, initializing Firebase...
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:SignInAnonymously()
                 DebugSceneController:OnGUI()
16:39:44.959  I  [FIREBASE_DEBUG] InitializeFirebase() called
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:InitializeFirebase()
                 DebugSceneController:SignInAnonymously()
                 DebugSceneController:OnGUI()
16:39:45.020  I  [FIREBASE_DEBUG] Firebase initialized. App name: __FIRAPP_DEFAULT
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:SignInAnonymously()
                 DebugSceneController:OnGUI()
16:39:45.021  I  [FIREBASE_DEBUG] Starting anonymous sign-in...
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:SignInAnonymously()
                 DebugSceneController:OnGUI()
16:39:45.272  I  [FIREBASE_DEBUG] User signed in: IyjqQUO6yLdBHz5jmyzVE42C2TK2
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:<SignInAnonymously>b__8_0(Task`1)
                 Firebase.Extensions.<>c__DisplayClass4_1`1:<ContinueWithOnMainThread>b__1()
                 Firebase.<>c__DisplayClass5_0`1:<RunAsync>b__0()
                 Firebase.ExceptionAggregator:Wrap(Action)
                 Firebase.Dispatcher:PollJobs()
                 Firebase.Platform.FirebaseHandler:Update()
16:40:00.376  I  [FIREBASE_DEBUG] Button: Query Firestore Document
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:OnGUI()
16:40:00.377  I  [FIREBASE_DEBUG] Running Firestore test query document...
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:QueryTestFirestore()
                 DebugSceneController:OnGUI()
16:40:00.714  I  [FIREBASE_DEBUG] Firestore query success. Document exists: True
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 <>c:<QueryTestFirestore>b__9_0(Task`1)
                 Firebase.Extensions.<>c__DisplayClass4_1`1:<ContinueWithOnMainThread>b__1()
                 Firebase.<>c__DisplayClass5_0`1:<RunAsync>b__0()
                 Firebase.ExceptionAggregator:Wrap(Action)
                 Firebase.Dispatcher:PollJobs()
                 Firebase.Platform.FirebaseHandler:Update()
16:40:10.243  I  [FIREBASE_DEBUG] Button: Application.Unload()
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:OnGUI()
16:40:14.746  I  [FIREBASE_DEBUG] Start() - Firebase will not sign in automatically.
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
16:40:20.196  I  [FIREBASE_DEBUG] Button: Sign In
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:OnGUI()
16:40:20.196  W  [FIREBASE_DEBUG] Auth is null, initializing Firebase...
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:SignInAnonymously()
                 DebugSceneController:OnGUI()
16:40:20.197  I  [FIREBASE_DEBUG] InitializeFirebase() called
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:InitializeFirebase()
                 DebugSceneController:SignInAnonymously()
                 DebugSceneController:OnGUI()
16:40:20.198  I  [FIREBASE_DEBUG] Firebase initialized. App name: __FIRAPP_DEFAULT
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:SignInAnonymously()
                 DebugSceneController:OnGUI()
16:40:20.199  I  [FIREBASE_DEBUG] Starting anonymous sign-in...
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:SignInAnonymously()
                 DebugSceneController:OnGUI()
16:40:38.624  I  [FIREBASE_DEBUG] Button: Query Firestore Document
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:OnGUI()
16:40:38.624  W  [FIREBASE_DEBUG] Cannot query Firestore: user not signed in
                 UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
                 DebugSceneController:OnGUI()

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!

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