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
This commit is contained in:
Joshua Gross
2020-06-16 17:04:22 -07:00
committed by Facebook GitHub Bot
parent fa0e6f8051
commit 2e2c881147
@@ -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;