title: CameraX - crash when unbinding Preview UseCase
body: <p>I need to freeze (stop) the preview when user initiates taking the photo. I've searched around and I've found <a href="https://stackoverflow.com/questions/59661727/how-to-make-camerax-preview-freeze-when-take-a-photo">this</a> SO post that mentions unbinding Preview UseCase. I've tried that and at first it works correctly on Android 9+, but on lower Android I receive following error in Logcat and picture is not taken.</p>
  
  <pre><code>ImageCapture: takePictureInternal onFailure
  
  androidx.camera.core.ImageCaptureException: The completer object was garbage collected - this future would otherwise never complete. The tag was: FutureChain[androidx.camera.core.impl.utils.futures.ChainingListenableFuture@3ee79178]
          at androidx.camera.core.ImageCapture$ImageCaptureRequest.lambda$notifyCallbackError$1$ImageCapture$ImageCaptureRequest(ImageCapture.java:1911)
          at androidx.camera.core.-$$Lambda$ImageCapture$ImageCaptureRequest$1G7WSvt8TANxhZtOyewefm68pg4.run(lambda)
          at android.os.Handler.handleCallback(Handler.java:739)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:135)
          at android.app.ActivityThread.main(ActivityThread.java:5221)
          at java.lang.reflect.Method.invoke(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:372)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: androidx.concurrent.futures.CallbackToFutureAdapter$FutureGarbageCollectedException: The completer object was garbage collected - this future would otherwise never complete. The tag was: FutureChain[androidx.camera.core.impl.utils.futures.ChainingListenableFuture@3ee79178]
  </code></pre>
  
  <p>And also a lot of logs starts to appear like</p>
  
  <pre><code>gralloc_ranchu: gralloc_lock usage mismatch usage=0x30 cb-&gt;usage=0x3
  </code></pre>
  
  <p>My suspicion is that the way how I retrieve <code>ProcessCameraProvider</code> instance is wrong - I just store it once I get from the Future returned from <code>getInstance</code> method and use it later. But when I tried getting the future again it did not helped. I've found no workaround around this and I am considering replacing CameraX with some other Camera library because I've spent too many time on that but maybe someone has some answer. </p>
  
  <p>I've created a <a href="https://github.com/davidbilik/camerax-crash-sample/blob/master/app/src/main/java/com/bilikdavid/cameraxsample/MainActivity.kt" rel="nofollow noreferrer">demo project</a> where I test this weird behavior so you can take a look at the full code.</p>