From 8e91843cc7da4a791e5fe78078998f1c30592863 Mon Sep 17 00:00:00 2001 From: "Andrew Y. Chen" Date: Mon, 10 Oct 2016 14:40:55 -0700 Subject: [PATCH] Fix crash when resolveView fails to find a view Reviewed By: yungsters Differential Revision: D3997107 fbshipit-source-id: 7bf03ff06a6b56d192bab7fa567a11a38148f076 --- .../react/uimanager/NativeViewHierarchyManager.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 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 3d6ad539a..a5b157d0f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -10,6 +10,7 @@ package com.facebook.react.uimanager; import android.content.res.Resources; +import android.util.Log; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.view.Menu; @@ -64,6 +65,8 @@ import javax.annotation.concurrent.NotThreadSafe; @NotThreadSafe public class NativeViewHierarchyManager { + private static final String TAG = NativeViewHierarchyManager.class.getSimpleName(); + private final AnimationRegistry mAnimationRegistry; private final SparseArray mTagsToViews; private final SparseArray mTagsToViewManagers; @@ -116,9 +119,13 @@ public class NativeViewHierarchyManager { public void updateProperties(int tag, ReactStylesDiffMap props) { UiThreadUtil.assertOnUiThread(); - ViewManager viewManager = resolveViewManager(tag); - View viewToUpdate = resolveView(tag); - viewManager.updateProperties(viewToUpdate, props); + try { + ViewManager viewManager = resolveViewManager(tag); + View viewToUpdate = resolveView(tag); + viewManager.updateProperties(viewToUpdate, props); + } catch (IllegalViewOperationException e) { + Log.e(TAG, "Unable to update properties for view tag " + tag, e); + } } public void updateViewExtraData(int tag, Object extraData) {