Change YuvConverter.convert to catch GLExceptions and return null.

With https://webrtc-review.googlesource.com/c/src/+/222582,
I420 conversion is allowed to fail.

Bug: webrtc:12877
Change-Id: Iadae21ad889f084b8027206af4478223d7733d3e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/222653
Reviewed-by: Xavier Lepaul‎ <xalep@webrtc.org>
Commit-Queue: Fabian Bergmark <fabianbergmark@google.com>
Cr-Commit-Position: refs/heads/master@{#34320}
diff --git a/sdk/android/api/org/webrtc/YuvConverter.java b/sdk/android/api/org/webrtc/YuvConverter.java
index 0e2d505..9c00678 100644
--- a/sdk/android/api/org/webrtc/YuvConverter.java
+++ b/sdk/android/api/org/webrtc/YuvConverter.java
@@ -12,6 +12,8 @@
 
 import android.graphics.Matrix;
 import android.opengl.GLES20;
+import android.opengl.GLException;
+import android.support.annotation.Nullable;
 import java.nio.ByteBuffer;
 import org.webrtc.VideoFrame.I420Buffer;
 import org.webrtc.VideoFrame.TextureBuffer;
@@ -20,7 +22,9 @@
  * Class for converting OES textures to a YUV ByteBuffer. It can be constructed on any thread, but
  * should only be operated from a single thread with an active EGL context.
  */
-public class YuvConverter {
+public final class YuvConverter {
+  private static final String TAG = "YuvConverter";
+
   private static final String FRAGMENT_SHADER =
       // Difference in texture coordinate corresponding to one
       // sub-pixel in the x direction.
@@ -122,9 +126,17 @@
   }
 
   /** Converts the texture buffer to I420. */
+  @Nullable
   public I420Buffer convert(TextureBuffer inputTextureBuffer) {
-    threadChecker.checkIsOnValidThread();
+    try {
+      return convertInternal(inputTextureBuffer);
+    } catch (GLException e) {
+      Logging.w(TAG, "Failed to convert TextureBuffer", e);
+    }
+    return null;
+  }
 
+  private I420Buffer convertInternal(TextureBuffer inputTextureBuffer) {
     TextureBuffer preparedBuffer = (TextureBuffer) videoFrameDrawer.prepareBufferForViewportSize(
         inputTextureBuffer, inputTextureBuffer.getWidth(), inputTextureBuffer.getHeight());