Open ibrahim-ytl opened 1 month ago
Guten Tag, Hans here! 🍻
Thanks for your detailed report! It looks like you have a valid concern with the Camera
component still being active after unmounting, but I need to point out that you haven't provided any relevant logs. For issues like this, mrousavy will need to see logs from Xcode to better understand what's happening.
You can gather logs by running your app in Xcode and checking the console output. If you share those logs, it will greatly help in troubleshooting the issue. Also, it would be beneficial if you could check whether you can reproduce this issue in the VisionCamera Example app, as that info is quite essential.
Feel free to update the issue with the logs, and we'll look into it further!
Note: If you think I made a mistake, please ping
@mrousavy
to take a look.
Please help me take a look. I have also provided the reproduceable code. @mrousavy
No. You didn't provide logs, which is the most important detail here. Can't help you.
I believe this is a dupe of this issue. Below is a patch to 4.5.3
to work around the behavior:
diff --git a/node_modules/react-native-vision-camera/ios/React/CameraView.swift b/node_modules/react-native-vision-camera/ios/React/CameraView.swift
index 6b85538..0cbfd44 100644
--- a/node_modules/react-native-vision-camera/ios/React/CameraView.swift
+++ b/node_modules/react-native-vision-camera/ios/React/CameraView.swift
@@ -278,7 +278,9 @@ public final class CameraView: UIView, CameraSessionDelegate, PreviewViewDelegat
}
// Prevent phone from going to sleep
- UIApplication.shared.isIdleTimerDisabled = isActive
+ // Remove this line and instead rely on expo keep-awake.
+ // See: https://github.com/mrousavy/react-native-vision-camera/issues/3041#issuecomment-2263720909
+ // UIApplication.shared.isIdleTimerDisabled = isActive
}
func updatePreview() {
I believe this is a dupe of this issue. Below is a patch to
4.5.3
to work around the behavior:diff --git a/node_modules/react-native-vision-camera/ios/React/CameraView.swift b/node_modules/react-native-vision-camera/ios/React/CameraView.swift index 6b85538..0cbfd44 100644 --- a/node_modules/react-native-vision-camera/ios/React/CameraView.swift +++ b/node_modules/react-native-vision-camera/ios/React/CameraView.swift @@ -278,7 +278,9 @@ public final class CameraView: UIView, CameraSessionDelegate, PreviewViewDelegat } // Prevent phone from going to sleep - UIApplication.shared.isIdleTimerDisabled = isActive + // Remove this line and instead rely on expo keep-awake. + // See: https://github.com/mrousavy/react-native-vision-camera/issues/3041#issuecomment-2263720909 + // UIApplication.shared.isIdleTimerDisabled = isActive } func updatePreview() {
this patch does not work. The main reason that the isActive
need to be false
first before the component unmounted. If the isActive
state never change to false
before navigating away, the green dot will be there.
ref: https://github.com/mrousavy/react-native-vision-camera/issues/3041#issuecomment-2401622720
Look like this same exact issue still exist until now: https://github.com/mrousavy/react-native-vision-camera/issues/905
By the way, since I am using react-navigation. The workaround is to delay the goBack navigations.
const onPressClose = () => {
setIsCameraActive(false)
setTimeout(() => goBack(), 10);
}
Side note: Thanks for the awesome library. ❤️
What's happening?
When I unmount the
Camera
component. The device camera is still active behind the scene. Below is the screenshot and video.[Video]
[Image]
Reproduceable Code
Relevant log output
Camera Device
Device
iPhone XS
VisionCamera Version
4.5.3
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