title: Firebase addOnSuccessListener callback running context throws `NetworkOnMainThreadException`
body: <p>Suppose I have a repository class that defines a method to retrieve an image from Firebase Storage and defines a success listener that invokes a callback defined from a view model</p>
  
  <pre><code>fun getAdImg(imgId: String, callback: (stream: Bitmap?) -&gt; Unit) {
          storage.child(FOLDER).child(imgId+EXTENSION).stream
              .addOnSuccessListener {
                  callback(BitmapFactory.decodeStream(it.stream))
                  Log.i(TAG, "getAdImg success")
              }
              .addOnCanceledListener {
                  Log.e(TAG, "getAdImg canceled")
              }
              .addOnFailureListener {
                  Log.e(TAG, "getAdImg failure")
              }
  
      }
  </code></pre>
  
  <p>The function in the view model that defines the callback and invokes the repository is the following</p>
  
  <pre><code>fun loadImage(imgId: String?) {
          imgId?.let { id -&gt;
              if (_img.value == null) {
                  viewModelScope.launch (context = IO) {
                      AdvertisementRepository.getInstance().getAdImg(id) { bitmap -&gt;
                          _img.postValue(bitmap)
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <p>I have a couple of questions:</p>
  
  <ul>
  <li>What's the lifecycle of the listener defined by <code>addOnSuccessListener</code> in the repository class?</li>
  <li>What's the scope from which the <code>callback</code> function is invoked in the listener?</li>
  <li>When I try to run this code, <code>BitmapFactory.decodeStream(it.stream)</code> will throw a <code>android.os.NetworkOnMainThreadException</code> that seems like an exception due to the context in which the <code>decodeStream</code> function is invoked</li>
  </ul>