Open
Description
[REQUIRED] Step 2: Describe your environment
- Android Studio version: Bumblebee 2021.1.1 Patch 3
- Firebase Component: Storage
- Component version: firebase-storage:20.0.1
[REQUIRED] Step 3: Describe the problem
StorageTask cannot be canceled while the network connection is unavailable.
Relevant Code:
suspend fun reproduceBug() {
// STEP 1 - turn off network connection (wifi/mobile)
val task = FirebaseStorage.getInstance()
.getReference("my-firebase-storage.json")
.getFile(File("my-file-pathname"))
task.addOnCanceledListener {
// even though task.cancel() returns true,
// listener will not be called until network connection gets established
}
task.addOnCompleteListener {
// even though task.cancel() returns true,
// listener will not be called until network connection gets established
}
delay(5000)
val isCanceled = task.cancel() // returns true, but not canceled
}
StorageTask goes into 'canceling' state:
ExponentialBackoffSender is stuck in the while loop, wasting resources, until it hits max-wait-time or network connection is established, because 'cancel' is not yet called.