Kudo/react-native-v8

Couldn't find DSO to load: libv8executor.so

RodolfoGS opened this issue ยท 7 comments

I'm having a lot of errors in Crashlytics with the following stack trace, I don't know how to reproduce since in my device all works perfectly. This happens to some users in production and I noticed that all devices are in Android 5.

Devices affected:

image

image

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libv8executor.so caused by: dlopen failed: empty/missing DT_HASH in "libv8android.so" (built with --hash-style=gnu?) result: 0
       at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:1098)
       at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SoLoader.java:914)
       at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:826)
       at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:773)
       at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:743)
       at io.csie.kudo.reactnative.v8.executor.V8Executor.<clinit>(V8Executor.java:21)
       at io.csie.kudo.reactnative.v8.executor.V8ExecutorFactory.create(V8ExecutorFactory.java:50)
       at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1112)
       at java.lang.Thread.run(Thread.java:818)
Caused by java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH in "libv8android.so" (built with --hash-style=gnu?)
       at java.lang.Runtime.load(Runtime.java:331)
       at java.lang.System.load(System.java:981)
       at com.facebook.soloader.SoLoader$1.load(SoLoader.java:529)
       at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:110)
       at com.facebook.soloader.DirectorySoSource.loadLibrary(DirectorySoSource.java:63)
       at com.facebook.soloader.ApplicationSoSource.loadLibrary(ApplicationSoSource.java:91)
       at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:1038)
       at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SoLoader.java:914)
       at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:826)
       at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:773)
       at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:743)
       at io.csie.kudo.reactnative.v8.executor.V8Executor.<clinit>(V8Executor.java:21)
       at io.csie.kudo.reactnative.v8.executor.V8ExecutorFactory.create(V8ExecutorFactory.java:50)
       at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1112)
       at java.lang.Thread.run(Thread.java:818)

I'm using:

expo: 45.0.5
react-native: 0.68.2
react-native-v8: 1.4.1
v8-android-nointl: 10.100.0
Kudo commented

hi there! the issue sounds like this one: https://stackoverflow.com/questions/28638809/android-ndk-unsatisfiedlinkerror-dlopen-failed-empty-missing-dt-hash
i checked the v8's default minSdkVersion is 23, will try to build a v8-android with minSdkVersion=21.
will update here once it's released. thanks!

@Kudo were you be able to test it on Android 5?

I couldn't because my Android Studio Simulator crash with that Android version (The emulator process for AVD has terminated), not related to v8, and I can't use Genymotion because it's not compatible with Apple M1

Finally I could reproduce the crash using Genymotion Cloud running a Samsung Galaxy S6 with Android 5.0, it's super easy to reproduce. Just create an APK release and run on Android 5. It crash at start.

I tested with react-native 0.68.2 since 0.69 fails to compile.

I created a repo to reproduce but just consist in create a new react-native project, configure v8, create apk release and run on Android 5.

How to reproduce

Clone the repo: https://github.com/RodolfoGS/react-native-v8-crash/tree/main

Here are 2 branched (v8-enabled and v8-disabled)

  1. Just checkout v8-disabled branch, yarn install, create apk release and run on Android 5. It works.
  2. Then checkout v8-enabled branch, yarn install, create apk release and run on Android 5. It crash.

According to this seems that the flag --hash-style=both fixes the issue:

GNU hashes (Availible in API level >= 23)

The GNU hash style available with --hash-style=gnu allows faster symbol lookup and is now supported by the dynamic linker in API 23 and above. (Use --hash-style=both if you want to build code that uses this feature >= Android M but still works on older releases.)

Source 1: https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#gnu-hashes-availible-in-api-level-23
Source 2: https://stackoverflow.com/a/53806411/1687136

@Kudo do you know where I need to put that flag? (--hash-style=both)

I tried putting in node_modules/react-native-v8/android/CMakeLists.txt

APP_LDFLAGS := -Wl,--build-id,--hash-style=both

But doesn't work, do you have any idea about this?

Kudo commented

that's clever to use genymotion cloud. if that don't take too much time, could you help me to verify whether v8-android-*@next, e.g. v8-android-jit@next fixes the crash issue? i'm not pretty sure if this change can fix the issue

Woow that worked!! Tested v8-android-nointl: 10.100.1 (next) and works perfectly on Android 5 (API 21)

Kudo commented

awesome! thanks @RodolfoGS. everything looks good and i promoted 10.100.1 as latest.
i am going to close this issue. if there's any other problems, please create a new issue for me. thanks!