Skip to content

[Bug] Unity 6 editor hangs during domain reload in mono_domain_try_unload after FirebaseRemoteConfig.OnAppDisposed #1485

Description

@vg-swift

Description

Unity Editor hangs indefinitely during script/domain reload after a successful compile. The editor remains alive/responding at the OS process level, but the reload never completes.

The last Firebase-related managed log before the hang is:

FirebaseRemoteConfig.OnAppDisposed()
Firebase.RemoteConfig.FirebaseRemoteConfig:OnAppDisposed (object,System.EventArgs) (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/remote_config/src/FirebaseRemoteConfig.cs:111)
Firebase.FirebaseApp:Dispose (bool) (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/macos_unity/x86_64/app/swig/Firebase.App_fixed.cs:2062)
Firebase.FirebaseApp:Finalize () (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/macos_unity/x86_64/app/swig/Firebase.App_fixed.cs:2046)

After this, the editor never logs Mono: successfully reloaded assembly.

This appears to be a Mono domain unload/finalization hang involving Firebase app disposal/finalizers. A native dump captured while stuck shows the main thread waiting inside Mono domain unload, and a dedicated domain unloader thread waiting inside Mono domain finalization. The dump also contains many active FirebaseCppApp_13_13_0 native threads.

Reproducing the issue

I do not yet have a minimal repro project. In our project, this happened after a forced synchronous recompile/domain reload in the Unity Editor.

Observed sequence:

  1. Open Unity project.
  2. Make a script change / trigger script compilation.
  3. Compilation completes successfully.
  4. Unity starts domain reload.
  5. Unity hangs after Begin MonoManager ReloadAssembly.

Relevant Editor.log sequence:

*** Tundra build success (12.35 seconds), 11 items updated, 3326 evaluated
Reloading assemblies after forced synchronous recompile.
Duplicate assembly 'Microsoft.Bcl.AsyncInterfaces.dll' with different versions detected, using 'Packages/com.unity.ai.assistant/Plugins/Shared/Microsoft.Bcl.AsyncInterfaces.dll, AssemblyName=Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and ignoring 'Assets/Plugins/Google.Apis/Microsoft.Bcl.AsyncInterfaces.dll, AssemblyName=Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
Duplicate assembly 'System.Runtime.CompilerServices.Unsafe.dll' with different versions detected, using 'Packages/com.unity.ai.assistant/Plugins/Shared/System.Runtime.CompilerServices.Unsafe.dll, AssemblyName=System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and ignoring 'Assets/Plugins/Google.Apis/System.Runtime.CompilerServices.Unsafe.dll, AssemblyName=System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Duplicate assembly 'System.Runtime.CompilerServices.Unsafe.dll' with different versions detected, using 'Packages/com.unity.ai.assistant/Plugins/Shared/System.Runtime.CompilerServices.Unsafe.dll, AssemblyName=System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and ignoring 'Packages/com.unity.collections/Unity.Collections.Tests/System.Runtime.CompilerServices.Unsafe/System.Runtime.CompilerServices.Unsafe.dll, AssemblyName=System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Begin MonoManager ReloadAssembly
FirebaseRemoteConfig.OnAppDisposed()
Firebase.RemoteConfig.FirebaseRemoteConfig:OnAppDisposed (object,System.EventArgs) (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/remote_config/src/FirebaseRemoteConfig.cs:111)
Firebase.FirebaseApp:Dispose (bool) (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/macos_unity/x86_64/app/swig/Firebase.App_fixed.cs:2062)
Firebase.FirebaseApp:Finalize () (at /Users/runner/work/firebase-unity-sdk/firebase-unity-sdk/macos_unity/x86_64/app/swig/Firebase.App_fixed.cs:2046)

There is no later Mono: successfully reloaded assembly.

Firebase Unity SDK Version

13.13.0

Unity editor version

6000.3.8f1

Installation Method

Unity Package Manager

Problematic Firebase Component(s)

Analytics, Crashlytics, App Check, App Distribution, Authentication, Database, Firestore, Functions, In-App Messaging, Installations, Messaging, Remote Config, Storage

Other Firebase Component(s) in use

No response

Additional SDKs you are using

Not exhaustive, but relevant editor/package environment includes:

  • External Dependency Manager for Unity 1.2.187
  • Unity AI Assistant 2.7.0-pre.3
  • Unity Entities 1.4.4
  • Singularity Group Hot Reload embedded package
  • AppLovin MAX / mediation packages

Targeted Platform(s)

Apple Platforms, Android

Unity editor platform

