RestComm / restcomm-android-sdk

Android Mobile SDK to easily integrate communication features (WebRTC, messaging, presence, voice, video, screensharing) based on RestComm into native Mobile Applications
http://www.restcomm.com/
GNU Affero General Public License v3.0
153 stars 109 forks source link

NetworkOnMainThreadException when exiting Olympus when using TLS #317

Closed atsakiridis closed 8 years ago

atsakiridis commented 8 years ago

Turns out sipStack.deleteSipProvider(sipProvider) takes considerable longer to execute when using TLS.

06-29 16:14:41.088 12043-12043/com.telestax.restcomm_olympus E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.telestax.restcomm_olympus, PID: 12043
android.os.NetworkOnMainThreadException
    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
    at com.android.org.conscrypt.OpenSSLSocketImpl.shutdownAndFreeSslNative(OpenSSLSocketImpl.java:1131)
    at com.android.org.conscrypt.OpenSSLSocketImpl.close(OpenSSLSocketImpl.java:1126)
    at android.gov.nist.javax.sip.stack.TLSMessageChannel.close(TLSMessageChannel.java:180)
    at android.gov.nist.javax.sip.stack.ConnectionOrientedMessageChannel.close(ConnectionOrientedMessageChannel.java:127)
    at android.gov.nist.javax.sip.stack.TLSMessageProcessor.stop(TLSMessageProcessor.java:225)
    at android.gov.nist.javax.sip.SipProviderImpl.removeListeningPoints(SipProviderImpl.java:1082)
    at android.gov.nist.javax.sip.SipStackImpl.deleteSipProvider(SipStackImpl.java:1691)
    at org.mobicents.restcomm.android.sipua.impl.SipManager.unbind(SipManager.java:282)
    at org.mobicents.restcomm.android.sipua.impl.SipManager.shutdown(SipManager.java:265)
    at org.mobicents.restcomm.android.sipua.impl.DeviceImpl.Shutdown(DeviceImpl.java:143)
    at org.mobicents.restcomm.android.client.sdk.RCDevice$1.run(RCDevice.java:278)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5466)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
atsakiridis commented 8 years ago

Fixed with refactoring activity. Although this activity spanned multiple commits, here's one of the last: 1969681