可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
In my class that extends SipAccount class I've onRegState() callback which i receive frequently I've notice that after few callback later at any callback like 4th or 5th time it crashes.
this is the code from onRegState() callback
@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(); } }
This is the log from pjsip client.
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
回答1:
Preface
I was also struggling on this problem for several months and got the same on the real-world app usage (crashes form the play market). And used your code to handle registration results.
The difficult was that we couldn't experience that issues during our tests on any of our devices but our users got it approx 500 crashes per 1000 installs (very high).
Initially I was dealing with Pjsip from UI thread, then I tried to create my own thread for the Pjsip (with uaConfig.setThreadCnt(0) and uaConfig.setMainThreadOnly(true)) but it failed to work at all, or I don't know how to do this right and there is no clue about it anywhere. Then I moved all our business logic from UI to worker thread and worked with Pjsip from worker thread. Nothing helped and the issues were the same.
Finally yesterday we were able to catch this issue and at the same time we had Pjsip logs turned on level 9.
And here is the full log for this crash with preceding info (I've replaced actual server credentials for obvious reason):
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: ;reg-id=1;+sip.instance=">>>00000000-0000-0000-0000-0000e922f243>00000000-0000-0000-0000-0000e922f243>
>