SurfaceView: Avoid over-reporting DRAW_FINISHED.

To some extent we rely on the app to call the draw callback
if they want the app to work properly, but this case is fairly easy
to detect, so why not prevent it and provide a helpful log.

Bug: 62051758
Test: Warm start camera a few times. go/wm-smoke.
Change-Id: I39f4e015bfa15a1e0c37dba70b4a700803a6a274
This commit is contained in:
Robert Carr
2017-05-25 18:20:49 -07:00
parent 5366cfbef3
commit b53670aecf

View File

@@ -264,6 +264,22 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
updateSurface();
}
private void performDrawFinished() {
if (mPendingReportDraws > 0) {
mDrawFinished = true;
if (mAttachedToWindow) {
mParent.requestTransparentRegion(SurfaceView.this);
notifyDrawFinished();
invalidate();
}
} else {
Log.e(TAG, System.identityHashCode(this) + "finished drawing"
+ " but no pending report draw (extra call"
+ " to draw completion runnable?)");
}
}
void notifyDrawFinished() {
ViewRootImpl viewRoot = getViewRootImpl();
if (viewRoot != null) {
@@ -729,12 +745,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
}
runOnUiThread(() -> {
mDrawFinished = true;
if (mAttachedToWindow) {
mParent.requestTransparentRegion(SurfaceView.this);
notifyDrawFinished();
invalidate();
}
performDrawFinished();
});
}