Windows

Scripting Runtime

IL2CPP

Release Distribution Type

Pre-built SDK from https://firebase.google.com/download/unity

Relevant Log Output

I captured a full dump with Windows Task Manager while Unity was stuck, then inspected it with WinDbg.

Main thread:


0:000> ~0 k
 # Child-SP          RetAddr               Call Site
00 00000045`4d5ad748 00007ff8`7030c2ef     ntdll!NtWaitForSingleObject+0x14
01 00000045`4d5ad750 00007fff`702fd2da     KERNELBASE!WaitForSingleObjectEx+0xaf
02 00000045`4d5ad7f0 00007fff`702fca50     mono_2_0_bdwgc!mono_os_event_wait_multiple+0x7ea
03 00000045`4d5ad850 00007fff`70313a91     mono_2_0_bdwgc!mono_os_event_wait_one+0x70
04 00000045`4d5ad890 00007fff`704e01ea     mono_2_0_bdwgc!mono_domain_try_unload+0xe21
05 00000045`4d5adb70 00007fff`4736a1f6     mono_2_0_bdwgc!mono_unity_domain_unload+0x1a
06 00000045`4d5adba0 00007fff`4738c302     Unity+0xeda1f6
07 00000045`4d5adbe0 00007fff`4738ae01     Unity+0xefc302
08 00000045`4d5adcd0 00007fff`47394d70     Unity+0xefae01
09 00000045`4d5ade50 00007fff`480c849c     Unity+0xf04d70


Domain unloader thread:


314  Id: 6450.2c134 Suspend: 0 Teb: 00000045`598fc000 Unfrozen "Domain unloader"
 # Child-SP          RetAddr               Call Site
00 00000045`501ff4d8 00007ff8`7030c2ef     ntdll!NtWaitForSingleObject+0x14
01 00000045`501ff4e0 00007fff`702fd2da     KERNELBASE!WaitForSingleObjectEx+0xaf
02 00000045`501ff580 00007fff`702fe370     mono_2_0_bdwgc!mono_os_event_wait_multiple+0x7ea
03 00000045`501ff5e0 00007fff`704ccc58     mono_2_0_bdwgc!mono_os_sem_timedwait+0x30
04 00000045`501ff620 00007fff`7031273b     mono_2_0_bdwgc!mono_domain_finalize+0x188
05 00000045`501ff680 00007fff`704682fb     mono_2_0_bdwgc!mono_domain_is_unloading+0x4fb
06 00000045`501ff6e0 00007fff`7046850e     mono_2_0_bdwgc!mono_profiler_init_etw+0x393b
07 00000045`501ff8a0 00007ff8`71e9e957     mono_2_0_bdwgc!mono_profiler_init_etw+0x3b4e


Example Firebase native thread:


304  Id: 6450.1f474 Suspend: 0 Teb: 00000045`5981c000 Unfrozen
 # Child-SP          RetAddr               Call Site
00 00000045`5e9ff7b8 00007ff8`730a26de     ntdll!NtWaitForAlertByThreadId+0x14
01 00000045`5e9ff7c0 00007ff8`70312ea8     ntdll!RtlSleepConditionVariableSRW+0x1de
02 00000045`5e9ff860 00007fff`0c78d37d     KERNELBASE!SleepConditionVariableSRW+0x38
03 00000045`5e9ff8a0 00007fff`0c78d28e     FirebaseCppApp_13_13_0!uWS::HttpSocket<0>::upgrade+0x7fbe7d
04 00000045`5e9ff8e0 00007fff`0c78ce68     FirebaseCppApp_13_13_0!uWS::HttpSocket<0>::upgrade+0x7fbd8e
05 00000045`5e9ff910 00007fff`0c45e82a     FirebaseCppApp_13_13_0!uWS::HttpSocket<0>::upgrade+0x7fb968
06 00000045`5e9ff9c0 00007fff`0c45ebe8     FirebaseCppApp_13_13_0!uWS::HttpSocket<0>::upgrade+0x4cd32a
07 00000045`5e9ffa70 00007fff`0c45bf37     FirebaseCppApp_13_13_0!uWS::HttpSocket<0>::upgrade+0x4cd6e8
08 00000045`5e9ffb00 00007fff`0c76e6bc     FirebaseCppApp_13_13_0!uWS::HttpSocket<0>::upgrade+0x4caa37
09 00000045`5e9ffb30 00007ff8`71e9e957     FirebaseCppApp_13_13_0!uWS::HttpSocket<0>::upgrade+0x7dd1bc

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