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

Commit bc7616ea authored by Romain Guy's avatar Romain Guy
Browse files

Postpone DisplayList recycling when detached from window

This was causing a crash in apps that remove views during a draw pass.

Change-Id: I1c4621639fe920291b2c6fb7bfd17a69101a1329
parent acdd4b9c
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.view;

import android.os.Handler;

/**
 * A display lists records a series of graphics related operation and can replay
 * them later. Display lists are usually built by recording operations on a
@@ -26,6 +28,13 @@ package android.view;
 * @hide 
 */
public abstract class DisplayList {
    private final Runnable mInvalidate = new Runnable() {
        @Override
        public void run() {
            invalidate();
        }
    };

    /**
     * Flag used when calling
     * {@link HardwareCanvas#drawDisplayList(DisplayList, int, int, android.graphics.Rect, int)}.
@@ -56,6 +65,13 @@ public abstract class DisplayList {
     */
    public abstract void invalidate();

    /**
     * Posts a call to {@link #invalidate()} in the specified handler.
     */
    final void postInvalidate(Handler handler) {
        handler.post(mInvalidate);
    }

    /**
     * Returns whether the display list is currently usable. If this returns false,
     * the display list should be re-recorded prior to replaying it.
+1 −1
Original line number Diff line number Diff line
@@ -9975,7 +9975,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
        destroyLayer();
        if (mDisplayList != null) {
            mDisplayList.invalidate();
            mDisplayList.postInvalidate(mAttachInfo.mHandler);
        }
        if (mAttachInfo != null) {