mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Check that CatalystInstance is active for non-NativeModule callsites of ReactContext.getJSModule
Summary: In previous diffs I migrated many (all?) NativeModules in FB and open-source to check for `hasActiveCatalystInstance` before calling `getJSModule`. We log SoftExceptions in those cases to find more potential race condition and lifecycle bugs without crashing. In this diff, I migrate all the non-NativeModule callsites that I could find. Previous diffs: see D18032458, D18035359, D18032788, D18092136, D18092137, D18112989, D18134400 Changelog: [Internal] Reviewed By: mdvacca, mmmulani Differential Revision: D18134694 fbshipit-source-id: 4729abfb84280b634463b1cd9b4dd808f310b6e7
This commit is contained in:
committed by
Facebook Github Bot
parent
9446277fc1
commit
b55146f776
@@ -67,6 +67,8 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReactMarker;
|
||||
import com.facebook.react.bridge.ReactMarkerConstants;
|
||||
import com.facebook.react.bridge.ReactNoCrashSoftException;
|
||||
import com.facebook.react.bridge.ReactSoftException;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.bridge.WritableNativeMap;
|
||||
@@ -477,10 +479,15 @@ public class ReactInstanceManager {
|
||||
|
||||
private void toggleElementInspector() {
|
||||
ReactContext currentContext = getCurrentReactContext();
|
||||
if (currentContext != null) {
|
||||
if (currentContext != null && currentContext.hasActiveCatalystInstance()) {
|
||||
currentContext
|
||||
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
||||
.emit("toggleElementInspector", null);
|
||||
} else {
|
||||
ReactSoftException.logSoftException(
|
||||
TAG,
|
||||
new ReactNoCrashSoftException(
|
||||
"Cannot toggleElementInspector, CatalystInstance not available"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user