(For fadden) Is this the same Android MediaCodec crash?

1

This question was directed specifically to fadden, and then re-directed to nikhilelite, who posted the question "Media codec decoding without surface causes crash". I don't see any followups in the aforementioned post, so I am asking the question here.

Now I am re-directing this question again to fadden, or anyone with insight about Android's MediaCodec:

I have an app, which uses Android MediaCodec but not Surface, crashing on a few phones while running OK on most other phones. This is how I configured the MediaCodec as decoder:

vidDecoder.configure(mVideoDecoderFormat, null, null, 0);

Looking at the logcat, I realized that the backtrace is identical to what nikhilelite posted. This led me to believe that I am seeing exactly the same crash, i.e. it's probably caused by not having an output Surface.

My abridged logcat is below.

D/VideoTranscodingLib( 8389): input frame (throughput):  0
D/VideoTranscodingLib( 8389):  inIndex = 0
D/VideoTranscodingLib( 8389): input frame (throughput):  1
D/VideoTranscodingLib( 8389):  inIndex = 2
D/VideoTranscodingLib( 8389): input frame (throughput):  2
D/VideoTranscodingLib( 8389):  inIndex = 3
D/VideoTranscodingLib( 8389): input frame (throughput):  3
D/VideoTranscodingLib( 8389):  inIndex = 1
E/OMX-VDEC-1080P(  268): Streamon on OUTPUT Plane was successful 
E/OMX-VDEC-1080P(  268): 
E/OMX-VDEC-1080P(  268):  VIDC Some Event recieved 
D/VideoTranscodingLib( 8389): input frame (throughput):  4
D/VideoTranscodingLib( 8389):  inIndex = 0
I/ACodec  ( 8389): Sending format change with buffer 0x44809b48
I/ACodec  ( 8389): Update Resolution Change for buffer 0x44809b48
E/OMX-VDEC-1080P(  268): 
E/OMX-VDEC-1080P(  268):  No color conversion required
E/OMX-VDEC-1080P(  268): update_portdef Width = 1280 Height = 736 Stride = 1280 SliceHeight = 736 
I/ACodec  ( 8389): Calling native window update buffer geometry [1280 x 736]
F/libc    ( 8389): Fatal signal 11 (SIGSEGV) at 0x00000058 (code=1), thread 8492 (MediaCodec_loop)
I/DEBUG   (  263): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  263): Build fingerprint: 'lge/g2_open_cn/g2:4.2.2/JDQ39B/D80210d.1379696461:user/release-keys'
I/DEBUG   (  263): Revision: '10'
I/DEBUG   (  263): pid: 8389, tid: 8492, name: MediaCodec_loop  >>> com.bdti.certimo.transcoding <<<
I/DEBUG   (  263): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000058
I/DEBUG   (  263):     r0 00000000  r1 00000012  r2 00000500  r3 000002e0
I/DEBUG   (  263):     r4 69c20d18  r5 5ca76343  r6 00000000  r7 00000001
I/DEBUG   (  263):     r8 69c20d18  r9 6144ee78  sl 00000000  fp 00000000
I/DEBUG   (  263):     ip 4016fe50  sp 6144ec10  lr 5c9e5af5  pc 5c9e5b00  cpsr 20000030
I/DEBUG   (  263):     d0  20676e696c6c6143  d1  772065766974616e
I/DEBUG   (  263):     d2  707520776f646e69  d3  6675622065746164
I/DEBUG   (  263):     d4  0000000000000000  d5  0000000000000000
I/DEBUG   (  263):     d6  0193000000020000  d7  000000414ecf951d
I/DEBUG   (  263):     d8  4487000000000438  d9  000000004409c000
I/DEBUG   (  263):     d10 0000000000000000  d11 0000000000000000
I/DEBUG   (  263):     d12 0000000000000000  d13 0000000000000000
I/DEBUG   (  263):     d14 0000000000000000  d15 0000000000000000
I/DEBUG   (  263):     d16 8f70b9cae566ee6f  d17 00000000164aa694
I/DEBUG   (  263):     d18 0000001200000012  d19 000000010015a000
I/DEBUG   (  263):     d20 0000000100000001  d21 00000001c0000000
I/DEBUG   (  263):     d22 000002e000000500  d23 000002e000000500
I/DEBUG   (  263):     d24 003e003d003c003b  d25 0040003f003e003c
I/DEBUG   (  263):     d26 0000000000000000  d27 0000000000000000
I/DEBUG   (  263):     d28 001e001d001c001b  d29 0020001f001e001c
I/DEBUG   (  263):     d30 0040004000400040  d31 0000000000000000
I/DEBUG   (  263):     scr 2800001f
I/DEBUG   (  263): 
I/DEBUG   (  263): backtrace:
I/DEBUG   (  263):     #00  pc 00058b00  /system/lib/libstagefright.so (android::ACodec::sendFormatChange()+1003)
I/DEBUG   (  263):     #01  pc 00059bb3  /system/lib/libstagefright.so (android::ACodec::BaseState::onOutputBufferDrained(android::sp<android::AMessage> const&)+186)
I/DEBUG   (  263):     #02  pc 0005a4af  /system/lib/libstagefright.so (android::ACodec::BaseState::onMessageReceived(android::sp<android::AMessage> const&)+46)
I/DEBUG   (  263):     #03  pc 0005a851  /system/lib/libstagefright.so (android::ACodec::ExecutingState::onMessageReceived(android::sp<android::AMessage> const&)+364)
I/DEBUG   (  263):     #04  pc 000066a5  /system/lib/libstagefright_foundation.so (android::AHierarchicalStateMachine::onMessageReceived(android::sp<android::AMessage> const&)+80)
I/DEBUG   (  263):     #05  pc 00007439  /system/lib/libstagefright_foundation.so (android::ALooperRoster::deliverMessage(android::sp<android::AMessage> const&)+188)
I/DEBUG   (  263):     #06  pc 00006ced  /system/lib/libstagefright_foundation.so (android::ALooper::loop()+204)
I/DEBUG   (  263):     #07  pc 00011253  /system/lib/libutils.so (android::Thread::_threadLoop(void*)+94)
I/DEBUG   (  263):     #08  pc 00010dcd  /system/lib/libutils.so
I/DEBUG   (  263):     #09  pc 0000e538  /system/lib/libc.so (__thread_entry+72)
I/DEBUG   (  263):     #10  pc 0000dc24  /system/lib/libc.so (pthread_create+160)

