是否可以通过 HEVC 解码器防止崩溃 "libc: Fatal signal 6 (SIGABRT), code -6 in tid 31891 (le.hevc.decoder)"

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

我可以通过在 Android 设备上流式传输 H.265 视频来重现崩溃。所有相关代码都是 try-catch 块。是否有可能捕获异常并防止应用程序崩溃。跟踪不指向任何应用程序的代码。我怀疑它不是由任何特定语句引起的。

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)

好像是下面code中的"CHECK_EQ(reInitDecoder(), (status_t)OK);"造成的:

   // 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;
    }

有没有办法找出 Android 设备的 HEVC 解码器的不支持尺寸?

如果您正在寻求一种方法来获取编解码器不同参数的支持范围,您可以使用 MediaCodecInfo.VideoCapabilities

特别是,您可以通过调用

获得支持的高度和宽度
Range<Integer>  getSupportedWidths() 
Range<Integer>  getSupportedHeights() 

此外,您可以通过调用 getSupportedHeightsFor(int width)getSupportedWidthsFor(int height) 获得给定宽度值支持的高度,反之亦然。您可以对帧率执行相同的操作...

最后,在你的情况下,你可以直接调用boolean isSizeSupported(int width, int height)

请查看此要点以获取给定 MedaCodec 的格式化功能值: https://gist.github.com/aelqsimi/f773d63fd5f234df7892276e3b05e5f8