Skip to content

Commit

Permalink
Add Yoga JNI bindings to libcoldstart
Browse files Browse the repository at this point in the history
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
  • Loading branch information
davidaurelio authored and facebook-github-bot committed Nov 7, 2018
1 parent 31439f8 commit 2a8f6c3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ReactAndroid/src/main/java/com/facebook/yoga/YogaJNI.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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;
Expand All @@ -19,12 +20,13 @@ public class YogaJNI {

private static native void jni_bindNativeMethods(boolean useFastCall);

static boolean init() {
if (SoLoader.loadLibrary("yoga")) {
static synchronized boolean init() {
if (!isInitialized) {
isInitialized = true;
SoLoader.loadLibrary("yoga");
jni_bindNativeMethods(useFastCall);
return true;
}

return false;
}
}

0 comments on commit 2a8f6c3

Please sign in to comment.