Pretty-print Native AnimatedNode values

Summary:
For debugging, add prettyPrint method to AnimatedNode classes.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22752292

fbshipit-source-id: ce1f08fc4fd97f38629dd82151c6ea762026c7c9
This commit is contained in:
Joshua Gross
2020-07-25 13:40:35 -07:00
committed by Facebook GitHub Bot
parent 8d613c6f32
commit ab5e87fd95
13 changed files with 130 additions and 0 deletions
@@ -43,4 +43,14 @@ import com.facebook.react.bridge.ReadableMap;
}
}
}
@Override
public String prettyPrint() {
return "AdditionAnimatedNode["
+ mTag
+ "]: input nodes: "
+ (mInputNodes != null ? mInputNodes.toString() : "null")
+ " - super: "
+ super.prettyPrint();
}
}
@@ -57,4 +57,20 @@ import java.util.List;
* it can be used to calculate node's value.
*/
public void update() {}
/**
* Pretty-printer for the AnimatedNode. Only called in production pre-crash for debug diagnostics.
*/
public abstract String prettyPrint();
public String prettyPrintWithChildren() {
String children = "";
if (mChildren != null && mChildren.size() > 0) {
for (AnimatedNode child : mChildren) {
children += " " + child.mTag;
}
}
return prettyPrint() + (children.length() > 0 ? " children: " + children : "");
}
}
@@ -46,4 +46,19 @@ import com.facebook.react.bridge.ReadableMap;
return ((ValueAnimatedNode) animatedNode).getValue();
}
public String prettyPrint() {
return "DiffClampAnimatedNode["
+ mTag
+ "]: InputNodeTag: "
+ mInputNodeTag
+ " min: "
+ mMin
+ " max: "
+ mMax
+ " lastValue: "
+ mLastValue
+ " super: "
+ super.prettyPrint();
}
}
@@ -51,4 +51,14 @@ import com.facebook.react.bridge.ReadableMap;
}
}
}
@Override
public String prettyPrint() {
return "DivisionAnimatedNode["
+ mTag
+ "]: input nodes: "
+ (mInputNodes != null ? mInputNodes.toString() : "null")
+ " - super: "
+ super.prettyPrint();
}
}
@@ -249,4 +249,8 @@ import java.util.regex.Pattern;
}
}
}
public String prettyPrint() {
return "InterpolationAnimatedNode[" + mTag + "] super: " + super.prettyPrint();
}
}
@@ -34,4 +34,15 @@ import com.facebook.react.bridge.ReadableMap;
"Illegal node ID set as an input for " + "Animated.modulus node");
}
}
public String prettyPrint() {
return "NativeAnimatedNodesManager["
+ mTag
+ "] inputNode: "
+ mInputNode
+ " modulus: "
+ mModulus
+ " super: "
+ super.prettyPrint();
}
}
@@ -43,4 +43,14 @@ import com.facebook.react.bridge.ReadableMap;
}
}
}
@Override
public String prettyPrint() {
return "MultiplicationAnimatedNode["
+ mTag
+ "]: input nodes: "
+ (mInputNodes != null ? mInputNodes.toString() : "null")
+ " - super: "
+ super.prettyPrint();
}
}
@@ -113,4 +113,15 @@ import java.util.Map;
mUIManager.synchronouslyUpdateViewOnUIThread(mConnectedViewTag, mPropMap);
}
public String prettyPrint() {
return "PropsAnimatedNode["
+ mTag
+ "] connectedViewTag: "
+ mConnectedViewTag
+ " mPropNodeMapping: "
+ (mPropNodeMapping != null ? mPropNodeMapping.toString() : "null")
+ " mPropMap: "
+ (mPropMap != null ? mPropMap.toString() : "null");
}
}
@@ -49,4 +49,11 @@ import java.util.Map;
}
}
}
public String prettyPrint() {
return "StyleAnimatedNode["
+ mTag
+ "] mPropMapping: "
+ (mPropMapping != null ? mPropMapping.toString() : "null");
}
}
@@ -47,4 +47,14 @@ import com.facebook.react.bridge.ReadableMap;
}
}
}
@Override
public String prettyPrint() {
return "SubtractionAnimatedNode["
+ mTag
+ "]: input nodes: "
+ (mInputNodes != null ? mInputNodes.toString() : "null")
+ " - super: "
+ super.prettyPrint();
}
}
@@ -33,4 +33,18 @@ import com.facebook.react.bridge.ReadableMap;
mNativeAnimatedNodesManager.startAnimatingNode(
mAnimationId, mValueNode, mAnimationConfig, null);
}
@Override
public String prettyPrint() {
return "TrackingAnimatedNode["
+ mTag
+ "]: animationID: "
+ mAnimationId
+ " toValueNode: "
+ mToValueNode
+ " valueNode: "
+ mValueNode
+ " animationConfig: "
+ mAnimationConfig;
}
}
@@ -82,4 +82,12 @@ import java.util.List;
propsMap.putArray("transform", JavaOnlyArray.from(transforms));
}
@Override
public String prettyPrint() {
return "TransformAnimatedNode["
+ mTag
+ "]: mTransformConfigs: "
+ (mTransformConfigs != null ? mTransformConfigs.toString() : "null");
}
}
@@ -60,4 +60,8 @@ import com.facebook.react.bridge.ReadableMap;
public void setValueListener(@Nullable AnimatedNodeValueListener listener) {
mValueListener = listener;
}
public String prettyPrint() {
return "ValueAnimatedNode[" + mTag + "]: value: " + mValue + " offset: " + mOffset;
}
}