-
-
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
🐛 Camera disconnects occasionally (race condition) #1801
Comments
This comment was marked as resolved.
This comment was marked as resolved.
Can you try removing those 25 lines: react-native-vision-camera/package/android/src/main/java/com/mrousavy/camera/core/CameraSession.kt Lines 436 to 460 in 4e96eb7
And see what happens? |
The camera is now rendering after removing those lines |
The camera is working now, but while using a frame processor that requires the yuv format I'm getting some stutters (in debug and release builds). Whenever the stutters happen I get a bunch of logs saying
The performance of the frame processor is always fast before and after the stutters. This can mean 5-10 seconds of good performance followed by 1-5 seconds of a frozen image on the screen. Any ideas that I could try for this? |
This worked for me. Was getting blank after enabling |
@iketiunn @lc-mm thanks for testing. Can you try to add each setting back one by one to find out which of those format settings is causing the Camera to fail? Thanks I appreciate your help, I don't have any device to test this on so I'm relying on you guys ❤️ @lc-mm regarding the pixelFormat, this is WIP I found an amazing solution here: #1789 (+ needs this to fix video recording: #1799) @satyabrata-dash5 you don't have any Camera Devices. You're doing something wrong there. Check the docs |
Thanks @mrousavy I will let you know when I have a chance to narrow down which setting is causing the camera to fail. For the slight performance issue - I was running on code with the changes from #1789 and I was seeing the intermittent pause with the message |
I do the development on the Mi Mix 2s, but I also tested it on my day-to-day phone. Tested device:
Tested device:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
captureRequest.set(CaptureRequest.CONTROL_ZOOM_RATIO, zoom)
} else {
val cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId!!)
val size = cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE)!!
captureRequest.set(CaptureRequest.SCALER_CROP_REGION, size.zoomed(zoom))
} The problem might be on the phone before Android 12. deps:
|
Wait so zoom makes it break? |
Apparently yes, same here #1858 (comment) |
I have an issue that on my react native application MaskView causing my camera to not open using android device but all i have done is that I update my MaskView and Expo Camera library and make a new Development Client after that my application is running Fine and issue resolved. |
@mrousavy I have had more time to look at this now, I have updated to version 3.5.1 and this is still an issue. This issue is this line: When Here is some code that I used to stop the crash, not sure if it is the correct approach:
|
Gotcha, yep I'll try to fix this on the fly when I finish #2049 :) |
I have same issue when i change the pixel format to yuv or rgb and assign frameprocessor. With pixelFormat Native it works fine, but the frameprocessor plugin cannot read the image and convert to bitmap for example. I am using in natario1/CameraView |
I think I just fixed this in #2049, and released it to npm (v3.6.0) 🎉 Please try the latest release and let me know if this is still an issue. 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! |
I am seeing the
This happens after I navigate to a new screen (modal) and then go back to the previous Screen View (regular screen view), which is where the camera view lives. As suggested, I have upgraded to the latest version EDIT: I need to test on physical device still, but upgrading fixes the simulator so far. |
With 3.6.4 the camera is not working steadily on Android, sometimes it is working but sometimes the camera view is dark. I got some error logs from Logcat:
|
@zjkuang what happens if you change this line here: react-native-vision-camera/package/android/src/main/java/com/mrousavy/camera/core/CameraSession.kt Line 367 in f4617a3
to val captureSession = captureSession ?: return ? |
Thanks @mrousavy . I tried this change but it didn't work, or perhaps I could say, it's getting worse. Without this change, occasionally the camera view could show up. (Thus it seemed to be a race condition I guess?) But with this change I tested quite a few times and the camera view is always black. Also the error logs seem to be a little different with this change:
|
So it is a race condition I'd say |
您好!您发送的邮件我已收到。谢谢!
|
I'm having the same issue using the back camera on Android v10 (Nokia 7.1) and react-native-vision-camera v3.6.8. Camera screen is black and after a few seconds i get the following error:
The problem is probably still coming from the zoom, in: react-native-vision-camera/package/android/src/main/java/com/mrousavy/camera/core/CameraSession.kt Line 446 in ccb0401
Deleting this line is solving the problem for me. |
您好!您发送的邮件我已收到。谢谢!
|
I wonder why zoom makes this break, are you passing a custom zoom value? What's going on here |
Not at all, here is settings i'm using inside my test component.
|
Same issue for me, it is related to codeScanner. Without codeScanner it works perfect |
I'm going through the same problem. However, 25% of my app's user base are on Android version 12, making the use of the library unfeasible. |
Most of my users who are having this problem are on Android 13. |
recently having this issue too, last week it's fine though :// |
I managed to solve this bug by activating the function App() {
const device = useCameraDevice('back')
if (!device) return null
return (
<Camera
style={StyleSheet.absoluteFill}
device={device}
isActive={true}
photo={true}
video={true}
/>
)
} |
This comment was marked as spam.
This comment was marked as spam.
I'll add some special conditional checks to make sure this works |
I'm facing the same issue on Android 12 when navigating between screens version: 3.9.0 |
What's happening?
On 3 different Android devices running the example app from the main branch results in the error
[session/camera-has-been-disconnected: [session/camera-has-been-disconnected] The given Camera device (id: 0) has been disconnected! Error: UNKNOWN_CAMERA_DEVICE_ERROR]
Screen is just blank and the app crashes upon pressing the buttons in the top right.
Reproduceable Code
Relevant log output
Camera Device
No response
Device
Pixel 6a (Android 12)
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: