From 99f2f5ffdd4b35e4d9b15ccc6deb55714fd686ef Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Mon, 7 Dec 2020 17:57:05 -0800 Subject: [PATCH] `deleteRootView`: use concurrent pattern with `mTagToViewState` Summary: Instead of doing a "containsKey then get", just get the rootViewTag and see if it's non-null. Theoretically, since it's a concurrent data-structure, it could be removed from the ConcurrentHashMap between "containsKey" returning true and the "get". This does not fix any known, existing problems. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25378703 fbshipit-source-id: 62a44e68e4443dac5a557263cc4bb33de9eea993 --- .../facebook/react/fabric/mounting/MountingManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java index 1dfeb478cb9..be91c29c23e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.java @@ -124,11 +124,12 @@ public class MountingManager { }); } - /** Delete rootView and all children/ */ + /** Delete rootView and all children recursively. */ @UiThread public void deleteRootView(int reactRootTag) { - if (mTagToViewState.containsKey(reactRootTag)) { - dropView(mTagToViewState.get(reactRootTag).mView, true); + ViewState rootViewState = mTagToViewState.get(reactRootTag); + if (rootViewState != null && rootViewState.mView != null) { + dropView(rootViewState.mView, true); } }