~singpolyma/cheogram-android

80d195d35eba1d1b12f9efbb86734c33d234ad61 — Daniel Gultsch 1 year, 5 months ago 16f1405
avoid race condition when restarting ICE
1 files changed, 14 insertions(+), 6 deletions(-)

M src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java
M src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java => src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java +14 -6
@@ 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) {