如何解决Android WebRTC通话结束时App崩溃的问题

问题描述 投票:0回答:2

我正在使用 WebRTC Android 库来创建视频通话应用程序。 但有时,当我完成活动时,应用程序会崩溃。 我不知道是我的关闭流程错误还是库本身错误。

我注意到错误指向 signal_thread。 因为这个应用程序是在本地网络中使用的,所以我没有将 STUN 和 IceCandidate Server 添加到 PeerConnection 中。

另外,我正在使用最新的库

implementation 'org.webrtc:google-webrtc:1.0.32006'

关闭时编码:

    private void close() {

    if (localVideoView != null) {
        localVideoView.release();
        localVideoView = null;
    }

    if (remoteVideoView != null) {
        remoteVideoView.release();
        remoteVideoView = null;
    }

    if (peerConnection != null) {
        Log.e(TAG, "peerConnection close");
        peerConnection.dispose();
    }

    if (audioSource != null) {
        audioSource.dispose();
        audioSource = null;
        Log.e(TAG, "audioSource close");
    }

    if (videoCapturer != null) {
        try {
            videoCapturer.stopCapture();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        videoCapturer.dispose();
        videoCapturer = null;
        Log.e(TAG, "videoCapture close");
    }

    if (videoSource != null) {
        videoSource.dispose();
        videoSource = null;
        Log.e(TAG, "videoSource close");
    }

    if (surfaceTextureHelper != null) {
        Log.e(TAG, "surfaceTextureHelper close");
        surfaceTextureHelper.dispose();
        surfaceTextureHelper = null;
    }

    if (mediaStreamLocal != null) {
        while (mediaStreamLocal.audioTracks.size() > 0) {
            mediaStreamLocal.removeTrack(mediaStreamLocal.audioTracks.get(0));
            Log.e(TAG, "audioTrack close");
        }
        while (mediaStreamLocal.videoTracks.size() > 0) {
            mediaStreamLocal.removeTrack(mediaStreamLocal.videoTracks.get(0));
            Log.e(TAG, "videoTrack close");
        }
        mediaStreamLocal = null;
        Log.e(TAG, "mediaStream close");
    }

    if (peerConnectionFactory != null) {
        peerConnectionFactory.dispose();
        Log.e(TAG, "peerConnectionFactory close");
    }

    if (eglBaseContext != null) {
        Log.e(TAG, "eglBaseContext close");
        eglBaseContext = null;
    }

    PeerConnectionFactory.stopInternalTracingCapture();
    PeerConnectionFactory.shutdownInternalTracer();
    Log.e(TAG, "close done");
}

崩溃时的错误消息:

--------- beginning of crash
03-03 14:05:31.630 26351 28454 F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 28454 (signaling_threa), pid 26351 (getupsetting_ap)
03-03 14:05:31.753 28489 28489 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
03-03 14:05:31.758 28489 28489 I crash_dump64: performing dump of process 26351 (target tid = 28454)
03-03 14:05:31.764 28489 28489 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-03 14:05:31.764 28489 28489 F DEBUG   : Build fingerprint: 'asus/WW_Z01RD/ASUS_Z01R_1:10/QKQ1.191008.001/WW_100.10.107.123_20210131:user/release-keys'
03-03 14:05:31.764 28489 28489 F DEBUG   : Revision: '0'
03-03 14:05:31.764 28489 28489 F DEBUG   : ABI: 'arm64'
03-03 14:05:31.765 28489 28489 F DEBUG   : Timestamp: 2022-03-03 14:05:31+0800
03-03 14:05:31.765 28489 28489 F DEBUG   : pid: 26351, tid: 28454, name: signaling_threa  >>> org.getupsetting_ap <<<
03-03 14:05:31.765 28489 28489 F DEBUG   : uid: 10614
03-03 14:05:31.765 28489 28489 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
03-03 14:05:31.765 28489 28489 F DEBUG   : Cause: null pointer dereference
03-03 14:05:31.765 28489 28489 F DEBUG   :     x0  0000000000000000  x1  0000000000000005  x2  0000000000000001  x3  000000739b95d000
03-03 14:05:31.765 28489 28489 F DEBUG   :     x4  0000000000000001  x5  00000073a43da8a5  x6  5500ff315500ff30  x7  7f7f7f7f7f7f7f7f
03-03 14:05:31.765 28489 28489 F DEBUG   :     x8  88b5a5d1c44b6fe5  x9  88b5a5d1c44b6fe5  x10 0000000000430000  x11 0000000000000001
03-03 14:05:31.765 28489 28489 F DEBUG   :     x12 0000000000000000  x13 0000000012f80670  x14 0000000000000012  x15 00000000000000ff
03-03 14:05:31.765 28489 28489 F DEBUG   :     x16 0000000000000000  x17 00000000000000d7  x18 000000736bedc000  x19 000000739be3aa00
03-03 14:05:31.765 28489 28489 F DEBUG   :     x20 0000000000000005  x21 000000736de1c020  x22 000000736de1ba10  x23 000000736de1c020
03-03 14:05:31.765 28489 28489 F DEBUG   :     x24 000000736ef9dab8  x25 00000000ffffffff  x26 000000736de1c020  x27 000000748e620020
03-03 14:05:31.765 28489 28489 F DEBUG   :     x28 0000000000000000  x29 000000736de1bac0
03-03 14:05:31.765 28489 28489 F DEBUG   :     sp  000000736de1ba00  lr  000000736f545700  pc  000000736f54570c
03-03 14:05:31.767 28489 28489 F DEBUG   : 
03-03 14:05:31.767 28489 28489 F DEBUG   : backtrace:
03-03 14:05:31.767 28489 28489 F DEBUG   :       #00 pc 000000000062870c  /data/app/org.getupsetting_ap-nOEyGd0pleQwgSv_ZsLzkw==/base.apk!libjingle_peerconnection_so.so (offset 0x16c000) (BuildId: d011a5fc83d6e795)
03-03 14:05:31.767 28489 28489 F DEBUG   :       #01 pc 0000000000628440  /data/app/org.getupsetting_ap-nOEyGd0pleQwgSv_ZsLzkw==/base.apk!libjingle_peerconnection_so.so (offset 0x16c000) (BuildId: d011a5fc83d6e795)
03-03 14:05:31.767 28489 28489 F DEBUG   :       #02 pc 000000000026f3b8  /data/app/org.getupsetting_ap-nOEyGd0pleQwgSv_ZsLzkw==/base.apk!libjingle_peerconnection_so.so (offset 0x16c000) (BuildId: d011a5fc83d6e795)
03-03 14:05:31.767 28489 28489 F DEBUG   :       #03 pc 000000000025c08c  /data/app/org.getupsetting_ap-nOEyGd0pleQwgSv_ZsLzkw==/base.apk!libjingle_peerconnection_so.so (offset 0x16c000) (BuildId: d011a5fc83d6e795)
03-03 14:05:31.767 28489 28489 F DEBUG   :       #04 pc 000000000025b098  /data/app/org.getupsetting_ap-nOEyGd0pleQwgSv_ZsLzkw==/base.apk!libjingle_peerconnection_so.so (offset 0x16c000) (BuildId: d011a5fc83d6e795)
03-03 14:05:31.767 28489 28489 F DEBUG   :       #05 pc 000000000025c544  /data/app/org.getupsetting_ap-nOEyGd0pleQwgSv_ZsLzkw==/base.apk!libjingle_peerconnection_so.so (offset 0x16c000) (BuildId: d011a5fc83d6e795)
03-03 14:05:31.767 28489 28489 F DEBUG   :       #06 pc 00000000000e6890  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: cf739dbc84bcc78f7a1500721bfb3758)
03-03 14:05:31.767 28489 28489 F DEBUG   :       #07 pc 0000000000084b6c  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: cf739dbc84bcc78f7a1500721bfb3758)

另外,我正在使用 add2lin 来查找 libjingle_peerconnection_so.so 上的错误,该工具显示以下功能:

Java_org_webrtc_TurnCustomizer_nativeFreeTurnCustomizer
Java_org_webrtc_Logging_nativeLog
Java_org_webrtc_Metrics_nativeGetAndReset
android webrtc
2个回答
0
投票

几天前我遇到了同样的问题,以下内容可能会解决您的问题:

  1. 使 Android Studio 的缓存失效并重新启动。
  2. 重新安装应用程序(如果是物理设备)或擦除数据并执行冷启动(如果是模拟器)。

0
投票

我也面临同样的问题, 通过在 Icecandidate 中发送正确的数据解决了这个问题,之前我发送了空值。

你应该检查这 3 个属性

iceCandidate.setSdpMid(connectionGeneratedIceCandidate.sdpMid);
iceCandidate.setSdp(connectionGeneratedIceCandidate.sdp);
           iceCandidate.setSdpMLineIndex(connectionGeneratedIceCandidate.sdpMLineIndex);
© www.soinside.com 2019 - 2024. All rights reserved.