mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
In modules or classes that call ReactApplicationContext.getJSModule, ensure that there's still a CatalystInstance alive
Summary: In D18032458 we introduce getReactApplicationContextIfActiveOrWarn. In this diff, modules that access a JS or Native module through ReactApplicationContext need to check if the CatalystInstance is still alive before continuing. Modules that don't derive from `ReactContextBaseJavaModule` manually check for the catalyst impl and log their own SoftExceptions. In this diff we also introduce SoftExceptions that by contract never cause crashes, even in debug mode. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D18112989 fbshipit-source-id: 868f01f388aa2db3518db9f873f2afc2a62eed45
This commit is contained in:
committed by
Facebook Github Bot
parent
070520beea
commit
94cb4bf90c
+10
-3
@@ -25,6 +25,8 @@ import com.facebook.react.R;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
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.ReadableMapKeySetIterator;
|
||||
@@ -278,9 +280,14 @@ public class ReactAccessibilityDelegate extends AccessibilityDelegateCompat {
|
||||
final WritableMap event = Arguments.createMap();
|
||||
event.putString("actionName", mAccessibilityActionsMap.get(action));
|
||||
ReactContext reactContext = (ReactContext) host.getContext();
|
||||
reactContext
|
||||
.getJSModule(RCTEventEmitter.class)
|
||||
.receiveEvent(host.getId(), "topAccessibilityAction", event);
|
||||
if (reactContext.hasActiveCatalystInstance()) {
|
||||
reactContext
|
||||
.getJSModule(RCTEventEmitter.class)
|
||||
.receiveEvent(host.getId(), "topAccessibilityAction", event);
|
||||
} else {
|
||||
ReactSoftException.logSoftException(
|
||||
TAG, new ReactNoCrashSoftException("Cannot get RCTEventEmitter, no CatalystInstance"));
|
||||
}
|
||||
|
||||
// In order to make Talkback announce the change of the adjustable's value,
|
||||
// schedule to send a TYPE_VIEW_SELECTED event after performing the scroll actions.
|
||||
|
||||
Reference in New Issue
Block a user