firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
835 stars 433 forks source link

GetValueAsync() in Realtime Database often enters infinite wait #1371

Open king24371 opened 7 months ago

king24371 commented 7 months ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

In yesterday, reading and writing data was working fine. However, this morning when I opened the editor to test the game, I was often unable to read the data in the database. I tried different login methods, including Email and Facebook. Among them, FB could not receive the data every time I executed it, while email is some times good and some times bad, and even if it receive data, it is also from the past. After searching with different prints, I found that the problem lies here: GetUserReference().Child("logs").GetValueAsync(); I used a coroutine to execute this function. I found that when it reaches this line, it often waits indefinitely and then there is no result.

Relevant Code:

IEnumerator LoadID() { print("Load ID"); var task = GetUserReference().Child("logs").GetValueAsync(); print("catch the data from base"); yield return new WaitUntil(() => task.IsCompleted); print("wait for end of coroutine");

    if (task.IsFaulted || task.IsCanceled)
    {
        print(task.Exception);
        yield break;
    }

    DataSnapshot snapshot = task.Result;
    print("retuen result: " + snapshot);
    if (snapshot.Value != null)
    {
        print("load player data");
        LoadJson(snapshot);
        StartCoroutine(LoadCats());
        StartCoroutine(LoadBuilds());
    }
    else
    {
        //SaveID();
        print("no data");
        SaveJson_F();
        //authManager.validateSignIn(true);
    }
}
google-oss-bot commented 7 months ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.