Add Yoga JNI bindings to libcoldstart
Summary: Yoga's JNI bindings are usually loaded during class loading, and can stall the UI thread. Here, we try to mitigate the problem by adding the bindings to libcoldstart. Reviewed By: michalgr Differential Revision: D12956818 fbshipit-source-id: 9dda5cb6d26c2bae64606bc2d7c98ab8f7c05a30
This commit is contained in:
committed by
Facebook Github Bot
parent
a0b3586fb3
commit
7a60399b2b
@@ -10,6 +10,7 @@ yoga_cxx_library(
|
|||||||
srcs = glob(["jni/*.cpp"]),
|
srcs = glob(["jni/*.cpp"]),
|
||||||
headers = glob(["jni/*.h"]),
|
headers = glob(["jni/*.h"]),
|
||||||
header_namespace = "",
|
header_namespace = "",
|
||||||
|
allow_jni_merging = True,
|
||||||
compiler_flags = [
|
compiler_flags = [
|
||||||
"-fno-omit-frame-pointer",
|
"-fno-omit-frame-pointer",
|
||||||
"-fexceptions",
|
"-fexceptions",
|
||||||
|
@@ -10,6 +10,7 @@ package com.facebook.yoga;
|
|||||||
import com.facebook.soloader.SoLoader;
|
import com.facebook.soloader.SoLoader;
|
||||||
|
|
||||||
public class YogaJNI {
|
public class YogaJNI {
|
||||||
|
private static boolean isInitialized = false;
|
||||||
|
|
||||||
// Known constants. 1-3 used in previous experiments. Do not reuse.
|
// Known constants. 1-3 used in previous experiments. Do not reuse.
|
||||||
public static int JNI_FAST_CALLS = 4;
|
public static int JNI_FAST_CALLS = 4;
|
||||||
@@ -19,12 +20,13 @@ public class YogaJNI {
|
|||||||
|
|
||||||
private static native void jni_bindNativeMethods(boolean useFastCall);
|
private static native void jni_bindNativeMethods(boolean useFastCall);
|
||||||
|
|
||||||
static boolean init() {
|
static synchronized boolean init() {
|
||||||
if (SoLoader.loadLibrary("yoga")) {
|
if (!isInitialized) {
|
||||||
|
isInitialized = true;
|
||||||
|
SoLoader.loadLibrary("yoga");
|
||||||
jni_bindNativeMethods(useFastCall);
|
jni_bindNativeMethods(useFastCall);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -174,6 +174,8 @@ def yoga_cxx_binary(*args, **kwargs):
|
|||||||
def yoga_cxx_library(*args, **kwargs):
|
def yoga_cxx_library(*args, **kwargs):
|
||||||
# Currently unused
|
# Currently unused
|
||||||
kwargs.pop("platforms", None)
|
kwargs.pop("platforms", None)
|
||||||
|
kwargs.pop("allow_jni_merging", None)
|
||||||
|
|
||||||
native.cxx_library(*args, **kwargs)
|
native.cxx_library(*args, **kwargs)
|
||||||
|
|
||||||
def yoga_cxx_test(*args, **kwargs):
|
def yoga_cxx_test(*args, **kwargs):
|
||||||
|
Reference in New Issue
Block a user