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

Commit 35c193c7 authored by Chris Wailes's avatar Chris Wailes
Browse files

Adjusted tracing of reportFullyDrawn() API call.

This patch adjusts how the reportFullyDrawn() API call records this
information in the tracing system.  Instead of an asynch slice that may
or may not be ended by reportFullyDrawn() we now emit a slice around the
function used to handle this callback.  This slice name now also
includes the name of the package that made the callback.

Test: Built and loaded the image; launched Photos
Change-Id: I8d55be73303133a8a1e4648b1fc9eb7938a453ab
parent 7cc5a53c
Loading
Loading
Loading
Loading
+13 −17
Original line number Diff line number Diff line
@@ -155,7 +155,6 @@ class ActivityMetricsLogger {
    private final H mHandler;

    private ArtManagerInternal mArtManagerInternal;
    private boolean mDrawingTraceActive;
    private final StringBuilder mStringBuilder = new StringBuilder();

    private final class H extends Handler {
@@ -496,7 +495,6 @@ class ActivityMetricsLogger {
                if (mWindowingModeTransitionInfo.size() == 0) {
                    reset(true /* abort */, info);
                }
                stopFullyDrawnTraceIfNeeded();
            }
        }
    }
@@ -694,6 +692,13 @@ class ActivityMetricsLogger {
        if (info == null) {
            return null;
        }

        // Record the handling of the reportFullyDrawn callback in the trace system. This is not
        // actually used to trace this function, but instead the logical task that this function
        // fullfils (handling reportFullyDrawn() callbacks).
        Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER,
                "ActivityManager:ReportingFullyDrawn " + info.launchedActivity.packageName);

        final LogMaker builder = new LogMaker(APP_TRANSITION_REPORTED_DRAWN);
        builder.setPackageName(r.packageName);
        builder.addTaggedData(FIELD_CLASS_NAME, r.info.name);
@@ -715,7 +720,11 @@ class ActivityMetricsLogger {
                info.launchedActivity.info.name,
                info.currentTransitionProcessRunning,
                startupTimeMs);
        stopFullyDrawnTraceIfNeeded();

        // Ends the trace started at the beginning of this function. This is located here to allow
        // the trace slice to have a noticable duration.
        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);

        final WindowingModeTransitionInfoSnapshot infoSnapshot =
                new WindowingModeTransitionInfoSnapshot(info, r, (int) startupTimeMs);
        BackgroundThread.getHandler().post(() -> logAppFullyDrawn(infoSnapshot));
@@ -882,10 +891,7 @@ class ActivityMetricsLogger {
    }

    /**
     * Starts traces for app launch and draw times. We stop the fully drawn trace if its already
     * active since the app may not have reported fully drawn in the previous launch.
     *
     * See {@link android.app.Activity#reportFullyDrawn()}
     * Starts traces for app launch.
     *
     * @param info
     * */
@@ -893,14 +899,11 @@ class ActivityMetricsLogger {
        if (info == null) {
            return;
        }
        stopFullyDrawnTraceIfNeeded();
        int transitionType = getTransitionType(info);
        if (!info.launchTraceActive && transitionType == TYPE_TRANSITION_WARM_LAUNCH
                || transitionType == TYPE_TRANSITION_COLD_LAUNCH) {
            Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "launching: "
                    + info.launchedActivity.packageName, 0);
            Trace.asyncTraceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "drawing", 0);
            mDrawingTraceActive = true;
            info.launchTraceActive = true;
        }
    }
@@ -915,11 +918,4 @@ class ActivityMetricsLogger {
            info.launchTraceActive = false;
        }
    }

    void stopFullyDrawnTraceIfNeeded() {
        if (mDrawingTraceActive) {
            Trace.asyncTraceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER, "drawing", 0);
            mDrawingTraceActive = false;
        }
    }
}
+0 −2
Original line number Diff line number Diff line
@@ -1509,8 +1509,6 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        prev.getTask().touchActiveTime();
        clearLaunchTime(prev);

        mStackSupervisor.getActivityMetricsLogger().stopFullyDrawnTraceIfNeeded();

        mService.updateCpuStats();

        if (prev.attachedToProcess()) {