Add more traces for activity callback

It's easier to identify where the application is spending time.

Not all traces include component name because those can be
known by the nearby traces.

Bug: 206872204
Test: Launch an activity and check trace.
Change-Id: Iffde279dfc2a8c1a8f640f8efb1ea795f1257c62
This commit is contained in:
Riddle Hsu
2022-11-01 22:16:34 +08:00
parent c84d661e07
commit 5e405d3121
2 changed files with 11 additions and 0 deletions

View File

@@ -8364,11 +8364,17 @@ public class Activity extends ContextThemeWrapper
}
final void performNewIntent(@NonNull Intent intent) {
Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "performNewIntent");
mCanEnterPictureInPicture = true;
onNewIntent(intent);
Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
}
final void performStart(String reason) {
if (Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) {
Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "performStart:"
+ mComponent.getClassName());
}
dispatchActivityPreStarted();
mActivityTransitionState.setEnterActivityOptions(this, getActivityOptions());
mFragments.noteStateNotSaved();
@@ -8415,6 +8421,7 @@ public class Activity extends ContextThemeWrapper
mActivityTransitionState.enterReady(this);
dispatchActivityPostStarted();
Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
}
/**
@@ -8424,6 +8431,7 @@ public class Activity extends ContextThemeWrapper
* multiple lifecycle transitions is in progress.
*/
final void performRestart(boolean start, String reason) {
Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "performRestart");
mCanEnterPictureInPicture = true;
mFragments.noteStateNotSaved();
@@ -8469,6 +8477,7 @@ public class Activity extends ContextThemeWrapper
performStart(reason);
}
}
Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
}
final void performResume(boolean followedByPause, String reason) {

View File

@@ -3714,12 +3714,14 @@ public final class ActivityThread extends ClientTransactionHandler
// Call postOnCreate()
if (pendingActions.shouldCallOnPostCreate()) {
activity.mCalled = false;
Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "onPostCreate");
if (r.isPersistable()) {
mInstrumentation.callActivityOnPostCreate(activity, r.state,
r.persistentState);
} else {
mInstrumentation.callActivityOnPostCreate(activity, r.state);
}
Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
if (!activity.mCalled) {
throw new SuperNotCalledException(
"Activity " + r.intent.getComponent().toShortString()