项目开发过程中,使用ijk内核播放器在Android 11上播放视频,报如下错误:
2021-09-14 15:54:30.034 25577-25831/com.component.detail A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x616c0036333730 in tid 25831 (ff_read), pid 25577 (omponent.detail)
2021-09-14 15:54:30.200 25836-25836/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x616c0036333730
2021-09-14 15:54:30.200 25836-25836/? A/DEBUG: x0 b400007a67833800 x1 0000000000000001 x2 00000079daef9900 x3 0000000000001020
2021-09-14 15:54:30.200 25836-25836/? A/DEBUG: x4 79616c0036333730 x5 8080808080808080 x6 fefefefefefefeff x7 7f7f7f7f7f7f7f7f
2021-09-14 15:54:30.200 25836-25836/? A/DEBUG: x8 0101010101010101 x9 a7fecc0609a444b9 x10 0101010101010101 x11 0000000000000000
2021-09-14 15:54:30.200 25836-25836/? A/DEBUG: x12 0000000000000005 x13 0000000000000000 x14 00000000000000a0 x15 aaaaaaaaaaaaaaab
2021-09-14 15:54:30.200 25836-25836/? A/DEBUG: x16 00000079e1ba5388 x17 0000007af72bccf0 x18 00000079d928c000 x19 00000079daef9900
2021-09-14 15:54:30.200 25836-25836/? A/DEBUG: x20 b400007a67833800 x21 b400007a5fea3f40 x22 b400007a5fea3ee0 x23 00000079daefaa68
2021-09-14 15:54:30.200 25836-25836/? A/DEBUG: x24 b400007a5fe23ad0 x25 00000079e5685000 x26 0000000000000001 x27 00000000000fc000
2021-09-14 15:54:30.200 25836-25836/? A/DEBUG: x28 00000079dae02000 x29 00000079daefaaa0
2021-09-14 15:54:30.200 25836-25836/? A/DEBUG: lr 00000079e19506a0 sp 00000079daef98c0 pc 00616c0036333730 pst 0000000000000000
2021-09-14 15:54:30.201 25836-25836/? A/DEBUG: backtrace:
2021-09-14 15:54:30.201 25836-25836/? A/DEBUG: #00 pc 00616c0036333730 <unknown>
2021-09-14 15:54:30.201 25836-25836/? A/DEBUG: #01 pc 00000000002c669c /data/app/~~0NsBySuEPHOzIxzdZ_D-2Q==/com.component.detail-R3INT6htNmMKkxEGVcaoHg==/lib/arm64/libijkffmpeg.so (av_application_on_http_event+24)
分析错误日志:signal的错误,jni底层报错,根据backtrace中的信息,指向ijk的libijkffmpeg.so文件,故导致崩溃的问题就是ijk旧版so文件在Android 11上存在问题!
现给出两种解决方案:
- 第一种(临时解决方案,不推荐)
在清单文件的application节点添加如下配置
android:allowNativeHeapPointerTagging="false"
- 第二种(推荐方案)
a. 编译最新的ijk库,生成最新的so文件
b. 当然,不想自己编译,也是有现成的可以下载的,这里提供郭神的GSYVideoPlayer库,可直接下载使用