-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
🐛 App Crashes When Navigating Back to Camera Screen #1988
Comments
The same issue on my side |
Same
...
|
The same issue |
I had some similar issues and found using navigation.replace instead of navigation.navigate worked for me. |
I added
Also I changed
|
I think this will get fixed with this: #1996 |
Yea basically I need to do a refactor on the Codebase - I now know exactly what I need for the session configuration, and need to do all of this fully atomically. |
thinks |
518.826.325.2023-10-19.14-09-14.mp4Click the back button to see the following situation const device = useCameraDevice('back');
const camera = useRef<Camera>(null);
const isFocused = useIsFocused();
const navigation = useNavigation();
const appState = useAppState();
const [active, setActive] = useState(true);
useEffect(() => {
const unsubscribe = navigation.addListener('beforeRemove', () => {
setTimeout(() => {
setActive(false);
}, 0);
});
return unsubscribe;
}, [navigation]);
const isActive = active && isFocused && appState === 'active';
const takePhoto = async () => {
const photo = await camera.current!.takePhoto();
console.log(photo);
};
if (!device) {
return (<View className="flex-1">
<Text>请打开摄像头</Text>
</View>);
}
if (!isActive) {
return (<View className="flex-1">
<Text>请打开摄像头</Text>
</View>);
}
return <View className="h-full w-full items-center justify-end">
{isActive && <Camera
ref={camera}
style={{ position: 'absolute', left: 0, right: 0, bottom: 0, top: 0 }}
//https://github.com/mrousavy/react-native-vision-camera/issues/1988 不然会崩溃
fps={60}
device={device} //此相机设备包含的物理设备类型列表。
// video={true} //录像功能打开关闭
// supportsVideoHDR={true}
isActive={isActive} //是否打开相机, 可以缓存相机,加快打开速度
photo={true} //拍照功能是否打开
/>}
<TouchableOpacity className=" w-16 h-16 rounded-full bg-slate-500 mt-[100%] mb-[20%]" onPress={takePhoto} />
</View>; |
@810505339 can you share your adb logcat logs |
NOT FIXED FOR ME I HAVE "react-native-vision-camera": "^3.5.1", "react-native-worklets-core": "^0.2.2", "react-native-reanimated": "^3.5.4"
|
|
i think i can fix this in #2049 |
I update ```"react-native-vision-camera": "^3.5.1" ```` ,It seems that the problem still exists . |
I tried adding key and solved the problem |
I just fixed this in #2049, and released it to npm (v3.6.0) 🎉 If you appreciate my work and dedication to fix your issues and make VisionCamera better, please 💖 consider sponsoring me on GitHub 💖 to say thanks. Thanks! |
- These updates include fixes for: - mrousavy/react-native-vision-camera#2049 - mrousavy/react-native-vision-camera#1988 - mrousavy/react-native-vision-camera#2001
What's happening?
The app crashes when I navigate back from the camera screen and then attempt to return to the camera screen.
Steps to Reproduce:
Error:
Reproduceable Code
Relevant log output
Camera Device
Device
Any Android Devices
VisionCamera Version
3.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
The text was updated successfully, but these errors were encountered: