From 63ba21a5127783a96b31da1f8566df9d016b551a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 27 May 2020 15:53:05 +0200 Subject: [PATCH] catch ISE cause by race when displaying video track. fixes #3752 --- .../siacs/conversations/ui/RtpSessionActivity.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 4a68d1b03..bf691db6c 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -764,14 +764,14 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe //paint local view over remote view binding.localVideo.setZOrderMediaOverlay(true); binding.localVideo.setMirror(requireRtpConnection().isFrontCamera()); - localVideoTrack.get().addSink(binding.localVideo); + addSink(localVideoTrack.get(), binding.localVideo); } else { binding.localVideo.setVisibility(View.GONE); } final Optional remoteVideoTrack = getRemoteVideoTrack(); if (remoteVideoTrack.isPresent()) { ensureSurfaceViewRendererIsSetup(binding.remoteVideo); - remoteVideoTrack.get().addSink(binding.remoteVideo); + addSink(remoteVideoTrack.get(), binding.remoteVideo); if (state == RtpEndUserState.CONNECTED) { binding.appBarLayout.setVisibility(View.GONE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); @@ -791,6 +791,14 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe } } + private static void addSink(final VideoTrack videoTrack, final SurfaceViewRenderer surfaceViewRenderer) { + try { + videoTrack.addSink(surfaceViewRenderer); + } catch (final IllegalStateException e) { + Log.e(Config.LOGTAG,"possible race condition on trying to display video track. ignoring",e); + } + } + private Optional getLocalVideoTrack() { final JingleRtpConnection connection = this.rtpConnectionReference != null ? this.rtpConnectionReference.get() : null; if (connection == null) {