Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,7 @@ public enum ReactMarkerConstants {
REACT_BRIDGE_LOADING_START,
REACT_BRIDGE_LOADING_END,
REACT_BRIDGELESS_LOADING_START,
REACT_BRIDGELESS_LOADING_END
REACT_BRIDGELESS_LOADING_END,
LOAD_REACT_NATIVE_MAPBUFFER_SO_FILE_START,
LOAD_REACT_NATIVE_MAPBUFFER_SO_FILE_END,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [],
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
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;
Expand All @@ -23,7 +22,7 @@
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public class ReactFeatureFlags {
/** Enables JS Responder in Fabric */
public static boolean enableJSResponder = false;

/** Feature flag to configure eager initialization of MapBuffer So file */
public static boolean enableEagerInitializeMapBufferSoFile = false;

/** An interface used to compute flags on demand. */
public interface FlagProvider {
boolean get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.bridge.queue.MessageQueueThread;
import com.facebook.react.common.mapbuffer.ReadableMapBuffer;
import com.facebook.react.common.mapbuffer.ReadableMapBufferSoLoader;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.fabric.events.EventBeatManager;
import com.facebook.react.fabric.events.EventEmitterWrapper;
Expand Down Expand Up @@ -67,6 +69,9 @@ public UIManager get() {
if (ReactFeatureFlags.eagerInitializeFabricClasses) {
loadClasses();
}
if (ReactFeatureFlags.enableEagerInitializeMapBufferSoFile) {
ReadableMapBufferSoLoader.staticInit();
}
MessageQueueThread jsMessageQueueThread =
mReactApplicationContext
.getCatalystInstance()
Expand Down Expand Up @@ -138,5 +143,6 @@ private static void loadClasses() {
SurfaceHandlerBinding.class.getClass();
BatchEventDispatchedListener.class.getClass();
ReactNativeConfig.class.getClass();
ReadableMapBuffer.class.getClass();
}
}