Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Crash in Android release build #2999

Open
4 of 5 tasks
malkawi00 opened this issue Jun 16, 2024 · 5 comments
Open
4 of 5 tasks

馃悰 Crash in Android release build #2999

malkawi00 opened this issue Jun 16, 2024 · 5 comments
Labels
馃悰 bug Something isn't working

Comments

@malkawi00
Copy link

malkawi00 commented Jun 16, 2024

What's happening?

when I try to run the app from react native metro work fine , but when I make release APK , I have an issue app crash when open the camera , is there any solution

Reproduceable Code

export const CustomCamera = forwardRef((props, ref) => {
  const {
    isVisible = false,
    frameProcessor = null,
    cameraType = 'back',
    zoom = 1,
    torch = 'off',
  } = props;
  const device = useCameraDevice(cameraType);
  if (device == null) {
    return (
      <View style={styles.loadingView}>
        <Text style={styles.loadingText}>Loading</Text>
      </View>
    );
  }
  return (
    <Camera
      device={device}
      isActive={isVisible}
      zoom={zoom}
      style={EStyleSheet.absoluteFill}
      frameProcessor={frameProcessor}
      ref={ref}
      pixelFormat={'yuv'}
      photo={true}
      video={true}
      torch={isVisible ? torch : 'off'}
      photoQualityBalance="balanced">
      {props.children}
    </Camera>
  );
});


this code use custom camera 
 const frameLogicJS = Worklets.createRunOnJS((scannedData, type) => {
    const result = scannedData.data || {};
    setSdkResult(scannedData);

    // console.log('scannedData--', JSON.stringify(scannedData, null, 2));
   
  });

 

const frameProcessor = useFrameProcessor(
    frame => {
      'worklet';
      runAsync(frame, () => {
        'worklet';
        runAtTargetFps(60, () => {
          'worklet';
          let scannedData = scanDocument(frame);
          if (isFrontFrameProcessor.value) {
            frameLogicJS(scannedData, 'front');
          } else {
            frameLogicJS(scannedData, 'back');
          }
        });
      });
    },
    [isFrontFrameProcessor],
  );
I try to remove runAsync it work fine but with lag in camera 

const frameProcessor = useFrameProcessor(
    frame => {
      'worklet';
        let scannedData = scanDocument(frame);
        if (isFrontFrameProcessor.value) {
          frameLogicJS(scannedData, 'front');
        } else {
          frameLogicJS(scannedData, 'back');
        }
    },
    [isFrontFrameProcessor],
  );

Relevant log output

"react-native-vision-camera": "4.3.1",
"react-native-worklets-core": "^1.3.3",
Failed to acquire image.
                                                                                                    java.lang.IllegalStateException: maxImages (6) has already been acquired, call #close before acquiring more.
                                                                                                    	at android.media.ImageReader.acquireNextImage(ImageReader.java:661)
                                                                                                    	at androidx.camera.core.AndroidImageReaderProxy.acquireNextImage(AndroidImageReaderProxy.java:88)
                                                                                                    	at androidx.camera.core.SafeCloseImageReaderProxy.acquireNextImage(SafeCloseImageReaderProxy.java:88)
                                                                                                    	at androidx.camera.core.ImageAnalysisBlockingAnalyzer.acquireImage(ImageAnalysisBlockingAnalyzer.java:41)
                                                                                                    	at androidx.camera.core.ImageAnalysisAbstractAnalyzer.onImageAvailable(ImageAnalysisAbstractAnalyzer.java:128)
                                                                                                    	at androidx.camera.core.SafeCloseImageReaderProxy.lambda$setOnImageAvailableListener$1$androidx-camera-core-SafeCloseImageReaderProxy(SafeCloseImageReaderProxy.java:213)
                                                                                                    	at androidx.camera.core.SafeCloseImageReaderProxy$$ExternalSyntheticLambda1.onImageAvailable(Unknown Source:4)
                                                                                                    	at androidx.camera.core.AndroidImageReaderProxy.lambda$setOnImageAvailableListener$0$androidx-camera-core-AndroidImageReaderProxy(AndroidImageReaderProxy.java:169)
                                                                                                    	at androidx.camera.core.AndroidImageReaderProxy$$ExternalSyntheticLambda0.run(Unknown Source:4)

Camera Device

{
  "formats": [],
  "sensorOrientation": "landscape-left",
  "hardwareLevel": "full",
  "maxZoom": 10,
  "minZoom": 0.6000000238418579,
  "maxExposure": 20,
  "supportsLowLightBoost": false,
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera",
    "ultra-wide-angle-camera",
    "wide-angle-camera",
    "telephoto-camera"
  ],
  "supportsFocus": true,
  "supportsRawCapture": false,
  "isMultiCam": true,
  "minFocusDistance": 0,
  "minExposure": -20,
  "name": "0 (BACK) androidx.camera.camera2",
  "hasFlash": true,
  "hasTorch": true,
  "position": "back",
  "id": "0"
}

Device

Samsung s23 , OPPO A5s , Honor 90 REA-NX9

VisionCamera Version

4.3.1

Can you reproduce this issue in the VisionCamera Example app?

I didn't try (鈿狅笍 your issue might get ignored & closed if you don't try this)

Additional information

@malkawi00 malkawi00 added the 馃悰 bug Something isn't working label Jun 16, 2024
@maintenance-hans maintenance-hans bot changed the title 馃悰 Crash in Android release build 馃悰 Crash in Android release build Jun 16, 2024
Copy link

maintenance-hans bot commented Jun 16, 2024

Guten Tag, Hans here.

Note

New features, bugfixes, updates and other improvements are all handled mostly by @mrousavy in his free time.
To support @mrousavy, please consider 馃挅 sponsoring him on GitHub 馃挅.
Sponsored issues will be prioritized.

@aguedob
Copy link

aguedob commented Jun 18, 2024

Why are you nesting runAsync with runAtTargetFps? I think you should use one or the other.

@malkawi00
Copy link
Author

malkawi00 commented Jun 19, 2024

@aguedob if I use runAsync without runAtTargetFps the camera lagging

@nameishuy

This comment was marked as off-topic.

@mrousavy
Copy link
Owner

Why are you nesting runAsync with runAtTargetFps? I think you should use one or the other.

No you can also nest them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃悰 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants