Skip to content

Strange behavior occurs when sending requests at the same time #1292

@towberapp

Description

@towberapp

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2022.1.5
  • Firebase Unity SDK version: 9.1.0
  • Problematic Firebase Component: Firestore
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: Android
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the issue here:

If you send 2 requests at the same time: 1 for writing and 1 for reading, then when reading you will receive what was sent for writing, and not what is stored in the database.

If you send 1 read request, then get all the data from the Firestore as usual.

In the Unity editor, concurrent requests are handled correctly.
BUT when compiling for Android, what happens is what is indicated.

Relevant Code:

DocumentReference docRef = db.Collection("users").Document("aturing");

//write 1
Dictionary<string, object> userWriteFirst = new Dictionary<string, object>
{
        { "First", "Alan" },
};
docRef.SetAsync(userWriteFirst).ContinueWithOnMainThread(task => {
        Debug.Log("Added data to the aturing document in the users collection.");
});


//read1
docRef.GetSnapshotAsync().ContinueWithOnMainThread(task =>
{
  DocumentSnapshot snapshot = task.Result;
  if (snapshot.Exists) {

    Dictionary<string, object> user = snapshot.ToDictionary();
    foreach (KeyValuePair<string, object> pair in city) {

         Debug.Log(String.Format("{0}: {1}", pair.Key, pair.Value));
    
        /* 
           At this point, you expect to see the entire array of data retrieved from the Firebase database, 
           but you only get this:
            > First: Alan
            Even if there are dozens of rows in the database
         */
    }
});

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions