mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
33 lines
829 B
Java
33 lines
829 B
Java
/*
|
|
* 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.yoga;
|
|
|
|
import com.facebook.soloader.SoLoader;
|
|
|
|
public class YogaJNI {
|
|
private static boolean isInitialized = false;
|
|
|
|
// Known constants. 1-3 used in previous experiments. Do not reuse.
|
|
public static int JNI_FAST_CALLS = 4;
|
|
|
|
// set before loading any other Yoga code
|
|
public static boolean useFastCall = false;
|
|
|
|
private static native void jni_bindNativeMethods(boolean useFastCall);
|
|
|
|
static synchronized boolean init() {
|
|
if (!isInitialized) {
|
|
isInitialized = true;
|
|
SoLoader.loadLibrary("yoga");
|
|
jni_bindNativeMethods(useFastCall);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|