Create ReactFeatureFlag to initialize MapBufferSo file during Fabric initialization

Summary:
This diff creates a ReactFeatureFlag to initialize MapBufferSo file during Fabric initialization.

This is necessary to be able to compare properly Mapbuffer vs ReadableNativeMap (because ReadableNativeMap c++ files is already included in the bridge so file)

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D28436044

fbshipit-source-id: 338e1bb72b5313dc29a309e1b0e979e7c8bd1c18
This commit is contained in:
David Vacca
2021-05-14 12:55:24 -07:00
committed by Facebook GitHub Bot
parent 73fbe80fc4
commit 0b371304aa
6 changed files with 49 additions and 3 deletions
@@ -21,6 +21,9 @@ rn_android_library(
react_native_dep("third-party/android/androidx:annotation"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_target("java/com/facebook/react/common:common"),
# dependencies used for systraces
react_native_dep("java/com/facebook/systrace:systrace"),
react_native_target("java/com/facebook/react/bridge:bridge"),
],
exported_deps = [],
)
@@ -10,7 +10,6 @@ package com.facebook.react.common.mapbuffer;
import androidx.annotation.Nullable;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Iterator;
@@ -23,7 +22,7 @@ import java.util.Iterator;
public class ReadableMapBuffer implements Iterable<ReadableMapBuffer.MapBufferEntry> {
static {
SoLoader.loadLibrary("mapbufferjni");
ReadableMapBufferSoLoader.staticInit();
}
// Value used to verify if the data is serialized with LittleEndian order.
@@ -0,0 +1,33 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.common.mapbuffer;
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.soloader.SoLoader;
import com.facebook.systrace.Systrace;
public class ReadableMapBufferSoLoader {
private static volatile boolean sDidInit = false;
public static void staticInit() {
if (sDidInit) {
return;
}
Systrace.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"ReadableMapBufferSoLoader.staticInit::load:mapbufferjni");
ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_MAPBUFFER_SO_FILE_START);
SoLoader.loadLibrary("mapbufferjni");
ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_MAPBUFFER_SO_FILE_END);
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
sDidInit = true;
}
}