From 21eb540d6eddaf848e2fd93c6bcd2913f96c78c2 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 2 Apr 2020 14:07:29 -0700 Subject: [PATCH] Fix TextInlineViews when UIImplementation processes two roots at the same time Summary: This diff cleans the variable NativeViewHierarchyOptimizer.mTagsWithLayoutVisited right after all the view updates for a rootShadowNode have been processed by the UIImplementation class. This intends to fix the bug reported in the task: T61185028, which root cause seems related to the fact that the variable NativeViewHierarchyOptimizer.mTagsWithLayoutVisited is not cleaned up when updating multiple rootShadowNodes as part of the same batch changelog: [Android][internal] internal bug fix Reviewed By: JoshuaGross Differential Revision: D20812921 fbshipit-source-id: 28067ee29a931d7a9e9c33c90aceb4e3512dac1a --- .../react/uimanager/NativeViewHierarchyOptimizer.java | 10 ++++++++++ .../com/facebook/react/uimanager/UIImplementation.java | 1 + 2 files changed, 11 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyOptimizer.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyOptimizer.java index a42f3501ad5..701fb1f2855 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyOptimizer.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyOptimizer.java @@ -446,4 +446,14 @@ public class NativeViewHierarchyOptimizer { } return true; } + + /** + * Called when all the view updates of {@link ReactShadowNode} received as a parameter were + * processed. + */ + void onViewUpdatesCompleted(ReactShadowNode cssNode) { + // cssNode is not being used, but it is passed as a parameter in case this is required in the + // future. + mTagsWithLayoutVisited.clear(); + } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index ea6d4894821..267461d84fb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -920,6 +920,7 @@ public class UIImplementation { } } cssNode.markUpdateSeen(); + mNativeViewHierarchyOptimizer.onViewUpdatesCompleted(cssNode); } public void addUIBlock(UIBlock block) {