Android Camera2 picture display very slow

837 Views Asked by At

I'm working with the android camera2 component and I have problems with understanding why after taking a picture it takes a lot of time before it will be displayed in another activity. Basically what happens is, that when I take the picture and save it, I open up a new activity that should display the picture taken, which it does but after around 5 sec. Then I get these messages in the log:

12-08 11:39:15.507 21995-22727/com.artlandapp.cameratest       E/CameraDeviceGLThread-0: Received exception on GL render thread: 
                                                                                   java.lang.IllegalStateException: swapBuffers: EGL error: 0x300d
                                                                                      at android.hardware.camera2.legacy.SurfaceTextureRenderer.checkEglError(SurfaceTextureRenderer.java:530)
                                                                                   at android.hardware.camera2.legacy.SurfaceTextureRenderer.swapBuffers(SurfaceTextureRenderer.java:523)
                                                                                   at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawIntoSurfaces(SurfaceTextureRenderer.java:727)
                                                                                   at android.hardware.camera2.legacy.GLThreadManager$1.handleMessage(GLThreadManager.java:105)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                                   at android.os.Looper.loop(Looper.java:168)
                                                                                       at android.os.HandlerThread.run(HandlerThread.java:61)
12-08 11:39:15.507 21995-22727/com.artlandapp.cameratest I/CameraDeviceState: Legacy camera service transitioning to state ERROR
12-08 11:39:19.421 21995-22725/com.artlandapp.cameratest E/RequestThread-0: Timed out while waiting for request to complete.
12-08 11:39:19.421 21995-22725/com.artlandapp.cameratest W/CaptureCollector: Preview buffers dropped for request: 0
12-08 11:39:19.421 21995-22725/com.artlandapp.cameratest E/CameraDeviceState: Cannot receive result while in state: 0
12-08 11:39:19.433 21995-22725/com.artlandapp.cameratest E/CameraDeviceState: Cannot receive result while in state: 0
12-08 11:39:19.445 21995-22104/com.artlandapp.cameratest E/BufferQueueProducer: [SurfaceTexture-1-21995-3] queueBuffer: BufferQueue has been abandoned
12-08 11:39:19.446 21995-22006/com.artlandapp.cameratest E/BufferQueueProducer: [SurfaceTexture-1-21995-3] dequeueBuffer: BufferQueue has been abandoned
12-08 11:39:19.471 21995-22007/com.artlandapp.cameratest E/BufferQueueProducer: [SurfaceTexture-1-21995-3] cancelBuffer: BufferQueue has been abandoned
12-08 11:39:19.471 21995-22104/com.artlandapp.cameratest E/BufferQueueProducer: [SurfaceTexture-1-21995-3] cancelBuffer: BufferQueue has been abandoned
12-08 11:39:19.471 21995-22006/com.artlandapp.cameratest E/BufferQueueProducer: [SurfaceTexture-1-21995-3] cancelBuffer: BufferQueue has been abandoned
12-08 11:39:19.472 21995-22007/com.artlandapp.cameratest E/BufferQueueProducer: [SurfaceTexture-1-21995-3] cancelBuffer: BufferQueue has been abandoned
12-08 11:39:19.612 21995-21995/com.artlandapp.cameratest I/Choreographer: Skipped 245 frames!  The application may be doing too much work on its main thread.

I would highly appreciate any type of help or suggestion!

1

There are 1 best solutions below

3
On BEST ANSWER

It seems you are not using AsyncTask to perform the capture operation. You may refer to this link and check if it helps you.