quickstart-unity: Editor get stuck on Application.Reload when using Listen() on a collection or document reference
[REQUIRED] Please fill in the following fields:
- Unity editor version: 2020.1.8f1
- Firebase Unity SDK version: 6.16.0
- Source you installed the SDK: Unity Package Manager
- Problematic Firebase Component: Firestore
- Other Firebase Components in use: Auth, Functions
- Additional SDKs you are using: none
- Platform you are using the Unity editor on: Windows
- Platform you are targeting: Android, iOS
- Scripting Runtime: IL2CPP
[REQUIRED] Please describe the issue here:
When listening for changes on a collection or a document in any part of a script, Editor get stuck on Application.Reload state after recompiling or when entering play mode.
Steps to reproduce:
- Add a document or collection listener with ref.Listen() in any part of a monobehaviour script.
- Return to the Editor and wait for compilation
- Try to enter play mode
- Editor get stuck on Application.Reload state and is unusable.
Appens 100% of the time. If not listener is set, everything is ok.
Relevant Code:
Example class:
using Firebase.Firestore;
using UnityEngine;
public class TestListenFirebase : MonoBehaviour
{
void Start()
{
var db = FirebaseFirestore.DefaultInstance;
CollectionReference col = db.Collection("users");
col.Listen(snapshot =>
{
Debug.Log("Listening...");
});
}
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16
@Sov3rain One of my colleagues suggested an even better workaround: Call
FirebaseApp.Dispose()
in theOnApplicationQuit()
method of yourMonoBehaviour
.For example, in the code sample from the first comment of this issue, the bug can be worked around by adding an
OnApplicationQuit()
method as follows:FYI The Firebase Unity SDK v7.0.0 was just released and contains the fix for this issue.
Although I was not able to reproduce the issue on my Mac, I was able to easily reproduce it on a colleague’s Windows laptop. This is great news because it means that investigation can start. The root cause is still unknown but I will continue to investigate. So unfortunately, at this time I do not have an ETA for a fix nor a suggestion for a workaround.
Good news! I have submitted a fix for this bug today. It should be included in the next release, for which, unfortunately, I do not have an ETA. Until then, please employ one of the workarounds described in earlier comments in this issue. I’m going to close this issue as “fixed” since there is no further work to do from our end; however, feel free to re-open if the next release still contains this bug.
Oh great! I’ll try it out and let you know what I find.