twilio / twilio-chat-demo-android

Chat API Demo Application for Android
MIT License
62 stars 51 forks source link

4.0.0-rc12 Native crash #68

Closed smelfungus closed 5 years ago

smelfungus commented 6 years ago

Description

Hi there! Getting floating native crash with 4.0.0-rc12. Spawned right after channel onSynchronizationChanged() callback invocation.

Logs

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/bullhead/bullhead:8.1.0/OPM6.171019.030.K1/4947289:user/release-keys'
Revision: 'rev_1.0'
ABI: 'arm64'
pid: 22576, tid: 22773, name: application - 22773  >>> com.example.application <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
    x0   0000000000000000  x1   00000000000058f5  x2   0000000000000006  x3   0000000000000008
    x4   fefeff70fe002eff  x5   fefeff70fe002eff  x6   fefeff70fe002eff  x7   7f7f7f7fff7f7f7f
    x8   0000000000000083  x9   0000000010000000  x10  00000071ff10ef40  x11  0000000000000001
    x12  00000071ff10eb58  x13  ffffffffffffffff  x14  ffffffffff000000  x15  ffffffffffffffff
    x16  0000005573340fa8  x17  00000072a30f54b8  x18  0000000012e40110  x19  0000000000005830
    x20  00000000000058f5  x21  0000000000000083  x22  00000072a315a638  x23  0000000000005830
    x24  00000071ff10f588  x25  00000071ff013000  x26  00000072a3cd2a40  x27  000000000000000b
    x28  0000000000000002  x29  00000071ff10ef80  x30  00000072a30aa6ec
    sp   00000071ff10ef40  pc   00000072a30aa714  pstate 0000000060000000
backtrace:
    #00 pc 000000000001d714  /system/lib64/libc.so (abort+120)
    #01 pc 0000000000851918  /data/app/com.example.application-GBZY9MlreZDUCtL7JdFaXw==/lib/arm64/libtwilio-rtd-native.so (jni_mate::FatalMessage::~FatalMessage()+324)
    #02 pc 000000000044f954  /data/app/com.example.application-GBZY9MlreZDUCtL7JdFaXw==/lib/arm64/libtwilio-rtd-native.so (_ZN8jni_mate14CallRefAdaptorIvEclIJP8_jobjectEEEvP7_JNIEnvS4_P10_jmethodIDDpT_+360)
    #03 pc 000000000044f4ec  /data/app/com.example.application-GBZY9MlreZDUCtL7JdFaXw==/lib/arm64/libtwilio-rtd-native.so (ChatListenerWrapper::onError(_JNIEnv*, std::__ndk1::shared_ptr<rtd::ITMResult>) const+140)
    #04 pc 0000000000499e6c  /data/app/com.example.application-GBZY9MlreZDUCtL7JdFaXw==/lib/arm64/libtwilio-rtd-native.so
    #05 pc 0000000000525ff4  /data/app/com.example.application-GBZY9MlreZDUCtL7JdFaXw==/lib/arm64/libtwilio-rtd-native.so (_ZNSt6__ndk120__packaged_task_funcINS_6__bindIRNS_8functionIFvNS_10shared_ptrIN3rtd9ITMResultEEENS_4listINS3_INS4_9ITMessageEEENS_9allocatorIS9_EEEEEEEJS6_RSC_EEENSA_ISH_EEFvvEEclEv+116)
    #06 pc 00000000004b1a9c  /data/app/com.example.application-GBZY9MlreZDUCtL7JdFaXw==/lib/arm64/libtwilio-rtd-native.so (std::__ndk1::packaged_task<void ()>::operator()()+88)
    #07 pc 00000000004b1954  /data/app/com.example.application-GBZY9MlreZDUCtL7JdFaXw==/lib/arm64/libtwilio-rtd-native.so (_ZNSt6__ndk114__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEENS_13packaged_taskIFvvEEEEEEEEPvSB_+48)
    #08 pc 0000000000067d0c  /system/lib64/libc.so (__pthread_start(void*)+36)
    #09 pc 000000000001eba4  /system/lib64/libc.so (__start_thread+68)

Chat Android SDK

4.0.0-rc12

Android API

28

Android Device

Nexus 5X, 8.1.0

Thank you!

berkus commented 6 years ago

What about logs?

Do you have ChatListener?

smelfungus commented 6 years ago

@berkus unfortunately log level was not set :( Will try to reproduce with it. Yep, both ChatClientListener & ChannelListener are used. UPD: One more observation - crash happened after first Channel creation attempt.

berkus commented 5 years ago

It looks like it crashes because your listener does not have an onError method. Can you double check that?

smelfungus commented 5 years ago

I'm afraid that behaviour is related to unhanded exception in my code of onError callback. Safe to close now, thank you!

aalap03 commented 5 years ago

@DummyCo How did you trace it back to the unhandled exception of onError? This stacktrace does not state that ? As I get the same error like this, help me understand how do u got the error point please thanks in advance.

Stack trace

Screen Shot 2019-05-30 at 2 10 11 PM

I see getUserDescriptor method only known from all the logs, based on what you said I added onError method, but still I got the crash and stack trace similar to this, with UserDescriptor method reference, so I am using getAndSubscribeUser method with onError implemented along side onSuccess, not sure what is wrong with the previous one.

smelfungus commented 5 years ago

@aalap03 In my case Twilio onError callbacks (placed in custom manager wrapping all the Twilio-related staff) were invoking custom subscribed listeners. One of the listeners was located in ViewModel with an idea to process and populate Twilio errors to the related view layer if needed via LiveData. As a result, Twilio onError callback was invoked on non-main thread, what caused LiveData value setting exception throwing and Twilio crash. Maybe it would be useful to double check whether any exceptions are thrown in your callbacks' invoked code too?