Add logging to catch null TurboModules

Summary:
We're still seeing NativeModule eager-init crashes in T46487253. So, just to be extra careful, in case this diff doesn't fix the problem, I'm adding logging into `TurboModuleManager.getModule(moduleName)` to see why TurboModules are showing up as `null`.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21027984

fbshipit-source-id: 74ee62aeac09a4fdb29547e90ef4fa7c07de17a6
This commit is contained in:
Ramanpreet Nara
2020-04-14 18:27:15 -07:00
committed by Facebook GitHub Bot
parent eaba38361f
commit 8901d9518a
2 changed files with 14 additions and 0 deletions
@@ -16,9 +16,11 @@ rn_android_library(
react_native_dep("third-party/android/androidx:annotation"),
react_native_dep("java/com/facebook/proguard/annotations:annotations"),
react_native_dep("java/com/facebook/systrace:systrace"),
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/turbomodule/core/jni:jni"),
react_native_target("java/com/facebook/debug/holder:holder"),
react_native_target("java/com/facebook/react/bridge:interfaces"),
@@ -10,6 +10,7 @@ package com.facebook.react.turbomodule.core;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
@@ -17,6 +18,7 @@ import com.facebook.react.bridge.CxxModuleWrapper;
import com.facebook.react.bridge.JSIModule;
import com.facebook.react.bridge.JavaScriptContextHolder;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
import com.facebook.react.turbomodule.core.interfaces.TurboModuleRegistry;
@@ -114,6 +116,12 @@ public class TurboModuleManager implements JSIModule, TurboModuleRegistry {
/*
* Always return null after cleanup has started, so that getModule(moduleName) returns null.
*/
FLog.e(
ReactConstants.TAG,
"TurboModuleManager.getOrMaybeCreateTurboModuleHolder: Tried to require TurboModule "
+ moduleName
+ " after cleanup initiated");
return null;
}
@@ -174,6 +182,10 @@ public class TurboModuleManager implements JSIModule, TurboModuleRegistry {
* Therefore, we should initialize on the TurboModule now.
*/
((NativeModule) turboModule).initialize();
} else {
FLog.e(
ReactConstants.TAG,
"TurboModuleManager.getModule: TurboModule " + moduleName + " not found in delegate");
}
synchronized (moduleHolder) {