fixed rare race condition when receiving transport info right after WebRTCWrapper closes

fixes #3849
This commit is contained in:
Daniel Gultsch 2020-08-01 14:18:00 +02:00
parent 1ae7d6be16
commit 637c0cb15a
2 changed files with 15 additions and 3 deletions

View File

@ -239,7 +239,11 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
}
final Set<Map.Entry<String, RtpContentMap.DescriptionTransport>> 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;

View File

@ -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;