From ebc856b2de095b5e03515e0d4079cd99a3d47d94 Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Tue, 8 Feb 2022 08:29:02 -0800 Subject: [PATCH] Check if view exists before skipping CREATE command Summary: Updates early return in the CREATE command codepath that checks if the view already exists before allocating it. Normally the view state is expected to be created only if the view is preallocated, but empty view state is also created for the flattened nodes when they create an event emitter. By checking the view existence, we can ensure that view was indeed preallocated before, and skip for optimization purposes. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D34050884 fbshipit-source-id: 489fc1052fec9f71712ea729121ac8ef3e3f3d4e --- .../facebook/react/fabric/mounting/SurfaceMountingManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index 7422f18de05..3c7311af3f8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -548,7 +548,8 @@ public class SurfaceMountingManager { // generated. // This represents a perf issue only, not a correctness issue. In the future we need to // refactor View preallocation to correct the currently incorrect assumptions. - if (getNullableViewState(reactTag) != null) { + ViewState viewState = getNullableViewState(reactTag); + if (viewState != null && viewState.mView != null) { return; }