Skip to content

Commit

Permalink
Clears RenderTree from MountState on unmount all
Browse files Browse the repository at this point in the history
Reviewed By: pasqualeanatriello

Differential Revision: D46150681

fbshipit-source-id: b187c1057d6c4d9da6d896eff5736f068455bb75
  • Loading branch information
adityasharat authored and facebook-github-bot committed May 25, 2023
1 parent d08e22c commit 7f339dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.view.View;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray;
import androidx.core.util.Preconditions;
import com.facebook.rendercore.debug.DebugEvent;
import com.facebook.rendercore.extensions.ExtensionState;
import com.facebook.rendercore.extensions.MountExtension;
Expand All @@ -53,7 +54,7 @@ public class MountState implements MountDelegateTarget {

private boolean mIsMounting;
private boolean mNeedsRemount;
private RenderTree mRenderTree;
private @Nullable RenderTree mRenderTree;
private @Nullable MountDelegate mMountDelegate;
private @Nullable UnmountDelegateExtension mUnmountDelegateExtension;

Expand Down Expand Up @@ -145,6 +146,8 @@ public void mount(RenderTree renderTree) {
return;
}

Preconditions.checkNotNull(mRenderTree);

final boolean isTracing = mTracer.isTracing();
if (isTracing) {
mTracer.beginSection("MountState.mount");
Expand Down Expand Up @@ -356,6 +359,11 @@ public void unmountAllItems() {
}

mNeedsRemount = true;

if (RenderCoreConfig.shouldClearRenderTreeOnUnmountAll) {
mRenderTree = null;
}

} finally {
if (RenderCoreConfig.shouldSetInLayoutDuringUnmountAll) {
mRootHost.unsetInLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ public class RenderCoreConfig {
* so that layouts are not request when removing content from the hierarchy.
*/
public static boolean shouldSetInLayoutDuringUnmountAll = false;

/** Enabling this will clear the render tree from the MountState when unmount all is invoked. */
public static boolean shouldClearRenderTreeOnUnmountAll = false;
}

0 comments on commit 7f339dd

Please sign in to comment.