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

Commit 6fc7651c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Catch unexpected detached view while creating FrameTracker" into tm-qpr-dev am: 05914b98

parents 06eab40b 05914b98
Loading
Loading
Loading
Loading
+35 −2
Original line number Original line Diff line number Diff line
@@ -439,6 +439,22 @@ public class InteractionJankMonitor {
    @VisibleForTesting
    @VisibleForTesting
    public FrameTracker createFrameTracker(Configuration config, Session session) {
    public FrameTracker createFrameTracker(Configuration config, Session session) {
        final View view = config.mView;
        final View view = config.mView;

        if (!config.hasValidView()) {
            boolean attached = false;
            boolean hasViewRoot = false;
            boolean hasRenderer = false;
            if (view != null) {
                attached = view.isAttachedToWindow();
                hasViewRoot = view.getViewRootImpl() != null;
                hasRenderer = view.getThreadedRenderer() != null;
            }
            Log.d(TAG, "create FrameTracker fails: view=" + view
                    + ", attached=" + attached + ", hasViewRoot=" + hasViewRoot
                    + ", hasRenderer=" + hasRenderer, new Throwable());
            return null;
        }

        final ThreadedRendererWrapper threadedRenderer =
        final ThreadedRendererWrapper threadedRenderer =
                view == null ? null : new ThreadedRendererWrapper(view.getThreadedRenderer());
                view == null ? null : new ThreadedRendererWrapper(view.getThreadedRenderer());
        final ViewRootWrapper viewRoot =
        final ViewRootWrapper viewRoot =
@@ -545,6 +561,7 @@ public class InteractionJankMonitor {


        // begin a new trace session.
        // begin a new trace session.
        tracker = createFrameTracker(conf, new Session(cujType, conf.mTag));
        tracker = createFrameTracker(conf, new Session(cujType, conf.mTag));
        if (tracker == null) return false;
        putTracker(cujType, tracker);
        putTracker(cujType, tracker);
        tracker.begin();
        tracker.begin();


@@ -1066,9 +1083,19 @@ public class InteractionJankMonitor {
                    msg.append("Must pass in a valid surface control if only instrument surface; ");
                    msg.append("Must pass in a valid surface control if only instrument surface; ");
                }
                }
            } else {
            } else {
                if (mView == null || !mView.isAttachedToWindow()) {
                if (!hasValidView()) {
                    shouldThrow = true;
                    shouldThrow = true;
                    msg.append("Null view or unattached view while instrumenting view; ");
                    boolean attached = false;
                    boolean hasViewRoot = false;
                    boolean hasRenderer = false;
                    if (mView != null) {
                        attached = mView.isAttachedToWindow();
                        hasViewRoot = mView.getViewRootImpl() != null;
                        hasRenderer = mView.getThreadedRenderer() != null;
                    }
                    String err = "invalid view: view=" + mView + ", attached=" + attached
                            + ", hasViewRoot=" + hasViewRoot + ", hasRenderer=" + hasRenderer;
                    msg.append(err);
                }
                }
            }
            }
            if (shouldThrow) {
            if (shouldThrow) {
@@ -1076,6 +1103,12 @@ public class InteractionJankMonitor {
            }
            }
        }
        }


        boolean hasValidView() {
            return mSurfaceOnly
                    || (mView != null && mView.isAttachedToWindow()
                    && mView.getViewRootImpl() != null && mView.getThreadedRenderer() != null);
        }

        /**
        /**
         * @return true if only instrumenting surface, false otherwise
         * @return true if only instrumenting surface, false otherwise
         */
         */