diff --git a/sdk/android/api/org/webrtc/SurfaceTextureHelper.java b/sdk/android/api/org/webrtc/SurfaceTextureHelper.java index f11b70b6d6..b8f5624d89 100644 --- a/sdk/android/api/org/webrtc/SurfaceTextureHelper.java +++ b/sdk/android/api/org/webrtc/SurfaceTextureHelper.java @@ -205,6 +205,7 @@ public class SurfaceTextureHelper { handler.post(() -> { this.textureWidth = textureWidth; this.textureHeight = textureHeight; + tryDeliverTextureFrame(); }); } @@ -286,6 +287,12 @@ public class SurfaceTextureHelper { if (isQuitting || !hasPendingTexture || isTextureInUse || listener == null) { return; } + if (textureWidth == 0 || textureHeight == 0) { + // Information about the resolution needs to be provided by a call to setTextureSize() before + // frames are produced. + Logging.w(TAG, "Texture size has not been set."); + return; + } isTextureInUse = true; hasPendingTexture = false; @@ -297,9 +304,6 @@ public class SurfaceTextureHelper { if (timestampAligner != null) { timestampNs = timestampAligner.translateTimestamp(timestampNs); } - if (textureWidth == 0 || textureHeight == 0) { - throw new RuntimeException("Texture size has not been set."); - } final VideoFrame.Buffer buffer = new TextureBufferImpl(textureWidth, textureHeight, TextureBuffer.Type.OES, oesTextureId, RendererCommon.convertMatrixToAndroidGraphicsMatrix(transformMatrix), handler,