question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Unity Editor crashes in TokenAsync after updating to 11.2.0 and 11.3.0

See original GitHub issue

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2023.3.28f1
  • Firebase Unity SDK version: 11.3.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Auth
  • Other Firebase Components in use: N/A - Repros with just Auth
  • Additional SDKs you are using: N/A - Repros with just Auth
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: iOS, Android - Irrelevant, Repros in Editor
  • Scripting Runtime: IL2CPP - Irrelevant, Repros in Editor.
  • Pre-built SDK from the website or open-source from this repo: Pre-built

[REQUIRED] Please describe the issue here:

Ever since updating to 11.2.0, and now 11.3.0, calling TokenAsync(true) crashes the editor. This did not happen on version 10.4.0 or any version before that. It usually does not crash on the first call to it, but it will crash on subsequent ones. On our real project it always crashes on the second call, on the repro project it may take some more.

Steps to reproduce:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)? Yes. Attached repro based on Quickstart project. What’s the issue repro rate? 100%

What happened? Crash

How can we make the problem occur?

Open attached project. Add a suitable GoogleServices config file, I have not attached our own for obvious reasons. Press play. Right click on the Sign In component attached to the main camera and press Reauth a few times. Crash. I’ve had this happen on the first reauth, I’ve also had it take 4-5, either way it can always be reproduced.

The stack trace is the following:

=================================================================
	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:
=================================================================
	  at <unknown> <0xffffffff>
	  at Firebase.Auth.AuthUtilPINVOKE:FirebaseUser_Token <0x001ac>
	  at Firebase.Auth.FirebaseUser:TokenAsync <0x000e2>
	  at <Reauth>d__2:MoveNext <0x000e2>
	  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start <0x001f1>
	  at SignIn:Reauth <0x001da>
	  at <Module>:runtime_invoke_object__this__ <0x000e5>
=================================================================
Received signal SIGSEGV
Obtained 34 stack frames
0x00007fff04536555 (FirebaseCppApp-11_3_0) uS::Socket::freeMessage
0x00007fff04567e2d (FirebaseCppApp-11_3_0) uS::TLS::Context::operator bool
0x00007fff0456d79d (FirebaseCppApp-11_3_0) uS::TLS::Context::operator bool
0x00007fff0456d744 (FirebaseCppApp-11_3_0) uS::TLS::Context::operator bool
0x00007fff0455fb05 (FirebaseCppApp-11_3_0) uS::TLS::Context::operator bool
0x00007fff044efa0f (FirebaseCppApp-11_3_0) Firebase_Auth_CSharp_FirebaseUser_Token
0x000001fa53e10fed (Mono JIT Code) (wrapper managed-to-native) Firebase.Auth.AuthUtilPINVOKE:FirebaseUser_Token (System.Runtime.InteropServices.HandleRef,bool)
0x000001fa53e10c03 (Mono JIT Code) Firebase.Auth.FirebaseUser:TokenAsync (bool)
0x000001fa53f5b253 (Mono JIT Code) [SignIn.cs:37] SignIn/<Reauth>d__2:MoveNext () 
0x000001fa53f5b062 (Mono JIT Code) System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start<TStateMachine_REF> (TStateMachine_REF&)
0x000001fa53f597eb (Mono JIT Code) SignIn:Reauth ()
0x000001fa53f599b6 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_object__this__ (object,intptr,intptr,intptr)
0x00007ffef2f1fb64 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke 
0x00007ffef2e5e7a4 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke 
0x00007ffef2e5e93c (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke 
0x00007ff6214a81c4 (Unity) scripting_method_invoke
0x00007ff621487b04 (Unity) ScriptingInvocation::Invoke
0x00007ff621487bee (Unity) ScriptingInvocation::InvokeChecked
0x00007ff6222e1857 (Unity) ScriptContextCommands::InvokeContextMenuItem
0x00007ff6222df22b (Unity) ScriptContextCommands::Execute
0x00007ff621ef2500 (Unity) MenuController::ExecuteMenuItem
0x00007ff62252ea22 (Unity) ShowDelayedContextMenu
0x00007ff62253f756 (Unity) GUIView::OnInputEvent
0x00007ff621fabee3 (Unity) GUIView::ProcessInputEventFromAPI
0x00007ff621fabdb8 (Unity) GUIView::ProcessInputEvent
0x00007ff62253853e (Unity) GUIView::DoPaint
0x00007ff6225418cd (Unity) GUIView::RepaintAll
0x00007ff6220db3a7 (Unity) PlayerLoopController::UpdateScene
0x00007ff6220d939b (Unity) Application::TickTimer
0x00007ff6225154fa (Unity) MainMessageLoop
0x00007ff622519d8b (Unity) WinMain
0x00007ff6238f98ae (Unity) __scrt_common_main_seh
0x00007fffefee7614 (KERNEL32) BaseThreadInitThunk
0x00007ffff11c26b1 (ntdll) RtlUserThreadStart

Relevant Code:

Simply run the following a few times:

	string token = await CurrentUser.TokenAsync(true);

I have stripped out all the platform-specific plugins from the repro project to make it fit here.

Crash Dump Editor Log FirebaseCrashRepro.zip

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
a-mauricecommented, Aug 8, 2023

So I’ve identified the problem, and am trying to find the solution. Essentially, there is a problem with caching the User object, where the internals are being cleaned up incorrectly, and thus when in your example the Reauth is called, and it tries using the cached CurrentUser, it crashes.

A workaround in the meantime is to instead cache the Auth object (or use the DefaultInstance), and access the User via the CurrentUser property on that. So like:

public async Task Reauth()
{
  CurrentUser = Firebase.Auth.FirebaseAuth.DefaultInstance.CurrentUser;
  if (CurrentUser != null) {
    string token = await CurrentUser.TokenAsync(true);
    Debug.Log($"Reauth token: {token}");
  } else {
    Debug.Log("CurrentUser was null");
  }
}
1reaction
AlkisFortuneFishcommented, Aug 3, 2023

Hey @a-maurice, I’ve attached the relevant log, although it doesn’t contain that much information. I tried both debug and verbose (redacting where necessary). Editor.log

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug - Editor keeps crashing constantly | Page 2
I just upgraded to 2022.3.1f1 from 2021. It continuously crash when any changes made to the scene and even when trying to save...
Read more >
Unity editor crashes when opening project, with no error in ...
Update : I have tried copying Unity from other normal computer, using a flashdrive. And the copied Unity, which is OK on other...
Read more >
OCULUSXR crashing Unity editor and any OculusXR bu...
OculusXR within Unity Editor and any builds created are now constantly crashing after this latest Oculus Update. These are the 2 errors -...
Read more >
GUI/Unity crashing in 16.04 LTS after updates 2018-01-04 ...
It seems a bug with more or less the same symptoms hit a couple of users beginning of March 2018. This new bug...
Read more >
Unity is always crashing when the editor loads : r/Unity3D
On unity 2021.1.1f1 it says "EditorApplication.update" When I load the editor then it pops up the unity crash handler.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found