From e661a551cb153951daabae12b7cebf6232cfd9b7 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Sat, 20 Jun 2020 17:45:25 -0700 Subject: [PATCH] Potential fix for, and more diagnostics for, NativeAnimatedModule crash Summary: Searching for details and maybe a fix for T68843308 crashing in disconnectFromView, "Attempting to disconnect view that has not been connected with the given animated node". May be related to recent refactoring but it's not clear. Change logic slightly and add more diagnostic information. Changelog: [Internal] Reviewed By: shergin Differential Revision: D22153179 fbshipit-source-id: b95dbaf01ae8bca154c61442898b0f9d3aebb4de --- .../com/facebook/react/animated/PropsAnimatedNode.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/PropsAnimatedNode.java b/ReactAndroid/src/main/java/com/facebook/react/animated/PropsAnimatedNode.java index 4a0293e982b..42cb57a7ec3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/animated/PropsAnimatedNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/PropsAnimatedNode.java @@ -45,17 +45,20 @@ import java.util.Map; public void connectToView(int viewTag, UIManager uiManager) { if (mConnectedViewTag != -1) { throw new JSApplicationIllegalArgumentException( - "Animated node " + mTag + " is " + "already attached to a view"); + "Animated node " + mTag + " is " + "already attached to a view: " + mConnectedViewTag); } mConnectedViewTag = viewTag; mUIManager = uiManager; } public void disconnectFromView(int viewTag) { - if (mConnectedViewTag != viewTag) { + if (mConnectedViewTag != viewTag && mConnectedViewTag != -1) { throw new JSApplicationIllegalArgumentException( "Attempting to disconnect view that has " - + "not been connected with the given animated node"); + + "not been connected with the given animated node: " + + viewTag + + " but is connected to view " + + mConnectedViewTag); } mConnectedViewTag = -1;