Skip to content

Commit

Permalink
Makes keeping node and results saner
Browse files Browse the repository at this point in the history
Summary: Makes keeping node and results saner

Reviewed By: pentiumao

Differential Revision: D45393246

fbshipit-source-id: 26f892d5848144890d7f1dcafa730c584f86277b
  • Loading branch information
adityasharat authored and facebook-github-bot committed Apr 28, 2023
1 parent 1cde080 commit 576f5ce
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
30 changes: 21 additions & 9 deletions litho-core/src/main/java/com/facebook/litho/LayoutState.java
Original file line number Diff line number Diff line change
Expand Up @@ -1226,17 +1226,29 @@ static void setSizeAfterMeasureAndCollectResults(
ComponentsSystrace.endSection();
}

final LithoNode forSaving = layoutState.mRoot;
if (!c.isReconciliationEnabled()
&& !ComponentsConfiguration.isDebugModeEnabled
&& !ComponentsConfiguration.isEndToEndTestRun
&& !ComponentsConfiguration.keepLithoNodes) {
layoutState.mRoot = null;
layoutState.mLayoutResult = null;
final LithoNode nodeForSaving = layoutState.mRoot;
final LithoLayoutResult layoutResultForSaving = layoutState.mLayoutResult;

// clean it up for sanity
layoutState.mRoot = null;
layoutState.mLayoutResult = null;

// enabled for debugging and end to end tests
if (ComponentsConfiguration.isDebugModeEnabled || ComponentsConfiguration.isEndToEndTestRun) {
layoutState.mRoot = nodeForSaving;
layoutState.mLayoutResult = layoutResultForSaving;
return;
}

// only keep the node if reconciliation is enabled for legacy render
if (c.isReconciliationEnabled()
&& c.mLithoConfiguration.mComponentsConfiguration.isLegacyRenderEnabled()) {
layoutState.mRoot = nodeForSaving;
}

if (ComponentsConfiguration.keepLithoNodes) {
layoutState.mRoot = forSaving;
// override used by analytics teams
if (ComponentsConfiguration.keepLayoutResults) {
layoutState.mLayoutResult = layoutResultForSaving;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ public static boolean isRenderInfoDebuggingEnabled() {
/** When {@code true}, disables incremental mount globally. */
public static boolean isIncrementalMountGloballyDisabled = false;

/** Keeps the litho node tree in the LayoutState. This will increase memory use. */
public static boolean keepLithoNodes = false;
/** Keeps the litho layout result tree in the LayoutState. This will increase memory use. */
public static boolean keepLayoutResults = false;

/**
* Used by LithoViews to determine whether or not to self-manage the view-port changes, rather
Expand Down

0 comments on commit 576f5ce

Please sign in to comment.