From 5296a740a76820bab4d19c9b888cd7f657936e2a Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Mon, 16 Mar 2020 13:24:21 -0700 Subject: [PATCH] Dispatching ViewCommands to a non-existent tag should log SoftException, but not crash Summary: Patch for T63997094. Will still crash in debug mode, and log soft errors, so as not to entirely hide errors. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D20473855 fbshipit-source-id: 8b052b1ae3c886f83d6a7922feb158172cdcd33d --- .../uimanager/NativeViewHierarchyManager.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index 55208453fc7..806073ad0dc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -24,6 +24,7 @@ import com.facebook.react.R; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.ReactContext; +import com.facebook.react.bridge.ReactSoftException; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.SoftAssertions; @@ -765,8 +766,11 @@ public class NativeViewHierarchyManager { UiThreadUtil.assertOnUiThread(); View view = mTagsToViews.get(reactTag); if (view == null) { - throw new IllegalViewOperationException( - "Trying to send command to a non-existing view " + "with tag " + reactTag); + ReactSoftException.logSoftException( + TAG, + new IllegalViewOperationException( + "Trying to send command to a non-existing view " + "with tag " + reactTag)); + return; } ViewManager viewManager = resolveViewManager(reactTag); @@ -778,8 +782,11 @@ public class NativeViewHierarchyManager { UiThreadUtil.assertOnUiThread(); View view = mTagsToViews.get(reactTag); if (view == null) { - throw new IllegalViewOperationException( - "Trying to send command to a non-existing view " + "with tag " + reactTag); + ReactSoftException.logSoftException( + TAG, + new IllegalViewOperationException( + "Trying to send command to a non-existing view " + "with tag " + reactTag)); + return; } ViewManager viewManager = resolveViewManager(reactTag);