CameraView icon indicating copy to clipboard operation
CameraView copied to clipboard

setParameters failed and crash

Open leacode opened this issue 3 years ago • 1 comments
trafficstars

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"
                     />

leacode avatar Jun 05 '22 00:06 leacode

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.

naymushin avatar Aug 04 '22 08:08 naymushin

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.

leacode avatar Aug 17 '22 04:08 leacode