diff options
| author | 2021-03-23 16:49:53 +0000 | |
|---|---|---|
| committer | 2021-03-23 16:49:53 +0000 | |
| commit | cb1cc4f5a97217bff3d6dd76597b828cedd269a2 (patch) | |
| tree | 800e53a68496d36e60982c7fa54541a8d93f9c16 | |
| parent | 5785c5c68f52f85f06f5d4ecb39a2498b254362c (diff) | |
| parent | f3a77c8fa598a371238bfa4362883ae6a0007908 (diff) | |
Merge "[incremental] add incremental info to crash/anr reports in dropbox" into sc-dev
4 files changed, 39 insertions, 24 deletions
diff --git a/services/core/java/com/android/server/Watchdog.java b/services/core/java/com/android/server/Watchdog.java index 963664149b38..211999f43183 100644 --- a/services/core/java/com/android/server/Watchdog.java +++ b/services/core/java/com/android/server/Watchdog.java @@ -35,11 +35,11 @@ import android.os.ServiceDebugInfo; import android.os.ServiceManager; import android.os.SystemClock; import android.os.SystemProperties; +import android.sysprop.WatchdogProperties; import android.util.EventLog; import android.util.Log; import android.util.Slog; import android.util.SparseArray; -import android.sysprop.WatchdogProperties; import com.android.internal.os.ProcessCpuTracker; import com.android.internal.os.ZygoteConnectionConstants; @@ -56,9 +56,9 @@ import java.io.IOException; import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; -import java.util.concurrent.TimeUnit; import java.util.HashSet; import java.util.List; +import java.util.concurrent.TimeUnit; /** This class calls its monitor every minute. Killing this process if they don't return **/ public class Watchdog { @@ -688,7 +688,7 @@ public class Watchdog { if (mActivity != null) { mActivity.addErrorToDropBox( "watchdog", null, "system_server", null, null, null, - subject, report.toString(), stack, null); + subject, report.toString(), stack, null, null, null); } FrameworkStatsLog.write(FrameworkStatsLog.SYSTEM_SERVER_WATCHDOG_OCCURRED, subject); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 492759f7c73d..321e3b14896c 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -7706,9 +7706,8 @@ public class ActivityManagerService extends IActivityManager.Stub */ void handleApplicationCrashInner(String eventType, ProcessRecord r, String processName, ApplicationErrorReport.CrashInfo crashInfo) { - boolean isIncremental = false; float loadingProgress = 1; - long millisSinceOldestPendingRead = 0; + IncrementalMetrics incrementalMetrics = null; // Notify package manager service to possibly update package state if (r != null && r.info != null && r.info.packageName != null) { final String codePath = r.info.getCodePath(); @@ -7719,8 +7718,7 @@ public class ActivityManagerService extends IActivityManager.Stub if (incrementalStatesInfo != null) { loadingProgress = incrementalStatesInfo.getProgress(); } - isIncremental = IncrementalManager.isIncrementalPath(codePath); - if (isIncremental) { + if (IncrementalManager.isIncrementalPath(codePath)) { // Report in the main log about the incremental package Slog.e(TAG, "App crashed on incremental package " + r.info.packageName + " which is " + ((int) (loadingProgress * 100)) + "% loaded."); @@ -7729,8 +7727,7 @@ public class ActivityManagerService extends IActivityManager.Stub if (incrementalService != null) { final IncrementalManager incrementalManager = new IncrementalManager( IIncrementalService.Stub.asInterface(incrementalService)); - IncrementalMetrics metrics = incrementalManager.getMetrics(codePath); - millisSinceOldestPendingRead = metrics.getMillisSinceOldestPendingRead(); + incrementalMetrics = incrementalManager.getMetrics(codePath); } } } @@ -7760,7 +7757,9 @@ public class ActivityManagerService extends IActivityManager.Stub processName.equals("system_server") ? ServerProtoEnums.SYSTEM_SERVER : (r != null) ? r.getProcessClassEnum() : ServerProtoEnums.ERROR_SOURCE_UNKNOWN, - isIncremental, loadingProgress, millisSinceOldestPendingRead + incrementalMetrics != null /* isIncremental */, loadingProgress, + incrementalMetrics != null ? incrementalMetrics.getMillisSinceOldestPendingRead() + : -1 ); final int relaunchReason = r == null ? RELAUNCH_REASON_NONE @@ -7773,7 +7772,8 @@ public class ActivityManagerService extends IActivityManager.Stub } addErrorToDropBox( - eventType, r, processName, null, null, null, null, null, null, crashInfo); + eventType, r, processName, null, null, null, null, null, null, crashInfo, + new Float(loadingProgress), incrementalMetrics); mAppErrors.crashApplication(r, crashInfo); } @@ -7955,7 +7955,8 @@ public class ActivityManagerService extends IActivityManager.Stub FrameworkStatsLog.write(FrameworkStatsLog.WTF_OCCURRED, callingUid, tag, processName, callingPid, (r != null) ? r.getProcessClassEnum() : 0); - addErrorToDropBox("wtf", r, processName, null, null, null, tag, null, null, crashInfo); + addErrorToDropBox("wtf", r, processName, null, null, null, tag, null, null, crashInfo, + null, null); return r; } @@ -7980,7 +7981,7 @@ public class ActivityManagerService extends IActivityManager.Stub for (Pair<String, ApplicationErrorReport.CrashInfo> p = list.poll(); p != null; p = list.poll()) { addErrorToDropBox("wtf", proc, "system_server", null, null, null, p.first, null, null, - p.second); + p.second, null, null); } } @@ -8069,12 +8070,15 @@ public class ActivityManagerService extends IActivityManager.Stub * @param report in long form describing the error, null if absent * @param dataFile text file to include in the report, null if none * @param crashInfo giving an application stack trace, null if absent + * @param loadingProgress the loading progress of an installed package, range in [0, 1]. + * @param incrementalMetrics metrics for apps installed on Incremental. */ public void addErrorToDropBox(String eventType, ProcessRecord process, String processName, String activityShortComponentName, String parentShortComponentName, ProcessRecord parentProcess, String subject, final String report, final File dataFile, - final ApplicationErrorReport.CrashInfo crashInfo) { + final ApplicationErrorReport.CrashInfo crashInfo, + @Nullable Float loadingProgress, @Nullable IncrementalMetrics incrementalMetrics) { // NOTE -- this must never acquire the ActivityManagerService lock, // otherwise the watchdog may be prevented from resetting the system. @@ -8135,6 +8139,18 @@ public class ActivityManagerService extends IActivityManager.Stub if (crashInfo != null && crashInfo.crashTag != null && !crashInfo.crashTag.isEmpty()) { sb.append("Crash-Tag: ").append(crashInfo.crashTag).append("\n"); } + if (loadingProgress != null) { + sb.append("Loading-Progress: ").append(loadingProgress.floatValue()).append("\n"); + } + if (incrementalMetrics != null) { + sb.append("Incremental: Yes").append("\n"); + final long millisSinceOldestPendingRead = + incrementalMetrics.getMillisSinceOldestPendingRead(); + if (millisSinceOldestPendingRead > 0) { + sb.append("Millis-Since-Oldest-Pending-Read: ").append( + millisSinceOldestPendingRead).append("\n"); + } + } sb.append("\n"); // Do the rest in a worker thread to avoid blocking the caller on I/O diff --git a/services/core/java/com/android/server/am/AppProfiler.java b/services/core/java/com/android/server/am/AppProfiler.java index 31ea14a73409..074e8fe42016 100644 --- a/services/core/java/com/android/server/am/AppProfiler.java +++ b/services/core/java/com/android/server/am/AppProfiler.java @@ -1627,7 +1627,7 @@ public class AppProfiler { dropBuilder.append(catSw.toString()); FrameworkStatsLog.write(FrameworkStatsLog.LOW_MEM_REPORTED); mService.addErrorToDropBox("lowmem", null, "system_server", null, - null, null, tag.toString(), dropBuilder.toString(), null, null); + null, null, tag.toString(), dropBuilder.toString(), null, null, null, null); synchronized (mService) { long now = SystemClock.uptimeMillis(); if (mLastMemUsageReportTime < now) { diff --git a/services/core/java/com/android/server/am/ProcessErrorStateRecord.java b/services/core/java/com/android/server/am/ProcessErrorStateRecord.java index 93f30cc8ac5e..ab4a2d59ed90 100644 --- a/services/core/java/com/android/server/am/ProcessErrorStateRecord.java +++ b/services/core/java/com/android/server/am/ProcessErrorStateRecord.java @@ -300,9 +300,8 @@ class ProcessErrorStateRecord { } // Check if package is still being loaded - boolean isIncremental = false; float loadingProgress = 1; - long millisSinceOldestPendingRead = 0; + IncrementalMetrics incrementalMetrics = null; final PackageManagerInternal packageManagerInternal = mService.getPackageManagerInternal(); if (aInfo != null && aInfo.packageName != null) { IncrementalStatesInfo incrementalStatesInfo = @@ -312,8 +311,7 @@ class ProcessErrorStateRecord { loadingProgress = incrementalStatesInfo.getProgress(); } final String codePath = aInfo.getCodePath(); - isIncremental = IncrementalManager.isIncrementalPath(codePath); - if (isIncremental) { + if (IncrementalManager.isIncrementalPath(codePath)) { // Report in the main log that the incremental package is still loading Slog.e(TAG, "App crashed on incremental package " + aInfo.packageName + " which is " + ((int) (loadingProgress * 100)) + "% loaded."); @@ -322,8 +320,7 @@ class ProcessErrorStateRecord { if (incrementalService != null) { final IncrementalManager incrementalManager = new IncrementalManager( IIncrementalService.Stub.asInterface(incrementalService)); - IncrementalMetrics metrics = incrementalManager.getMetrics(codePath); - millisSinceOldestPendingRead = metrics.getMillisSinceOldestPendingRead(); + incrementalMetrics = incrementalManager.getMetrics(codePath); } } } @@ -345,7 +342,7 @@ class ProcessErrorStateRecord { info.append("Parent: ").append(parentShortComponentName).append("\n"); } - if (isIncremental) { + if (incrementalMetrics != null) { // Report in the main log about the incremental package info.append("Package is ").append((int) (loadingProgress * 100)).append("% loaded.\n"); } @@ -434,12 +431,14 @@ class ProcessErrorStateRecord { : FrameworkStatsLog.ANROCCURRED__FOREGROUND_STATE__BACKGROUND, mApp.getProcessClassEnum(), (mApp.info != null) ? mApp.info.packageName : "", - isIncremental, loadingProgress, millisSinceOldestPendingRead); + incrementalMetrics != null /* isIncremental */, loadingProgress, + incrementalMetrics != null ? incrementalMetrics.getMillisSinceOldestPendingRead() + : -1); final ProcessRecord parentPr = parentProcess != null ? (ProcessRecord) parentProcess.mOwner : null; mService.addErrorToDropBox("anr", mApp, mApp.processName, activityShortComponentName, parentShortComponentName, parentPr, annotation, report.toString(), tracesFile, - null); + null, new Float(loadingProgress), incrementalMetrics); if (mApp.getWindowProcessController().appNotResponding(info.toString(), () -> { |