nttcom / SkyWay-Android-SDK

[Deprecated]
3 stars 3 forks source link

Crash application when close mediastream during remote accept phone call. #7

Open tranductam2802 opened 7 years ago

tranductam2802 commented 7 years ago

When remote accept phone call, local perform hangup and disconnect to remote. The first, local check mediastream not null and are opened. Local call close method and get Null pointer exception after that.

Reproduce step:

Actual:

Expect:

Exception information:

io.skyway.skw_sample E/AndroidRuntime: FATAL EXCEPTION: io.skyway.peer.handler
    Process: io.skyway.skw_sample, PID: 17485
    method 'void io.skyway.Peer.Peer.queueWSMessage(org.json.JSONObject)' on a null object reference
    at io.skyway.Peer.BaseConnection$4.run(BaseConnection.java:867)
    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.os.HandlerThread.run(HandlerThread.java:61)

Reason:

this.provider.handler.postDelayed(new Runnable() {
        public void run() {
            if(null != BaseConnection.this._jsonOffer) {
                BaseConnection.this.provider.queueWSMessage(BaseConnection.this._jsonOffer);
                BaseConnection.this._jsonOffer = null;
            }
         }
}, 500L);

When remote accept phone call. this code above will be called. This code delay for 0.5 second and if local call close() method during this time, BaseConnection.this.provider will be clear. Only BaseConnection.this._jsonOffer had been checked null. Therefore, Null pointer exception occurred.