Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b53670ae authored by Robert Carr's avatar Robert Carr
Browse files

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
parent 5366cfbe
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -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();
        });
    }