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

Commit 086ee8ad authored by Kean Mariotti's avatar Kean Mariotti Committed by Android (Google) Code Review
Browse files

Merge "viewcapture: fix NPE (WindowListener#mRoot)" into main

parents 5945a00f ecb3891d
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -328,7 +328,14 @@ public abstract class ViewCapture {
        @UiThread
        public void onDraw() {
            Trace.beginSection("vc#onDraw");
            captureViewTree(mRoot, mViewPropertyRef);
            try {
                View root = mRoot;
                if (root == null) {
                    // Handle the corner case where another (non-UI) thread
                    // concurrently stopped the capture and set mRoot = null
                    return;
                }
                captureViewTree(root, mViewPropertyRef);
                ViewPropertyRef captured = mViewPropertyRef.next;
                if (captured != null) {
                    captured.callback = mCaptureCallback;
@@ -336,8 +343,10 @@ public abstract class ViewCapture {
                    mBgExecutor.execute(captured);
                }
                mIsFirstFrame = false;
            } finally {
                Trace.endSection();
            }
        }

        /**
         * Copy clean views from the last frame on the background thread. Clean views are