where VideoTranscodingLib is my own code. It can be seen that the input buffers were been filled nicely. The output side is not so clearly seen as I commented out the logging instructions. However, it appears that the crash happened when outIndex changed status from MediaCodec.INFO_TRY_AGAIN_LATER to MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED, like this:

    switch (outIndex) {
        case MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED:
            decoderOutputBuffers = decoder.getOutputBuffers();
            break;
        case ....
    }

The call to getOutputBuffers() somehow triggered an update to the native window's buffer geometry, which was part of the output Surface, which in turn was not defined in my case. Thus the crash.

I don't have the device (Qualcomm MSM8974 & Android 4.2.2) to repeat the crash, so can only make an educated guess. I looked at the AOSP source code libstagefright/ACodec.cpp, but couldn't find the instruction that produced the logcat output

I/ACodec  ( 8389): Calling native window update buffer geometry [1280 x 736]

Maybe I was looking at the wrong place, or maybe ACodec.cpp has since been updated. Could some AOSP/MediaCodec implementers shine some light on my guess? Thanks!

Edit 1: My question was initially directed to fadden, who clarified that nikhilelite was the real poster of the aforementioned question. My question has been edited to reflect this.

Edit 2: After exchanging information with nikhilelite, and doing some research on my own. I updated my question with an educated guess. It'd be great if fadden or someone else with the knowledge could confirm or correct me, and provide a solution.

android
h.264
android-mediacodec
asked on Stack Overflow Mar 13, 2014 by hubeir • edited May 2, 2014 by hubeir

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0