From 2e2c8811472be491521c08b56b2e72a0e1330b0d Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 16 Jun 2020 17:02:37 -0700 Subject: [PATCH] NativeAnimatedModule should not crash if UIManager disappears Summary: If UIManager disappears, it's likely due to (1) teardown due to memory pressure, (2) teardown due to crash, (3) normal teardown. In all of those cases, I would just want NativeAnimatedModule to stop executing and fail silently ASAP. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D22079209 fbshipit-source-id: 21650abdfdb119a6f4abccd6962d0c09f7c7c6cd --- .../react/animated/NativeAnimatedNodesManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java index 0e8f92e3991..0156393d310 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java @@ -16,6 +16,8 @@ import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.JSApplicationCausedNativeException; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReactNoCrashSoftException; +import com.facebook.react.bridge.ReactSoftException; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.UIManager; @@ -321,8 +323,12 @@ import java.util.Queue; UIManager uiManager = UIManagerHelper.getUIManagerForReactTag(mReactApplicationContext, viewTag); if (uiManager == null) { - throw new IllegalStateException( - "Animated node could not be connected to UIManager: " + viewTag); + ReactSoftException.logSoftException( + TAG, + new ReactNoCrashSoftException( + "Animated node could not be connected to UIManager - uiManager disappeared for tag: " + + viewTag)); + return; } PropsAnimatedNode propsAnimatedNode = (PropsAnimatedNode) node;