duanhong169 / Camera

📸 Use Android camera to take pictures and videos, based on `camera2` api.
Apache License 2.0
131 stars 45 forks source link

Crash: CameraAccessException: The camera device has encountered a serious error #17

Open adaonder opened 5 years ago

adaonder commented 5 years ago

Android API 21 this is Library not working.

My logcat;


09-18 10:37:03.569 5606-5636/top.defaults.cameraapp E/GED: Failed to get GED Log Buf, err(0)
09-18 10:37:26.807 5606-5679/top.defaults.cameraapp E/MALI: get_target_buffer:967: winsysp_window_buffer_get failed 12299
09-18 10:37:26.846 5606-5679/top.defaults.cameraapp E/MALI: gles_state_set_error_internal:56: GLES ctx: 0x7f91006008, error code:0x505
09-18 10:37:26.874 5606-5679/top.defaults.cameraapp E/CameraDeviceGLThread-0: Received exception on GL render thread: 
    java.lang.IllegalStateException: glDrawArrays: GLES20 error: 0x505
        at android.hardware.camera2.legacy.SurfaceTextureRenderer.checkGlError(SurfaceTextureRenderer.java:537)
        at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawFrame(SurfaceTextureRenderer.java:346)
        at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawIntoSurfaces(SurfaceTextureRenderer.java:726)
        at android.hardware.camera2.legacy.GLThreadManager$1.handleMessage(GLThreadManager.java:105)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:194)
        at android.os.HandlerThread.run(HandlerThread.java:61)
09-18 10:37:26.978 5606-5606/top.defaults.cameraapp E/CameraCaptureSession: Session 1: Exception while stopping repeating: 
    android.hardware.camera2.CameraAccessException: The camera device has encountered a serious error
        at android.hardware.camera2.impl.CameraDeviceImpl.checkIfCameraClosedOrInError(CameraDeviceImpl.java:1478)
        at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:677)
        at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:328)
        at top.defaults.camera.Camera2Photographer.closePreviewSession(Camera2Photographer.java:700)
        at top.defaults.camera.Camera2Photographer.closeCamera(Camera2Photographer.java:687)
        at top.defaults.camera.Camera2Photographer.stopPreview(Camera2Photographer.java:452)
        at top.defaults.camera.Camera2Photographer$1.onError(Camera2Photographer.java:130)
        at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks$1.run(CameraDeviceImpl.java:1207)
        at android.os.Handler.handleCallback(Handler.java:815)
        at android.os.Handler.dispatchMessage(Handler.java:104)
        at android.os.Looper.loop(Looper.java:194)
        at android.app.ActivityThread.main(ActivityThread.java:5624)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
09-18 10:37:30.830 5606-5678/top.defaults.cameraapp E/RequestThread-0: Timed out while waiting for request to complete.
09-18 10:37:30.831 5606-5678/top.defaults.cameraapp E/CameraDeviceState: Cannot receive result while in state: 0
09-18 10:37:30.831 5606-5678/top.defaults.cameraapp E/CameraDeviceState: Cannot receive result while in state: 0
09-18 10:37:30.834 5606-5678/top.defaults.cameraapp E/CameraDeviceState: Cannot receive result while in state: 0
09-18 10:37:30.957 5606-5623/top.defaults.cameraapp E/BufferQueueProducer: [unnamed-5606-2](this:0x7f91234000,id:2,api:4,p:245,c:-1) queueBuffer: BufferQueue has been abandoned
09-18 10:37:30.958 5606-5684/top.defaults.cameraapp E/BufferQueueProducer: [unnamed-5606-2](this:0x7f91234000,id:2,api:4,p:245,c:-1) dequeueBuffer: BufferQueue has been abandoned
09-18 10:37:30.988 5606-5624/top.defaults.cameraapp E/BufferQueueProducer: [unnamed-5606-2](this:0x7f91234000,id:2,api:4,p:245,c:-1) queueBuffer: BufferQueue has been abandoned
09-18 10:37:30.990 5606-5623/top.defaults.cameraapp E/BufferQueueProducer: [unnamed-5606-2](this:0x7f91234000,id:2,api:4,p:245,c:-1) dequeueBuffer: BufferQueue has been abandoned
09-18 10:37:31.449 5606-5684/top.defaults.cameraapp E/BufferQueueProducer: [unnamed-5606-2](this:0x7f91234000,id:2,api:4,p:245,c:-1) cancelBuffer: BufferQueue has been abandoned
09-18 10:37:31.450 5606-5678/top.defaults.cameraapp E/BufferQueueProducer: [unnamed-5606-2](this:0x7f91234000,id:2,api:4,p:245,c:-1) query: BufferQueue has been abandoned
09-18 10:37:31.621 5606-5606/top.defaults.cameraapp E/PhotographerActivity: Error happens: The camera device has encountered a serious error
09-18 10:37:31.623 5606-5606/top.defaults.cameraapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: top.defaults.cameraapp, PID: 5606
    java.lang.RuntimeException: MediaRecorder is not initialized
        at top.defaults.camera.Camera2Photographer.throwIfNoMediaRecorder(Camera2Photographer.java:260)
        at top.defaults.camera.Camera2Photographer.startRecording(Camera2Photographer.java:798)
        at top.defaults.cameraapp.PhotographerActivity.action(PhotographerActivity.java:166)
        at top.defaults.cameraapp.PhotographerActivity_ViewBinding$5.doClick(PhotographerActivity_ViewBinding.java:93)
        at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
        at android.view.View.performClick(View.java:4848)
        at android.view.View$PerformClick.run(View.java:20260)
        at android.os.Handler.handleCallback(Handler.java:815)
        at android.os.Handler.dispatchMessage(Handler.java:104)
        at android.os.Looper.loop(Looper.java:194)
        at android.app.ActivityThread.main(ActivityThread.java:5624)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
leitao commented 4 years ago

I hit the exact same problem on android/x86. Any idea what is happening here? It seems that we are not able to allocated memory in the GLES side. Is this correct?