You must register external thread with PjSip threa

2019-06-11 03:07发布

问题:

When navigating through app app got crashed due to pjsip and it's says you must register external thread with pjsip thread. I've also regsitered pjsip with the main thread like this

  try {
            mEndpoint.libRegisterThread(Thread.currentThread().getName());
            Log.d(TAG, "Registering with thread "+Thread.currentThread().getName());
        } catch (Exception e) {
            e.printStackTrace();
        }

This crashed happend so randomly and don't exactly know what causing this and I also not calling any pjsip method when that crashed happend. So what's going wrong here?

07-04 14:36:18.183 32089-32097/com.safarifone.waafi A/libc: ../src/pj/os_core_unix.c:692: pj_thread_this: assertion "!"Calling pjlib from unknown/external thread. You must " "register external threads with pj_thread_register() " "before calling any pjlib functions."" failed
    07-04 14:36:18.183 32089-32097/com.safarifone.waafi A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 32097 (FinalizerDaemon)
    07-04 14:36:18.193 32089-32089/com.safarifone.waafi D/ContactListAdapter: user which is recently added and not sync...
    07-04 14:36:18.203 32089-32089/com.safarifone.waafi D/ContactListAdapter: user which is recently added and not sync...
    07-04 14:36:18.213 32089-32089/com.safarifone.waafi D/ContactListAdapter: user which is recently added and not sync...
    07-04 14:36:18.243 326-326/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    07-04 14:36:18.243 326-326/? A/DEBUG: Build fingerprint: 'samsung/grandpplteser/grandpplte:6.0.1/MMB29T/G532FXWU1APK6:user/release-keys'
    07-04 14:36:18.243 326-326/? A/DEBUG: Revision: '0'
    07-04 14:36:18.243 326-326/? A/DEBUG: ABI: 'arm'
    07-04 14:36:18.243 326-326/? A/DEBUG: pid: 32089, tid: 32097, name: FinalizerDaemon  >>> com.safarifone.waafi <<<
    07-04 14:36:18.243 326-326/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
    07-04 14:36:18.273 326-326/? A/DEBUG: Abort message: '../src/pj/os_core_unix.c:692: pj_thread_this: assertion "!"Calling pjlib from unknown/external thread. You must " "register external threads with pj_thread_register() " "before calling any pjlib functions."" failed'
    07-04 14:36:18.273 326-326/? A/DEBUG:     r0 00000000  r1 00007d61  r2 00000006  r3 b37c2978
    07-04 14:36:18.273 326-326/? A/DEBUG:     r4 b37c2980  r5 b37c2930  r6 0000000b  r7 0000010c
    07-04 14:36:18.273 326-326/? A/DEBUG:     r8 00000000  r9 b4424f00  sl b37c1b20  fp b37c1a64
    07-04 14:36:18.273 326-326/? A/DEBUG:     ip 00000006  sp b37c19d0  lr b6d4cdcd  pc b6d4f1bc  cpsr 400e0010
    07-04 14:36:18.293 326-326/? A/DEBUG: backtrace:
    07-04 14:36:18.293 326-326/? A/DEBUG:     #00 pc 000431bc  /system/lib/libc.so (tgkill+12)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #01 pc 00040dc9  /system/lib/libc.so (pthread_kill+32)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #02 pc 0001c7e7  /system/lib/libc.so (raise+10)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #03 pc 00019a65  /system/lib/libc.so (__libc_android_abort+34)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #04 pc 00017600  /system/lib/libc.so (abort+4)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #05 pc 0001b3fb  /system/lib/libc.so (__libc_fatal+16)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #06 pc 00019aed  /system/lib/libc.so (__assert2+20)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #07 pc 0034be3c  /data/app/com.safarifone.waafi-2/lib/arm/libpjsua2.so (pj_thread_this+84)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #08 pc 0034c9b8  /data/app/com.safarifone.waafi-2/lib/arm/libpjsua2.so (pj_mutex_lock+124)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #09 pc 001931c0  /data/app/com.safarifone.waafi-2/lib/arm/libpjsua2.so (PJSUA_LOCK+32)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #10 pc 00194e1c  /data/app/com.safarifone.waafi-2/lib/arm/libpjsua2.so (pjsua_acc_set_user_data+268)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #11 pc 00156464  /data/app/com.safarifone.waafi-2/lib/arm/libpjsua2.so (_ZN2pj7AccountD2Ev+232)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #12 pc 000d6584  /data/app/com.safarifone.waafi-2/lib/arm/libpjsua2.so (_ZN20SwigDirector_AccountD2Ev+116)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #13 pc 000d65fc  /data/app/com.safarifone.waafi-2/lib/arm/libpjsua2.so (_ZN20SwigDirector_AccountD0Ev+20)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #14 pc 00114764  /data/app/com.safarifone.waafi-2/lib/arm/libpjsua2.so (Java_org_pjsip_pjsua2_pjsua2JNI_delete_1Account+76)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #15 pc 000ea539  /system/lib/libart.so (art_quick_generic_jni_trampoline+40)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #16 pc 000e5e41  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #17 pc 003e92d9  /system/lib/libart.so (art_quick_invoke_static_stub+172)
    07-04 14:36:18.293 326-326/? A/DEBUG:     #18 pc 00101c4c  [stack:32097]

回答1:

Looks like one of PjSip objects is getting collected by GC from the thread other than the one you've registered.

According to documentation:

... application ‘’‘MUST immediately destroy PJSUA2 objects using object’s delete() 
method (in Java)’‘’, instead of relying on the GC to clean up the object

So you MUST delete PjSip objects manually, for example:

account.delete();

Link to GC issue in official documentation



标签: android pjsip