Search code examples
android-mediacodec

Is it possible to prevent the crash by HEVC decoder "libc: Fatal signal 6 (SIGABRT), code -6 in tid 31891 (le.hevc.decoder)"


I can reproduce the crash by streaming H.265 video on an Android device. All the relevant code is try-catch blocks. Is it possible to catch an exception and prevent the app crash. The trace does not point to any app's code. I suspect it is not caused by any specific statement.

10-03 00:26:46.891 31480-31888/net.mydomain.appid I/OMXClient: Using client-side OMX mux.
10-03 00:26:46.894 31480-31882/net.mydomain.appid D/SoftHEVC: Number of CPU cores: 8
10-03 00:26:46.897 31480-31882/net.mydomain.appid D/SoftHEVC: Initializing decoder
10-03 00:26:46.900 31480-31882/net.mydomain.appid D/SoftHEVC: Set number of cores to 4
10-03 00:26:46.900 31480-31882/net.mydomain.appid D/SoftHEVC: Ittiam decoder version number: @(#)Id:HEVCDEC_production Ver:04.01 Released by ITTIAM Build: Feb 18 2019 @ 12:15:02
10-03 00:26:46.905 31480-31882/net.mydomain.appid W/OMXNodeInstance: [1:google.hevc.decoder] component does not support metadata mode; using fallback
10-03 00:26:46.905 31480-31882/net.mydomain.appid E/ACodec: [OMX.google.hevc.decoder] storeMetaDataInBuffers failed w/ err -1010
10-03 00:26:46.905 31480-31882/net.mydomain.appid D/SoftHEVC: Freeing codec memory
10-03 00:26:46.908 31480-31888/net.mydomain.appid D/SoftHEVC: Number of CPU cores: 8
10-03 00:26:46.908 31480-31888/net.mydomain.appid D/SoftHEVC: Initializing decoder
10-03 00:26:46.909 31480-31888/net.mydomain.appid D/SoftHEVC: Set number of cores to 4
10-03 00:26:46.909 31480-31888/net.mydomain.appid D/SoftHEVC: Ittiam decoder version number: @(#)Id:HEVCDEC_production Ver:04.01 Released by ITTIAM Build: Feb 18 2019 @ 12:15:02
10-03 00:26:46.909 31480-31882/net.mydomain.appid D/SoftHEVC: Number of CPU cores: 8
10-03 00:26:46.912 31480-31882/net.mydomain.appid D/SoftHEVC: Initializing decoder
10-03 00:26:46.914 31480-31888/net.mydomain.appid W/OMXNodeInstance: [1:google.hevc.decoder] component does not support metadata mode; using fallback
10-03 00:26:46.914 31480-31888/net.mydomain.appid E/ACodec: [OMX.google.hevc.decoder] storeMetaDataInBuffers failed w/ err -1010
10-03 00:26:46.915 31480-31888/net.mydomain.appid D/SoftHEVC: Freeing codec memory
10-03 00:26:46.916 31480-31882/net.mydomain.appid D/SoftHEVC: Set number of cores to 4
10-03 00:26:46.916 31480-31882/net.mydomain.appid D/SoftHEVC: Ittiam decoder version number: @(#)Id:HEVCDEC_production Ver:04.01 Released by ITTIAM Build: Feb 18 2019 @ 12:15:02
10-03 00:26:46.925 31480-31888/net.mydomain.appid D/SoftHEVC: Number of CPU cores: 8
10-03 00:26:46.926 31480-31888/net.mydomain.appid E/SoftHEVC: Allocation failure for memory record #30 of size 402427776
10-03 00:26:46.926 31480-31888/net.mydomain.appid E/SoftHEVC: Create failure
10-03 00:26:46.926 31480-31888/net.mydomain.appid D/SoftHEVC: Freeing codec memory
10-03 00:26:46.935 31480-31891/net.mydomain.appid D/SoftHEVC: Number of CPU cores: 8
10-03 00:26:46.935 31480-31891/net.mydomain.appid D/SoftHEVC: Initializing decoder
10-03 00:26:46.937 31480-31891/net.mydomain.appid D/SoftHEVC: Set number of cores to 4
10-03 00:26:46.937 31480-31891/net.mydomain.appid D/SoftHEVC: Ittiam decoder version number: @(#)Id:HEVCDEC_production Ver:04.01 Released by ITTIAM Build: Feb 18 2019 @ 12:15:02
10-03 00:26:46.943 31480-31891/net.mydomain.appid D/SoftHEVC: Freeing codec memory
10-03 00:26:46.946 31480-31891/net.mydomain.appid D/SoftHEVC: Number of CPU cores: 8
10-03 00:26:46.947 31480-31891/net.mydomain.appid E/SoftHEVC: Allocation failure for memory record #30 of size 402427776
10-03 00:26:46.947 31480-31891/net.mydomain.appid E/SoftHEVC: Create failure
10-03 00:26:46.947 31480-31891/net.mydomain.appid D/SoftHEVC: Freeing codec memory
10-03 00:26:46.949 31480-31891/net.mydomain.appid A/SoftHEVC: frameworks/av/media/libstagefright/codecs/hevcdec/SoftHEVC.cpp:678 CHECK_EQ( reInitDecoder(),(status_t)OK) failed: -12 vs. 0

    --------- beginning of crash
10-03 00:26:46.950 31480-31891/net.mydomain.appid A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 31891 (le.hevc.decoder)
10-03 00:26:47.067 322-322/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-03 00:26:47.067 322-322/? I/DEBUG: Build fingerprint: 'foo/tm_a83t/tm-a83t:5.1.1/LMY48B/20190312:eng/test-keys'
10-03 00:26:47.067 322-322/? I/DEBUG: Revision: '0'
10-03 00:26:47.067 322-322/? I/DEBUG: ABI: 'arm'
10-03 00:26:47.068 322-322/? I/DEBUG: pid: 31480, tid: 31891, name: le.hevc.decoder  >>> net.mydomain.appid <<<
10-03 00:26:47.068 322-322/? I/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
10-03 00:26:47.164 322-322/? I/DEBUG: Abort message: 'frameworks/av/media/libstagefright/codecs/hevcdec/SoftHEVC.cpp:678 CHECK_EQ( reInitDecoder(),(status_t)OK) failed: -12 vs. 0'
10-03 00:26:47.164 322-322/? I/DEBUG:     r0 00000000  r1 00007c93  r2 00000006  r3 00000000
10-03 00:26:47.164 322-322/? I/DEBUG:     r4 98e39db8  r5 00000006  r6 0000000c  r7 0000010c
10-03 00:26:47.164 322-322/? I/DEBUG:     r8 00000000  r9 98e39a58  sl 98e399dc  fp 98e399d0
10-03 00:26:47.164 322-322/? I/DEBUG:     ip 00007c93  sp 98e39538  lr b6df2855  pc b6e15a68  cpsr 60030010
10-03 00:26:47.165 322-322/? I/DEBUG: backtrace:
10-03 00:26:47.165 322-322/? I/DEBUG:     #00 pc 0003aa68  /system/lib/libc.so (tgkill+12)
10-03 00:26:47.166 322-322/? I/DEBUG:     #01 pc 00017851  /system/lib/libc.so (pthread_kill+52)
10-03 00:26:47.166 322-322/? I/DEBUG:     #02 pc 00018467  /system/lib/libc.so (raise+10)
10-03 00:26:47.166 322-322/? I/DEBUG:     #03 pc 00014c25  /system/lib/libc.so (__libc_android_abort+36)
10-03 00:26:47.166 322-322/? I/DEBUG:     #04 pc 00012f70  /system/lib/libc.so (abort+4)
10-03 00:26:47.166 322-322/? I/DEBUG:     #05 pc 00002215  /system/lib/liblog.so (__android_log_assert+88)
10-03 00:26:47.166 322-322/? I/DEBUG:     #06 pc 00009d87  /system/lib/libstagefright_soft_hevcdec.so
10-03 00:26:47.166 322-322/? I/DEBUG:     #07 pc 00016ca5  /system/lib/libstagefright_omx.so (android::SimpleSoftOMXComponent::onMessageReceived(android::sp<android::AMessage> const&)+220)
10-03 00:26:47.166 322-322/? I/DEBUG:     #08 pc 00016deb  /system/lib/libstagefright_omx.so
10-03 00:26:47.167 322-322/? I/DEBUG:     #09 pc 0000c55f  /system/lib/libstagefright_foundation.so (android::ALooperRoster::deliverMessage(android::sp<android::AMessage> const&)+166)
10-03 00:26:47.167 322-322/? I/DEBUG:     #10 pc 0000bedd  /system/lib/libstagefright_foundation.so (android::ALooper::loop()+220)
10-03 00:26:47.167 322-322/? I/DEBUG:     #11 pc 000104e1  /system/lib/libutils.so (android::Thread::_threadLoop(void*)+112)
10-03 00:26:47.167 322-322/? I/DEBUG:     #12 pc 00010051  /system/lib/libutils.so
10-03 00:26:47.167 322-322/? I/DEBUG:     #13 pc 0001703f  /system/lib/libc.so (__pthread_start(void*)+30)
10-03 00:26:47.167 322-322/? I/DEBUG:     #14 pc 00014f87  /system/lib/libc.so (__start_thread+6)
10-03 00:26:47.168 322-322/? I/debuggerd: type=1400 audit(0.0:8): avc: denied { read } for name="pvrsrvkm" dev="tmpfs" ino=2176 scontext=u:r:debuggerd:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=1
10-03 00:26:47.168 322-322/? I/debuggerd: type=1400 audit(0.0:9): avc: denied { open } for name="pvrsrvkm" dev="tmpfs" ino=2176 scontext=u:r:debuggerd:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=1
10-03 00:26:47.168 322-322/? I/debuggerd: type=1400 audit(0.0:10): avc: denied { getattr } for path="/dev/pvrsrvkm" dev="tmpfs" ino=2176 scontext=u:r:debuggerd:s0 tcontext=u:object_r:gpu_device:s0 tclass=chr_file permissive=1
10-03 00:26:49.165 433-581/system_process E/NativeCrashListener: Exception dealing with report
    android.system.ErrnoException: read failed: EAGAIN (Try again)
        at libcore.io.Posix.readBytes(Native Method)
        at libcore.io.Posix.read(Posix.java:165)
        at libcore.io.BlockGuardOs.read(BlockGuardOs.java:230)
        at android.system.Os.read(Os.java:350)
        at com.android.server.am.NativeCrashListener.consumeNativeCrashData(NativeCrashListener.java:240)
        at com.android.server.am.NativeCrashListener.run(NativeCrashListener.java:138)

It seems to be caused by "CHECK_EQ(reInitDecoder(), (status_t)OK);" in the following code:

   // This is needed to handle CTS DecoderTest testCodecResetsHEVCWithoutSurface,
    // which is not sending SPS/PPS after port reconfiguration and flush to the codec.
    if (unsupportedDimensions && !mFlushNeeded) {
        bool portWillReset = false;
        handlePortSettingsChange(&portWillReset, s_dec_op.u4_pic_wd, s_dec_op.u4_pic_ht);
        CHECK_EQ(reInitDecoder(), (status_t)OK);
        setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx);
        ivdec_api_function(mCodecCtx, (void *)&s_dec_ip, (void *)&s_dec_op);
        return;
    }

Is there a way to find out the unsupportedDimensions of the HEVC decoder of an Android device?


Solution

  • If you are asking for a way to get Supported ranges of different params for a codec, you can use MediaCodecInfo.VideoCapabilities

    Especially, you can get supported heights and widths by calling

    Range<Integer>  getSupportedWidths() 
    Range<Integer>  getSupportedHeights() 
    

    Also, you can get supported heights for a given width value and vice versa by calling getSupportedHeightsFor(int width) and getSupportedWidthsFor(int height). You can do the same for framerate...

    Finally, in your case, you can call directly boolean isSizeSupported(int width, int height)

    Please take a look at this gist to get formatted capabilities values for a given MedaCodec : https://gist.github.com/aelqsimi/f773d63fd5f234df7892276e3b05e5f8