From f22e33e3ea4aef71b638e823249c73ae7db92d3e Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 1 Aug 2020 08:20:08 +0200 Subject: [PATCH] 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 --- .../conversations/xmpp/jingle/JingleRtpConnection.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index 830695831..efc6d6b49 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -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) {