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

Commit cee04b57 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add traces for app launch / fully drawn times.

Note that we don't know the fully drawn time unless the app
tells it has finished drawing, so for apps that don't do this
we will end up just continuing to consider it to be drawing until
the next app is launched.

Change-Id: I766b71cf61b8d7324ccf239b7a44bef2518e2454
parent db3c19fd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -820,7 +820,7 @@ final class ActivityRecord {
            final long totalTime = stack.mFullyDrawnStartTime != 0
                    ? (curTime - stack.mFullyDrawnStartTime) : thisTime;
            if (ActivityManagerService.SHOW_ACTIVITY_START_TIME) {
                Trace.traceCounter(Trace.TRACE_TAG_ACTIVITY_MANAGER, "fully-drawn", (int)totalTime);
                Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "drawing", 0);
                EventLog.writeEvent(EventLogTags.AM_ACTIVITY_FULLY_DRAWN_TIME,
                        userId, System.identityHashCode(this), shortComponentName,
                        thisTime, totalTime);
@@ -851,7 +851,7 @@ final class ActivityRecord {
        final long totalTime = stack.mLaunchStartTime != 0
                ? (curTime - stack.mLaunchStartTime) : thisTime;
        if (ActivityManagerService.SHOW_ACTIVITY_START_TIME) {
            Trace.traceCounter(Trace.TRACE_TAG_ACTIVITY_MANAGER, "launch", (int)totalTime);
            Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "launching", 0);
            EventLog.writeEvent(EventLogTags.AM_ACTIVITY_LAUNCH_TIME,
                    userId, System.identityHashCode(this), shortComponentName,
                    thisTime, totalTime);
+19 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import static com.android.server.am.ActivityStackSupervisor.DEBUG_SAVED_STATE;
import static com.android.server.am.ActivityStackSupervisor.DEBUG_STATES;
import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID;

import android.os.Trace;
import com.android.internal.os.BatteryStatsImpl;
import com.android.internal.util.Objects;
import com.android.server.Watchdog;
@@ -595,13 +596,30 @@ final class ActivityStack {
        if (DEBUG_SAVED_STATE) Slog.i(TAG, "Launch completed; removing icicle of " + r.icicle);
    }

    private void startLaunchTraces() {
        if (mFullyDrawnStartTime != 0)  {
            Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "drawing", 0);
        }
        Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "launching", 0);
        Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "drawing", 0);
    }

    private void stopFullyDrawnTraceIfNeeded() {
        if (mFullyDrawnStartTime != 0 && mLaunchStartTime == 0) {
            Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "drawing", 0);
            mFullyDrawnStartTime = 0;
        }
    }

    void setLaunchTime(ActivityRecord r) {
        if (r.displayStartTime == 0) {
            r.fullyDrawnStartTime = r.displayStartTime = SystemClock.uptimeMillis();
            if (mLaunchStartTime == 0) {
                startLaunchTraces();
                mLaunchStartTime = mFullyDrawnStartTime = r.displayStartTime;
            }
        } else if (mLaunchStartTime == 0) {
            startLaunchTraces();
            mLaunchStartTime = mFullyDrawnStartTime = SystemClock.uptimeMillis();
        }
    }
@@ -717,6 +735,7 @@ final class ActivityStack {
        prev.task.touchActiveTime();
        clearLaunchTime(prev);
        prev.updateThumbnail(screenshotActivities(prev), null);
        stopFullyDrawnTraceIfNeeded();

        mService.updateCpuStats();