react-native-vision-camera: ๐Ÿ› 3.6.17 Android Regression: Camera blacks out on Android (working fine on 3.6.16)

Whatโ€™s happening?

Iโ€™ve started to encounter a black screen on Android while working in development mode, <Camera /> starts black and stays black 100% of the time. I can fix it by adding a timeout to toggle the the isActive prop after one second.

It used to work flawlessly before (same device same OS version) ~but Iโ€™m not sure which version introduced the regression as I develop mainly on iOS. Could try to bisect the version if interested~. The regression did occur in latest 3.6.17 has it does work correctly using the previous 3.6.16 release.

Culprit is probably https://github.com/mrousavy/react-native-vision-camera/commit/977bf56c6de70c981b87991dcf5b0a69b9ed66e1

Iโ€™ve captured two adb traces, one when the bug occurs, one with a working start with the timeout.

There seems to be related issues but not exactly the same:

Reproduceable Code

const devices = useCameraDevices();
const device = devices.find(({position}) => position === 'back');
return <Camera
         style={StyleSheet.absoluteFill}
         device={device}
         resizeMode="contain"
       />

Relevant log output

https://gist.github.com/mgcrea/8bce7771c8dbca5fdd1c0358c89fcd9e

Camera Device

{
  "sensorOrientation": "landscape-right",
  "hardwareLevel": "full",
  "maxZoom": 8,
  "minZoom": 1,
  "maxExposure": 72,
  "supportsLowLightBoost": false,
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "supportsFocus": true,
  "supportsRawCapture": true,
  "isMultiCam": false,
  "minExposure": -72,
  "name": "BACK (0)",
  "hasFlash": true,
  "hasTorch": true,
  "position": "back",
  "id": "0"
}

Device

OnePlus 6

VisionCamera Version

3.6.17

Can you reproduce this issue in the VisionCamera Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Reactions: 10
  • Comments: 18 (4 by maintainers)

Most upvoted comments

I have this same issue using 3.6.17 with RN 0.73.1. Switching to 3.6.16 gets rid of the issue.

For me this worked-


const [isActive, setIsActive] = useState(false);
useEffect(() => {
    setTimeout(() => {
      setIsActive(true);
    }, 500);
  }, []);
<Camera
          style={StyleSheet.absoluteFill}
          ref={cameraRef}
          device={device}
          isActive={isActive}
          onError={handleCameraError}
        />


Hey! Thanks for reporting this issue.

Iโ€™ve been working the past days on making sure the Camera lifecycle is safely handled and released when needed, so this crash doesnโ€™t occur anymore.

I just created a PR for this - can you please this to see if that fixes the issue for you? https://github.com/mrousavy/react-native-vision-camera/pull/2339

If this fixes your issue, please consider ๐Ÿ’– sponsoring me on GitHub ๐Ÿ’– to support me / thank me for building VisionCamera and continuously improving it.

If this does not fix your issue, please clone the repo, check out the branch fix/blackscreen (the PR above), run the Example app, reproduce your issue there and share the adb logcat logs with me (upload to pastebin or gist) so I can investigate this further.

Thank you! ๐Ÿ™