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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 FATAL EXCEPTION: mrousavy/VisionCamera.video #3332

Open
3 of 5 tasks
looooool11111 opened this issue Dec 17, 2024 · 2 comments
Open
3 of 5 tasks

🐛 FATAL EXCEPTION: mrousavy/VisionCamera.video #3332

looooool11111 opened this issue Dec 17, 2024 · 2 comments
Labels
🐛 bug Something isn't working

Comments

@looooool11111
Copy link

What's happening?

When I exited the scanning page, a crash occurred
image

Reproduceable Code

let device = useCameraDevice('front');
  // 添加设备检查
  if (!device) {
    console.error('未找到相机设备');
    return null; // 或者返回一个占位符组件
  }
  const {hasPermission, requestPermission} = useCameraPermission();
  const isFocused = useIsFocused();
  const [isActive, setIsActive] = useState(false);
  const cameraRef = useRef<VisionCamera | null>(null);
  const [isForeground, setIsForeground] = useState(true);
  const targetFps = 5;
  const screenAspectRatio = 16 / 9;
  const format = useCameraFormat(device, [
    {fps: targetFps},
    {videoAspectRatio: screenAspectRatio},
    {photoAspectRatio: screenAspectRatio},
  ]);
  const codeScanner = useCodeScanner({
    codeTypes: ['qr'],
    onCodeScanned: codes => {
      console.log('Scanned codes:', codes);

      if (codes[0]?.value) {
        navigation.navigate('Index', {
          code: codes[0]?.value as string,
        });
      }
    },
  });

  const renderCamera = () => {
    return isActive && device ? (
      <Camera
        style={styles.absoluteFill}
        device={device}
        format={format}
        isActive={isActive}
        enableZoomGesture={false}
        ref={cameraRef}
        resizeMode="cover"
        exposure={0}
        onStarted={() => console.log('Camera started!')}
        onStopped={() => console.log('Camera stopped!')}
        photo={true}
        video={false}
        codeScanner={codeScanner}
      />
    ) : (
      <></>
    );
  };

Relevant log output

FATAL EXCEPTION: mrousavy/VisionCamera.video
                                                                                                    Process: com.airdoc.visiontrain, PID: 13485
                                                                                                    java.lang.NullPointerException: Attempt to invoke virtual method 'java.nio.ByteBuffer android.media.Image$Plane.getBuffer()' on a null object reference
                                                                                                    	at com.google.mlkit.vision.common.InputImage.zzb(com.google.mlkit:vision-common@@17.3.0:15)
                                                                                                    	at com.google.mlkit.vision.common.InputImage.fromMediaImage(com.google.mlkit:vision-common@@17.3.0:1)
                                                                                                    	at com.mrousavy.camera.core.CodeScannerPipeline._init_$lambda$4(CodeScannerPipeline.kt:53)
                                                                                                    	at com.mrousavy.camera.core.CodeScannerPipeline.$r8$lambda$J9uS5V_QrF4Y46dODUvYa6w1Wm0(Unknown Source:0)
                                                                                                    	at com.mrousavy.camera.core.CodeScannerPipeline$$ExternalSyntheticLambda0.onImageAvailable(Unknown Source:4)
                                                                                                    	at android.media.ImageReader$1.run(ImageReader.java:916)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                    	at android.os.Looper.loop(Looper.java:288)
                                                                                                    	at android.os.HandlerThread.run(HandlerThread.java:67)

Camera Device

{"autoFocusSystem": "contrast-detection", "fieldOfView": 0, "maxFps": 30, "maxISO": 0, "maxZoom": 4, "minFps": 1, "minISO": 0, "photoHeight": 720, "photoWidth": 1280, "pixelFormats": ["yuv", "native"], "supportsDepthCapture": false, "supportsPhotoHdr": false, "supportsVideoHdr": false, "videoHeight": 720, "videoStabilizationModes": ["off", "off"], "videoWidth": 1280}

Device

Android 13

VisionCamera Version

3.9.2

Can you reproduce this issue in the VisionCamera Example app?

No, I cannot reproduce the issue in the Example app

Additional information

@looooool11111 looooool11111 added the 🐛 bug Something isn't working label Dec 17, 2024
Copy link

Guten Tag, Hans here, 🍻

Thanks for reporting ze issue! It seems ze log you provided indicates a NullPointerException, which is likely related to ze camera image processing. One thing to note is that you mentioned you cannot reproduce this issue in ze Example app, which could suggest ze issue might be with your specific implementation or environment.

To better assist you, please make sure to check for any potential discrepancies in ze implementation compared to ze Example app. Additionally, if you encounter any more issues, ensure you attach ze logs from adb logcat for a deeper look into ze problem.

If you're finding value in this project, consider sponsoring mrousavy here to support further development.

Let's keep zis issue open for now!

Note: If you think I made a mistake, please ping @mrousavy to take a look.

@looooool11111
Copy link
Author

Additional error messages

image

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

1 participant