firebase / firebase-unity-sdk

The Firebase SDK for Unity
http://firebase.google.com
Apache License 2.0
202 stars 35 forks source link

[Bug] PutFileAsync won't finish or throws errors in Windows #1053

Closed ChurikiTenna closed 1 day ago

ChurikiTenna commented 2 weeks ago

Description

I have this code to upload a file to storage which works fine on Mac. However, it doesnt continue to the next line of the code after var metadata = await uploadTask;

I see the file is successfully uploaded on Storage, and log seems to indicate the same. image It just doesn't continue to the next process (i.e. Debug.Log("Upload task completed");) after uploading.

public static async Task<string> UploadFileAsync(string localFilePath)
    {
        try
        {
            Debug.Log($"UploadFileAsync {localFilePath}");

            string uniqueFileName = $"custom_chara/{FirebaseAuthHelper.uid}_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}_{Path.GetFileName(localFilePath)}";
            Debug.Log($"UploadFileAsync.uniqueFileName {uniqueFileName}");

            FirebaseStorage storage = FirebaseStorage.DefaultInstance;
            var uploadTask = storage.GetReferenceFromUrl("gs://projectname.appspot.com")
                .Child(uniqueFileName)
                .PutFileAsync(localFilePath);
            Debug.Log($"Upload task created {uploadTask}");
            var metadata = await uploadTask;
            if (uploadTask.IsCompleted)
            {
                Debug.Log("Upload task completed");
            }
            else if (uploadTask.IsFaulted)
            {
                Debug.LogError("Upload task faulted");
            }
            else if (uploadTask.IsCanceled)
            {
                Debug.LogError("Upload task canceled");
            }
            Debug.Log($"Finished uploaded to... {metadata.Path}");
            return metadata.Path;
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
            return null;
        }
    }

Reproducing the issue

Run the code above in windows.

Firebase Unity SDK Version

11.6.0

Unity editor version

2022.3.17f1

Installation Method

.unitypackage

Problematic Firebase Component(s)

Storage

Other Firebase Component(s) in use

Authentication, Firestore

Additional SDKs you are using

No response

Targeted Platform(s)

Desktop

Unity editor platform

Windows

Scripting Runtime

Mono

Release Distribution Type

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

Relevant Log Output

No response

If using CocoaPods for Apple platforms, the project's Podfile.lock

Expand Podfile.lock snippet
```yml 👀 Replace this line with the contents of your Podfile.lock! ```
argzdev commented 2 weeks ago

Hey @ChurikiTenna, could you try testing with our latest version 12.1.0 to see if that makes any difference? We usually advise this to avoid issues that might've already been fixed in the most recent versions. Thanks!

google-oss-bot commented 1 week ago

Hey @ChurikiTenna. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 1 day ago

Since there haven't been any recent updates here, I am going to close this issue.

@ChurikiTenna if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.