summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatherine Liu <wlcl05@motorola.com>2012-06-27 15:11:04 -0700
committerMarcus Stojcevich <mstojcevich@gmail.com>2012-06-27 15:11:04 -0700
commitd96dab724b2655864f4e1cc761b0573fb00726b4 (patch)
tree8b4db1367581ebccccf5ffbaf2bdbbe57f9b84cb
parent44f9c784306665b040acab64b37aa514f8e22920 (diff)
downloadframeworks_base-d96dab724b2655864f4e1cc761b0573fb00726b4.zip
frameworks_base-d96dab724b2655864f4e1cc761b0573fb00726b4.tar.gz
frameworks_base-d96dab724b2655864f4e1cc761b0573fb00726b4.tar.bz2
Fix sluggish to launch an app
The new trace feature/code in 4.0.4, which will dump the app stack trace every 500ms if an app can't be launched within 500ms, is holding the global ActivityManagerService lock unnecessarily. It slows down the app's startup. Change-Id: I91fbb043912b4d1fcf3e80d8ac4e61cd20ad89d1 Solution: move the trace file write operations out of sync block.
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java8
-rw-r--r--services/java/com/android/server/am/ActivityStack.java24
2 files changed, 24 insertions, 8 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 3bed489..a274891 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -3004,7 +3004,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
- final void logAppTooSlow(ProcessRecord app, long startTime, String msg) {
+ final void logAppTooSlow(int pid, long startTime, String msg) {
if (IS_USER_BUILD) {
return;
}
@@ -3037,7 +3037,7 @@ public final class ActivityManagerService extends ActivityManagerNative
sb.append(msg);
FileOutputStream fos = new FileOutputStream(tracesFile);
fos.write(sb.toString().getBytes());
- if (app == null) {
+ if (pid <= 0) {
fos.write("\n*** No application process!".getBytes());
}
fos.close();
@@ -3047,9 +3047,9 @@ public final class ActivityManagerService extends ActivityManagerNative
return;
}
- if (app != null) {
+ if (pid > 0) {
ArrayList<Integer> firstPids = new ArrayList<Integer>();
- firstPids.add(app.pid);
+ firstPids.add(pid);
dumpStackTraces(tracesPath, firstPids, null, null);
}
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 86d3a1a..d581d33 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -307,11 +307,18 @@ final class ActivityStack {
// We don't at this point know if the activity is fullscreen,
// so we need to be conservative and assume it isn't.
Slog.w(TAG, "Activity pause timeout for " + r);
+ int pid = -1;
+ long pauseTime = 0;
+ String m = null;
synchronized (mService) {
if (r.app != null) {
- mService.logAppTooSlow(r.app, r.pauseTime,
- "pausing " + r);
+ pid = r.app.pid;
}
+ pauseTime = r.pauseTime;
+ m = "pausing " + r;
+ }
+ if (pid > 0) {
+ mService.logAppTooSlow(pid, pauseTime, m);
}
activityPaused(r != null ? r.appToken : null, true);
@@ -332,12 +339,21 @@ final class ActivityStack {
} break;
case LAUNCH_TICK_MSG: {
ActivityRecord r = (ActivityRecord)msg.obj;
+ int pid = -1;
+ long launchTickTime = 0;
+ String m = null;
synchronized (mService) {
if (r.continueLaunchTickingLocked()) {
- mService.logAppTooSlow(r.app, r.launchTickTime,
- "launching " + r);
+ if (r.app != null) {
+ pid = r.app.pid;
+ }
+ launchTickTime = r.launchTickTime;
+ m = "launching " + r;
}
}
+ if (pid > 0) {
+ mService.logAppTooSlow(pid, launchTickTime, m);
+ }
} break;
case DESTROY_TIMEOUT_MSG: {
ActivityRecord r = (ActivityRecord)msg.obj;