From ebbc4f6cc467faca4d77e4f72da32003d490d4b9 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Wed, 10 Apr 2019 16:10:40 -0700 Subject: [PATCH] Adding debug information in Mounting Manager Summary: This diff adds extra debug information in the mounting manager Reviewed By: shergin Differential Revision: D14817456 fbshipit-source-id: 5619c94eb76cdc20f5d7767f1aa4263e63f8d021 --- .../fabric/mounting/MountingManager.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 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 c7a2fa5c5..5f0b65c59 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 @@ -120,9 +120,10 @@ public class MountingManager { UiThreadUtil.assertOnUiThread(); ViewState parentViewState = getViewState(parentTag); final ViewGroup parentView = (ViewGroup) parentViewState.mView; - final View view = getViewState(tag).mView; + ViewState viewState = getViewState(tag); + final View view = viewState.mView; if (view == null) { - throw new IllegalStateException("Unable to find view for tag " + tag); + throw new IllegalStateException("Unable to find view for view " + viewState); } getViewGroupManager(parentViewState).addView(parentView, view, index); } @@ -130,7 +131,7 @@ public class MountingManager { private ViewState getViewState(int tag) { ViewState viewState = mTagToViewState.get(tag); if (viewState == null) { - throw new IllegalStateException("Unable to find viewState for tag " + tag); + throw new IllegalStateException("Unable to find viewState view " + viewState); } return viewState; } @@ -152,7 +153,7 @@ public class MountingManager { @SuppressWarnings("unchecked") // prevents unchecked conversion warn of the type private static ViewGroupManager getViewGroupManager(ViewState viewState) { if (viewState.mViewManager == null) { - throw new IllegalStateException("Unable to find ViewManager"); + throw new IllegalStateException("Unable to find ViewManager for view: " + viewState); } return (ViewGroupManager) viewState.mViewManager; } @@ -175,6 +176,10 @@ public class MountingManager { String componentName, int reactTag, boolean isLayoutable) { + if (mTagToViewState.get(reactTag) != null) { + return; + } + View view = null; ViewManager viewManager = null; @@ -264,7 +269,7 @@ public class MountingManager { ViewManager viewManager = viewState.mViewManager; if (viewManager == null) { - throw new IllegalStateException("Unable to find ViewManager for tag: " + reactTag); + throw new IllegalStateException("Unable to find ViewManager for view: " + viewState); } Object extraData = viewManager.updateLocalData( @@ -304,7 +309,9 @@ public class MountingManager { ReadableMap props, boolean isLayoutable) { - if (mTagToViewState.get(reactTag) != null) return; + if (mTagToViewState.get(reactTag) != null) { + throw new IllegalStateException("View for component " + componentName + " with tag " + reactTag + " already exists."); + } createView(reactContext, componentName, reactTag, isLayoutable); if (isLayoutable) { @@ -365,5 +372,10 @@ public class MountingManager { mIsRoot = isRoot; mViewManager = viewManager; } + + @Override + public String toString() { + return "ViewState [" + mReactTag + "] - isRoot: " + mIsRoot + " - props: " + mCurrentProps + " - localData: " + mCurrentLocalData + " - viewManager: " + mViewManager; + } } }