Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

Unified Diff: webrtc/api/java/android/org/webrtc/SurfaceViewRenderer.java

Issue 2111933002: Android SurfaceViewRenderer: Fix deadlock (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressing samis comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/java/android/org/webrtc/SurfaceViewRenderer.java
diff --git a/webrtc/api/java/android/org/webrtc/SurfaceViewRenderer.java b/webrtc/api/java/android/org/webrtc/SurfaceViewRenderer.java
index c37d24770f3d754e685cdbae6291c6c422a0ecdc..4b79fe49bf99d22d7fdc4155f971c1a01afc275f 100644
--- a/webrtc/api/java/android/org/webrtc/SurfaceViewRenderer.java
+++ b/webrtc/api/java/android/org/webrtc/SurfaceViewRenderer.java
@@ -295,7 +295,6 @@ public class SurfaceViewRenderer extends SurfaceView
VideoRenderer.renderFrameDone(pendingFrame);
}
pendingFrame = frame;
- updateFrameDimensionsAndReportEvents(frame);
renderThreadHandler.post(renderFrameRunnable);
}
}
@@ -321,23 +320,26 @@ public class SurfaceViewRenderer extends SurfaceView
// View layout interface.
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
+ final boolean isNewSize;
synchronized (layoutLock) {
if (frameWidth == 0 || frameHeight == 0) {
super.onMeasure(widthSpec, heightSpec);
return;
}
desiredLayoutSize = getDesiredLayoutSize(widthSpec, heightSpec);
- if (desiredLayoutSize.x != getMeasuredWidth() || desiredLayoutSize.y != getMeasuredHeight()) {
- // Clear the surface asap before the layout change to avoid stretched video and other
- // render artifacs. Don't wait for it to finish because the IO thread should never be
- // blocked, so it's a best-effort attempt.
- synchronized (handlerLock) {
- if (renderThreadHandler != null) {
- renderThreadHandler.postAtFrontOfQueue(makeBlackRunnable);
- }
+ isNewSize = (desiredLayoutSize.x != getMeasuredWidth()
+ || desiredLayoutSize.y != getMeasuredHeight());
+ setMeasuredDimension(desiredLayoutSize.x, desiredLayoutSize.y);
+ }
+ if (isNewSize) {
+ // Clear the surface asap before the layout change to avoid stretched video and other
+ // render artifacs. Don't wait for it to finish because the IO thread should never be
+ // blocked, so it's a best-effort attempt.
+ synchronized (handlerLock) {
+ if (renderThreadHandler != null) {
+ renderThreadHandler.postAtFrontOfQueue(makeBlackRunnable);
}
}
- setMeasuredDimension(desiredLayoutSize.x, desiredLayoutSize.y);
}
}
@@ -446,6 +448,7 @@ public class SurfaceViewRenderer extends SurfaceView
frame = pendingFrame;
pendingFrame = null;
}
+ updateFrameDimensionsAndReportEvents(frame);
if (eglBase == null || !eglBase.hasSurface()) {
Logging.d(TAG, getResourceName() + "No surface to draw on");
VideoRenderer.renderFrameDone(frame);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698