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

Commit 067b5bf1 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Fix ANR for real

Imagine the following sequence:
- Activity is requested to to be visible.
- Activity draws, app transition starts.
- Activity is requested to be invisible, but transition is still
pending because of another opening activity that hasn't drawn yet.
hiddenRequested=true
- First app transition finishes. clientHidden=true at the end of
the transition because hiddenRequested==true
- Activity is requested to be visible again. However, hidden==false
since we haven't started the new transition yet.

But then BOOOOM clientHidden is stuck at true and we ANR because
we never make the window visible again.

Fix this by uncoditionally setting client visibility when changing
app visibility.

Test:
adb shell monkey -p com.google.android.deskclock -p com.android.calculator -p com.android.calculator2 -p com.google.android.contacts -p com.android.launcher -p com.google.android.launcher -p com.android.mms -p com.google.android.apps.messaging -p com.android.phone -p com.google.android.dialer -p com.android.providers.downloads.ui -p com.android.settings -p com.google.android.calendar -p com.google.android.GoogleCamera -p com.google.android.apps.photos -p com.google.android.gms -p com.google.android.setupwizard -p com.google.android.googlequicksearchbox -p com.google.android.packageinstaller -p com.google.android.apps.nexuslauncher -c android.intent.category.LAUNCHER --ignore-security-exceptions --monitor-native-crashes -s 814 -v -v -v 125000

Change-Id: I40160266a465cb5a1a9c2ac6476d89e2829a537e
Fixes: 72160186
parent e06975dd
Loading
Loading
Loading
Loading
+7 −8
Original line number Original line Diff line number Diff line
@@ -367,15 +367,14 @@ public class AppWindowContainerController
                    if (wtoken.isHidden()) {
                    if (wtoken.isHidden()) {
                        wtoken.waitingToShow = true;
                        wtoken.waitingToShow = true;
                    }
                    }
                }


                    if (wtoken.isClientHidden()) {
                // In the case where we are making an app visible but holding off for a transition,
                        // In the case where we are making an app visible but holding off for a
                // we still need to tell the client to make its windows visible so they get drawn.
                        // transition, we still need to tell the client to make its windows visible
                // Otherwise, we will wait on performing the transition until all windows have been
                        // so they get drawn. Otherwise, we will wait on performing the transition
                // drawn, they never will be, and we are sad.
                        // until all windows have been drawn, they never will be, and we are sad.
                wtoken.setClientHidden(false);
                wtoken.setClientHidden(false);
                    }

                }
                wtoken.requestUpdateWallpaperIfNeeded();
                wtoken.requestUpdateWallpaperIfNeeded();


                if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM, "No longer Stopped: " + wtoken);
                if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM, "No longer Stopped: " + wtoken);
+2 −0
Original line number Original line Diff line number Diff line
@@ -367,6 +367,8 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        if (mClientHidden == hideClient || (hideClient && mDeferHidingClient)) {
        if (mClientHidden == hideClient || (hideClient && mDeferHidingClient)) {
            return;
            return;
        }
        }
        if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setClientHidden: " + this
                + " clientHidden=" + hideClient + " Callers=" + Debug.getCallers(5));
        mClientHidden = hideClient;
        mClientHidden = hideClient;
        sendAppVisibilityToClients();
        sendAppVisibilityToClients();
    }
    }