title: Why am I getting the error "frame processor crashed"?
body: <p>I am creating an app which will detect faces in real time and also detect face landmarks in a photo using <a href="https://developers.google.com/ml-kit/vision/face-detection/android" rel="nofollow noreferrer">Google's ML Kit</a>(the post of Firebase ML Kit). I have obtained the functionality for the landmark detection, but am struggling with real time detection.</p>
  <p>I am not going to include the whole program(as it's over 500 lines of code), but rather a <a href="https://stackoverflow.com/help/minimal-reproducible-example">minimal reproducible example</a>.</p>
  <p>In my debugger, the code crashes at this line of code:</p>
  <pre><code>Task&lt;List&lt;Face&gt;&gt; result = faceDetector.process(image).addOnSuccessListener(new OnSuccessListener&lt;List&lt;Face&gt;&gt;() {
  </code></pre>
  <p>and invokes the failure listener attached to <code>faceDetector.process(image)</code></p>
  <p>It goes into the CameraView class with the exception &quot;Frame Processor Crashed&quot;:</p>
  <pre><code> @Override
      public void dispatchFrame(@NonNull final Frame frame) {
          // The getTime() below might crash if developers incorrectly release
          // frames asynchronously.
          LOG.v(&quot;dispatchFrame:&quot;, frame.getTime(), &quot;processors:&quot;, mFrameProcessors.size());
          if (mFrameProcessors.isEmpty()) {
              // Mark as released. This instance will be reused.
              frame.release();
          } else {
              // Dispatch this frame to frame processors.
              mFrameProcessingExecutor.execute(new Runnable() {
                  @Override
                  public void run() {
                      LOG.v(&quot;dispatchFrame: executing. Passing&quot;, frame.getTime(),
                              &quot;to processors.&quot;);
                      for (FrameProcessor processor : mFrameProcessors) {
                          try {
                              processor.process(frame);
                          } catch (Exception e) {
                              LOG.w(&quot;Frame processor crashed:&quot;, e);
                          }
                      }
                      frame.release();
                  }
              });
          }
      }
  </code></pre>
  <p>The image which I'm processing is the InputImage as documented by the <a href="https://developers.google.com/ml-kit/vision/face-detection/android" rel="nofollow noreferrer">Google ML Kit documentation</a>:</p>
  <pre><code>int width = frame.getSize().getWidth();
          int height = frame.getSize().getHeight();
  
          byte[] byteArray = frame.getData();
          InputImage image = InputImage.fromByteArray(
                  //frame.getData()
                  byteArray,
                  width,
                  height,
                  //rotation
                  (cameraFacing == Facing.FRONT) ? 90 : 270,
                  //image format
                  InputImage.IMAGE_FORMAT_YV12 // or IMAGE_FORMAT_YV12
  
          );
  </code></pre>
  <p><em><strong>What may be going wrong here?</strong></em></p>
  <blockquote>
  <p><em><strong>Context information</strong></em></p>
  <ul>
  <li><p>I am using the <a href="https://github.com/natario1/CameraView" rel="nofollow noreferrer">CameraView library</a> which supports Camera1 and Camera2</p>
  </li>
  <li><p>I am also using the <a href="https://github.com/ArthurHub/Android-Image-Cropper" rel="nofollow noreferrer">Crop Image library</a></p>
  </li>
  </ul>
  </blockquote>
  <p>Thanks!</p>