voice-quickstart-android: Native SDK crashes on Java_com_twilio_voice_Voice_nativeHandleMessage for incoming calls

Description

We see many crashes in our app when receiving incoming calls.

The trace is not very useful so we don’t really know how to approach this. Everything is done in the Main thread as the push notification arrives.

Steps to Reproduce

No clear repro steps, we haven’t been able to reproduce it but we see +2k crashes weekly from this. It looks like it mostly happens for incoming calls

Expected Behavior

No crash happening.

Actual Behavior

Sometimes it the app crashes and because it’s in the native code we can’t really catch the exception.

Reproduces How Often

7% of our users are affected by this.

Twilio Call SID(s)

CAa37e338e2a412480cd171bdd92b1fc9a

Logs

Crashed: Thread: SIGABRT  0x0000000000000000
#00 pc 0x66b38 libc.so (BuildId: 97f8621d2a4b9ffed8f5196d93a8a78e)
#01 pc 0x66b08 libc.so (BuildId: 97f8621d2a4b9ffed8f5196d93a8a78e)
#02 pc 0x688bc libc.so (BuildId: 97f8621d2a4b9ffed8f5196d93a8a78e)
#03 pc 0x90b10 libc.so (BuildId: 97f8621d2a4b9ffed8f5196d93a8a78e)
#04 pc 0x479c80 libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#05 pc 0x4e02a0 libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#06 pc 0x4e241c libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#07 pc 0x55a720 libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#08 pc 0x55e310 libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#09 pc 0x4dee54 libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#10 pc 0x4df598 libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#11 pc 0x4df67c libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#12 pc 0x52d128 libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#13 pc 0x4c745c libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#14 pc 0x55a464 libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#15 pc 0x4701d0 libtwilio_voice_android_so.so (Java_com_twilio_voice_Voice_nativeHandleMessage) (BuildId: 62e0d7afc022295681860f9c7a2da6256bf21058)
#16 pc 0xcb888 libc.so (BuildId: 97f8621d2a4b9ffed8f5196d93a8a78e)
#17 pc 0x68370 libc.so (BuildId: 97f8621d2a4b9ffed8f5196d93a8a78e)

Voice Android SDK

com.twilio:voice-android:6.7.0
com.twilio:audioswitch:1.2.0

OS Version

It happens in multiple Android versions: Android 11, 12, 13, 14, 15

Device Model

It happens in multiple device models. Samsung, Google Pixel, etc.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 23 (10 by maintainers)

Most upvoted comments

@jamesbluecrow The two issues you have reported, no one has reported before. Its very unlikely that a race condition is occurring if all the SDK calls are being made from the same thread. Is it possible that the thread your application is making the SDK calls from, is not a thread with a Looper? If the thread does not have a looper, then all the callbacks from the SDK get posted to the UI thread (which has a looper), which can cause multiple SDK calls coming from different threads if subsequent sdk calls are made from those callbacks.

Also, Java_com_twilio_voice_Voice_nativeHandleMessage is only called when Voice.handleMessage is called from the java layer and is used to process incoming firebase messages and it entirely synchronous, ie, it does not interact with any other threads and onCallInvite/onCancelledCallInvite callback invocation come directly out of that function.

https://twilio.github.io/twilio-voice-android/docs/6.7.1/com/twilio/voice/Voice.html#handleMessage(android.content.Context,android.os.Bundle,com.twilio.voice.MessageListener