Device crash when videos to decode starts increasing

Hi everyone,

I have been struggling with a crash on some Android devices that I am not sure how to solve.
I tried doing some searching on my own and thought it might originate from the hardware codec in the device.

The bug occurs when I try to show a bunch of videos on the screen, it seems to be going well and then all streams stop and the application crashes. Sometimes this occurs early in the application but on average it crashed at around 15 video streams - for conference calls - (this might differ for other devices).

I think it is because of hardware codec because when I forced the android application to use software codec the application could show up to 30 videos without crashing.
Do I understand correctly that the device should try and use hardware codec and fall back to software codec?
Could it be that this functionality causes some devices to crash?
Does anyone know of a possible solution for this?

Thank you in advance.

Build Information
React Native version : 0.64.2
react-native-webrtc : 1.89.3

Device that does crash - Samsung A71, Android 11, OMX.qcom.video.decoder.vp8
Device that does not crash - Hauwei P10 lite, Android 9, OMX.hisi.video.decoder.vp8

Fatal Logs

07-05 10:46:44.311  7997 12020 F libc    : Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 12020 (EncoderQueue - ), pid 7997 (com.uhura)
07-05 10:46:44.607 12035 12035 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-05 10:46:44.607 12035 12035 F DEBUG   : Build fingerprint: 'samsung/a71naxx/a71:11/RP1A.200720.012/A715FXXS4BUC1:user/release-keys'
07-05 10:46:44.607 12035 12035 F DEBUG   : Revision: '6'
07-05 10:46:44.607 12035 12035 F DEBUG   : ABI: 'arm64'
07-05 10:46:44.607 12035 12035 F DEBUG   : Timestamp: 2021-07-05 10:46:44+0200
07-05 10:46:44.608 12035 12035 F DEBUG   : pid: 7997, tid: 12020, name: EncoderQueue -  >>> com.uhura <<<
07-05 10:46:44.608 12035 12035 F DEBUG   : uid: 10462
07-05 10:46:44.608 12035 12035 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
07-05 10:46:44.608 12035 12035 F DEBUG   :     x0  0000000000000000  x1  0000000000002ef4  x2  0000000000000006  x3  0000006e6406aba0
07-05 10:46:44.608 12035 12035 F DEBUG   :     x4  fefefefefefefeff  x5  fefefefefefefeff  x6  fefefefefefefeff  x7  7f7f7f7f7f7f7f7f
07-05 10:46:44.608 12035 12035 F DEBUG   :     x8  00000000000000f0  x9  bbdc77d3398e103b  x10 0000000000000000  x11 ffffffc0fffffbdf
07-05 10:46:44.608 12035 12035 F DEBUG   :     x12 0000000000000001  x13 0000000060e2c6f3  x14 0000000000000000  x15 0000926c89a9bac4
07-05 10:46:44.608 12035 12035 F DEBUG   :     x16 0000007b34287c80  x17 0000007b34267600  x18 0000006e5c4ca000  x19 0000000000001f3d
07-05 10:46:44.608 12035 12035 F DEBUG   :     x20 0000000000002ef4  x21 00000000ffffffff  x22 00000078099d24df  x23 00000000000000f0
07-05 10:46:44.608 12035 12035 F DEBUG   :     x24 000000000000010a  x25 000000000000003c  x26 00000000000034c6  x27 0000000000000000
07-05 10:46:44.608 12035 12035 F DEBUG   :     x28 0000000000000001  x29 0000006e6406ac20
07-05 10:46:44.608 12035 12035 F DEBUG   :     lr  0000007b34217038  sp  0000006e6406ab80  pc  0000007b34217064  pst 0000000000000000
07-05 10:46:44.616 12035 12035 F DEBUG   : backtrace:
07-05 10:46:44.616 12035 12035 F DEBUG   :       #00 pc 000000000004f064  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: 6788fe7b9e02c9fa2752fe60cd2f6cc9)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #01 pc 000000000026bb90  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #02 pc 000000000026bb2c  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #03 pc 000000000024a468  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #04 pc 000000000024a38c  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #05 pc 00000000003ef32c  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #06 pc 00000000003f3008  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #07 pc 00000000005a23f4  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #08 pc 00000000005a3d24  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #09 pc 00000000005a6f1c  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #10 pc 00000000004d9a64  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #11 pc 00000000004db080  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.616 12035 12035 F DEBUG   :       #12 pc 00000000004d9880  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.617 12035 12035 F DEBUG   :       #13 pc 00000000002752fc  /data/app/~~BIUzXvwTPkSJXzCU6AUHTQ==/com.uhura-dA39L71rC4u30t9_LvBrGg==/base.apk!libjingle_peerconnection_so.so (offset 0x3c6e000) (BuildId: c2390899c2e501a6)
07-05 10:46:44.617 12035 12035 F DEBUG   :       #14 pc 00000000000b6374  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64) (BuildId: 6788fe7b9e02c9fa2752fe60cd2f6cc9)
07-05 10:46:44.617 12035 12035 F DEBUG   :       #15 pc 0000000000050fa4  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 6788fe7b9e02c9fa2752fe60cd2f6cc9)

I am also facing same issue. I believe it happens because each hardware has a limit of EglContext that it can support. Once that limit is reached, hardware crashes with native exception which we are not able to catch.

Is there a way to handle this exception or if we can know that there is not enough space for creating the context, then also it can be avoided.

@Tjaart-Booyens were you able to solve this issue?

Hi @poorvasingh04,

Unfortunately, we could not solve this issue however we implemented a workaround. Because our use case uses simulcasting (which is not available for hardware codecs as far as I know), we changed the logic of the WebRTC module to use software codecs.