Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the injected treeProps for Layout PerfEvent #574

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ private void calculateLayout(
final PerfEvent layoutEvent =
logger != null
? LogTreePopulator.populatePerfEventFromLogger(
mContext, logger, logger.newPerformanceEvent(mContext, EVENT_LAYOUT_CALCULATE))
mContext, treeProps, logger, logger.newPerformanceEvent(mContext, EVENT_LAYOUT_CALCULATE))
: null;

if (layoutEvent != null) {
Expand Down
26 changes: 21 additions & 5 deletions litho-core/src/main/java/com/facebook/litho/LogTreePopulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,34 @@
public final class LogTreePopulator {
private LogTreePopulator() {}

/**
* Annotate a log event with the log tag set in the context, and extract the treeprops from a
* given {@link ComponentContext} and convert them into perf event annotations using a {@link
* ComponentsLogger} implementation.
*
* @return Annotated perf event, or <code>null</code> if the resulting event isn't deemed worthy
* of reporting.
*/
@Nullable
@CheckReturnValue
public static PerfEvent populatePerfEventFromLogger(
ComponentContext c, ComponentsLogger logger, @Nullable PerfEvent perfEvent) {
return populatePerfEventFromLogger(c, null, logger, perfEvent);
}

/**
* Annotate a log event with the log tag set in the context, and extract the treeprops from a
* given {@link ComponentContext} and convert them into perf event annotations using a {@link
* ComponentsLogger} implementation.
* Annotate a log event with the log tag set in the context, and extract the treeprops from saved
* treeprops or a given {@link ComponentContext} and convert them into perf event annotations
* using a {@link ComponentsLogger} implementation. If the saved treeprops is null, the treeprops
* of the given {@link ComponentContext} will be used.
*
* @return Annotated perf event, or <code>null</code> if the resulting event isn't deemed worthy
* of reporting.
*/
@Nullable
@CheckReturnValue
public static PerfEvent populatePerfEventFromLogger(
ComponentContext c, ComponentsLogger logger, @Nullable PerfEvent perfEvent) {
ComponentContext c, @Nullable TreeProps savedTreeProps, ComponentsLogger logger, @Nullable PerfEvent perfEvent) {
if (perfEvent == null) {
return null;
}
Expand All @@ -50,7 +66,7 @@ public static PerfEvent populatePerfEventFromLogger(

perfEvent.markerAnnotate(FrameworkLogEvents.PARAM_LOG_TAG, logTag);

@Nullable final TreeProps treeProps = c.getTreeProps();
@Nullable final TreeProps treeProps = savedTreeProps == null ? c.getTreeProps() : savedTreeProps;
if (treeProps == null) {
return perfEvent;
}
Expand Down