react-native-vision-camera: ๐Ÿ› Camera freezes on first frame when running frameProcessors on Galaxy S8, Android 9

Whatโ€™s happening?

So I am testing frame processors on SAMSUNG Galaxy S8, running Android 9.0. The previous version works fine (v2), but on v3 the Camera freezes on the first frame, when (and only when) running frame processors. If I comment out the frameProcessor prop, it works fine. So in theory I am able to have the worklet initialized, itโ€™s only when I actually try to use it and bind it to the camera, it freezes and stops the camera from working. Also the console.logs from the frame processor are not being logged, so the worklet does not seem to be running as well (or binded).

I tried running the example app and the same thing happens over there as well. Will be pasting both the example app and my app logs. Both the logs are just launching the app and it arriving on the camera preview screen. I have dealt with permissions beforehand. I open the apps up and then the camera freezes, so I wait a bit, pressing on the screen so that it doesnโ€™t lock the phone, and then I open up the app list to close the app and end the session.

Iโ€™m super not familiar with native development, so I might be using the wrong lingo or something and this is quite as much context as I can possibly provide.

Reproduceable Code

// this is for my app, but nothing really special here, so I would
// assume that the problem is somewhere deep down

const frameProcessor = useFrameProcessor((frame) => {
    'worklet'
    console.log('hello')
    return null
  }, [])

  const device = useCameraDevice('back')

  if (device == null) return <Text>No camera</Text>
  return <Camera
    style={{
      flex: 1,
      width: '100%',
    }}
    device={device}
    isActive={true}
    frameProcessor={frameProcessor}
  />

Relevant log output

It says, that my logs are too long, I've created a pastebin
https://pastebin.com/aEezEEZi

Sorry, I'm not great at native, I don't really understand what logs are relevant
There are no real faults or exceptions (nothing too read), but a few Java errors
are being logged with the INFO status

Nothing interesting on the React Native logs

Camera Device

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

Device

SAMSUNG Galaxy S8

VisionCamera Version

3.6.16

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 7 months ago
  • Reactions: 9
  • Comments: 26 (7 by maintainers)

Most upvoted comments

Just had a very similiar issue. I fixed it by setting:

photo={true}

Also saw in a thread similiar that:

video={true}

Also worked for some.

  const format = React.useMemo(() => {
    const desiredWidth = 1920;
    const desiredHeight = 1080;
    if (device) {
      for (let index = 0; index < device.formats.length; index++) {
        const format = device.formats[index];
        if (format) {
          if (
            format.videoWidth == desiredWidth &&
            format.videoHeight == desiredHeight
          ) {
            return format;
          }
        }
      }
    }
    return undefined;
  }, [device?.formats]);

I had the same problem, but when I assigned the correct format, the camera worked fine

2024-02-01 17:29:19.942 10876-10974 HermesVM                lt.joncys.example                    I  Compiling JS failed: 1:1:invalid empty parentheses '( )',  Buffer size 3 starts with: 280a29 and has protection mode(s): rw-p
2024-02-01 17:29:19.981 10876-10974 VideoPipeline           lt.joncys.example                    E  FrameProcessor/ImageReader pipeline threw an error!
                                                                                                    com.facebook.jni.CppException: Compiling JS failed: 1:1:invalid empty parentheses '( )' Buffer size 3 starts with: 280a29 and has protection mode(s): rw-p

@joncys This is a different issue and has been reported before a lot - it is basically some compatibility issue in your Babel plugins (Worklets vs Reanimated). Make sure to clean cache, update your versions, and try again.

Once that is gone let me know if 3.9 works ๐Ÿ˜ƒ

I had the same issue, but it works with pixelFormat="yuv". (Galaxy S8+, Android 9)

This is already the default pixel format on main (https://github.com/mrousavy/react-native-vision-camera/commit/11eb1f68e4912309589855ee81edea12f5261df4, https://github.com/mrousavy/react-native-vision-camera/commit/d64fc08e167a6f2787f6deccfb3ba0caf16557b0) and used by the codeScanner.

Iโ€™m experiencing the same issue with the POCO F3 Pro.

@fazzysyed Setting the format helps a little in my case because it goes straight to an

 Camera.onError(unknown/unknown): [unknown/unknown] CAMERA_ERROR (3): waitUntilIdle:1339: Camera 0: Error waiting to drain: Connection timed out (-110) [unknown/unknown: [unknown/unknown] CAMERA_ERROR (3): waitUntilIdle:1339: Camera 0: Error waiting to drain: Connection timed out (-110)]

camera error instead of just hanging on a black screen.

But the camera / plugin still does not seem to be working as expected.

experiencing the same issue on a one plus nord with android 11