title: Why does Picasso running in a background thread block onActivityResult?
body: <p>We are working on a share mode for photos in an app, and one of the share options is to load an overlay for the image online. If the user shares the photo before the overlay finishes loading we are sending an intent with the unmodified image to share to other apps with startActivityForResult, and then in onActivityResult we are returning the user to the normal photo view from the share view.</p>
  
  <p>The issue we are running into is that when the user returns from sharing the photo, onActivityResult isn't called until the background thread that is loading the overlay finishes. Is there a reason that a background thread would suddenly start to block the UI thread?</p>
  
  <p>Here is the code we are using inside of our overlay view class which extends ImageView to manage this:</p>
  
  <pre><code>private void asyncLoadImage() {
      new Thread(new Runnable() {
          @Override
          public void run() {
              loadImage();
          }
      }).start();
  }
  
  private void loadImage() {
      try {
          overlayBitmap = Picasso.with(getContext()).load(url).get();
          if (overlayBitmap != null) {
              displayBitmap();
          } else {
              displayError();
          }
  
      } catch (IOException ignored) {
          displayError();
      }
  }
  </code></pre>
  
  <p>We have tried using Picasso targets as well instead of creating our own thread and we run into the exact same issue, the only solution so far has been to use Ion asynchronously (however, using Ion synchronously or trying to cancel the Ion request futures before we call startActivityForResult result in the same UI thread blocking issues). This feels like a huge hack since we are using Picasso everywhere else in the app.</p>
  
  <p>Is there a reason why these background tasks would be blocking the UI thread when returning to the activity?</p>