🐛 Application crashes on start recording
What were you trying to do?
I simply want to record a video nothing else but the application crashes whenever I trigger the start recording function
Reproduceable Code
/* Camera with Capture button Component */
<Camera
ref={CameraRef}
style={StyleSheet.absoluteFill}
device={device}
isActive={isActive}
preset="medium"
video={true}
audio={true}
orientation="portrait"
torch={supportsFlash ? flash : "off"}
enableZoomGesture={true}
onInitialized={() => setIsCameraInitialized(true)}
/>
<CaptureButton style={styles.captureButton} camera={CameraRef} />
/* Capture Button code */
const CaptureButton = (props) => {
const { style, camera } = props;
return (
<>
<TouchableOpacity
style={[
style,
{
width: BTN_SIZE,
height: BTN_SIZE,
zIndex: 4,
alignItems: "center",
justifyContent: "center",
backgroundColor: "pink",
},
]}
onPress={() => {
camera.current.startRecording({
onRecordingFinished: (video) => console.log(video),
onRecordingError: (error) => console.error(error),
});
setTimeout(() => {
camera.current.stopRecording();
}, 5000);
}}
/>
</>
);
What happened instead?
I made this small code for debugging and testing the video component. After the camera component renders, I press that capture button to run that startrecording function and my application crashes without any error in the console
Relevant log output
No response
Device
Android
VisionCamera Version
2.13.2
Additional information
- [ ] I am using Expo
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar issues in this repository and found none.
Experiencing this as well from a new build. No stack trace on the javascript side.
Java side:
2022-05-17 10:21:47.924 26216-29757/com.XXXXXX.XXXXXXX E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
Process: com.XXXXXX.XXXXXXX, PID: 26216
com.mrousavy.camera.ViewNotFoundError: [system/view-not-found] The given view (ID 2199) was not found in the view manager.
at com.mrousavy.camera.CameraViewModule.findCameraView(CameraViewModule.kt:78)
at com.mrousavy.camera.CameraViewModule.access$findCameraView(CameraViewModule.kt:27)
at com.mrousavy.camera.CameraViewModule$startRecording$1.invokeSuspend(CameraViewModule.kt:105)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
On further investigation this is related to the modal issue, however, I am using react-native-actions-sheet which could very well use a modal under the covers... Pulling the camera out of this component solves the crash...
I have the same issue. @mrousavy please help.
Hey! I've rewritten the entire Android codebase of VisionCamera from CameraX to Camera2 in the efforts of ✨ VisionCamera V3.
I just now completed the Camera2 rewrite and I believe the core structure is running, but there might be some edge cases to iron out. Can you try and test the PR #1674 for me to see if you can still reproduce this issue here?
Here's an instruction on how you can test that: https://github.com/mrousavy/react-native-vision-camera/pull/1674#issuecomment-1684104217
If the issue cannot be reproduced with that version/PR anymore, then hoorayy, I fixed it! 🎉 Otherwise please let me know and I'll keep this issue open to keep track of it.
Thank you!