firebase-unity-sdk
firebase-unity-sdk copied to clipboard
[Bug] Unity crashes often when entering play mode due to the Firebase SDK
[REQUIRED] Please fill in the following fields:
- Unity editor version: 2021.3.23f1
- Firebase Unity SDK version: 10.6.0
- Source you installed the SDK: Unity Package
- Problematic Firebase Component: FirebaseCppApp
- Other Firebase Components in use: Auth, Analytics, Functions, Crashalytics, RemoteConfig
- Additional SDKs you are using: IronSource and a bunch of assets from the Asset Store (but the crash is very clearly due to Firebase)
- Platform you are using the Unity editor on: Windows & Mac
- Platform you are targeting: iOS & Android
- Scripting Runtime: IL2CPP
- Pre-built SDK from the website or open-source from this repo: Website
[REQUIRED] Please describe the issue here:
Frequently when I make a change in my code and go back to Unity it starts the recompile but then fully crashes and has to restart the editor. The editor logs clearly show an issue related to FirebaseCppApp not being able to release an internal reference to the functions library.
Steps to reproduce:
It's unclear what the real trigger is, it happens on macOS and Windows, targeting iOS and Android and it doesn't matter whether the game was already in play mode or not. I simply change some code in Rider, switch back to Unity and it crashes. The crash happens roughly 5% of the time but it's very disruptive to my workflow.
Crash log:
========== OUTPUTTING STACK TRACE ==================
0x00007FFD36264A06 (FirebaseCppApp-10_6_0) uWS::HttpSocket<0>::upgrade
0x00007FFD3624CF5B (FirebaseCppApp-10_6_0) uWS::HttpSocket<0>::upgrade
0x00007FFD3624E663 (FirebaseCppApp-10_6_0) uWS::HttpSocket<0>::upgrade
0x00007FFD3623FD78 (FirebaseCppApp-10_6_0) uWS::HttpSocket<0>::upgrade
0x00007FFD36206A14 (FirebaseCppApp-10_6_0) uWS::HttpSocket<0>::upgrade
0x00007FFD362045D1 (FirebaseCppApp-10_6_0) uWS::HttpSocket<0>::upgrade
0x00007FFD35D20BCB (FirebaseCppApp-10_6_0) uWS::WebSocket<0>::send
0x00007FFD35D1FC1C (FirebaseCppApp-10_6_0) uWS::WebSocket<0>::send
0x00007FFD35C4423D (FirebaseCppApp-10_6_0) uS::Socket::freeMessage
0x00007FFD35D1FEB0 (FirebaseCppApp-10_6_0) uWS::WebSocket<0>::send
0x00007FFD35D1FE29 (FirebaseCppApp-10_6_0) uWS::WebSocket<0>::send
0x00007FFD35C1F390 (FirebaseCppApp-10_6_0) SWIGRegisterStringCallback_FirestoreCpp
0x000001EC9904E1BC (Mono JIT Code) (wrapper managed-to-native) Firebase.Functions.FunctionsInternalPINVOKE:FirebaseFunctionsInternal_ReleaseReferenceInternal (System.Runtime.InteropServices.HandleRef)
0x000001EC9904DF2B (Mono JIT Code) Firebase.Functions.FirebaseFunctionsInternal:ReleaseReferenceInternal (Firebase.Functions.FirebaseFunctionsInternal)
0x000001EC9904DBAB (Mono JIT Code) Firebase.Functions.FirebaseFunctionsInternal:Dispose (bool)
0x000001EC9904D964 (Mono JIT Code) Firebase.Functions.FirebaseFunctionsInternal:Dispose ()
0x000001EC9904D5AB (Mono JIT Code) Firebase.Functions.FirebaseFunctions:Dispose ()
0x000001EC9904D173 (Mono JIT Code) Firebase.Functions.FirebaseFunctions:Finalize ()
0x000001EBE7FDF02C (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr)
0x00007FFD56310BA5 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\gc.c:383] mono_gc_run_finalize
0x00007FFD56311C5E (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\gc.c:944] finalize_domain_objects
0x00007FFD563121D3 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\gc.c:1036] finalizer_thread
0x00007FFD562AD2DB (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\threads.c:1268] start_wrapper_internal
0x00007FFD562AD4B6 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\threads.c:1344] start_wrapper
0x00007FFE0DBC7614 (KERNEL32) BaseThreadInitThunk
0x00007FFE0EAE26A1 (ntdll) RtlUserThreadStart
========== END OF STACKTRACE ===========
Hi @MileyHollenberg,
Thanks for letting us know about this. Could you try if updating the Firebase SDK to its latest version makes any difference? If it doesn't, please provide the latest crash logs so that we can identify what's causing this behavior.
Hey @paulinon ,
Currently upgrading everything to version 11.0, If there's no more crashes I'll let you know by the end of the week, otherwise earlier with a crash log
I was able to update the libraries to 11.0 but I'm no longer able to build my game for iOS, I'm getting this error during the build process:
Unable to update following assemblies:Assets/Firebase/Plugins/Firebase.Platform.dll (Name = Firebase.Platform, Error = 131) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp6f55c734.tmp)
System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Mono.Cecil.ModuleDefinition.ReadSymbols (Mono.Cecil.Cil.ISymbolReader reader) [0x0002f] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) [0x0005a] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleReader.CreateModule (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x00081] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleDefinition.ReadModule (Mono.Disposable`1[T] stream, System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000d] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0006c] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at AssemblyUpdater.Core.AssemblyUpdaterContext.ReadAssembly (System.String assemblyPath, APIUpdater.Framework.Log.IAPIUpdaterListener listener, System.IO.FileAccess mode, System.String[] searchPaths) [0x0006e] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at AssemblyUpdater.Core.AssemblyUpdaterContext.From (System.String assemblyPath, APIUpdater.Framework.Configuration.ConfigurationProvider configuration, System.String[] assemblySearchPaths, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x00015] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at AssemblyUpdater.Core.AssemblyUpdaterContext.From (System.String assemblyPath, System.String[] assemblySearchPaths, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x00000] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at AssemblyUpdater.Application.Program+<>c__DisplayClass0_0.<Main>b__1 (AssemblyUpdater.Application.UpdateOptions o) [0x0001d] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at CommandLine.ParserResultExtensions.WithParsed[T] (CommandLine.ParserResult`1[T] result, System.Action`1[T] action) [0x0001e] in <5f6458f0234f43a48c09047109c24684>:0
at AssemblyUpdater.Application.Program.Main (System.String[] args) [0x00048] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
Assets/Firebase/Editor/Firebase.Editor.dll (Name = Firebase.Editor, Error = 131) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp6370a0c7.tmp)
System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Mono.Cecil.ModuleDefinition.ReadSymbols (Mono.Cecil.Cil.ISymbolReader reader) [0x0002f] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) [0x0005a] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleReader.CreateModule (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x00081] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleDefinition.ReadModule (Mono.Disposable`1[T] stream, System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000d] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0006c] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at AssemblyUpdater.Core.AssemblyUpdaterContext.ReadAssembly (System.String assemblyPath, APIUpdater.Framework.Log.IAPIUpdaterListener listener, System.IO.FileAccess mode, System.String[] searchPaths) [0x0006e] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at AssemblyUpdater.Core.AssemblyUpdaterContext.From (System.String assemblyPath, APIUpdater.Framework.Configuration.ConfigurationProvider configuration, System.String[] assemblySearchPaths, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x00015] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at AssemblyUpdater.Core.AssemblyUpdaterContext.From (System.String assemblyPath, System.String[] assemblySearchPaths, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x00000] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at AssemblyUpdater.Application.Program+<>c__DisplayClass0_0.<Main>b__1 (AssemblyUpdater.Application.UpdateOptions o) [0x0001d] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at CommandLine.ParserResultExtensions.WithParsed[T] (CommandLine.ParserResult`1[T] result, System.Action`1[T] action) [0x0001e] in <5f6458f0234f43a48c09047109c24684>:0
at AssemblyUpdater.Application.Program.Main (System.String[] args) [0x00048] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
Assets/ExternalDependencyManager/Editor/Google.VersionHandler.dll (Name = Google.VersionHandler, Error = 131) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp60050f44.tmp)
Mono.CompilerServices.SymbolWriter.MonoSymbolFileException: Symbol file `Assets/ExternalDependencyManager/Editor/Google.VersionHandler.dll.mdb' does not match assembly
at Mono.CompilerServices.SymbolWriter.MonoSymbolFile.ReadSymbolFile (System.String mdbFilename, System.Guid assemblyGuid) [0x00029] in <248bd4c168e1483487f3ce2100716558>:0
at Mono.Cecil.Mdb.MdbReaderProvider.GetSymbolReader (Mono.Cecil.ModuleDefinition module, System.String fileName) [0x00019] in <248bd4c168e1483487f3ce2100716558>:0
at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) [0x00032] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleReader.CreateModule (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x00081] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleDefinition.ReadModule (Mono.Disposable`1[T] stream, System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000d] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0006c] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <a6860a9f6366437387ebdc1f225b7fd4>:0
at AssemblyUpdater.Core.AssemblyUpdaterContext.ReadAssembly (System.String assemblyPath, APIUpdater.Framework.Log.IAPIUpdaterListener listener, System.IO.FileAccess mode, System.String[] searchPaths) [0x0006e] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at AssemblyUpdater.Core.AssemblyUpdaterContext.From (System.String assemblyPath, APIUpdater.Framework.Configuration.ConfigurationProvider configuration, System.String[] assemblySearchPaths, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x00015] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at AssemblyUpdater.Core.AssemblyUpdaterContext.From (System.String assemblyPath, System.String[] assemblySearchPaths, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x00000] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at AssemblyUpdater.Application.Program+<>c__DisplayClass0_0.<Main>b__1 (AssemblyUpdater.Application.UpdateOptions o) [0x0001d] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
at CommandLine.ParserResultExtensions.WithParsed[T] (CommandLine.ParserResult`1[T] result, System.Action`1[T] action) [0x0001e] in <5f6458f0234f43a48c09047109c24684>:0
at AssemblyUpdater.Application.Program.Main (System.String[] args) [0x00048] in <8aa6a9e3d56644faaf7f8c1e07781edc>:0
Following assemblies were successfully updated but due to the failed ones above they were ignored (not copied to the destination folder):Assets/Firebase/Plugins/iOS/Firebase.Crashlytics.dll (Result = 0) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp64ca72d4.tmp)
Assets/Firebase/Plugins/Firebase.Crashlytics.dll (Result = 0) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp492599b2.tmp)
Assets/Firebase/Editor/Firebase.Crashlytics.Editor.dll (Result = 0) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp233ebd52.tmp)
Assets/ExternalDependencyManager/Editor/1.2.176/Google.PackageManagerResolver.dll (Result = 0) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp10eb2815.tmp)
Assets/ExternalDependencyManager/Editor/1.2.176/Google.IOSResolver.dll (Result = 0) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp14a272f7.tmp)
Assets/ExternalDependencyManager/Editor/1.2.176/Google.JarResolver.dll (Result = 0) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp301deee4.tmp)
Assets/ExternalDependencyManager/Editor/1.2.176/Google.VersionHandlerImpl.dll (Result = 0) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp4074e7c0.tmp)
Assets/Plugins/Sirenix/Assemblies/AOT/Sirenix.Serialization.AOTGenerated.dll (Result = 0) (Output: /var/folders/fv/7h42h6x14rg47xh34c_fg3mh0000gn/T/tmp21bff1cb.tmp)
UnityEditor.Scripting.APIUpdaterLogger:WriteErrorToConsole (string,object[])
UnityEditorInternal.APIUpdating.APIUpdaterManager:HandleAssemblyUpdaterErrors (System.Collections.Generic.IList`1<UnityEditorInternal.APIUpdating.AssemblyUpdaterUpdateTask>) (at /Users/bokken/build/output/unity/unity/Editor/Mono/Scripting/APIUpdater/APIUpdaterManager.bindings.cs:248)
UnityEditorInternal.APIUpdating.APIUpdaterManager:UpdateAssemblies () (at /Users/bokken/build/output/unity/unity/Editor/Mono/Scripting/APIUpdater/APIUpdaterManager.bindings.cs:104)
UnityEditorInternal.APIUpdating.APIUpdaterManager:ProcessImportedAssemblies (string[]) (at /Users/bokken/build/output/unity/unity/Editor/Mono/Scripting/APIUpdater/APIUpdaterManager.bindings.cs:413)
UnityEditor.AssetDatabase:Refresh ()
Sirenix.Serialization.Editor.AOTSupportUtilities:GenerateDLL (string,string,System.Collections.Generic.List`1<System.Type>,bool)
Sirenix.Serialization.AOTGenerationConfig:GenerateDLL ()
Sirenix.Serialization.Internal.PreBuildAOTAutomation:OnPreprocessBuild (UnityEditor.BuildTarget,string) (at Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/BuildAOTAutomation.cs:36)
Sirenix.Serialization.Internal.PreBuildAOTAutomation:OnPreprocessBuild (UnityEditor.Build.Reporting.BuildReport) (at Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/BuildAOTAutomation.cs:44)
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler () (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorApplication.cs:462)
I've already tried to fully clear my build folder in case it was stuck there but that doesn't seem to resolve it. Is this a known issue?
Ok that's interesting, I restarted my Macbook (wasn't able to delete the /var/folders folder as I believe it's a temp directory) and now the build seems to be working. First time turning it off and on again actually fixed an issue on macOS for me
Good to hear that it worked, @MileyHollenberg. That said, I'll be closing this for now. Let me know if an issue arises so this ticket can be reopened.
Oh I don't yet know if the random crashes are gone, I just know I updated to Firebase 11.0 and after a reboot I was able to build my game for iOS again. I'll update you by the end of the week if I've not had any crashes since or I'll post a crash log if one happens again
Unfortunately it didn't fix the issue, just had another crash and it's looking pretty similar as before
Thanks for the update, @MileyHollenberg. Let's isolate what's causing this to happen. Could you verify if the issue persists with just the Firebase SDK in your Unity project? You may also provide a minimal, reproducible example of your implementation as this could be used as a baseline for troubleshooting.
Hmm, I think that's gonna be difficult as the issue doesn't always happen, it happens enough that it's very noticable whilst I'm working on my game but not enough to easily reproduce it each time. I'm also working on my main game and thus don't have that much time to spend on a empty project trying to reproduce this bug
I think I may have found the reason for the crash, when I was calling my functions I just called the CallAsync
method and didn't follow it up with ContinueWithOnMainThread
as I saw in the examples as I was fine with it running in the background. I changed my code so the calls to Firebase Functions now do use the ContinueWithOnMainThread
and so far I haven't had a single crash since this morning when I sent the message.
I'll make sure to keep you updated on if this actually fixed it for me but this does sound like a bug in the SDK as it should never cause a full on Unity Editor crash
Nope, seems I was just lucky, just had another crash. This one is a lot bigger as it was running for so long but it has the same crash in the end
Same problem :(
@paulinon any update on this? The change to use continueWithOnMainThread definitely helped reduce the amount of crashes I have but it's definitely not fully fixed yet (also I think the oss bot lost track of this issue somehow)
I'm starting to get the feeling this is happening when the editor switches between play/edit mode whilst a request is currently being executed and it's not being closed properly
Hi @MileyHollenberg,
I'm unsuccessful in reproducing the issue so far. We're still identifying the possible causes of these crashes. In the meantime, could you try updating your Unity editor and see if the issue persists?
Hey there, I tried to update to 2021.3.26f1 yesterday with the same thought but no real change. The same crash still occurs at random intervals.
Is there any way to gracefully terminate/cancel currently running functions when the game stops?
Hi @MileyHollenberg,
For us to narrow things down, could you provide the code you're using to call your functions? How often are you calling these functions?
Additionally, are you facing a similar issue when running our quickstart project?
Here you go,
public void Init()
{
if (_hasInitialized || !IsReady)
return;
_hasInitialized = true;
_setUserData = Functions.GetHttpsCallable("setUserData_V1");
_getUserData = Functions.GetHttpsCallable("getUserData_V1");
_getAdSlots = Functions.GetHttpsCallable("getNextAdsForUser_V1");
_userCompletedAd = Functions.GetHttpsCallable("userCompletedAd_V1");
LoadCommandsFromFile();
OnReady?.Invoke(this, EventArgs.Empty);
}
~FunctionsManager()
{
_currentTask.Dispose();
OnSetUserDataFinished = null;
OnGetUserDataFinished = null;
OnGetAdSlotsFinished = null;
OnUserCompletedAd = null;
_commands.Clear();
_commands = null;
_currentCommand = null;
_setUserData = null;
_getUserData = null;
Functions.App.Dispose();
_instance = null;
}
private async Task<ApiResponse<T>> ExecuteFunction<T>(string guid, HttpsCallableReference function, object data)
{
if (!IsReady)
{
Debug.LogError("Firebase is not ready yet.");
return null;
}
try
{
MarkCommandAsBusy(guid);
TaskCompletionSource<ApiResponse<T>> tcs = new();
if (data is AdSlot slot)
data = JsonConvert.SerializeObject(slot);
_currentTask = function.CallAsync(data);
await _currentTask.ContinueWithOnMainThread(task =>
{
try
{
ApiResponse<T> response;
if (task.Result.Data is ApiResponse<T> template)
response = template;
else
response = JsonConvert.DeserializeObject<ApiResponse<T>>(
JsonConvert.SerializeObject(task.Result.Data),
new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
if (response == null)
Debug.LogError("Response is null, " + JsonConvert.SerializeObject(task.Result.Data));
tcs.SetResult(response);
}
catch (Exception ex)
{
Debug.Log("CallAsync Exception: " + ex.Message);
tcs.SetException(ex);
}
finally
{
ClearCommandLocally(guid);
}
});
ApiResponse<T> res = await tcs.Task;
return res;
}
catch (Exception e)
{
IncreaseErrorCount(guid);
Debug.Log("ExecuteFunction Exception: " + e.Message);
}
Debug.LogError("Something went wrong with ExecuteFunction");
return null;
}
The Init
gets called once when the class is instantiated. It's setup in a way where it will replay any previous calls that haven't completed yet in order to keep everything in the right order for the back end (I've setup a rudimentary cheat prevention system on there which need the data to arrive in order).
The ExecuteFunction
method gets called from the ProcessQueue
and is simply awaited there for a response, if it was successful it will call an event notifying whoever is listening or if it failed it will simply mark it as failed, save it back to the queue and then wait 1 second before going through the queue again (should also increase the timeouts here to not accidentally DDOS my back end in case something's wrong there).
The deconstructor I added yesterday as a test but it hasn't changed anything, probably going to remove it.
Oh and the Functions variable is setup in a different class,
private void InitializeFirebase()
{
// Setup Firebase
// AppOptions options = AppOptions.LoadFromJsonConfig(GameManager.Instance.GoogleServicesJsonFile.text);
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
{
Assert.IsNull(task.Exception);
App = FirebaseApp.Create();
Functions = FirebaseFunctions.GetInstance(App, "europe-west1");
Auth = FirebaseAuth.GetAuth(App);
// Authenticate
Auth.StateChanged += AuthStateChanged;
});
}
and it's just referenced in the functions manager
Oh and I'm calling it at least once per minute, and never any calls at the same time because of the queueing system of-course. Max I would say 5 per minute
FYI, I'm currently upgrading my project to the 2022 LTS but I already had my first crash with the same stacktrace unfortunately
@MileyHollenberg I had the same issue. The reason was using different versions for Remote Config and Analytics. Now I use both 11.1.0, my previous Analytics was 10.3.0 and Remote Config was 11.1.0.
@KSF000 Interesting, but I don't think that's my issue here, all my libraries have the same version (whenever I upgrade them I make sure to upgrade all of them to avoid any conflicts, takes a lot longer to do but eventually they'd need to be updated anyways so I just do it in one go)
Hi @MileyHollenberg
As you call out, it does seem to be having a problem when trying to clean up the underlying C++ object, though it isn't exactly clear why. Something that might help getting better logs would be adding something like to your initialization:
Firebase.FirebaseApp.LogLevel = Firebase.LogLevel.Debug;
(or Verbose). It might at least give a clearer idea on what is happening that leads to the crash.
If I had to guess, my assumption would be that the underlying C++ object is getting deleted out from underneath the C# Functions, which then tries to clean it up a second time, but I'm not clear how it could get into that state.
Hey, these crashes also started happening in our project as well. Probably after we updated to 9.4.0. Crash happens on PlayMode enter/exit, around 1 out of 20 times. I tend to think that the reason is Firebase Async methods implemented in a native code. We use them a lot in the project to work with storage, firestore, remote config. Unlike C# tasks, they can't be canceled and I believe some of them kept alive after exiting the play mode.
Unfortunately I couldn't find a solution. But may be these will help:
From the editor crash log:
ERROR: ret == ((((DWORD )0x00000000L) ) + 0 )
ERROR: ret == ((((DWORD )0x00000000L) ) + 0 )
=================================================================
Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=================================================================
Managed Stacktrace:
=================================================================
domain required for stack walk
=================================================================
Crash!!!
...
========== OUTPUTTING STACK TRACE ==================
0x00007FFEA195C5B8 (FirebaseCppApp-9_4_0) uS::Socket::freeMessage
0x00007FFEA19967BD (FirebaseCppApp-9_4_0) uS::TLS::Context::operator bool
0x00007FFEA1A437E2 (FirebaseCppApp-9_4_0) uWS::WebSocket<0>::send
0x00007FFEA1A44CE9 (FirebaseCppApp-9_4_0) uWS::WebSocket<0>::send
0x00007FFF46971BB2 (ucrtbase) configthreadlocale
0x00007FFF46BC7614 (KERNEL32) BaseThreadInitThunk
0x00007FFF48A426F1 (ntdll) RtlUserThreadStart
========== END OF STACKTRACE ===========
Sometimes it just crashes with signal SIGSEGV
Actually I get ret == ((((DWORD )0x00000000L) ) + 0 )
from FirebaseAppUtils.PollCallbacks()
message in the log quite often on play mode exit, but it's not always results in a crash.
Quite often I get these messages on PlayMode exit. They are the reason I blame native Firebase Async methods. I get them all together on exit.
WARNING: Future with handle 1 still exists though its backing API 0x4700D410 is being deleted. Please call Future::Release() before deleting the backing API.
Future with handle 1 still exists though its backing API 0x4700D410 is being deleted. Please call Future::Release() before deleting the backing API.
WARNING: Future with handle 1 still exists though its backing API 0x4700DA30 is being deleted. Please call Future::Release() before deleting the backing API.
Future with handle 1 still exists though its backing API 0x4700DA30 is being deleted. Please call Future::Release() before deleting the backing API.
WARNING: Remote Config object 0x21659990 should be deleted before the App 0xae6c8fe0 it depends upon.
Remote Config object 0x21659990 should be deleted before the App 0xae6c8fe0 it depends upon.
WARNING: Storage object 0x2363b7c0 should be deleted before the App 0xae6c8fe0 it depends upon.
Storage object 0x2363b7c0 should be deleted before the App 0xae6c8fe0 it depends upon.
Here is the stack trace of one of this messages:
WARNING: Future with handle 1 still exists though its backing API 0x24DAACA0 is being deleted. Please call Future::Release() before deleting the backing API.
Future with handle 1 still exists though its backing API 0x24DAACA0 is being deleted. Please call Future::Release() before deleting the backing API.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogWarning (object)
Firebase.Platform.FirebaseLogger:LogMessage (Firebase.Platform.PlatformLogLevel,string) (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/app/platform/Unity/FirebaseLogger.cs:92)
Firebase.LogUtil:LogMessage (Firebase.LogLevel,string) (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/app/src/LogUtil.cs:69)
Firebase.LogUtil:LogMessageFromCallback (Firebase.LogLevel,string) (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/app/src/LogUtil.cs:77)
Firebase.FirebaseApp:ReleaseReferenceInternal (Firebase.FirebaseApp) (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/android_unity/armeabi-v7a/app/swig/Firebase.App_fixed.cs:2836)
Firebase.FirebaseApp:RemoveReference () (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/android_unity/armeabi-v7a/app/swig/Firebase.App_fixed.cs:2124)
Firebase.FirebaseApp:Dispose (bool) (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/android_unity/armeabi-v7a/app/swig/Firebase.App_fixed.cs:1892)
Firebase.FirebaseApp:Dispose () (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/android_unity/armeabi-v7a/app/swig/Firebase.App_fixed.cs:1876)
Bootstrapper:OnApplicationQuit () (at Assets/Scripts/App/Modules/Social/Bootstrapper.cs:68)
Just found in my screenshots that I did while was investigating. I got such stacktrace in the crash log only once. Hope this helps
We're also encountering several crashes when using Editor + Firebase 11.1.0 Stack Trace:
===========================================================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at Firebase.Auth.AuthUtilPINVOKE:FirebaseUser_UserId_get <0x000a5>
at Firebase.Auth.FirebaseUser:get_UserId <0x0004a>
at Pixodust.Firebase.Auth.FirebaseAuthHandler:get_FirebaseId <0x00032>
at DisconnectController:TryGetValidUserId <0x0003d>
at DisconnectController:FindUserId <0x00032>
at DisconnectController:Initialize <0x00032>
...
at UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded <0x00052>
at <Module>:runtime_invoke_void_Scene_int <0x00098>
Not related with the editor crashes, but we've also found severe issues using CI + Firebase 11.0+ for building in Android This was due some Crashlytics Editor .DLL referencing XCode libs when not needed (i.e. Android run)
Same here... Out of nowhere, my game started crashing on play mode (it takes between 5 to 30 seconds) with the same stack trace as others. I stopped calling Firebase initiation and it became fine. But it took me so long to understand it's because of Firebase.
Any solutions?
For anyone currently experiencing these crashes in play mode, can you confirm which Firebase products you are using, and especially whether or not you are using Firebase Realtime Database?
I notice that several of the stack traces mention uWS::WebSocket<0>::send, but as far as I know Firebase only uses uWebSockets for the desktop implementation of database, and the original report of this issue did not mention Database at all.
Setting Firebase.FirebaseApp.LogLevel = Firebase.LogLevel.Debug; as a-maurice suggests above might also help with getting error logs that reveal what order of events is resulting in the crash.
Also @brenofurlanpixo, your stack trace looks pretty different from the others, as yours is the only one to mention Auth UserId. If you are still encountering this issue could you please file a separate issue to track this?