How to solve App Crash when end call Android WebRTC

Viewed 346

I'm using WebRTC Android Library to create video call app. But sometimes, when I finish the Activity, app will get crash. I don't know is my close flow wrong or library itself.

I've notice that error point to signal_thread. Because this app designed using in local network, so I didn't add STUN and IceCandidate Server to PeerConnection.

Also, I'm using latest library

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

Code when I close up:

    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");
}

Error message when crash:

--------- 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)

Also, I'm using add2lin to find error on libjingle_peerconnection_so.so, and that tool show the function below:

Java_org_webrtc_TurnCustomizer_nativeFreeTurnCustomizer
Java_org_webrtc_Logging_nativeLog
Java_org_webrtc_Metrics_nativeGetAndReset
1 Answers

I faced the same issue few days back, the following might solve your problem:

  1. Invalidating Android Studio's cache and restarting it.
  2. Re-install the app(if physical device) or wipe data and do cool boot(in case of Emulator).
Related