Skip to content

Commit

Permalink
[dev-launcher] Support react-native-v8 (expo#19117)
Browse files Browse the repository at this point in the history
# Why

another attempt than expo#18151 to support react-native-v8

# How

if there's *libv8android.so*, we just use the js executor factory from main ReactNativeHost.
for the bundled reanimated in dev-menu, i have a pr to keep jsc in debug build: Kudo/react-native-v8#142

# Test Plan

```sh
$ yarn create expo-app -t blank@sdk-46 sdk46v8
$ cd sdk46v8
$ npx expo install react-native-v8 v8-android-jit
# add "plugins": ["react-native-v8"] to app.json

$ npx expo install expo-dev-client
$ npx expo prebuild -p android
# patch node_modules/expo-dev-launcher

$ npx expo run:android
```
  • Loading branch information
Kudo authored and Ddv0623 committed Sep 26, 2022
1 parent f9c2a29 commit aef26c9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/expo-dev-launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
### 🐛 Bug fixes

- Remove the deprecated `Linking.removeEventListener` in expo-dev-launcher bundle. ([#18939](https://github.com/expo/expo/pull/18939) by [@kudo](https://github.com/kudo))
- Fixed the incompatibility with react-native-v8 on Android. ([#19117](https://github.com/expo/expo/pull/19117) by [@kudo](https://github.com/kudo))

### 💡 Others

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class DevLauncherReactNativeHostHandler(context: Context) : ReactNativeHostHandl
val applicationContext = context.applicationContext

SoLoader.init(applicationContext, /* native exopackage */ false)
if (SoLoader.getLibraryPath("libv8android.so") != null) {
// Assuming V8 overrides the `getJavaScriptExecutorFactory` in the main ReactNativeHost,
// return null here to use the default value.
return null
}
if (SoLoader.getLibraryPath("libjsc.so") != null) {
return JSCExecutorFactory(applicationContext.packageName, AndroidInfoHelpers.getFriendlyDeviceName())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class DevLauncherReactNativeHostHandler(context: Context) : ReactNativeHostHandl
val applicationContext = context.applicationContext

SoLoader.init(applicationContext, /* native exopackage */ false)
if (SoLoader.getLibraryPath("libv8android.so") != null) {
// Assuming V8 overrides the `getJavaScriptExecutorFactory` in the main ReactNativeHost,
// return null here to use the default value.
return null
}
if (SoLoader.getLibraryPath("libjsc.so") != null) {
return JSCExecutorFactory(applicationContext.packageName, AndroidInfoHelpers.getFriendlyDeviceName())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class DevLauncherReactNativeHostHandler(context: Context) : ReactNativeHostHandl
val applicationContext = context.applicationContext

SoLoader.init(applicationContext, /* native exopackage */ false)
if (SoLoader.getLibraryPath("libv8android.so") != null) {
// Assuming V8 overrides the `getJavaScriptExecutorFactory` in the main ReactNativeHost,
// return null here to use the default value.
return null
}
if (SoLoader.getLibraryPath("libjsc.so") != null) {
return JSCExecutorFactory(applicationContext.packageName, AndroidInfoHelpers.getFriendlyDeviceName())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class DevLauncherReactNativeHostHandler(context: Context) : ReactNativeHostHandl
val applicationContext = context.applicationContext

SoLoader.init(applicationContext, /* native exopackage */ false)
if (SoLoader.getLibraryPath("libv8android.so") != null) {
// Assuming V8 overrides the `getJavaScriptExecutorFactory` in the main ReactNativeHost,
// return null here to use the default value.
return null
}
if (SoLoader.getLibraryPath("libjsc.so") != null) {
return JSCExecutorFactory(applicationContext.packageName, AndroidInfoHelpers.getFriendlyDeviceName())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class DevLauncherReactNativeHostHandler(context: Context) : ReactNativeHostHandl
val applicationContext = context.applicationContext

SoLoader.init(applicationContext, /* native exopackage */ false)
if (SoLoader.getLibraryPath("libv8android.so") != null) {
// Assuming V8 overrides the `getJavaScriptExecutorFactory` in the main ReactNativeHost,
// return null here to use the default value.
return null
}
if (SoLoader.getLibraryPath("libjsc.so") != null) {
return JSCExecutorFactory(applicationContext.packageName, AndroidInfoHelpers.getFriendlyDeviceName())
}
Expand Down

0 comments on commit aef26c9

Please sign in to comment.