Open bayunvnt opened 4 years ago
Can you fill the bug report information? Thanks!
This issue has been automatically marked as stale because it has not had activity in the last 20 days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.
I have met this issue, too.
11-14 16:46:21.587 19645 19645 E AndroidRuntime: FATAL EXCEPTION: main 11-14 16:46:21.587 19645 19645 E AndroidRuntime: Process: com.tcl.tvcamera, PID: 19645 11-14 16:46:21.587 19645 19645 E AndroidRuntime: java.lang.RuntimeException: onConfigureFailed! Session android.hardware.camera2.impl.CameraCaptureSessionImpl@74bb74e 11-14 16:46:21.587 19645 19645 E AndroidRuntime: at com.tcl.cameraview.engine.Camera2Engine$4.onConfigureFailed(Camera2Engine.java:531) 11-14 16:46:21.587 19645 19645 E AndroidRuntime: at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.lambda$onConfigureFailed$1(CallbackProxies.java:64) 11-14 16:46:21.587 19645 19645 E AndroidRuntime: at android.hardware.camera2.impl.-$$Lambda$CallbackProxies$SessionStateCallbackProxy$gvbTsp9UPpKJAbdycdci_ZW5BeI.run(Unknown Source:4) 11-14 16:46:21.587 19645 19645 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:873) 11-14 16:46:21.587 19645 19645 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 11-14 16:46:21.587 19645 19645 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193) 11-14 16:46:21.587 19645 19645 E AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:65)
Im getting this same crash on Nexus 6P.
Is it possible for the library to not throw the exception (resulting in app crash) but report to client that initialization failed & the app can handle it gracefully ?
@nsekhar90 do you still get this error if you choose a smaller picture/video/preview stram/frame processing size?
I want to understand if the library can handle this better before deciding to simply pass the error to the app.
Im just using the default options and only for taking a picture (no video). I can try reducing the quality/size.
Yeah please do. With camera.setPictureSize(). By default it's the biggest available. You can try camera.setPictureSize(SizeSelectors.smallest()) as an extreme example.
That fixes the issue. Thanks @natario1 for very quick response. Is there anything I can do on the client side to adjust this based on device ?
Nice to know. What if you remove that line, but instead you add setPreviewStreamSize(SizeSelectors.smallest())
? Does this fix the issue as well?
You can adjust based on the device with these methods, just pass a SizeSelector that fixes the issue
yeah, the setPreviewStreamSize(SizeSelectors.smallest())
fixes the issue too. So, should I just check for a particular device (Nexus 6p in this case) & add the line setPreviewStreamSize(SizeSelectors.smallest())
?
I would call something like
setPreviewStreamSize(SizeSelectors.and(SizeSelectors.maxWidth(MAX_WIDTH), SizeSelectors.biggest())
.
You should find the value of MAX_WIDTH
by trying on your nexus (1000? 1200? 1400? 1900?). If you find an exact value please let me know.
Later we might improve this within the lib.
1000 works best, can we calculate this runtime instead of hard coding it ?
Im asking about run time calculation because this crash might occur on other devices right ? I noticed that other people posted about this crash in the top.
Are there any updates? Also got this on Redmi Note 7 & 8 & Galaxy S8.
I'm not actively working on this but my suggestion is to limit the preview stream size with setPreviewStreamSize()
. If you represent a company feel free to sponsor me to let me work on this sooner
I would like to support you. but unfortunately I am an independent developer.
How can I calculate MAX_WIDTH on runtime?
I don't know - you should find something that works for your app, as it likely depends on the picture/video size that you are choosing, whether you are using frame processing or not, what is the frame processing size, ...
I have the same issue on Redmi 8A
I faced a similar issue on Samsung S9+ a couple of times.
1) I set this in xml,
<com.otaliastudios.cameraview.CameraView
android:id="@+id/cv_uca_cameraview"
android:layout_width="@dimen/cell_2x"
android:layout_height="@dimen/cell_2x"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/cell_margin"
android:visibility="gone"
android:keepScreenOn="true"
app:cameraAudio="mono"
app:cameraEngine="camera2"
app:cameraExperimental="true"
app:cameraFacing="front"
app:cameraFlash="off"
app:cameraGestureLongTap="none"
app:cameraGesturePinch="none"
app:cameraGestureScrollHorizontal="none"
app:cameraGestureScrollVertical="none"
app:cameraGestureTap="none"
app:cameraGrid="off"
app:cameraHdr="off"
app:cameraMode="video"
app:cameraPlaySounds="false"
app:cameraPreview="glSurface"
app:cameraPreviewFrameRate="30"
app:cameraPreviewFrameRateExact="false"
app:cameraRequestPermissions="false"
app:cameraUseDeviceOrientation="false"
app:cameraVideoCodec="h264"
app:cameraWhiteBalance="auto" />
2) And in code, I change width and height programmatically as per our requirement,
val txrParam: RelativeLayout.LayoutParams = cameraView.layoutParams as RelativeLayout.LayoutParams
txrParam.width = cameraViewWidth
txrParam.height = cameraViewHeight
cameraViewWidth and cameraViewHeight can be different for square, landscape, or portrait video snapshot recording.
3) Finally, to record a video snapshot,
cameraView.videoMaxDuration = 15000
cameraView.takeVideoSnapshot(file)
"If you are planning to use the snapshot APIs, the size of the media output is that of the preview stream, accounting for any cropping made when measuring the view and other constraints. Please read the Snapshot Size document."(https://natario1.github.io/CameraView/docs/capture-size)
My question is do I still need to use setPreviewStreamSize? Because as mentioned above it is calculated when measuring the view,
setPreviewStreamSize(SizeSelectors.and(SizeSelectors.maxWidth(MAX_WIDTH), SizeSelectors.biggest())
If yes, what should be changed for square, landscape, or portrait video snapshot recording?
@natario1 Have an idea of what's the root cause/what flows lead to the onConfigureFailed
error? Or how to deterministically reproduce this?
@tomer8007 it happens when the set of output sizes that we chose (preview stream size, frame processing size if you're using it, picture size when in Mode.PICTURE, video size when in Mode.VIDEO) is rejected by the device. We respect all limits for each size individually, but sometimes the combination of them is too much.
Does anyone have a working solution for this problem? I got this error on devices Xiaomi (Redmi Note 7, Redmi Note 8, Redmi Note 8T, Redmi 8A) and Samsung (Galaxy A02s, Galaxy A01, Galaxy A10s)
It comes mostly on Redmi devices
It comes frequently on Galaxy A02s device
app:cameraVideoSizeMaxWidth="1000"
i have used above video max width size and now i am not getting this error, please try on your end as well , thanks
Does anyone able to find a solution for this. I had tried the solution but I am still getting this issue in Redmi 10T 5G devices.
I would call something like
setPreviewStreamSize(SizeSelectors.and(SizeSelectors.maxWidth(MAX_WIDTH), SizeSelectors.biggest())
.You should find the value of
MAX_WIDTH
by trying on your nexus (1000? 1200? 1400? 1900?). If you find an exact value please let me know.Later we might improve this within the lib.
Hallo, im using this library for my college project, then I have this issue "onConfigureFailed! Session android.hardware.camera2.impl.CameraCaptureSessionImpl@3a3e30a",
this is my stacktrace : java.lang.RuntimeException · onConfigureFailed! Session android.hardware.camera2.impl.CameraCaptureSessionImpl@2d4c3c1
Camera2Engine:479com.otaliastudios.cameraview.engine.Camera2Engine$4.onConfigureFailed
CallbackProxies.java:64android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.lambda$onConfigureFailed$1
Unknown:4android.hardware.camera2.impl.-$$Lambda$CallbackProxies$SessionStateCallbackProxy$gvbTsp9UPpKJAbdycdci_ZW5BeI.run
Handler.java:873android.os.Handler.handleCallback
Handler.java:99android.os.Handler.dispatchMessage
Looper.java:201android.os.Looper.loop
HandlerThread.java:65android.os.HandlerThread.run
this error mostly occured on xiaomi device (redmi note 7), can I have any solution? i hope this solve or you can give me any clue, thank you @natario1