- 
  Notifications
 
You must be signed in to change notification settings  - Fork 648
 
Open
@nikolajakshic 
 
 
 
 
 
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.
 
 
 
 
 
 
 
 
 
 
 
 
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:
firebase-android-sdk/firebase-storage/src/main/java/com/google/firebase/storage/StorageTask.java
Line 50 in f625c8c
 
  static final int INTERNAL_STATE_CANCELING = 32; 
 
 
 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.
Line 86 in f625c8c
 
  while (clock.elapsedRealtime() + currentSleepTime <= deadLine 
 
 
 Line 124 in f625c8c
 
  public void cancel() {