Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev-menu] Fix crash when using hermes on android react-native 0.67 #16099

Merged
merged 3 commits into from
Jan 28, 2022

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Jan 27, 2022

Why

fix crash when enableHermes: true with dev-menu on react-native 0.67. i tested it from bare-expo.
stacktrace:

FATAL EXCEPTION: main
Process: dev.expo.payments, PID: 18344
java.lang.NoClassDefFoundError: com.facebook.react.jscexecutor.JSCExecutor
    at com.facebook.react.jscexecutor.JSCExecutor.loadLibrary(JSCExecutor.java:24)
    at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:352)
    at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:319)
    at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:95)
    at expo.modules.devmenu.DevMenuHost.createReactInstanceManager(DevMenuHost.kt:41)
    at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:42)
    at expo.modules.devmenu.DevMenuManager.maybeInitDevMenuHost$lambda-8(DevMenuManager.kt:169)
    at expo.modules.devmenu.DevMenuManager.lambda$rZDvUiNHHHvkcRmdKO265huCv6U(Unknown Source:0)
    at expo.modules.devmenu.-$$Lambda$DevMenuManager$rZDvUiNHHHvkcRmdKO265huCv6U.run(Unknown Source:0)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7656)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libjscexecutor.so
    SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/dev.expo.payments/lib-main flags = 1]
    SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~ibMyBupkSRJXdt_c772rhw==/dev.expo.payments-ru7gzQ9g2MilqIhz24Lduw==/lib/arm64 flags = 0]
    SoSource 2: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
    SoSource 3: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
    Native lib dir: /data/app/~~ibMyBupkSRJXdt_c772rhw==/dev.expo.payments-ru7gzQ9g2MilqIhz24Lduw==/lib/arm64

the first time to create a ReactInstanceManager, it successes. however, the second time to create a ReactInstanceManager for dev-menu, it crashes with NoClassDefFoundError. it's also uncaughtable here

this is because the change landed in react-native 0.67: facebook/react-native#30749

according to jvm spec v2 2.17.5, (maybe from this spec). the second time to load a failure class, the vm throws NoClassDefFoundError. there's another reference in android art vm implementation

How

for dev-menu, we try to locate libjsc.so and create specific javascript executor.

Test Plan

tested on my react-native 0.67 upgrade branch: #16038

Checklist

  • Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md).
  • This diff will work correctly for expo build (eg: updated @expo/xdl).
  • This diff will work correctly for expo prebuild & EAS Build (eg: updated a module plugin).

@expo-bot expo-bot added the bot: passed checks ExpoBot has nothing to complain about label Jan 27, 2022
@Kudo Kudo mentioned this pull request Jan 27, 2022
10 tasks
@Kudo Kudo marked this pull request as ready for review January 27, 2022 20:33
@Kudo Kudo requested a review from lukmccall as a code owner January 27, 2022 20:33
@Kudo Kudo merged commit 3c654b4 into main Jan 28, 2022
@Kudo Kudo deleted the @kudo/dev-client/fix-rn67-hermes-crash branch January 28, 2022 14:45
Kudo added a commit that referenced this pull request Feb 17, 2022
# Why

try to bump react-native version for sdk 45

# How

- [x] upgrade package.json version to `react-native@0.67.2`
- [x] apply changes from [upgrade helper](https://react-native-community.github.io/upgrade-helper/?from=0.66.4&to=0.67.2)
- [x] since 0.67 upgrade to gradle 7 and remove `maven` plugin. ~this pr also migrate packages to use `maven-publish` plugin~ landed in separated pr #16080
- [x] [bare-expo][android] maven plugin from third-party: `react-native-appearance`. ~consider it's archived and deprecated, how to deal with this.~ since we are going to drop sdk 42, i've removed this dependency.
- [x] [bare-expo][android] maven plugin from third-party: `react-native-shared-element`. IjzerenHein/react-native-shared-element#90
- [x] [dev-launcher][android] having a `DevLauncherDevSupportManager.kt` for 0.67 and passing null to the new `SurfaceDelegateFactory`. simply to fix the build error first.
- [x] [dev-menu][android] it will crash from missing libjsc.so in hermes mode. ~workaround to use jsc mode first~. fix pr: #16099

# Test Plan

- bare-expo launch
lukmccall added a commit that referenced this pull request Feb 21, 2022
…67 (#16372)

# Why

Fixes:
```
FATAL EXCEPTION: main
Process: dev.expo.payments, PID: 18344
java.lang.NoClassDefFoundError: com.facebook.react.jscexecutor.JSCExecutor
```

It's turned out that we have to do a similar thing to #16099 in `dev-launcher`.

# Test Plan

- run `bare-expo` with Hermes.
prakashbask pushed a commit to prakashbask/expo that referenced this pull request Mar 16, 2022
# Why

try to bump react-native version for sdk 45

# How

- [x] upgrade package.json version to `react-native@0.67.2`
- [x] apply changes from [upgrade helper](https://react-native-community.github.io/upgrade-helper/?from=0.66.4&to=0.67.2)
- [x] since 0.67 upgrade to gradle 7 and remove `maven` plugin. ~this pr also migrate packages to use `maven-publish` plugin~ landed in separated pr expo#16080
- [x] [bare-expo][android] maven plugin from third-party: `react-native-appearance`. ~consider it's archived and deprecated, how to deal with this.~ since we are going to drop sdk 42, i've removed this dependency.
- [x] [bare-expo][android] maven plugin from third-party: `react-native-shared-element`. IjzerenHein/react-native-shared-element#90
- [x] [dev-launcher][android] having a `DevLauncherDevSupportManager.kt` for 0.67 and passing null to the new `SurfaceDelegateFactory`. simply to fix the build error first.
- [x] [dev-menu][android] it will crash from missing libjsc.so in hermes mode. ~workaround to use jsc mode first~. fix pr: expo#16099

# Test Plan

- bare-expo launch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants