Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in Show and Capture camera #2

Closed
uberspot opened this issue Mar 28, 2014 · 8 comments
Closed

Crash in Show and Capture camera #2

uberspot opened this issue Mar 28, 2014 · 8 comments

Comments

@uberspot
Copy link

If I comment the line 121 ContentManager.getInstance().createAll(this); where the app crashes the list menu appears correctly. If I then chose Show + capture camera it shows the preview correctly. I then press the "Record" button and get the following exception and the app crashes.

    03-28 14:10:16.726: I/OMXClient(1469): Using client-side OMX mux.
    03-28 14:10:16.726: I/SoftAVCEncoder(1469): Construct SoftAVCEncoder
    03-28 14:10:16.726: I/ACodec(1469): setupVideoEncoder succeeded
    03-28 14:10:16.726: E/OMXNodeInstance(1469): createInputSurface requires AndroidOpaque color format
    03-28 14:10:16.726: E/ACodec(1469): [OMX.google.h264.encoder] onCreateInputSurface returning error -38
    03-28 14:10:16.726: W/MediaCodec(1469): createInputSurface failed, err=-38
    03-28 14:10:16.726: W/dalvikvm(1469): threadid=12: thread exiting with uncaught exception (group=0xa4bfd648)
    03-28 14:10:16.730: E/AndroidRuntime(1469): FATAL EXCEPTION: TextureMovieEncoder
    03-28 14:10:16.730: E/AndroidRuntime(1469): java.lang.IllegalStateException
    03-28 14:10:16.730: E/AndroidRuntime(1469):     at android.media.MediaCodec.createInputSurface(Native Method)
    03-28 14:10:16.730: E/AndroidRuntime(1469):     at com.android.grafika.VideoEncoderCore.<init>(VideoEncoderCore.java:79)
    03-28 14:10:16.730: E/AndroidRuntime(1469):     at com.android.grafika.TextureMovieEncoder.prepareEncoder(TextureMovieEncoder.java:381)
    03-28 14:10:16.730: E/AndroidRuntime(1469):     at com.android.grafika.TextureMovieEncoder.handleStartRecording(TextureMovieEncoder.java:312)
    03-28 14:10:16.730: E/AndroidRuntime(1469):     at com.android.grafika.TextureMovieEncoder.access$0(TextureMovieEncoder.java:309)
    03-28 14:10:16.730: E/AndroidRuntime(1469):     at com.android.grafika.TextureMovieEncoder$EncoderHandler.handleMessage(TextureMovieEncoder.java:281)
    03-28 14:10:16.730: E/AndroidRuntime(1469):     at android.os.Handler.dispatchMessage(Handler.java:99)
    03-28 14:10:16.730: E/AndroidRuntime(1469):     at android.os.Looper.loop(Looper.java:137)
    03-28 14:10:16.730: E/AndroidRuntime(1469):     at com.android.grafika.TextureMovieEncoder.run(TextureMovieEncoder.java:248)
    03-28 14:10:16.730: E/AndroidRuntime(1469):     at java.lang.Thread.run(Thread.java:841)
    03-28 14:10:16.734: D/dalvikvm(1469): GC_FOR_ALLOC freed 110K, 7% free 4238K/4548K, paused 3ms, total 3ms
@fadden
Copy link
Contributor

fadden commented Mar 28, 2014

That's really bizarre. The color format is set 10 lines before the crash. What device and OS version? Can you enable the VERBOSE logging in VideoEncoderCore -- I'd like to see what comes out of the "format" log message on line 73.

@uberspot
Copy link
Author

It appeared both in Nexus 4 with 4.4.2 and in Moto X with 4.3 .
I'll try with verbose logging and i'll post in a bit.


