Skip to content

Commit

Permalink
Rename libv8.so to libv8android.so
Browse files Browse the repository at this point in the history
Summary:
    On some Android device, there is libv8.so in system ROM.
    E.g. /system/lib/libv8.so or /vendor/lib/libv8.so

    On old Android, dlopen() with RTLD_GLOBAL is not handled well and it's by default RTLD_LOCAL.
    Even we call System.loadLibrary("v8") before,
    during the time RNV8 call System.loadLibrary("v8executor") and search libv8.so in DT_NEEDED.
    It seems bionic linker will use system libv8.so instead of ours.
    Since our libv8.so is customized with libplatform.so, this leads to unresolved symbol as
    #29.

    That's why I am proposing to rename libv8.so as libv8android.so and to prevent name conflict from system libv8.so.

    Reference for RTLD_GLOBAL: android/ndk#201
  • Loading branch information
Kudo committed Nov 7, 2019
1 parent 9d0951e commit 7ae3b42
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ yarn add 'react-native-v8@>=0.60.0-patch.0 <0.60.1'
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
+ // Add v8-android - prebuilt libv8.so into APK
+ // Add v8-android - prebuilt libv8android.so into APK
+ implementation 'org.chromium:v8-android:+'

// JSC from node_modules
Expand All @@ -60,7 +60,7 @@ yarn add 'react-native-v8@>=0.60.0-patch.0 <0.60.1'
+ url("$rootDir/../node_modules/react-native-v8/dist")
+ }
+ maven {
+ // prebuilt libv8.so
+ // prebuilt libv8android.so
+ url("$rootDir/../node_modules/v8-android/dist")
}
maven {
Expand Down Expand Up @@ -109,7 +109,7 @@ $ yarn add v8-android-nointl
@@ -29,7 +29,7 @@ allprojects {
}
maven {
// prebuilt libv8.so
// prebuilt libv8android.so
- url("$rootDir/../node_modules/v8-android/dist")
+ url("$rootDir/../node_modules/v8-android-nointl/dist")
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"RN_VERSION": "v0.61.4"
},
"dependencies": {
"v8-android": "^7.8.0"
"v8-android": "7.8.x >= 7.8.1"
},
"peerDependencies": {
"react-native": "^0.61.0"
Expand Down
2 changes: 1 addition & 1 deletion src/androidexecutor/reactexecutor/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(REACT_NATIVE
LOCAL_CPP_FEATURES := exceptions

LOCAL_STATIC_LIBRARIES := libjsireact libjsi v8runtime
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni libv8
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni libv8android

include $(BUILD_SHARED_LIBRARY)
2 changes: 0 additions & 2 deletions src/androidexecutor/reactexecutor/V8Executor.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

public class V8Executor extends JavaScriptExecutor {
static {
// libv8 must be loaded explicitly to invoke its JNI_OnLoad.
SoLoader.loadLibrary("v8");
SoLoader.loadLibrary("v8executor");
}

Expand Down
2 changes: 1 addition & 1 deletion src/patches/build_with_v8.patch
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ index 3a155af..587c95d 100644
into("$buildDir/react-ndk/exported")
exclude("**/libjsc.so")
exclude("**/libhermes.so")
+ exclude("**/libv8.so")
+ exclude("**/libv8android.so")
}

task packageReactNdkLibsForBuck(dependsOn: packageReactNdkLibs, type: Copy) {
Expand Down
4 changes: 2 additions & 2 deletions src/sowrapper/Android.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= v8
LOCAL_SRC_FILES := jni/$(TARGET_ARCH_ABI)/libv8.so
LOCAL_MODULE:= v8android
LOCAL_SRC_FILES := jni/$(TARGET_ARCH_ABI)/libv8android.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)
2 changes: 1 addition & 1 deletion src/v8runtime/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ ifeq ($(APP_OPTIM),release)
LOCAL_CFLAGS += -O3
endif

LOCAL_SHARED_LIBRARIES := libfolly_json libv8 glog
LOCAL_SHARED_LIBRARIES := libfolly_json libv8android glog

include $(BUILD_STATIC_LIBRARY)

0 comments on commit 7ae3b42

Please sign in to comment.