Add logging to debug Fabric diffing algorithm

Reviewed By: achen1

Differential Revision: D7319185

fbshipit-source-id: fe47c21db5e1415aebe806f0d74b1f65f667a397
This commit is contained in:
David Vacca 2018-03-19 18:21:43 -07:00 committed by Facebook Github Bot
parent 7d3de1016a
commit cc3d45d2e9
3 changed files with 32 additions and 2 deletions

View File

@ -7,10 +7,12 @@
package com.facebook.react.fabric;
import android.util.Log;
import com.facebook.react.common.ArrayUtils;
import com.facebook.react.uimanager.ReactShadowNode;
import com.facebook.react.uimanager.UIViewOperationQueue;
import com.facebook.react.uimanager.ViewAtIndex;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
@ -20,6 +22,9 @@ import javax.annotation.Nullable;
public class FabricReconciler {
private static final String TAG = FabricReconciler.class.getSimpleName();
private static final boolean DEBUG = true;
private UIViewOperationQueue uiViewOperationQueue;
public FabricReconciler(UIViewOperationQueue uiViewOperationQueue) {
@ -101,8 +106,17 @@ public class FabricReconciler {
}
}
int[] tagsToDeleteArray = ArrayUtils.copyListToArray(tagsToDelete);
if (DEBUG) {
Log.d(
TAG,
"manageChildren.enqueueManageChildren parent: " + parent.getReactTag() +
"\n\tIndices2Remove: " + Arrays.toString(indicesToRemove) +
"\n\tViews2Add: " + Arrays.toString(viewsToAdd) +
"\n\tTags2Delete: " + Arrays.toString(tagsToDeleteArray));
}
uiViewOperationQueue.enqueueManageChildren(
parent.getReactTag(), indicesToRemove, viewsToAdd, ArrayUtils.copyListToArray(tagsToDelete));
parent.getReactTag(), indicesToRemove, viewsToAdd, tagsToDeleteArray);
}
}

View File

@ -42,7 +42,8 @@ import javax.annotation.Nullable;
@SuppressWarnings("unused") // used from JNI
public class FabricUIManager implements UIManager {
private static final String TAG = FabricUIManager.class.toString();
private static final String TAG = FabricUIManager.class.getSimpleName();
private static final boolean DEBUG = true;
private final RootShadowNodeRegistry mRootShadowNodeRegistry = new RootShadowNodeRegistry();
private final ReactApplicationContext mReactApplicationContext;
private final ViewManagerRegistry mViewManagerRegistry;
@ -225,9 +226,19 @@ public class FabricUIManager implements UIManager {
rootNode = calculateDiffingAndCreateNewRootNode(rootNode, childList);
if (DEBUG) {
Log.d(TAG, "ReactShadowNodeHierarchy after diffing: " + rootNode.getHierarchyInfo());
}
notifyOnBeforeLayoutRecursive(rootNode);
rootNode.calculateLayout();
if (DEBUG) {
Log.d(
TAG,
"ReactShadowNodeHierarchy after calculate Layout: " + rootNode.getHierarchyInfo());
}
applyUpdatesRecursive(rootNode, 0, 0);
mUIViewOperationQueue.dispatchViewUpdates(
mCurrentBatch++, System.currentTimeMillis(), System.currentTimeMillis());

View File

@ -28,4 +28,9 @@ public class ViewAtIndex {
mTag = tag;
mIndex = index;
}
@Override
public String toString() {
return "[" + mIndex + ", " + mTag + "]";
}
}