googlearchive / android-Camera2Video

Migrated:
https://github.com/android/camera
Apache License 2.0
1.21k stars 568 forks source link

App crash while stop video #5

Closed sdubey0201 closed 5 years ago

sdubey0201 commented 9 years ago

following error :

MediaRecorder﹕ start called in an invalid state: 4 MediaRecorder﹕ stop called in an invalid state: 4 com.example.android.camera2video E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.android.camera2video, PID: 2420 java.lang.IllegalStateException at android.media.MediaRecorder.stop(Native Method) at com.example.android.camera2video.Camera2VideoFragment.stopRecordingVideo(Camera2VideoFragment.java:536) at com.example.android.camera2video.Camera2VideoFragment.onClick(Camera2VideoFragment.java:292) at android.view.View.performClick(View.java:4756) at android.view.View$PerformClick.run(View.java:19749) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) 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:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

madhavajay commented 9 years ago

Mine crashes too, seems like it runs out of memory??? Device is Nexus 4 with Android 5.0.1

04-12 18:14:10.876 6643-6643/com.example.android.camera2video I/art﹕ Late-enabling -Xcheck:jni 04-12 18:14:11.067 6643-6671/com.example.android.camera2video D/OpenGLRenderer﹕ Render dirty regions requested: true 04-12 18:14:11.074 6643-6643/com.example.android.camera2video D/Atlas﹕ Validating map... 04-12 18:14:11.144 6643-6671/com.example.android.camera2video I/Adreno-EGL﹕ : QUALCOMM Build: 10/28/14, c33033c, Ia6306ec328 04-12 18:14:11.146 6643-6671/com.example.android.camera2video I/OpenGLRenderer﹕ Initialized EGL, version 1.4 04-12 18:14:11.169 6643-6671/com.example.android.camera2video D/OpenGLRenderer﹕ Enabling debug mode 0 04-12 18:14:11.218 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value normal 04-12 18:14:11.219 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value emboss 04-12 18:14:11.219 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value sketch 04-12 18:14:11.219 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value neon 04-12 18:14:11.222 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value asd 04-12 18:14:11.222 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value backlight 04-12 18:14:11.222 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value flowers 04-12 18:14:11.222 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value AR 04-12 18:14:11.233 6643-6643/com.example.android.camera2video E/Camera2VideoFragment﹕ Couldn't find any suitable preview size 04-12 18:14:11.240 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value normal 04-12 18:14:11.241 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value emboss 04-12 18:14:11.241 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value sketch 04-12 18:14:11.241 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value neon 04-12 18:14:11.241 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value asd 04-12 18:14:11.241 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value backlight 04-12 18:14:11.241 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value flowers 04-12 18:14:11.241 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value AR 04-12 18:14:11.247 6643-6643/com.example.android.camera2video I/CameraManager﹕ Using legacy camera HAL. 04-12 18:14:11.498 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value normal 04-12 18:14:11.498 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value emboss 04-12 18:14:11.498 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value sketch 04-12 18:14:11.499 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value neon 04-12 18:14:11.499 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value asd 04-12 18:14:11.499 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value backlight 04-12 18:14:11.499 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value flowers 04-12 18:14:11.499 6643-6643/com.example.android.camera2video W/ArrayUtils﹕ Ignoring invalid value AR 04-12 18:14:11.632 6643-6643/com.example.android.camera2video I/CameraDeviceState﹕ Legacy camera service transitioning to state CONFIGURING 04-12 18:14:11.633 6643-6693/com.example.android.camera2video I/RequestThread-0﹕ Configure outputs: 2 surfaces configured. 04-12 18:14:11.633 6643-6693/com.example.android.camera2video D/Camera﹕ app passed NULL surface 04-12 18:14:11.667 6643-6643/com.example.android.camera2video I/CameraDeviceState﹕ Legacy camera service transitioning to state IDLE 04-12 18:14:11.675 6643-6670/com.example.android.camera2video I/RequestQueue﹕ Repeating capture request set. 04-12 18:14:11.681 6643-6693/com.example.android.camera2video W/LegacyRequestMapper﹕ convertRequestMetadata - control.awbRegions setting is not supported, ignoring value 04-12 18:14:11.681 6643-6693/com.example.android.camera2video W/LegacyRequestMapper﹕ Only received metering rectangles with weight 0. 04-12 18:14:11.681 6643-6693/com.example.android.camera2video W/LegacyRequestMapper﹕ Only received metering rectangles with weight 0. 04-12 18:14:12.092 6643-6707/com.example.android.camera2video I/CameraDeviceState﹕ Legacy camera service transitioning to state CAPTURING 04-12 18:14:17.519 6643-6707/com.example.android.camera2video W/Adreno-EGLSUB﹕ DequeueBuffer:721: dequeue native buffer fail: No such device, buffer=0x0, handle=0x0 04-12 18:14:17.519 6643-6707/com.example.android.camera2video W/Adreno-ES20﹕ : GL_OUT_OF_MEMORY 04-12 18:14:17.523 6643-6707/com.example.android.camera2video W/GLConsumer﹕ [unnamed-6643-1] bindTextureImage: clearing GL error: 0x505 04-12 18:14:17.528 6643-6707/com.example.android.camera2video W/Adreno-EGLSUB﹕ DequeueBuffer:721: dequeue native buffer fail: No such device, buffer=0x0, handle=0x0 04-12 18:14:17.528 6643-6707/com.example.android.camera2video W/Adreno-ES20﹕ : GL_OUT_OF_MEMORY 04-12 18:14:17.532 6643-6707/com.example.android.camera2video E/CameraDeviceGLThread-0﹕ Received exception on GL render thread: java.lang.IllegalStateException: onDrawFrame start: GLES20 error: 0x505 at android.hardware.camera2.legacy.SurfaceTextureRenderer.checkGlError(SurfaceTextureRenderer.java:494) at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawFrame(SurfaceTextureRenderer.java:213) at android.hardware.camera2.legacy.SurfaceTextureRenderer.drawIntoSurfaces(SurfaceTextureRenderer.java:680) at android.hardware.camera2.legacy.GLThreadManager$1.handleMessage(GLThreadManager.java:103) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:135) at android.os.HandlerThread.run(HandlerThread.java:61) 04-12 18:14:17.532 6643-6707/com.example.android.camera2video I/CameraDeviceState﹕ Legacy camera service transitioning to state ERROR 04-12 18:14:17.875 6643-6643/com.example.android.camera2video W/System.err﹕ android.hardware.camera2.CameraAccessException: The camera device has encountered a serious error 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at android.hardware.camera2.impl.CameraDeviceImpl.checkIfCameraClosedOrInError(CameraDeviceImpl.java:1478) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureRequest(CameraDeviceImpl.java:476) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at com.example.android.camera2video.Camera2VideoFragment.startPreview(Camera2VideoFragment.java:408) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at com.example.android.camera2video.Camera2VideoFragment.stopRecordingVideo(Camera2VideoFragment.java:543) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at com.example.android.camera2video.Camera2VideoFragment.onClick(Camera2VideoFragment.java:292) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at android.view.View.performClick(View.java:4756) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at android.view.View$PerformClick.run(View.java:19749) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:739) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at android.os.Looper.loop(Looper.java:135) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5221) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at java.lang.reflect.Method.invoke(Native Method) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:372) 04-12 18:14:17.879 6643-6643/com.example.android.camera2video W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 04-12 18:14:17.880 6643-6643/com.example.android.camera2video W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 04-12 18:14:20.526 6643-6693/com.example.android.camera2video E/RequestThread-0﹕ Timed out while waiting for request to complete. 04-12 18:14:20.554 6643-6693/com.example.android.camera2video W/CaptureCollector﹕ Preview buffers dropped for request: 0 04-12 18:14:20.554 6643-6693/com.example.android.camera2video E/CameraDeviceState﹕ Cannot receive result while in state: 0 04-12 18:14:20.555 6643-6693/com.example.android.camera2video E/CameraDeviceState﹕ Cannot receive result while in state: 0 04-12 18:14:20.593 6643-6693/com.example.android.camera2video E/CameraDeviceState﹕ Cannot receive result while in state: 0 04-12 18:14:20.620 6643-6660/com.example.android.camera2video W/MessageQueue﹕ Handler (android.graphics.SurfaceTexture$1) {1582ed32} sending message to a Handler on a dead thread java.lang.IllegalStateException: Handler (android.graphics.SurfaceTexture$1) {1582ed32} sending message to a Handler on a dead thread at android.os.MessageQueue.enqueueMessage(MessageQueue.java:325) at android.os.Handler.enqueueMessage(Handler.java:631) at android.os.Handler.sendMessageAtTime(Handler.java:600) at android.os.Handler.sendMessageDelayed(Handler.java:570) at android.os.Handler.sendEmptyMessageDelayed(Handler.java:534) at android.os.Handler.sendEmptyMessage(Handler.java:519) at android.graphics.SurfaceTexture.postEventFromNative(SurfaceTexture.java:368) 04-12 18:14:20.644 6643-6693/com.example.android.camera2video E/BufferQueueProducer﹕ [unnamed-6643-1] cancelBuffer: BufferQueue has been abandoned 04-12 18:14:20.648 6643-6693/com.example.android.camera2video E/BufferQueueProducer﹕ [unnamed-6643-1] cancelBuffer: BufferQueue has been abandoned 04-12 18:14:20.652 6643-6693/com.example.android.camera2video E/BufferQueueProducer﹕ [unnamed-6643-1] cancelBuffer: BufferQueue has been abandoned 04-12 18:14:20.655 6643-6693/com.example.android.camera2video E/BufferQueueProducer﹕ [unnamed-6643-1] cancelBuffer: BufferQueue has been abandoned 04-12 18:14:20.659 6643-6693/com.example.android.camera2video E/BufferQueueProducer﹕ [unnamed-6643-1] cancelBuffer: BufferQueue has been abandoned 04-12 18:14:20.798 6643-6643/com.example.android.camera2video I/Choreographer﹕ Skipped 174 frames! The application may be doing too much work on its main thread.

