From 637c0cb15a04cdafc875895128c1d381ce162030 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 1 Aug 2020 14:18:00 +0200 Subject: [PATCH] fixed rare race condition when receiving transport info right after WebRTCWrapper closes fixes #3849 --- .../conversations/xmpp/jingle/JingleRtpConnection.java | 8 ++++++-- .../siacs/conversations/xmpp/jingle/WebRTCWrapper.java | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) 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 ec4c67d64..bc3487ad6 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -239,7 +239,11 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } final Set> candidates = contentMap.contents.entrySet(); if (this.state == State.SESSION_ACCEPTED) { - processCandidates(candidates); + try { + processCandidates(candidates); + } catch (final WebRTCWrapper.PeerConnectionNotInitialized e) { + Log.w(Config.LOGTAG, id.account.getJid().asBareJid() + ": PeerConnection was not initialized when processing transport info. this usually indicates a race condition that can be ignored"); + } } else { pendingIceCandidates.push(candidates); } @@ -810,7 +814,7 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web final PeerConnection.PeerConnectionState state; try { state = webRTCWrapper.getState(); - } catch (final IllegalStateException e) { + } catch (final WebRTCWrapper.PeerConnectionNotInitialized 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; diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java index 58dfa4e5f..454bb7a73 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java @@ -552,7 +552,7 @@ public class WebRTCWrapper { private PeerConnection requirePeerConnection() { final PeerConnection peerConnection = this.peerConnection; if (peerConnection == null) { - throw new IllegalStateException("initialize PeerConnection first"); + throw new PeerConnectionNotInitialized(); } return peerConnection; } @@ -617,6 +617,14 @@ public class WebRTCWrapper { } } + public static class PeerConnectionNotInitialized extends IllegalStateException { + + private PeerConnectionNotInitialized() { + super("initialize PeerConnection first"); + } + + } + private static class CapturerChoice { private final CameraVideoCapturer cameraVideoCapturer; private final CameraEnumerationAndroid.CaptureFormat captureFormat;