This is the verbose log from the crash. Tested on Nexus 4 with 4.4.2. In my Nexus 7 with 4.3 it seems to work without a crash though.

    03-28 18:23:00.388: D/dalvikvm(1232): Late-enabling CheckJNI
    03-28 18:23:00.484: D/Grafika(1232): Can't find readable /data/data/com.android.grafika/files/gen-eight-rects.mp4
    03-28 18:23:00.516: D/libEGL(1232): loaded /system/lib/egl/libEGL_genymotion.so
    03-28 18:23:00.516: D/(1232): HostConnection::get() New Host Connection established 0xb9717678, tid 1232
    03-28 18:23:00.528: D/libEGL(1232): loaded /system/lib/egl/libGLESv1_CM_genymotion.so
    03-28 18:23:00.528: D/libEGL(1232): loaded /system/lib/egl/libGLESv2_genymotion.so
    03-28 18:23:00.564: W/EGL_genymotion(1232): eglSurfaceAttrib not implemented
    03-28 18:23:00.564: E/OpenGLRenderer(1232): Getting MAX_TEXTURE_SIZE from GradienCache
    03-28 18:23:00.568: E/OpenGLRenderer(1232): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
    03-28 18:23:00.568: D/OpenGLRenderer(1232): Enabling debug mode 0
    03-28 18:23:08.720: D/Grafika(1232): onCreate complete: com.android.grafika.CameraCaptureActivity@529af168
    03-28 18:23:08.720: D/Grafika(1232): onResume -- acquiring camera
    03-28 18:23:08.768: W/Grafika(1232): Unable to set preview size to 1280x720
    03-28 18:23:08.772: D/Grafika(1232): onResume complete: com.android.grafika.CameraCaptureActivity@529af168
    03-28 18:23:08.772: D/Grafika(1232): setCameraPreviewSize
    03-28 18:23:08.816: W/EGL_genymotion(1232): eglSurfaceAttrib not implemented
    03-28 18:23:08.832: D/(1232): HostConnection::get() New Host Connection established 0xb981fb58, tid 1252
    03-28 18:23:08.920: D/Grafika(1232): onSurfaceCreated
    03-28 18:23:08.944: D/Grafika(1232): Created program 3 (TEXTURE_EXT)
    03-28 18:23:08.948: D/Grafika(1232): onSurfaceChanged 984x1317
    03-28 18:23:08.952: D/Grafika(1232): Updating filter to 0
    03-28 18:23:08.960: D/Grafika(1232): onItemSelected: 0
    03-28 18:23:09.040: D/Grafika(1232): CameraHandler [Handler (com.android.grafika.CameraCaptureActivity$CameraHandler) {529f10dc}]: what=0
    03-28 18:23:09.092: D/(1232): HostConnection::get() New Host Connection established 0xb979e2e0, tid 1243
    03-28 18:23:09.212: D/(1232): HostConnection::get() New Host Connection established 0xb98274d0, tid 1244
    03-28 18:23:50.340: D/Grafika(1232): changeRecordingState: was false now true
    03-28 18:23:50.368: D/Grafika(1232): START recording
    03-28 18:23:50.368: D/Grafika(1232): Encoder: startRecording()
    03-28 18:23:50.368: D/Grafika(1232): handleStartRecording EncoderConfig: 640x480 @1000000 to '/data/data/com.android.grafika/files/camera-test.mp4' ctxt=android.opengl.EGLContext@b9847c60
    03-28 18:23:50.368: D/Grafika(1232): format: {frame-rate=30, bitrate=1000000, height=480, mime=video/avc, color-format=2130708361, i-frame-interval=5, width=640}
    03-28 18:23:50.368: I/OMXClient(1232): Using client-side OMX mux.
    03-28 18:23:50.404: I/SoftAVCEncoder(1232): Construct SoftAVCEncoder
    03-28 18:23:50.408: I/ACodec(1232): setupVideoEncoder succeeded
    03-28 18:23:50.408: E/OMXNodeInstance(1232): createInputSurface requires AndroidOpaque color format
    03-28 18:23:50.408: E/ACodec(1232): [OMX.google.h264.encoder] onCreateInputSurface returning error -38
    03-28 18:23:50.408: W/MediaCodec(1232): createInputSurface failed, err=-38
    03-28 18:23:50.408: W/dalvikvm(1232): threadid=12: thread exiting with uncaught exception (group=0xa4c1e648)
    03-28 18:23:50.412: E/AndroidRuntime(1232): FATAL EXCEPTION: TextureMovieEncoder
    03-28 18:23:50.412: E/AndroidRuntime(1232): java.lang.IllegalStateException
    03-28 18:23:50.412: E/AndroidRuntime(1232):     at android.media.MediaCodec.createInputSurface(Native Method)
    03-28 18:23:50.412: E/AndroidRuntime(1232):     at com.android.grafika.VideoEncoderCore.<init>(VideoEncoderCore.java:79)
    03-28 18:23:50.412: E/AndroidRuntime(1232):     at com.android.grafika.TextureMovieEncoder.prepareEncoder(TextureMovieEncoder.java:381)
    03-28 18:23:50.412: E/AndroidRuntime(1232):     at com.android.grafika.TextureMovieEncoder.handleStartRecording(TextureMovieEncoder.java:312)
    03-28 18:23:50.412: E/AndroidRuntime(1232):     at com.android.grafika.TextureMovieEncoder.access$0(TextureMovieEncoder.java:309)
    03-28 18:23:50.412: E/AndroidRuntime(1232):     at com.android.grafika.TextureMovieEncoder$EncoderHandler.handleMessage(TextureMovieEncoder.java:281)
    03-28 18:23:50.412: E/AndroidRuntime(1232):     at android.os.Handler.dispatchMessage(Handler.java:99)
    03-28 18:23:50.412: E/AndroidRuntime(1232):     at android.os.Looper.loop(Looper.java:137)
    03-28 18:23:50.412: E/AndroidRuntime(1232):     at com.android.grafika.TextureMovieEncoder.run(TextureMovieEncoder.java:248)
    03-28 18:23:50.412: E/AndroidRuntime(1232):     at java.lang.Thread.run(Thread.java:841)
    03-28 18:23:50.660: D/Grafika(1232): onPause -- releasing camera
    03-28 18:23:50.680: D/Grafika(1232): releaseCamera -- done
    03-28 18:23:50.696: D/Grafika(1232): renderer pausing -- releasing SurfaceTexture
    03-28 18:23:50.696: D/Grafika(1232): onPause complete
    03-28 18:23:50.820: W/EGL_genymotion(1232): eglSurfaceAttrib not implemented
    03-28 18:23:51.228: D/Grafika(1232): onDestroy

