fixed race condition of WebRTCWrapper being closed before transitioning into terminal state

JingleRTPConnection shuts down the WebRTCWrapper before transitioning into a terminal state.
(This allows us to make sure it is actually closed when reaching that state);
However that means that, when we get a UI redrawn inbetween closing and transitioning we might
still be in SESSION_ACCEPTED but with no PeerConnection. This traditionally has triggered
an IllegalStateException on getting the EndUserState.
This commit catches the ISE and returns 'ENDING' instead.
Chances are that this is only visibiliy for a very brief time in the UI before the transition
triggers the UI to redraw with the proper state.

fixes #3848
This commit is contained in:
Daniel Gultsch 2020-08-01 08:20:08 +02:00
parent 47e3504a02
commit f22e33e3ea

View file

@ -807,7 +807,14 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
return RtpEndUserState.CONNECTING;
}
case SESSION_ACCEPTED:
final PeerConnection.PeerConnectionState state = webRTCWrapper.getState();
final PeerConnection.PeerConnectionState state;
try {
state = webRTCWrapper.getState();
} catch (final IllegalStateException e) {
//We usually close the WebRTCWrapper *before* transitioning so we might still
//be in SESSION_ACCEPTED even though the peerConnection has been torn down
return RtpEndUserState.ENDING_CALL;
}
if (state == PeerConnection.PeerConnectionState.CONNECTED) {
return RtpEndUserState.CONNECTED;
} else if (state == PeerConnection.PeerConnectionState.NEW || state == PeerConnection.PeerConnectionState.CONNECTING) {