Pjsip崩溃了RegState回调

时间:2017-06-21 12:22:15

标签: android pjsip

在我的课程中扩展了SipAccount课程I我经常收到的onRegState()回调我已经注意到,在第四次或第五次任何回调之后几次回调之后它会崩溃。

这是来自onRegState()回调的代码

 @Override
    public void onRegState(OnRegStateParam prm)
    {
        Log.d(TAG, "onRegState...");
        PresenceStatus prsenStatus =  new PresenceStatus();

        if (prm.getCode().swigValue()/100 == 2)
        {
            Log.d(TAG, "Going online!");
            listener.onLogIn(true);
            prsenStatus.setStatus(pjsua_buddy_status.PJSUA_BUDDY_STATUS_ONLINE);
        }
        else
        {
            Log.d(TAG, "Going offline!");
            listener.onLogIn(false);
            prsenStatus.setStatus(pjsua_buddy_status.PJSUA_BUDDY_STATUS_OFFLINE);
        }

        try
        {

            sipAccount.setOnlineStatus(prsenStatus);

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

    }

这是来自pjsip客户端的日志。

06-21 12:37:16.172 10428-10645/com.safarifone.waafi A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 10645 (Thread-3816)
    06-21 12:37:16.279 184-184/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    06-21 12:37:16.279 184-184/? I/DEBUG: Build fingerprint: 'google/occam/mako:5.1.1/LMY48T/2237560:user/release-keys'
    06-21 12:37:16.279 184-184/? I/DEBUG: Revision: '11'
    06-21 12:37:16.279 184-184/? I/DEBUG: ABI: 'arm'
    06-21 12:37:16.279 184-184/? I/DEBUG: pid: 10428, tid: 10645, name: Thread-3816  >>> com.safarifone.waafi <<<
    06-21 12:37:16.279 184-184/? I/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
    06-21 12:37:16.374 184-184/? I/DEBUG:     r0 00000000  r1 00002995  r2 00000006  r3 00000000
    06-21 12:37:16.374 184-184/? I/DEBUG:     r4 a2950dd8  r5 00000006  r6 0000000b  r7 0000010c
    06-21 12:37:16.374 184-184/? I/DEBUG:     r8 b89629b8  r9 b89629b8  sl b6e66155  fp a29502a4
    06-21 12:37:16.374 184-184/? I/DEBUG:     ip 00002995  sp a2950238  lr b6e66989  pc b6e8be24  cpsr 600f0010
    06-21 12:37:16.375 184-184/? I/DEBUG: backtrace:
    06-21 12:37:16.375 184-184/? I/DEBUG:     #00 pc 0003be24  /system/lib/libc.so (tgkill+12)
    06-21 12:37:16.375 184-184/? I/DEBUG:     #01 pc 00016985  /system/lib/libc.so (pthread_kill+52)
    06-21 12:37:16.375 184-184/? I/DEBUG:     #02 pc 00017597  /system/lib/libc.so (raise+10)
    06-21 12:37:16.375 184-184/? I/DEBUG:     #03 pc 00013d3d  /system/lib/libc.so (__libc_android_abort+36)
    06-21 12:37:16.375 184-184/? I/DEBUG:     #04 pc 000124ec  /system/lib/libc.so (abort+4)
    06-21 12:37:16.376 184-184/? I/DEBUG:     #05 pc 00464d10  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (__gnu_cxx::__verbose_terminate_handler()+348)
    06-21 12:37:16.376 184-184/? I/DEBUG:     #06 pc 0045e9e4  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (__cxxabiv1::__terminate(void (*)())+8)
    06-21 12:37:16.376 184-184/? I/DEBUG:     #07 pc 0045ea84  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (std::terminate()+12)
    06-21 12:37:16.376 184-184/? I/DEBUG:     #08 pc 0045ec10  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (__cxa_throw+156)
    06-21 12:37:16.376 184-184/? I/DEBUG:     #09 pc 000d6c00  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (SwigDirector_Account::onRegState(pj::OnRegStateParam&)+400)
    06-21 12:37:16.376 184-184/? I/DEBUG:     #10 pc 0015ef9c  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (pj::Endpoint::on_reg_state2(int, pjsua_reg_info*)+268)
    06-21 12:37:16.376 184-184/? I/DEBUG:     #11 pc 001996c0  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (regc_cb+1424)
    06-21 12:37:16.376 184-184/? I/DEBUG:     #12 pc 001dc944  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (call_callback+124)
    06-21 12:37:16.376 184-184/? I/DEBUG:     #13 pc 001ddc28  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (regc_tsx_callback+2120)
    06-21 12:37:16.377 184-184/? I/DEBUG:     #14 pc 00225a18  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (mod_util_on_tsx_state+232)
    06-21 12:37:16.377 184-184/? I/DEBUG:     #15 pc 00221304  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (tsx_set_state+540)
    06-21 12:37:16.377 184-184/? I/DEBUG:     #16 pc 00224dfc  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (tsx_on_state_proceeding_uac+712)
    06-21 12:37:16.377 184-184/? I/DEBUG:     #17 pc 002240cc  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (tsx_on_state_calling+656)
    06-21 12:37:16.377 184-184/? I/DEBUG:     #18 pc 002227a0  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (pjsip_tsx_recv_msg+180)
    06-21 12:37:16.377 184-184/? I/DEBUG:     #19 pc 002206ac  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (mod_tsx_layer_on_rx_response+232)
    06-21 12:37:16.377 184-184/? I/DEBUG:     #20 pc 002052b4  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (pjsip_endpt_process_rx_data+696)
    06-21 12:37:16.377 184-184/? I/DEBUG:     #21 pc 002055d0  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (endpt_on_rx_msg+636)
    06-21 12:37:16.377 184-184/? I/DEBUG:     #22 pc 0020f6b4  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (pjsip_tpmgr_receive_packet+1908)
    06-21 12:37:16.377 184-184/? I/DEBUG:     #23 pc 002152e8  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (on_data_read+252)
    06-21 12:37:16.378 184-184/? I/DEBUG:     #24 pc 00351ce0  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (ioqueue_on_read_complete+208)
    06-21 12:37:16.378 184-184/? I/DEBUG:     #25 pc 00347a14  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (ioqueue_dispatch_read_event+940)
    06-21 12:37:16.378 184-184/? I/DEBUG:     #26 pc 0034a1a8  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (pj_ioqueue_poll+1408)
    06-21 12:37:16.378 184-184/? I/DEBUG:     #27 pc 00204e20  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (pjsip_endpt_handle_events2+328)
    06-21 12:37:16.378 184-184/? I/DEBUG:     #28 pc 001ae420  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (pjsua_handle_events+92)
    06-21 12:37:16.378 184-184/? I/DEBUG:     #29 pc 001ab320  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (worker_thread+32)
    06-21 12:37:16.378 184-184/? I/DEBUG:     #30 pc 0034b9c8  /data/app/com.safarifone.waafi-1/lib/arm/libpjsua2.so (thread_main+176)
    06-21 12:37:16.378 184-184/? I/DEBUG:     #31 pc 00016173  /system/lib/libc.so (__pthread_start(void*)+30)
    06-21 12:37:16.379 184-184/? I/DEBUG:     #32 pc 0001409b  /system/lib/libc.so (__start_thread+6)

1 个答案:

答案 0 :(得分:0)

<强>前言

我几个月来一直在努力解决这个问题,并且在真实世界的应用程序使用方面也是如此(从游戏市场崩溃)。并使用您的代码处理注册结果。

困难在于我们在任何设备的测试中都无法遇到这些问题,但我们的用户每1000次安装(非常高)就会遇到大约500次崩溃。

最初我从UI线程处理Pjsip,然后我尝试为Pjsip创建自己的线程(使用 uaConfig.setThreadCnt(0) uaConfig.setMainThreadOnly(true)< / em>)但它根本无法工作,或者我不知道如何做到这一点并且在任何地方都没有任何线索。然后我将所有业务逻辑从UI移动到工作线程,并从工作线程使用Pjsip。什么都没有帮助,问题是一样的。

昨天终于我们能够抓住这个问题,同时我们将Pjsip日志打开了9级。

以下是此崩溃的完整日志以及之前的信息(由于显而易见的原因,我已替换了实际的服务器凭据):

09-07 19:27:49.475 25309-25328/? I/System.out: 19:27:49.474 sip_endpoint.c  .Module "mod-pjsua-log" registered
09-07 19:27:49.475 25309-25328/? I/System.out: 19:27:49.475 sip_endpoint.c  .Module "mod-tsx-layer" registered
09-07 19:27:49.475 25309-25328/? I/System.out: 19:27:49.475 sip_endpoint.c  .Module "mod-stateful-util" registered
09-07 19:27:49.475 25309-25328/? I/System.out: 19:27:49.475 sip_endpoint.c  .Module "mod-ua" registered
09-07 19:27:49.475 25309-25328/? I/System.out: 19:27:49.475 sip_endpoint.c  .Module "mod-100rel" registered
09-07 19:27:49.475 25309-25328/? I/System.out: 19:27:49.475 sip_endpoint.c  .Module "mod-pjsua" registered
09-07 19:27:49.475 25309-25328/? I/System.out: 19:27:49.475 sip_endpoint.c  .Module "mod-invite" registered
09-07 19:27:49.475 25309-25328/? I/System.out: 19:27:49.475 android_jni_de  ..Android JNI sound library initialized
09-07 19:27:49.475 25309-25328/? I/System.out: 19:27:49.475          pjlib  ..select() I/O Queue created (0xd1f53214)
09-07 19:27:49.476 25309-25328/? I/System.out: 19:27:49.476   conference.c  ..Creating conference bridge with 12 ports
09-07 19:27:49.476 25309-25328/? I/System.out: 19:27:49.476   Master/sound  ..Using delay buffer with WSOLA.
09-07 19:27:49.477 25309-25328/? I/System.out: 19:27:49.477    pjsua_vid.c  ..Initializing video subsystem..
09-07 19:27:49.478 25309-25328/? I/System.out: 19:27:49.477   openh264.cpp  ...OpenH264 codec initialized
09-07 19:27:49.478 25309-25328/? I/System.out: 19:27:49.478   opengl_dev.c  ...OpenGL device initialized
09-07 19:27:49.489 25309-25328/? I/System.out: 19:27:49.489  android_dev.c  ...Android video capture initialized with 0 device(s):
09-07 19:27:49.489 25309-25328/? I/System.out: 19:27:49.489 colorbar_dev.c  ...Colorbar video src initialized with 2 device(s):
09-07 19:27:49.489 25309-25328/? I/System.out: 19:27:49.489 colorbar_dev.c  ... 0: Colorbar generator
09-07 19:27:49.489 25309-25328/? I/System.out: 19:27:49.489 colorbar_dev.c  ... 1: Colorbar-active
09-07 19:27:49.489 25309-25328/? I/System.out: 19:27:49.489 sip_endpoint.c  .Module "mod-evsub" registered
09-07 19:27:49.490 25309-25328/? I/System.out: 19:27:49.490 sip_endpoint.c  .Module "mod-presence" registered
09-07 19:27:49.490 25309-25328/? I/System.out: 19:27:49.490        evsub.c  .Event pkg "presence" registered by mod-presence
09-07 19:27:49.490 25309-25328/? I/System.out: 19:27:49.490 sip_endpoint.c  .Module "mod-mwi" registered
09-07 19:27:49.490 25309-25328/? I/System.out: 19:27:49.490        evsub.c  .Event pkg "message-summary" registered by mod-mwi
09-07 19:27:49.490 25309-25328/? I/System.out: 19:27:49.490 sip_endpoint.c  .Module "mod-refer" registered
09-07 19:27:49.490 25309-25328/? I/System.out: 19:27:49.490        evsub.c  .Event pkg "refer" registered by mod-refer
09-07 19:27:49.490 25309-25328/? I/System.out: 19:27:49.490 sip_endpoint.c  .Module "mod-pjsua-pres" registered
09-07 19:27:49.491 25309-25328/? I/System.out: 19:27:49.491 sip_endpoint.c  .Module "mod-pjsua-im" registered
09-07 19:27:49.492 25309-25328/? I/System.out: 19:27:49.491 sip_endpoint.c  .Module "mod-pjsua-options" registered
09-07 19:27:49.492 25309-25328/? I/System.out: 19:27:49.492   pjsua_core.c  .1 SIP worker threads created
09-07 19:27:49.492 25309-25328/? I/System.out: 19:27:49.492   pjsua_core.c  .pjsua version 2.6-svn for Linux-3.10.73/armv8l initialized
09-07 19:27:49.492 25309-25328/? I/System.out: 19:27:49.492   pjsua_core.c  .PJSUA state changed: CREATED --> INIT
09-07 19:27:49.496 25309-25328/? I/System.out: 19:27:49.496   pjsua_core.c  SIP UDP socket reachable at 192.168.0.102:49790
09-07 19:27:49.496 25309-25328/? I/System.out: 19:27:49.496  udp0xc5e8bc00  SIP UDP transport started, published address is 192.168.0.102:49790
09-07 19:27:49.499 25309-25328/? I/System.out: 19:27:49.499    tcptp:39629  SIP TCP listener ready for incoming connections at 192.168.0.102:39629
09-07 19:27:49.499 25309-25328/? I/System.out: 19:27:49.499   pjsua_core.c  PJSUA state changed: INIT --> STARTING
09-07 19:27:49.499 25309-25328/? I/System.out: 19:27:49.499 sip_endpoint.c  .Module "mod-unsolicited-mwi" registered
09-07 19:27:49.499 25309-25328/? I/System.out: 19:27:49.499   pjsua_core.c  .PJSUA state changed: STARTING --> RUNNING
09-07 19:27:49.523 25309-25328/? I/System.out: 19:27:49.523    pjsua_acc.c  Adding account: id=sip:user85@192.168.0.1:5065;transport=tcp
09-07 19:27:49.523 25309-25328/? I/System.out: 19:27:49.523    pjsua_acc.c  .Account sip:user85@192.168.0.1:5065;transport=tcp added with id 0
09-07 19:27:49.523 25309-25328/? I/System.out: 19:27:49.523    pjsua_acc.c  .Acc 0: setting registration..
09-07 19:27:49.524 25309-25328/? I/System.out: 19:27:49.524 tcpc0xc8004414  ..TCP client transport created
09-07 19:27:49.525 25309-25328/? I/System.out: 19:27:49.525 tcpc0xc8004414  ..TCP transport 192.168.0.102:43292 is connecting to 192.168.0.1:5065...
09-07 19:27:49.525 25309-25328/? I/System.out: 19:27:49.525    pjsua_acc.c  ..Contact for acc 0 updated: <sip:user85@192.168.0.102:43292;transport=TCP;ob>;reg-id=1;+sip.instance="<urn:uuid:00000000-0000-0000-0000-0000e922f243>"
09-07 19:27:49.526 25309-25328/? I/System.out: 19:27:49.526       endpoint  ..Request msg REGISTER/cseq=27093 (tdta0xf2abe064) created.
09-07 19:27:49.526 25309-25328/? I/System.out: 19:27:49.526  tsx0xc5189864  ...Transaction created for Request msg REGISTER/cseq=27094 (tdta0xf2abe064)
09-07 19:27:49.526 25309-25328/? I/System.out: 19:27:49.526  tsx0xc5189864  ..Sending Request msg REGISTER/cseq=27094 (tdta0xf2abe064) in state Null
09-07 19:27:49.527 25309-25328/? I/System.out: 19:27:49.526  sip_resolve.c  ...Target '192.168.0.1:5065' type=TCP resolved to '192.168.0.1:5065' type=TCP (TCP transport)
09-07 19:27:49.527 25309-25328/? I/System.out: 19:27:49.527   pjsua_core.c  ...TX 670 bytes Request msg REGISTER/cseq=27094 (tdta0xf2abe064) to TCP 192.168.0.1:5065:
09-07 19:27:49.527 25309-25328/? I/System.out: REGISTER sip:192.168.0.1:5065;transport=tcp SIP/2.0
09-07 19:27:49.527 25309-25328/? I/System.out: Via: SIP/2.0/TCP 192.168.0.102:43292;rport;branch=z9hG4bKPjF2B-OwmauIYhdNKR-ZgJx.-1MSDez4W6;alias
09-07 19:27:49.527 25309-25328/? I/System.out: Max-Forwards: 70
09-07 19:27:49.527 25309-25328/? I/System.out: From: <sip:user85@192.168.0.1>;tag=4qxB-NvGjIr6mYvHsTZodmy3jlZbSaId
09-07 19:27:49.527 25309-25328/? I/System.out: To: <sip:user85@192.168.0.1>
09-07 19:27:49.527 25309-25328/? I/System.out: Call-ID: C5IqW1iZ3iPJDNHNPtQnk0L-9IoX3iUs
09-07 19:27:49.527 25309-25328/? I/System.out: CSeq: 27094 REGISTER
09-07 19:27:49.527 25309-25328/? I/System.out: User-Agent: Pjsua2 Android 2.6-svn
09-07 19:27:49.527 25309-25328/? I/System.out: Supported: outbound, path
09-07 19:27:49.527 25309-25328/? I/System.out: Contact: <sip:user85@192.168.0.102:43292;transport=TCP;ob>;reg-id=1;+sip.instance="<urn:uuid:00000000-0000-0000-0000-0000e922f243>"
09-07 19:27:49.527 25309-25328/? I/System.out: Expires: 300
09-07 19:27:49.527 25309-25328/? I/System.out: Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
09-07 19:27:49.527 25309-25328/? I/System.out: Content-Length:  0
09-07 19:27:49.527 25309-25328/? I/System.out: --end msg--
09-07 19:27:49.527 25309-25328/? I/System.out: 19:27:49.527  tsx0xc5189864  ...State changed from Null to Calling, event=TX_MSG
09-07 19:27:49.527 25309-25328/? I/System.out: 19:27:49.527    pjsua_acc.c  ..Acc 0: Registration sent
09-07 19:27:49.629 25309-25449/? I/System.out: 19:27:49.628 tcpc0xc8004414 !TCP connect() error: Connection refused [code=120111]
09-07 19:27:49.631 25309-25449/? I/System.out: 19:27:49.629  tsx0xc5189864  Failed to send Request msg REGISTER/cseq=27094 (tdta0xf2abe064)! err=120111 (Connection refused)
09-07 19:27:49.632 25309-25449/? I/System.out: 19:27:49.631  tsx0xc5189864  State changed from Calling to Terminated, event=TRANSPORT_ERROR
09-07 19:27:49.634 25309-25449/? I/System.out: 19:27:49.633    pjsua_acc.c  ..SIP registration failed, status=503 (Connection refused)
09-07 19:27:49.635 25309-25449/? I/System.out: 19:27:49.634    pjsua_acc.c  ..Scheduling re-registration retry for acc 0 in 7 seconds..
09-07 19:27:49.900 25453-25449/? A/google-breakpad: Microdump skipped (uninteresting)
09-07 19:27:49.930 25309-25449/? W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
09-07 19:27:49.930 25309-25449/? W/google-breakpad: Chrome build fingerprint:
09-07 19:27:49.930 25309-25449/? W/google-breakpad: 10
09-07 19:27:49.930 25309-25449/? W/google-breakpad: 10
09-07 19:27:49.930 25309-25449/? W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
09-07 19:27:49.933 25309-25449/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 25449 (Thread-18)

                                                                                       [ 09-07 19:27:49.940 16075:16075 W/         ]
                                                                                       debuggerd: handling request: pid=25309 uid=11700 gid=11700 tid=25449
09-07 19:27:49.970 25454-25454/? W/debuggerd: type=1400 audit(0.0:1124): avc: denied { search } for name="?" dev="dm-2" ino=441666 scontext=u:r:debuggerd:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
09-07 19:27:50.050 25454-25454/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-07 19:27:50.051 25454-25454/? A/DEBUG: Build fingerprint: 'google/bullhead/bullhead:7.1.2/N2G48C/4104010:user/release-keys'
09-07 19:27:50.051 25454-25454/? A/DEBUG: Revision: 'rev_1.0'
09-07 19:27:50.051 25454-25454/? A/DEBUG: ABI: 'arm'
09-07 19:27:50.051 25454-25454/? A/DEBUG: pid: 25309, tid: 25449, name: Thread-18  >>> ? <<<
09-07 19:27:50.051 25454-25454/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
09-07 19:27:50.051 25454-25454/? A/DEBUG:     r0 00000000  r1 00006369  r2 00000006  r3 00000008
09-07 19:27:50.051 25454-25454/? A/DEBUG:     r4 c3c01978  r5 00000006  r6 c3c01920  r7 0000010c
09-07 19:27:50.051 25454-25454/? A/DEBUG:     r8 c545f7e0  r9 c4022858  sl c3ff8a50  fp ffffffff
09-07 19:27:50.051 25454-25454/? A/DEBUG:     ip 00000000  sp c3c01048  lr f47e45e7  pc f47e6e44  cpsr 200f0010
09-07 19:27:50.063 25454-25454/? A/DEBUG: backtrace:
09-07 19:27:50.064 25454-25454/? A/DEBUG:     #00 pc 00049e44  /system/lib/libc.so (tgkill+12)
09-07 19:27:50.064 25454-25454/? A/DEBUG:     #01 pc 000475e3  /system/lib/libc.so (pthread_kill+34)
09-07 19:27:50.064 25454-25454/? A/DEBUG:     #02 pc 0001d8a5  /system/lib/libc.so (raise+10)
09-07 19:27:50.064 25454-25454/? A/DEBUG:     #03 pc 000193f1  /system/lib/libc.so (__libc_android_abort+34)
09-07 19:27:50.064 25454-25454/? A/DEBUG:     #04 pc 00017034  /system/lib/libc.so (abort+4)
09-07 19:27:50.064 25454-25454/? A/DEBUG:     #05 pc 001309af  /data/app/?-1/lib/arm/libpjsua2.so (_ZN9__gnu_cxx27__verbose_terminate_handlerEv+226)
09-07 19:27:50.064 25454-25454/? A/DEBUG:     #06 pc 0012b665  /data/app/?-1/lib/arm/libpjsua2.so (_ZN10__cxxabiv111__terminateEPFvvE+4)
09-07 19:27:50.064 25454-25454/? A/DEBUG:     #07 pc 0012b6d9  /data/app/?-1/lib/arm/libpjsua2.so (_ZSt9terminatev+8)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #08 pc 0012b7fd  /data/app/?-1/lib/arm/libpjsua2.so (__cxa_throw+120)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #09 pc 0006cfe3  /data/app/?-1/lib/arm/libpjsua2.so (_ZN20SwigDirector_Account10onRegStateERN2pj15OnRegStateParamE+186)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #10 pc 00091a53  /data/app/?-1/lib/arm/libpjsua2.so (_ZN2pj8Endpoint13on_reg_state2EiP14pjsua_reg_info+110)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #11 pc 000a8771  /data/app/?-1/lib/arm/libpjsua2.so (regc_cb+1092)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #12 pc 000c0c81  /data/app/?-1/lib/arm/libpjsua2.so (regc_tsx_callback+1368)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #13 pc 000d5223  /data/app/?-1/lib/arm/libpjsua2.so (tsx_set_state+190)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #14 pc 000d607b  /data/app/?-1/lib/arm/libpjsua2.so (send_msg_callback+446)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #15 pc 000cdb09  /data/app/?-1/lib/arm/libpjsua2.so (stateless_send_transport_cb+68)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #16 pc 000d0291  /data/app/?-1/lib/arm/libpjsua2.so (transport_send_callback+20)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #17 pc 000d21fb  /data/app/?-1/lib/arm/libpjsua2.so (on_data_sent+38)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #18 pc 000d24fb  /data/app/?-1/lib/arm/libpjsua2.so (on_connect_complete+82)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #19 pc 00122e3d  /data/app/?-1/lib/arm/libpjsua2.so (ioqueue_dispatch_write_event+124)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #20 pc 00123c03  /data/app/?-1/lib/arm/libpjsua2.so (pj_ioqueue_poll+462)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #21 pc 000cd519  /data/app/?-1/lib/arm/libpjsua2.so (pjsip_endpt_handle_events2+90)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #22 pc 000ae505  /data/app/?-1/lib/arm/libpjsua2.so (pjsua_handle_events+32)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #23 pc 000ae529  /data/app/?-1/lib/arm/libpjsua2.so (worker_thread+16)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #24 pc 0012453d  /data/app/?-1/lib/arm/libpjsua2.so (thread_main+40)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #25 pc 000470b3  /system/lib/libc.so (_ZL15__pthread_startPv+22)
09-07 19:27:50.065 25454-25454/? A/DEBUG:     #26 pc 00019e3d  /system/lib/libc.so (__start_thread+6)

如您所见,库在收到“连接被拒绝”错误后立即崩溃,并计划下一次重试(根据日志)。 所以我们做了一个测试来证明这个建议 - 我们配置SIP服务器拒绝任何连接,我们得到了它! 所以当出现连接错误时会出现问题。

记住这一点我在 onRegState()回调中设置了一个断点。我再次尝试并获得了突破点,然后我发布了它并且应用程序崩溃了。然后我在方法中注释掉了我的代码,并再次尝试:断点命中,释放和... NO CRASH 这很奇怪,因为我的逻辑很轻,对Pjsip本身没有任何作用。

然后我输入一个日志来找出回调正在运行的线程并且......惊讶!

答案(TL; DR)(mb原因不正确)

onRegState()回调方法在内部某处创建的Pjsip线程之一中运行。 因此,一旦我将调用替换为我的代码,将其发布到我的工作线程,崩溃就消失了。看起来Pjsip正在等待所有它的回调方法提前返回,并不意味着它们会延迟任何时间。

所以我建议用 Runnable 从那里包装对你代码的调用,并将它发布到 Handler (无论是UI线程还是你自己的工作线程)崩溃将消失。 我没有测试过其他Pjsip回调线程 - 它们是否也是内部Pjsip线程?但是我很确定它们是并且计划以相同的方式从任何Pjsip回调中包含对我的代码的所有调用( Runnable - &gt; post to Hadler

因此,您的代码可能会像这样来解决问题:

@Override
public void onRegState(OnRegStateParam prm) {
    Log.d(TAG, "onRegState...");

    final int stateCode = prm.getCode().swigValue();

    mHandler.post(new Runnable() {
        @Override
        public void run() {
            PresenceStatus prsenStatus =  new PresenceStatus();

            if (stateCode /100 == 2) {
                Log.d(TAG, "Going online!");
                listener.onLogIn(true);
                prsenStatus.setStatus(pjsua_buddy_status.PJSUA_BUDDY_STATUS_ONLINE);
            } else {
                Log.d(TAG, "Going offline!");
                listener.onLogIn(false);
                prsenStatus.setStatus(pjsua_buddy_status.PJSUA_BUDDY_STATUS_OFFLINE);
            }

            try {
                sipAccount.setOnlineStatus(prsenStatus);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

其中 mHandler 是您用于在某处创建Pjsip的线程的 Handler 。或者您可以使用任何其他解决方案将此方法从任何工作卸载到您的线程......

<强>更新

  1. 我检查过并发现所有Pjsip回调都是由库中的线程运行的。除了第一次调用 Call onCallState(OnCallStateParam prm)之外。第一次在创建 Call 的同一个线程中调用它,但是下次调用发生在Pjsip创建的不同线程上,每次都是一个新线程。
  2. 我发现以前我为注册失败扔了一个新的 RuntimeException 。实际上,这次崩溃是由此回调执行的代码中出现意外异常的结果。
  3. Pjsip线程中的 Exception 会导致本机库崩溃。

    更新回答

    我得出结论,当回调执行的代码(在回调线程中)中出现意外的 Exception 时,库会崩溃。

    但我推荐相同的解决方案:

    不要在回调中运行任何业务逻辑,将其发布到线程

    因此,你们两个都会:

    1. 防止库回调步骤与逻辑线程(UI,工作者或其他)之间的竞争条件
    2. 并保护图书馆中的这种神秘崩溃,获得良好的旧Java异常=)