I have a Unity3D (2017.3) app that uses Firebase Auth. Its initialization looks similar to, and indeed is copied from, the Firebase Auth Unity Example.
The app runs fine in regular builds.
If enabling Development Build (so we can use the Unity Profiler, which in turn is necessary because our app is out of memory on some low-end devices) Auth no longer initializes. It looks like this is during a call to the regular Auth.DefaultInstance constructor, as the code in initalizedFirebase() is innocuous, and looks like this:
if (!FirebaseDBUtil.IsRunningEditorFirebase) {
DebugLog("Setting up Firebase Auth");
auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
The reason this is going wrong is the (as in the example code on github, we do this: )
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
Which works fine in a retail build. I was under the impression that all Firebase task.ContinueWith() statements had been made to run on the main thread to avoid having to write our own main thread dispatcher, but it looks like this doesn't work in development builds, at least in this specific case. Rewriting the logic to use a Coroutine in Start() and a yield for task completion works fine.
Is this is known issue? Also, since we want to test our profile builds with confidence, are there other cases where this won't work, in which case we should probably write our own main-thread continuations.
01-14 22:13:36.966: E/Unity(21416): Unable to find /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
01-14 22:13:38.749: E/Unity(21416): get_realtimeSinceStartup can only be called from the main thread.
01-14 22:13:38.749: E/Unity(21416): Constructors and field initializers will be executed from the loading thread when loading a scene.
01-14 22:13:38.749: E/Unity(21416): Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
01-14 22:13:38.749: E/Unity(21416): UnityEngine.Time:get_realtimeSinceStartup()
01-14 22:13:38.749: E/Unity(21416): Firebase.Unity.FirebaseAuthService:OnIdTokenChanged(FirebaseAuth)
01-14 22:13:38.749: E/Unity(21416): Firebase.Auth.FirebaseAuth:GetAuth(FirebaseApp)
01-14 22:13:38.749: E/Unity(21416): Firebase.Auth.FirebaseAuth:get_DefaultInstance()
01-14 22:13:38.749: E/Unity(21416): FirebaseAuthTestUIHandlerModified:InitializeFirebase() (at /Users/alex/src/Colouring3D/Colouring3D-Android/Assets/FirebaseAuthTest/FirebaseAuthTestUIHandlerModified.cs:106)
01-14 22:13:38.749: E/Unity(21416): FirebaseAuthTestUIHandlerModified:<Start>m__0(Task`1) (at /Users/alex/src/Colouring3D/Colouring3D-Android/Assets/FirebaseAuthTest/FirebaseAuthTestUIHandlerModified.cs:82)
01-14 22:13:38.749: E/Unity(21416): System.Threading.Tasks.<ContinueWith>c__AnonStorey0:<>m__0(Task)
01-14 22:13:38.749: E/Unity(21416): System.Threading.Tasks.<ContinueWith>c__AnonStorey2:<>m__0(Task)
01-14 22:13:38.749: E/Unity(21416): System.Threading.Tasks.<ContinueWith>c__AnonSt