react-native-vision-camera: 💭 Enabling `video` slows down photo capture on Android

Question

Photo capture performance drops significantly and results in a preview layer freeze when the video prop is set to true.

Condition Format Filter Photo Video Duration[^1]
0 undefined true false 373.5ms
1 [{ photoResolution: { width: 480, height: 320 } }] true false 389.6ms
2 undefined true true 779.7ms
3 [{ photoResolution: { width: 480, height: 320 } }] true true 823.8ms

[^1]: Averaged across 10 sequential captures.

What I tried

Test app: rnvc3-test.zip

VisionCamera Version

3.8.2

Additional information

About this issue

  • Original URL
  • State: open
  • Created 5 months ago
  • Comments: 29 (16 by maintainers)

Most upvoted comments

It’s just reading the latest pixels from the preview or video stream. No AE/AF/AWB at all.

Results for 4.0.0-beta.8:

Condition Format Filter Photo Video Duration
0 undefined true false 921ms
1 skipped
2 undefined true true 697ms
3 skipped

To recap, capture with only photo enabled is slower in beta-8 than capture with video also enabled. Both conditions are slower than either of the same conditions in 3.8.2.

Hey! I just released a new V4 beta (v4.0.0-beta.7) where I fixed a bunch of issues! 💪🚀 Can you test that and see if that fixes the issue for you? 😅

yarn add react-native-vision-camera@beta

You might need to increase the compileSdk to the newest Android SDK (34) if you are behind.

Heyo, I just tested this on my end on my Huawei P10:

Without the stopRepeating() before capture, so just VisionCamera main codebase as it is today:

14:09:55.089 CameraSession            I  CAPTURE() took 265ms!
14:09:57.138 CameraSession            I  CAPTURE() took 232ms!
14:09:59.106 CameraSession            I  CAPTURE() took 249ms!
14:10:01.044 CameraSession            I  CAPTURE() took 241ms!
14:10:02.768 CameraSession            I  CAPTURE() took 241ms!
14:10:04.496 CameraSession            I  CAPTURE() took 225ms!
14:10:06.293 CameraSession            I  CAPTURE() took 263ms!
14:10:12.641 CameraSession            I  CAPTURE() took 254ms!

With the stopRepeating() added before the capture, so with the patch I suggested:

14:09:08.248 CameraSession            I  CAPTURE() took 260ms!
14:09:11.473 CameraSession            I  CAPTURE() took 246ms!
14:09:13.598 CameraSession            I  CAPTURE() took 250ms!
14:09:15.459 CameraSession            I  CAPTURE() took 233ms!
14:09:17.609 CameraSession            I  CAPTURE() took 254ms!
14:09:19.516 CameraSession            I  CAPTURE() took 234ms!
14:09:21.597 CameraSession            I  CAPTURE() took 246ms!

There doesn’t seem to be a difference here at all on my end.

Can you absolutely confirm that this changes the capture speed for you?

Confirmed. That brings Condition 2 in the table down to 218.5ms. All testing performed on a Pixel 3a.