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 a5e9e13ace4..83ec3105e76 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -29,6 +29,7 @@ import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.RetryableMountingLayerException; import com.facebook.react.bridge.SoftAssertions; import com.facebook.react.bridge.UiThreadUtil; +import com.facebook.react.common.build.ReactBuildConfig; import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.touch.JSResponderHandler; import com.facebook.react.uimanager.layoutanimation.LayoutAnimationController; @@ -69,6 +70,7 @@ import javax.annotation.concurrent.NotThreadSafe; public class NativeViewHierarchyManager { private static final String TAG = NativeViewHierarchyManager.class.getSimpleName(); + private final boolean DEBUG_MODE = ReactBuildConfig.DEBUG && false; private final SparseArray mTagsToViews; private final SparseArray mTagsToViewManagers; @@ -128,6 +130,9 @@ public class NativeViewHierarchyManager { } public synchronized void updateProperties(int tag, ReactStylesDiffMap props) { + if (DEBUG_MODE) { + FLog.d(TAG, "updateProperties[%d]: %s", tag, props.toString()); + } UiThreadUtil.assertOnUiThread(); try { @@ -143,6 +148,9 @@ public class NativeViewHierarchyManager { } public synchronized void updateViewExtraData(int tag, Object extraData) { + if (DEBUG_MODE) { + FLog.d(TAG, "updateViewExtraData[%d]: %s", tag, extraData.toString()); + } UiThreadUtil.assertOnUiThread(); ViewManager viewManager = resolveViewManager(tag); @@ -152,6 +160,9 @@ public class NativeViewHierarchyManager { public synchronized void updateLayout( int parentTag, int tag, int x, int y, int width, int height) { + if (DEBUG_MODE) { + FLog.d(TAG, "updateLayout[%d]->[%d]: %d %d %d %d", tag, parentTag, x, y, width, height); + } UiThreadUtil.assertOnUiThread(); SystraceMessage.beginSection( Systrace.TRACE_TAG_REACT_VIEW, "NativeViewHierarchyManager_updateLayout") @@ -250,6 +261,9 @@ public class NativeViewHierarchyManager { int tag, String className, @Nullable ReactStylesDiffMap initialProps) { + if (DEBUG_MODE) { + FLog.d(TAG, "createView[%d]: %s %s", tag, className, initialProps.toString()); + } UiThreadUtil.assertOnUiThread(); SystraceMessage.beginSection( Systrace.TRACE_TAG_REACT_VIEW, "NativeViewHierarchyManager_createView") @@ -372,6 +386,15 @@ public class NativeViewHierarchyManager { @Nullable int[] indicesToRemove, @Nullable ViewAtIndex[] viewsToAdd, @Nullable int[] tagsToDelete) { + if (DEBUG_MODE) { + FLog.d( + TAG, + "createView[%d]: %s %s %s", + tag, + (indicesToRemove != null ? indicesToRemove.toString() : ""), + (viewsToAdd != null ? viewsToAdd.toString() : ""), + (tagsToDelete != null ? tagsToDelete.toString() : "")); + } UiThreadUtil.assertOnUiThread(); final Set pendingDeletionTags = getPendingDeletionsForTag(tag); @@ -545,6 +568,13 @@ public class NativeViewHierarchyManager { /** Simplified version of manageChildren that only deals with adding children views */ public synchronized void setChildren(int tag, ReadableArray childrenTags) { + if (DEBUG_MODE) { + FLog.d( + TAG, + "setChildren[%d]: %s", + tag, + (childrenTags != null ? childrenTags.toString() : "")); + } UiThreadUtil.assertOnUiThread(); ViewGroup viewToManage = (ViewGroup) mTagsToViews.get(tag); ViewGroupManager viewManager = (ViewGroupManager) resolveViewManager(tag); @@ -568,6 +598,9 @@ public class NativeViewHierarchyManager { } protected final synchronized void addRootViewGroup(int tag, View view) { + if (DEBUG_MODE) { + FLog.d(TAG, "addRootViewGroup[%d]: %s", tag, (view != null ? view.toString() : "")); + } if (view.getId() != View.NO_ID) { FLog.e( TAG, @@ -587,6 +620,9 @@ public class NativeViewHierarchyManager { /** Releases all references to given native View. */ protected synchronized void dropView(View view) { + if (DEBUG_MODE) { + FLog.d(TAG, "dropView[%d]", (view != null ? view.getId() : -1)); + } UiThreadUtil.assertOnUiThread(); if (view == null) { // Ignore this drop operation when view is null. @@ -620,6 +656,9 @@ public class NativeViewHierarchyManager { } public synchronized void removeRootView(int rootViewTag) { + if (DEBUG_MODE) { + FLog.d(TAG, "removeRootView[%d]", rootViewTag); + } UiThreadUtil.assertOnUiThread(); if (!mRootTags.get(rootViewTag)) { SoftAssertions.assertUnreachable( @@ -635,6 +674,9 @@ public class NativeViewHierarchyManager { * {x, y, width, height}. */ public synchronized void measure(int tag, int[] outputBuffer) { + if (DEBUG_MODE) { + FLog.d(TAG, "measure[%d]", tag); + } UiThreadUtil.assertOnUiThread(); View v = mTagsToViews.get(tag); if (v == null) { @@ -699,6 +741,9 @@ public class NativeViewHierarchyManager { * relative to the device window */ public synchronized void measureInWindow(int tag, int[] outputBuffer) { + if (DEBUG_MODE) { + FLog.d(TAG, "measureInWindow[%d]", tag); + } UiThreadUtil.assertOnUiThread(); View v = mTagsToViews.get(tag); if (v == null) { @@ -720,6 +765,9 @@ public class NativeViewHierarchyManager { } public synchronized int findTargetTagForTouch(int reactTag, float touchX, float touchY) { + if (DEBUG_MODE) { + FLog.d(TAG, "findTargetTagForTouch[%d]: %f %f", reactTag, touchX, touchY); + } UiThreadUtil.assertOnUiThread(); View view = mTagsToViews.get(reactTag); if (view == null) { @@ -765,6 +813,14 @@ public class NativeViewHierarchyManager { @Deprecated public synchronized void dispatchCommand( int reactTag, int commandId, @Nullable ReadableArray args) { + if (DEBUG_MODE) { + FLog.d( + TAG, + "dispatchCommand[%d]: %d %s", + reactTag, + commandId, + (args != null ? args.toString() : "")); + } UiThreadUtil.assertOnUiThread(); View view = mTagsToViews.get(reactTag); if (view == null) { @@ -780,6 +836,14 @@ public class NativeViewHierarchyManager { public synchronized void dispatchCommand( int reactTag, String commandId, @Nullable ReadableArray args) { + if (DEBUG_MODE) { + FLog.d( + TAG, + "dispatchCommand[%d]: %s %s", + reactTag, + commandId, + (args != null ? args.toString() : "")); + } UiThreadUtil.assertOnUiThread(); View view = mTagsToViews.get(reactTag); if (view == null) {