Commit 479947d9 authored by sievers's avatar sievers Committed by Commit bot

Android: Fix GPU.GPUProcessTerminationStatus UMA stat

ChildProcessConnectionImpl.mAlwaysInForeground is used
for the GPU process and indicates that it does not participate
in hiding like renderers. The 'important' binding gives it the
same priority as the main application, so upon termination we
should just use the app's foreground status to determine whether
the GPU process was in the foreground or not.

BUG=462422

Review URL: https://codereview.chromium.org/987193003

Cr-Commit-Position: refs/heads/master@{#319768}
parent bfa20e6c
......@@ -177,9 +177,9 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
if (mServiceDisconnected) {
return;
}
mServiceDisconnected = true;
// Stash the status of the oom bindings, since stop() will release all bindings.
mWasOomProtected = mInitialBinding.isBound() || mStrongBinding.isBound();
mWasOomProtected = isCurrentlyOomProtected();
mServiceDisconnected = true;
Log.w(TAG, "onServiceDisconnected (crash or killed by oom): pid=" + mPid);
stop(); // We don't want to auto-restart on crash. Let the browser do that.
mDeathCallback.onChildProcessDied(ChildProcessConnectionImpl.this);
......@@ -407,11 +407,19 @@ public class ChildProcessConnectionImpl implements ChildProcessConnection {
if (mServiceDisconnected) {
return mWasOomProtected;
} else {
return mInitialBinding.isBound() || mStrongBinding.isBound();
return isCurrentlyOomProtected();
}
}
}
private boolean isCurrentlyOomProtected() {
synchronized (mLock) {
assert !mServiceDisconnected;
if (mAlwaysInForeground) return ChildProcessLauncher.isApplicationInForeground();
return mInitialBinding.isBound() || mStrongBinding.isBound();
}
}
@Override
public void dropOomBindings() {
synchronized (mLock) {
......
......@@ -351,6 +351,9 @@ public class ChildProcessLauncher {
private static Map<Pair<Integer, Integer>, Surface> sSurfaceTextureSurfaceMap =
new ConcurrentHashMap<Pair<Integer, Integer>, Surface>();
// Whether the main application is currently brought to the foreground.
private static boolean sApplicationInForeground = true;
@VisibleForTesting
public static void setBindingManagerForTesting(BindingManager manager) {
sBindingManager = manager;
......@@ -433,6 +436,7 @@ public class ChildProcessLauncher {
* Called when the embedding application is sent to background.
*/
public static void onSentToBackground() {
sApplicationInForeground = false;
sBindingManager.onSentToBackground();
}
......@@ -440,9 +444,17 @@ public class ChildProcessLauncher {
* Called when the embedding application is brought to foreground.
*/
public static void onBroughtToForeground() {
sApplicationInForeground = true;
sBindingManager.onBroughtToForeground();
}
/**
* Returns whether the application is currently in the foreground.
*/
static boolean isApplicationInForeground() {
return sApplicationInForeground;
}
/**
* Should be called early in startup so the work needed to spawn the child process can be done
* in parallel to other startup work. Must not be called on the UI thread. Spare connection is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment