From 8901d9518a5d578f528b6b94a797b4b6e4cf69c5 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 14 Apr 2020 18:24:23 -0700 Subject: [PATCH] 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 --- .../java/com/facebook/react/turbomodule/core/BUCK | 2 ++ .../react/turbomodule/core/TurboModuleManager.java | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK index ab6fd1ad0ef..f3e34f4e46e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/BUCK @@ -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"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java index 52647dd0129..1b97c5bd62d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleManager.java @@ -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) {