Delay turbomodulejsijni so load until we need it in TurboModulePerfLogger
Summary: Twilight doesn't have TMPerfLogging enabled. However, the TurboModule infra uses the TMPerfLogger java class everywhere, which loads the turbomodulejsijni library on class load. For some reason, this class load doesn't work, and causes Twilight prod to crash. To mitigate that crash, this diff delays the so load until it's absolutely necessary, which is by the time we call jniEnableCppLogging. This should never be called in Twilight, because it doesn't have TMPerfLogging enabled. Therefore, the crash should disappear on Twilight. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D23192072 fbshipit-source-id: b73ece580e4345dbf835b0fc2f7d43b90f202411
This commit is contained in:
Родитель
f3930a93d5
Коммит
3f77367883
|
@ -13,10 +13,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
public class TurboModulePerfLogger {
|
||||
@Nullable private static NativeModulePerfLogger sNativeModulePerfLogger = null;
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary("turbomodulejsijni");
|
||||
}
|
||||
private static boolean sIsSoLibraryLoaded = false;
|
||||
|
||||
public static void moduleDataCreateStart(String moduleName, int id) {
|
||||
if (sNativeModulePerfLogger != null) {
|
||||
|
@ -80,9 +77,17 @@ public class TurboModulePerfLogger {
|
|||
|
||||
private static native void jniEnableCppLogging(NativeModulePerfLogger perfLogger);
|
||||
|
||||
private static synchronized void maybeLoadSoLibrary() {
|
||||
if (!sIsSoLibraryLoaded) {
|
||||
SoLoader.loadLibrary("turbomodulejsijni");
|
||||
sIsSoLibraryLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void enableLogging(NativeModulePerfLogger perfLogger) {
|
||||
if (perfLogger != null) {
|
||||
sNativeModulePerfLogger = perfLogger;
|
||||
maybeLoadSoLibrary();
|
||||
jniEnableCppLogging(perfLogger);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче