CameraView
CameraView copied to clipboard
setParameters failed and crash
Describe the bug
I received an error online.
- device: Blackview BV9800Pro
- os: Android Pie (v9)(Level 28)
data:text/text;charset=utf-8, java.lang.RuntimeException: setParameters failed at android.hardware.Camera.native_setParameters(Native Method) at android.hardware.Camera.setParameters(Camera.java:2125) at com.otaliastudios.cameraview.engine.Camera1Engine$11.run(Camera1Engine.java:884) at com.otaliastudios.cameraview.engine.orchestrator.CameraStateOrchestrator$3.run(CameraStateOrchestrator.java:100) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator$1.call(CameraOrchestrator.java:84) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator$1.call(CameraOrchestrator.java:81) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator$3.run(CameraOrchestrator.java:152) at com.otaliastudios.cameraview.internal.WorkerHandler.run(WorkerHandler.java:137) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator.execute(CameraOrchestrator.java:147) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator.access$100(CameraOrchestrator.java:34) at com.otaliastudios.cameraview.engine.orchestrator.CameraOrchestrator$2.run(CameraOrchestrator.java:137) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.os.HandlerThread.run(HandlerThread.java:65)
Expected behavior
It should not crash my app.
XML layout
Part of the XML layout with the CameraView declaration, so we can read its attributes.
<com.otaliastudios.cameraview.CameraView
android:id="@+id/camera_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:keepScreenOn="true"
app:cameraAudio="off"
app:cameraAutoFocusMarker="@string/cameraview_default_autofocus_marker"
app:cameraWhiteBalance="auto"
app:cameraAutoFocusResetDelay="0"
app:cameraEngine="camera2"
app:cameraGestureTap="autoFocus"
app:cameraMode="picture"
app:cameraPreview="glSurface"
app:cameraPreviewFrameRate="30"
app:cameraPreviewFrameRateExact="false"
app:cameraUseDeviceOrientation="false"
/>
Hey @leacode! Hopefully my PR will get merged and this bug will go away. On a side note, you probably need to set the app:cameraExperimental="true" attribute, otherwise the app:cameraEngine="camera2" attribute has no effect and the library will fallback to camera1 API.
Thank you. I will try it.> Hey @leacode! Hopefully my PR will get merged and this bug will go away. On a side note, you probably need to set the app:cameraExperimental="true" attribute, otherwise the app:cameraEngine="camera2" attribute has no effect and the library will fallback to camera1 API.