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

Commit f0a60a9c authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Workaround for leaked dim layer.

Tasks are some how leaking their dim layer. The root cause of Task
not properly cleaning-up its dim layer in Task.removeImmediately()
hasn't being identified, but the CL will prevent user devices from
getting into a bad state until we figure-out the cause for the leak.

Note that when this occurs the task has been completely removed from
the system and the only reference left to it is for the dim layer...

Bug: 34395537
Test: This is a workaround until the real problem is identified.
Change-Id: Id8d45edb3b6858be82e4f057ae3da480da4f4b59
parent 96415fb6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ public class DimLayer {
        boolean dimFullscreen();
        /** Returns the display info. of the dim layer user. */
        DisplayInfo getDisplayInfo();
        /** Returns true if the dim layer user is currently attached to a display */
        boolean isAttachedToDisplay();
        /** Gets the bounds of the dim layer user. */
        void getDimBounds(Rect outBounds);
        String toShortString();
+15 −2
Original line number Diff line number Diff line
@@ -191,8 +191,21 @@ class DimLayerController {
        boolean result = false;

        for (int i = mState.size() - 1; i >= 0; i--) {
            DimLayer.DimLayerUser user = mState.keyAt(i);
            DimLayerState state = mState.valueAt(i);
            final DimLayer.DimLayerUser user = mState.keyAt(i);
            final DimLayerState state = mState.valueAt(i);

            if (!user.isAttachedToDisplay()) {
                // Leaked dim user that is no longer attached to the display. Go ahead and clean it
                // clean-up and log what happened.
                // TODO: This is a work around for b/34395537 as the dim user should have cleaned-up
                // it self when it was detached from the display. Need to investigate how the dim
                // user is leaking...
                Slog.wtfStack(TAG_WM, "Leaked dim user=" + user.toShortString()
                        + " state=" + state);
                removeDimLayerUser(user);
                continue;
            }

            // We have to check that we are actually the shared fullscreen layer
            // for this path. If we began as non fullscreen and became fullscreen
            // (e.g. Docked stack closing), then we may not be the shared layer
+5 −0
Original line number Diff line number Diff line
@@ -834,6 +834,11 @@ public class DockedStackDividerController implements DimLayerUser {
        return mDisplayContent.getDisplayInfo();
    }

    @Override
    public boolean isAttachedToDisplay() {
        return mDisplayContent != null;
    }

    @Override
    public void getDimBounds(Rect outBounds) {
        // This dim layer user doesn't need this.
+6 −1
Original line number Diff line number Diff line
@@ -628,7 +628,12 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU

    @Override
    public DisplayInfo getDisplayInfo() {
        return mStack.getDisplayContent().getDisplayInfo();
        return getDisplayContent().getDisplayInfo();
    }

    @Override
    public boolean isAttachedToDisplay() {
        return getDisplayContent() != null;
    }

    void forceWindowsScaleable(boolean force) {
+5 −0
Original line number Diff line number Diff line
@@ -692,6 +692,11 @@ class TaskPositioner implements DimLayer.DimLayerUser {
        return mTask.mStack.getDisplayInfo();
    }

    @Override
    public boolean isAttachedToDisplay() {
        return mTask != null && mTask.getDisplayContent() != null;
    }

    @Override
    public void getDimBounds(Rect out) {
        // This dim layer user doesn't need this.
Loading