为 Android 启用 PJSIP 登录强制关闭应用程序 [英] Enabling log in PJSIP for Android forces close the app
问题描述
我正在基于 SWIG 示例使用 PJSIP for android 构建 SIP Softphone.
I'm building a SIP Softphone using PJSIP for android based on SWIG example.
我按照示例中的描述启用日志:
I enable log as described in the sample:
LogConfig log_cfg = epConfig.getLogConfig();
SipLogWriter logWriter = new SipLogWriter();
log_cfg.setWriter(logWriter);
log_cfg.setDecor(log_cfg.getDecor() & ~(pj_log_decoration.PJ_LOG_HAS_CR.swigValue() | pj_log_decoration.PJ_LOG_HAS_NEWLINE.swigValue()));
我的 SipLogWriter 类在哪里:
where my SipLogWriter class is:
public class SipLogWriter extends LogWriter {
@Override
public void write(LogEntry entry) {
Log.d(Global.TAG, "[SipLogWriter] " + entry.getMsg());
}
}
Pjsip lib 时不时会因为这个回溯而停止:
Pjsip lib halts every now and then with this backtraces:
05-04 10:32:10.534 I/DEBUG ( 281): backtrace:
05-04 10:32:10.534 I/DEBUG ( 281): #00 pc 00037b58 /system/lib/libc.so (tgkill+12)
05-04 10:32:10.544 I/DEBUG ( 281): #01 pc 00013fc9 /system/lib/libc.so (pthread_kill+52)
05-04 10:32:10.544 I/DEBUG ( 281): #02 pc 00014be7 /system/lib/libc.so (raise+10)
05-04 10:32:10.544 I/DEBUG ( 281): #03 pc 00011529 /system/lib/libc.so (__libc_android_abort+36)
05-04 10:32:10.544 I/DEBUG ( 281): #04 pc 0000fcb4 /system/lib/libc.so (abort+4)
05-04 10:32:10.544 I/DEBUG ( 281): #05 pc 00001259 /system/lib/libstdc++.so
05-04 10:32:10.544 I/DEBUG ( 281): #06 pc 00000afb /system/lib/libstdc++.so (__cxa_pure_virtual+6)
05-04 10:32:10.544 I/DEBUG ( 281): #07 pc 0015d4e8 /data/app/com.sample.app-1/lib/arm/libpjsua2.so (pj::Endpoint::utilLogWrite(pj::LogEntry&)+180)
05-04 10:32:10.544 I/DEBUG ( 281): #08 pc 0015d734 /data/app/com.sample.app-1/lib/arm/libpjsua2.so (pj::Endpoint::logFunc(int, char const*, int)+292)
05-04 10:32:10.544 I/DEBUG ( 281): #09 pc 001a9fe0 /data/app/com.sample.app-1/lib/arm/libpjsua2.so (log_writer+164)
05-04 10:32:10.544 I/DEBUG ( 281): #10 pc 0034420c /data/app/com.sample.app-1/lib/arm/libpjsua2.so (pj_log+2324)
05-04 10:32:10.544 I/DEBUG ( 281): #11 pc 0034436c /data/app/com.sample.app-1/lib/arm/libpjsua2.so (pj_log_4+44)
05-04 10:32:10.544 I/DEBUG ( 281): #12 pc 0025c9c4 /data/app/com.sample.app-1/lib/arm/libpjsua2.so (play_cb+568)
05-04 10:32:10.544 I/DEBUG ( 281): #13 pc 0029c454 /data/app/com.sample.app-1/lib/arm/libpjsua2.so (bqPlayerCallback+420)
05-04 10:32:10.544 I/DEBUG ( 281): #14 pc 00008daf /system/lib/libwilhelm.so
05-04 10:32:10.544 I/DEBUG ( 281): #15 pc 000559fd /system/lib/libmedia.so (android::AudioTrack::processAudioBuffer()+1156)
05-04 10:32:10.544 I/DEBUG ( 281): #16 pc 00055c69 /system/lib/libmedia.so (android::AudioTrack::AudioTrackThread::threadLoop()+168)
05-04 10:32:10.544 I/DEBUG ( 281): #17 pc 0000ef55 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+112)
05-04 10:32:10.544 I/DEBUG ( 281): #18 pc 0000eac5 /system/lib/libutils.so
05-04 10:32:10.544 I/DEBUG ( 281): #19 pc 000137b3 /system/lib/libc.so (__pthread_start(void*)+30)
05-04 10:32:10.544 I/DEBUG ( 281): #20 pc 00011893 /system/lib/libc.so (__start_thread+6)
我怀疑它试图从错误的线程写入日志,但我不知道如何修复它.禁用 LogWriter 应用程序不会引发此错误.
I suspected that it's trying to write logs from the wrong thread, but I have no clue on how to fix it. Disabling LogWriter the app does not throw this error.
感谢任何帮助.
推荐答案
我遇到了同样的问题.我不知道它现在是否真实,但我解决了,正如 官方文档.请注意垃圾收集问题:
I had the same issue. I don't know is it actual now, but I solved, as adviced in Official Doc. Where notice it is Garbage Collection problems:
class MyApp {
private MyLogWriter logWriter;
public void init()
{
/* Maintain reference to log writer to avoid premature cleanup by GC */
logWriter = new MyLogWriter();
epConfig.getLogConfig.setWriter(logWriter);
}
}
这篇关于为 Android 启用 PJSIP 登录强制关闭应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!