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 b5ccf5c41..4bb26be72 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java @@ -415,12 +415,20 @@ public class WebRTCWrapper { } void restartIce() { - executorService.execute(() -> { - final PeerConnection peerConnection = requirePeerConnection(); - setIsReadyToReceiveIceCandidates(false); - peerConnection.restartIce(); - requirePeerConnection().restartIce();} - ); + executorService.execute( + () -> { + final PeerConnection peerConnection; + try { + peerConnection = requirePeerConnection(); + } catch (final PeerConnectionNotInitialized e) { + Log.w( + EXTENDED_LOGGING_TAG, + "PeerConnection vanished before we could execute restart"); + return; + } + setIsReadyToReceiveIceCandidates(false); + peerConnection.restartIce(); + }); } public void setIsReadyToReceiveIceCandidates(final boolean ready) {