@fadden
Copy link
Contributor

fadden commented Mar 28, 2014

The problem is this:

I/SoftAVCEncoder(1232): Construct SoftAVCEncoder

For some reason you're getting the software AVC codec rather than the hardware-accelerated implementation. The software codec doesn't support input from surfaces. That's going to prevent a number of things from working, including the movie generation (which might be related to the other bug you filed).

My guess would be that something running in the background is using all available hardware encoder resources. I don't know an easy way to figure out what.

Since this is affecting multiple devices it could be something that you have installed or run on them. I've run Grafika on N4, N5, N7(2012/2013), N10, Galaxy Nexus, Moto X, and my wife's Galaxy S4, and haven't encountered any problems, but I have very few Play Store apps installed on them. I down-revved my N4 just now and didn't see a failure.

@uberspot
Copy link
Author

I'm closing these since they seem to be related to some of my devices. :) I'll comment if I find out what is causing the usage of software encoder.

@fadden
Copy link
Contributor

fadden commented Mar 28, 2014

I'll add "to do" items to handle the failures better. Crashing mysteriously is Bad (even for Grafika, which makes few claims to robustness).

@dogtim
Copy link

dogtim commented Mar 30, 2014

Hi all,
I have this issue, too. Asus fonepad 4.2.2.
And my workaround is same as uberspot's comment.
finally, thx your effort to build this project, it indeeds help me to learn the MediaCodec's application.

@fadden
Copy link
Contributor

fadden commented Mar 30, 2014

If you're running Android 4.2.2, the surface-input feature doesn't exist at all (it was added in 4.3 / API 18).

AFAIK Grafika won't work on any of the emulators, as all of them rely on the software codecs.

@dogtim
Copy link

dogtim commented Mar 31, 2014

I got it ! thx for your reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants