From b3a07685f25c6d40a7177a1e40f899d407db4a4b Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 30 Apr 2019 15:01:38 -0700 Subject: [PATCH] Add debug information in Mounting Manager Summary: Easy diff that adds debug information in Mounting Manager Reviewed By: JoshuaGross Differential Revision: D15076577 fbshipit-source-id: 183c87c929ea7a99f0667956c33012d7dfdb246e --- .../fabric/mounting/MountingManager.java | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 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 050f6dd3083..ac6dc938d1c 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 @@ -7,14 +7,13 @@ package com.facebook.react.fabric.mounting; import android.content.Context; -import androidx.annotation.AnyThread; -import androidx.annotation.Nullable; -import androidx.annotation.UiThread; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; +import androidx.annotation.AnyThread; +import androidx.annotation.Nullable; +import androidx.annotation.UiThread; import com.facebook.infer.annotation.Assertions; -import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableNativeMap; @@ -33,7 +32,6 @@ import com.facebook.react.uimanager.ViewGroupManager; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManagerRegistry; import com.facebook.yoga.YogaMeasureMode; -import android.util.Log; import java.util.concurrent.ConcurrentHashMap; /** @@ -95,7 +93,8 @@ public class MountingManager { mTagToViewState.remove(reactTag); Context context = view.getContext(); if (context instanceof ThemedReactContext) { - // We only recycle views that were created by RN (its context is instance of ThemedReactContext) + // We only recycle views that were created by RN (its context is instance of + // ThemedReactContext) mViewFactory.recycle( (ThemedReactContext) context, Assertions.assertNotNull(viewManager).getName(), view); } @@ -123,7 +122,7 @@ public class MountingManager { ViewState viewState = getViewState(tag); final View view = viewState.mView; if (view == null) { - throw new IllegalStateException("Unable to find view for view " + viewState); + throw new IllegalStateException("Unable to find view for viewState " + viewState); } getViewGroupManager(parentViewState).addView(parentView, view, index); } @@ -305,21 +304,20 @@ public class MountingManager { if (viewManager == null) { throw new IllegalStateException("Unable to find ViewManager for tag: " + reactTag); } - viewManager.updateState( - viewState.mView, - stateWrapper); + viewManager.updateState(viewState.mView, stateWrapper); } @UiThread public void preallocateView( - ThemedReactContext reactContext, - String componentName, - int reactTag, - ReadableMap props, - boolean isLayoutable) { + ThemedReactContext reactContext, + String componentName, + int reactTag, + ReadableMap props, + boolean isLayoutable) { if (mTagToViewState.get(reactTag) != null) { - throw new IllegalStateException("View for component " + componentName + " with tag " + reactTag + " already exists."); + throw new IllegalStateException( + "View for component " + componentName + " with tag " + reactTag + " already exists."); } createViewWithProps(reactContext, componentName, reactTag, props, isLayoutable); @@ -381,7 +379,19 @@ public class MountingManager { @Override public String toString() { - return "ViewState [" + mReactTag + "] - isRoot: " + mIsRoot + " - props: " + mCurrentProps + " - localData: " + mCurrentLocalData + " - viewManager: " + mViewManager; + boolean isLayoutOnly = mViewManager == null; + return "ViewState [" + + mReactTag + + "] - isRoot: " + + mIsRoot + + " - props: " + + mCurrentProps + + " - localData: " + + mCurrentLocalData + + " - viewManager: " + + mViewManager + + " - isLayoutOnly: " + + isLayoutOnly; } } }