Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EasyRTMP推流过程概率性崩溃 #5

Closed
LinChengChun opened this issue Nov 30, 2017 · 1 comment
Closed

EasyRTMP推流过程概率性崩溃 #5

LinChengChun opened this issue Nov 30, 2017 · 1 comment

Comments

@LinChengChun
Copy link

11-30 09:28:15.613 1828 1828 F art : art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI GetObjectClass called with pending exception 'java.lang.StackOverflowError' thrown in void android.os.MessageQueue.nativePollOnce(long, int):-2
11-30 09:28:15.613 1828 1828 F art : art/runtime/check_jni.cc:65] in call to GetObjectClass
11-30 09:28:15.613 1828 1828 F art : art/runtime/check_jni.cc:65] from void android.os.MessageQueue.nativePollOnce(long, int)
11-30 09:28:15.613 1828 1828 F art : art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
11-30 09:28:15.613 1828 1828 F art : art/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x7285d000 self=0xb760c4a0
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] | sysTid=1828 nice=0 cgrp=default sched=0/0 handle=0xb6fb3bec
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] | state=R schedstat=( 127301785518 30307010498 276105 ) utm=11164 stm=1566 core=2 HZ=100
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] | stack=0xbe75f000-0xbe761000 stackSize=8MB
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #00 pc 00004e64 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #1 pc 00003665 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #2 pc 00256ba1 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits >&, int, char const*, art::mirror::ArtMethod*)+84)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #3 pc 00238fdf /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits >&) const+158)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #4 pc 000b0fdb /system/lib/libart.so (art::JniAbort(char const*, char const*)+610)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #5 pc 000b1715 /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+68)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #6 pc 000b49cf /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*, int, char const*)+1346)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #7 pc 000b6d2d /system/lib/libart.so (art::CheckJNI::GetObjectClass(_JNIEnv*, _jobject*)+28)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #8 pc 00006db1 /data/app/org.easydarwin.easyrtmp-2/lib/arm/libeasyrtmp.so (jni_callback(_jobject*, int)+40)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #9 pc 00006dff /data/app/org.easydarwin.easyrtmp-2/lib/arm/libeasyrtmp.so (__EasyRTMP_Callback(int, char*, __EASY_RTMP_STATE_T, void*)+10)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #10 pc 00008bf8 /data/app/org.easydarwin.easyrtmp-2/lib/arm/libeasyrtmp.so (__PushProcThread(void*)+592)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #11 pc 0001659b /system/lib/libc.so (__pthread_start(void*)+30)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] native: #12 pc 000144c3 /system/lib/libc.so (__start_thread+6)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] at android.os.MessageQueue.nativePollOnce(Native method)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] at android.os.MessageQueue.next(MessageQueue.java:143)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] at android.os.Looper.loop(Looper.java:122)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] at android.app.ActivityThread.main(ActivityThread.java:5280)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] at java.lang.reflect.Method.invoke!(Native method)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] at java.lang.reflect.Method.invoke(Method.java:372)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)
11-30 09:28:15.614 1828 1828 F art : art/runtime/check_jni.cc:65]
从log来看,是本底层报了的错误。麻烦尽快修复。^-^

@LinChengChun
Copy link
Author

经过添加log发现是由于连接异常断开,导致出现崩溃。更换网络环境后,没有出现奔溃,可能是连接断开情况下,上层依然往下层push数据导致堆栈溢出。
public class EasyRTMP implements Pusher {
private boolean isRTMPConnectNormal = false; // 用于标记连接是否正常

@OverRide
public synchronized void initPush(final String url, final Context context, final InitCallback callback, int fps) {
/*
*本Key为3个月临时授权License,如需商业使用,请邮件至[email protected]申请此产品的授权。
*/
Log.e(TAG, "startpush begin");
mPusherObj = init(url, RTMP_KEY, context, new OnInitPusherCallback() {
int code = Integer.MAX_VALUE;
@OverRide
public void onCallback(int code) {
if (code != this.code) {
this.code = code;
switch (code) {
case EasyRTMP.OnInitPusherCallback.CODE.EASY_ACTIVATE_INVALID_KEY:
// sendMessage("无效Key");
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_ACTIVATE_SUCCESS:
// sendMessage("激活成功");
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_CONNECTING:
// sendMessage("连接中");
isRTMPConnectNormal = false; // 标记连接断开
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_CONNECTED:
// sendMessage("连接成功");
isRTMPConnectNormal = true; // 标记连接成功
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_CONNECT_FAILED:
// sendMessage("连接失败");
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_CONNECT_ABORT:
// sendMessage("连接异常中断");
isRTMPConnectNormal = false; // 标记连接断开
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_PUSHING:
// sendMessage("推流中");
isRTMPConnectNormal = true; // 标记连接成功
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_DISCONNECTED:
// sendMessage("断开连接");
isRTMPConnectNormal = false; // 标记连接断开
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_ACTIVATE_PLATFORM_ERR:
// sendMessage("平台不匹配");
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_ACTIVATE_COMPANY_ID_LEN_ERR:
// sendMessage("断授权使用商不匹配");
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_ACTIVATE_PROCESS_NAME_LEN_ERR:
// sendMessage("进程名称长度不匹配");
break;
}
Log.e("cclin", "RTMP 当前连接状态:"+isRTMPConnectNormal);
if (callback != null) callback.onCallback(code);
}
}
},
fps);
Log.e(TAG, "startpush end");
}

public synchronized void push(byte[] data, int offset, int length, long timestamp, int type){
    mTotal += length;
    if (type == 1){
        mTotalFrms++;
    }
    long interval = System.currentTimeMillis() - pPreviewTS;
    if (interval >= 3000){
        long bps = mTotal * 1000 / (interval);
        long fps = mTotalFrms * 1000 / (interval);
        Log.i(TAG, String.format("bps:%d, fps:%d", fps, bps)+"  myTid = "+android.os.Process.myTid());
        pPreviewTS = System.currentTimeMillis();
        mTotal = 0;
        mTotalFrms = 0;
        if (mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK)
            BUS.post(new StreamStatBack((int)fps, (int)bps));
        else
            BUS.post(new StreamStatFront((int)fps, (int)bps));
    }
    if (mPusherObj == 0 || !isRTMPConnectNormal) return;

    push(mPusherObj, data, offset, length, timestamp,type);
}

不知这样修改,是否能够优化push逻辑呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant