在进行任何调用之前,必须向 PjSip 线程注册外部线程



当浏览应用程序应用程序时,由于pjsip而崩溃,并且说您必须向pjsip线程注册外部线程。我也像这样用主线程重新注册了 pjsip

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

这崩溃是如此随机地发生,并不完全知道是什么原因造成的,当崩溃发生时,我也没有调用任何 pjsip 方法。那么这里出了什么问题呢?

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]

看起来 GC 正在从您注册的线程以外的线程中收集 PjSip 对象之一。

根据文档:

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

因此,您必须手动删除 PjSip 对象,例如:

account.delete();

官方文档中GC问题的链接

最新更新