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 6ff40bda0ff..632f57af48f 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 @@ -63,9 +63,9 @@ public class MountingManager { mViewManagerRegistry = viewManagerRegistry; } - private static void logViewHierarchy(ViewGroup parent) { + private static void logViewHierarchy(ViewGroup parent, boolean recurse) { int parentTag = parent.getId(); - FLog.e(TAG, " "); + FLog.e(TAG, " "); for (int i = 0; i < parent.getChildCount(); i++) { FLog.e( TAG, @@ -73,11 +73,24 @@ public class MountingManager { + i + " tag=" + parent.getChildAt(i).getId() - + " toString=" - + parent.getChildAt(i).toString() + + " class=" + + parent.getChildAt(i).getClass().toString() + ">"); } FLog.e(TAG, " "); + + if (recurse) { + FLog.e(TAG, "Displaying Ancestors:"); + ViewParent ancestor = parent.getParent(); + while (ancestor != null) { + ViewGroup ancestorViewGroup = (ancestor instanceof ViewGroup ? (ViewGroup) ancestor : null); + int ancestorId = ancestorViewGroup == null ? View.NO_ID : ancestorViewGroup.getId(); + FLog.e( + TAG, + ""); + ancestor = ancestor.getParent(); + } + } } /** @@ -218,7 +231,7 @@ public class MountingManager { // Display children before inserting if (SHOW_CHANGED_VIEW_HIERARCHIES) { FLog.e(TAG, "addViewAt: [" + tag + "] -> [" + parentTag + "] idx: " + index + " BEFORE"); - logViewHierarchy(parentView); + logViewHierarchy(parentView, false); } try { @@ -243,7 +256,7 @@ public class MountingManager { public void run() { FLog.e( TAG, "addViewAt: [" + tag + "] -> [" + parentTag + "] idx: " + index + " AFTER"); - logViewHierarchy(parentView); + logViewHierarchy(parentView, false); } }); } @@ -359,7 +372,7 @@ public class MountingManager { if (SHOW_CHANGED_VIEW_HIERARCHIES) { // Display children before deleting any FLog.e(TAG, "removeViewAt: [" + tag + "] -> [" + parentTag + "] idx: " + index + " BEFORE"); - logViewHierarchy(parentView); + logViewHierarchy(parentView, false); } ViewGroupManager viewGroupManager = getViewGroupManager(viewState); @@ -398,6 +411,7 @@ public class MountingManager { return; } + logViewHierarchy(parentView, true); throw new IllegalStateException( "Tried to remove view [" + tag @@ -431,6 +445,8 @@ public class MountingManager { // enough that we shouldn't try to change this invariant, without a lot of thought. int childCount = viewGroupManager.getChildCount(parentView); + logViewHierarchy(parentView, true); + throw new IllegalStateException( "Cannot remove child at index " + index @@ -451,7 +467,7 @@ public class MountingManager { FLog.e( TAG, "removeViewAt: [" + tag + "] -> [" + parentTag + "] idx: " + index + " AFTER"); - logViewHierarchy(parentView); + logViewHierarchy(parentView, false); } }); }