hantc commented 9 years ago

Same here, Nexus 4, Android 5.1

madhavajay commented 9 years ago

Hey Hantc, check my PR: https://github.com/googlesamples/android-Camera2Video/pull/6

Its based on a fix from someone over on the Xamarin port. Works for me on the Nexus 4 on 5.1 :)

hantc commented 9 years ago

Many thanks! Works. I tried to fix it by myself (according to xamarin fix), but as I'm new in this technology so I wasn't able to:)

2015-04-24 8:57 GMT+02:00 madhavajay notifications@github.com:

Hey Hantc, check my PR:

6 https://github.com/googlesamples/android-Camera2Video/pull/6

Its based on a fix from someone over on the Xamarin port. Works for me on the Nexus 4 on 5.1 :)

— Reply to this email directly or view it on GitHub https://github.com/googlesamples/android-Camera2Video/issues/5#issuecomment-95824393 .

madhavajay commented 9 years ago

No problems! :) Good luck.

xyz1hang commented 8 years ago

I think the description of the stop() method does mean something. Perhaps the reason it crashes is that no valid audio/video data received, which is also why there's empty output file ? Do you not get empty output file ? @madhavajay

Stops recording. Call this after start(). Once recording is stopped,
     * you will have to configure it again as if it has just been constructed.
     * Note that a RuntimeException is intentionally thrown to the
     * application, if no valid audio/video data has been received when stop()
     * is called. This happens if stop() is called immediately after
     * start(). The failure lets the application take action accordingly to
     * clean up the output file (delete the output file, for instance), since
     * the output file is not properly constructed when this happens.
     *
     * @throws IllegalStateException if it is called before start()
ghost commented 7 years ago

check out this stackoverflow answer worked for me

prudhvirajkumar10 commented 7 years ago

For those who are getting SurfaceAbandonedException just remove the mMediaRecorder.stop() / mMediaRecorder.release(); from the stopRecordingVideo() method. The mediaplayer causes the surface to destroy and leading to app crash

codingjeremy commented 5 years ago

This sample has been migrated to a new location where we can accept Pull Requests (check README for more information).

As recommended by GitHub, we are closing all issues and pull requests now that this older repo will be archived.

If you still see this issue in the updated repo, please reopen the issue/PR there. Thank you!