-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
🐛 [V3] (Android) NullPointerException Camera2 #1785
Comments
Huh this is weird. What happens if you remove pretty much all the |
After commenting out all |
Yea please try that out and let me know, thank you! |
Hi again and thanks for the help 👊 Okay I think i've localized the issue, It seems to be related to Video Stabilization. If I comment out this line: captureRequest.set(CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, videoStabilizationMode?.toDigitalStabilizationMode()) The app does not crash anymore, e.g. it fixes this error: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference But when I try to start a recording it fails on this (no crash):
If i comment out BOTH of the Video Stabilization calls I can record videos again e.g: // Video Stabilization
// captureRequest.set(CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, videoStabilizationMode?.toDigitalStabilizationMode()) <-- This gives java.lang.NullPointerException
// captureRequest.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE, videoStabilizationMode?.toOpticalStabilizationMode()) <-- This makes start recording fail, (if the other one is commented out?) The rest of the |
That's interesting. And you're 100% sure that the react-native-vision-camera/package/src/CameraDevice.ts Lines 122 to 125 in 4e96eb7
? |
This is format that I'm passing to the {
"pixelFormats": [
"rgb",
"native",
"yuv",
"unknown"
],
"videoStabilizationModes": [
"off",
"standard",
"off",
"cinematic-extended"
],
"autoFocusSystem": "contrast-detection",
"supportsPhotoHDR": false,
"photoHeight": 2052,
"supportsVideoHDR": false,
"maxISO": 3200,
"minISO": 25,
"minFps": 1,
"videoWidth": 3840,
"videoHeight": 2160,
"photoWidth": 4560,
"fieldOfView": 66.53434119576576,
"maxFps": 30
} The modes are listed in the type so that seems fine? The weird thing being that there are 2 "off" modes? I'm not using the FYI: I'm resolving the format the exact same way as in the example app. |
Did you try setting |
I'm on it, will report back asap! |
Yeah explicitly setting the If I'm passing an empty string I also (kind of) found the culprit for the startRecording issue that I got before:
The problem seems to be cause by having the startRecording React.useCallback async e.g. // Using async caused the start recording to fail
const startRecording = React.useCallback(async () => {
// ...
try {
// ...
camera.current.startRecording({
flash,
onRecordingError: (error) => {
console.error('Recording failed!', error);
onStoppedRecording();
},
onRecordingFinished: (video) => {
console.log(`Recording successfully finished!' ${video.path}`);
onMediaCaptured(video, 'video');
onStoppedRecording();
},
});
// ...
// This works
const startRecording = React.useCallback(() => {
// ... But the weird thing being that I could start recording when commenting out both of the video stabilization |
Interesting, yea I probably need to add some sanity checks before that so the user can't make those mistakes. Thanks for your help here, imma leave this open until I added those checks! |
Yeah that sounds good. Thanks all the same for the help troubleshooting and your work on the library, it's much appreciated 💪 |
Hey! I think this is fixed in the latest PR where I added some sanity checks! |
What's happening?
Hi! First and foremost thanks for the great work on this library <3
I think i've might stumbled upon a Camera2 problem, it seems related to other issues mentioned in this Camera2 Rewrite PR #1674
I'm getting this error pretty much as soon as the camera goes active. E.g. if i set isActive={false} the component renders, but when i change to isActive={true} the crash happens.
I'm using Expo development builds (SDK 49) and EAS to build the app but all that seems fine.
I've not been able to test it in the example app because i can't seem to get it to build properly. But my current project is more or less basically the same, the difference being that it's built through Expo EAS.
I've prebuilt the code and tried looking for the problem and it seems to originate from CameraSession.kt:
Note: I've used "react-native-vision-camera": "^2.15.4", before on my ASUS Zenfone 8 without problems.
Reproduceable Code
Relevant log output
Camera Device
Device
ASUS Zenfone 8, Android 13
VisionCamera Version
3.0.0
Can you reproduce this issue in the VisionCamera Example app?
Additional information
The text was updated successfully, but these errors were encountered: