Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase Storage Upload/Download Failures #12812

Open
KunalxBhandari opened this issue Apr 18, 2024 · 6 comments
Open

Firebase Storage Upload/Download Failures #12812

KunalxBhandari opened this issue Apr 18, 2024 · 6 comments

Comments

@KunalxBhandari
Copy link

KunalxBhandari commented Apr 18, 2024

Description

I'm using firebase storage in order to upload some files and download those files later. I'm using the code down below in order to download the files from firebase storage.

func downloadFileFromFirebase(fireBasePath: String, localURL: String) {
let fireBaseStorage = Storage.storage().reference()
let storeRef = fireBaseStorage.child("(String(describing: fireBasePath))")
let downloadTask = storeRef.write(toFile: localURL)

downloadTask.observe(.progress) { snapshot in
// Updating the progress bar
}

downloadTask.observe(.success) { snapshot in
//Updating the UI
}
}

Here, what I noticed is that my downloadTask.observe closures are not invoking and I did some digging in the framework and found out that my task is never enqueued and the StorageDownloadTask is deallocated before that.

Screenshot 2024-04-18 at 2 28 45 PM

Line 110 is never executed.

Screenshot 2024-04-18 at 2 33 44 PM

Here in StorageReference on Line 204 we are creating a strong reference cycle with StorageDownloadTask but still it is deallocating before the enqueue implementation I don't know why. So, in order to confirm that issue is happening due to this deallocation reason, I deliberately created a retain cycle in StorageReference and made sure that the StorageDownloadTask is not deallocated.

Screenshot 2024-04-18 at 2 40 37 PM Screenshot 2024-04-18 at 2 41 23 PM

And after creating this retain cycle my downloadTask.observe closures are invoking and I'm able to download the media from firebase storage. But this is not a solution to the problem as it will create retain cycle. Can somebody help with this problem and tell me why this is happening?

This problem started coming after 10.2.0 versions. Currently, I'm using the 10.24.0 version.

Reproducing the issue

No response

Firebase SDK Version

10.24.0

Xcode Version

15.3

Installation Method

CocoaPods

Firebase Product(s)

Storage

Targeted Platforms

iOS

Relevant Log Output

No response

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@paulb777
Copy link
Member

Sorry about the trouble @KunalxBhandari. I'm not able to reproduce. The only possible impacting change since 10.2.0 I see is #10492 and I'm not sure why that would matter.

I'm not sure how the task could be deallocated between the StorageDownloadTask init and the task.enqueue() call.

Does adding a wait or sleep to the bottom of downloadFileFromFirebase make a difference?

Are you able to share a sample app that reproduces the issue?

@KunalxBhandari
Copy link
Author

@paulb777 I'm using putData, delete, putFile, getMetadata, downloadURL functions of Storage and all of these are working fine expect the write function which I'm using for downloading the file from firebase storage. But on using sleep it's working fine. Is there any particular reason why this function is behaving like this?

@paulb777
Copy link
Member

It's possible the write to FirebaseStorage is succeeding, but the UI doesn't update because the function finishes first.

@klinkert0728
Copy link

Hello, I'm facing a similar issue, where the downloadProgressBlock never gets called
line 134 never gets executed.

Screenshot 2024-04-29 at 17 04 34

Any idea what could cause this ?

@klinkert0728
Copy link

nor the fetcherCompletion
Screenshot 2024-04-29 at 17 48 53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants