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

Commit cf1cceb2 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Add log and return if invalid leash onThemeChange

We are seeing reports on PipTransitionState#isInPip()
being bypassed onThemeChanged() despite the state=undefined
with getPinnedTaskLeash returning null, causing an NPE when
applying box shadows.

As a preliminary measure, we are adding a wtflog and returning
early to avoid crashes and to detect future cases during real time
usage.

Bug: 433316431
FLAG: EXEMPT bugfix
Test: N/A
Change-Id: I48273bb6eb87435fe6539f1b23398cc5fb43ef13
parent 758f4dc9
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Debug;
import android.util.Log;
import android.view.SurfaceControl;
import android.window.DesktopExperienceFlags;
@@ -382,6 +383,14 @@ public class PipController implements ConfigurationChangeListener,
        if (Flags.enablePipBoxShadows()) {
            if (mPipTransitionState.isInPip()) {
                SurfaceControl pipLeash = mPipTransitionState.getPinnedTaskLeash();
                if (pipLeash == null) {
                    // TODO (b/433316431): Remove once onThemeChange pip leash NPE is root-caused.
                    Log.wtf(TAG, String.format("""
                        PipTransitionState#isInPip()=true without a valid leash;
                        callers=%s""", Debug.getCallers(4)));
                    return;
                }

                mPipSurfaceTransactionHelper.onThemeChanged(mContext);
                SurfaceControl.Transaction tx = mSurfaceControlTransactionFactory.getTransaction();
                mPipSurfaceTransactionHelper.shadow(tx, pipLeash, true /* applyShadowRadius */);