Search code examples
androidwebrtc

Fatal signal6 during disposing PeerConnection WebRTC


I am using WebRTC for voice calling everything work fine. When Call hangUp i am disposing the PeerConnection as follows before finishing Call Activity .

 executor.execute(() -> {
        if (peerConnectionFactory != null) {
            peerConnectionFactory.dispose();
            peerConnectionFactory=null;
        }
        if (localPeer != null) {
            localPeer.dispose();
            localPeer=null;
        }
    });

I am getting fatal-signal-6. I have read what-is-fatal-signal-6 . Its says Do not block the UI thread, this can cause a SIGABRT as the OS will kill a non-responsive app . But i am calling it on non Ui thread and still getting the issue.

Fatal signal 6 (SIGABRT) at 0x00007e2f (code=-6), thread 32390 (worker_thread)

Please look into issue.


Solution

  • I was doing wrong during closing the peerConnection . Correct flow of closing connection is below.

     executor.execute(() -> {
                if (peerConnectionFactory != null) {
                    peerConnectionFactory.stopAecDump();
                }
                if (localPeer != null) {
                    localPeer.dispose();
                    localPeer = null;
                }
                if (peerConnectionFactory != null) {
                    peerConnectionFactory.dispose();
                    peerConnectionFactory = null;
                }
                PeerConnectionFactory.stopInternalTracingCapture();
                PeerConnectionFactory.shutdownInternalTracer();
            });