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

v2.14.1 needs libhermes-executor-debug.so in release build #3952

Closed
pnthach95 opened this issue Jan 16, 2023 · 28 comments · Fixed by #3956
Closed

v2.14.1 needs libhermes-executor-debug.so in release build #3952

pnthach95 opened this issue Jan 16, 2023 · 28 comments · Fixed by #3956
Labels
Build or config issue This issue is likely related to the reporter's specific project config Platform: Android This issue is specific to Android Repro provided A reproduction with a snippet of code, snack or repo is provided Reproducible 🎉

Comments

@pnthach95
Copy link

Description

I upgrade reanimated from 2.13.0 to 2.14.1, then build release APK and install and run and it crashes

Logcat:

E  couldn't find DSO to load: libjscexecutor.so
   	SoSource 0: com.facebook.soloader.DirectorySoSource[root = /data/app/~~i4sIAeJeCdloEyfbCYD0zQ==/vn.pnthach.karthuria-TswsCwXKhOLa3CLzizen7Q==/lib/arm64 flags = 0]
   	SoSource 1: com.facebook.soloader.DirectApkSoSource[root = (/data/app/~~i4sIAeJeCdloEyfbCYD0zQ==/vn.pnthach.karthuria-TswsCwXKhOLa3CLzizen7Q==/base.apk!/lib/arm64-v8a, )]
   	SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
   	SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
   	Native lib dir: /data/app/~~i4sIAeJeCdloEyfbCYD0zQ==/vn.pnthach.karthuria-TswsCwXKhOLa3CLzizen7Q==/lib/arm64
    result: 0
E  couldn't find DSO to load: libhermes-executor-debug.so
   	SoSource 0: com.facebook.soloader.DirectorySoSource[root = /data/app/~~i4sIAeJeCdloEyfbCYD0zQ==/vn.pnthach.karthuria-TswsCwXKhOLa3CLzizen7Q==/lib/arm64 flags = 0]
   	SoSource 1: com.facebook.soloader.DirectApkSoSource[root = (/data/app/~~i4sIAeJeCdloEyfbCYD0zQ==/vn.pnthach.karthuria-TswsCwXKhOLa3CLzizen7Q==/base.apk!/lib/arm64-v8a, )]
   	SoSource 2: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2]
   	SoSource 3: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2]
   	Native lib dir: /data/app/~~i4sIAeJeCdloEyfbCYD0zQ==/vn.pnthach.karthuria-TswsCwXKhOLa3CLzizen7Q==/lib/arm64
    result: 0
E  Error: Exception in HostFunction: java.lang.UnsatisfiedLinkError: dlopen failed: library "libhermes-executor-debug.so" not found: needed by /data/app/~~i4sIAeJeCdloEyfbCYD0zQ==/vn.pnthach.karthuria-TswsCwXKhOLa3CLzizen7Q==/base.apk!/lib/arm64-v8a/libreanimated.so in namespace classloader-namespace, js engine: hermes
E  FATAL EXCEPTION: mqt_native_modules
   Process: vn.pnthach.karthuria, PID: 18772
   com.facebook.react.common.JavascriptException: Error: Exception in HostFunction: java.lang.UnsatisfiedLinkError: dlopen failed: library "libhermes-executor-debug.so" not found: needed by /data/app/~~i4sIAeJeCdloEyfbCYD0zQ==/vn.pnthach.karthuria-TswsCwXKhOLa3CLzizen7Q==/base.apk!/lib/arm64-v8a/libreanimated.so in namespace classloader-namespace, js engine: hermes, stack:
   callNativeSyncHook@1:96238
   nonPromiseMethodWrapper@1:93718
   NativeReanimated@1:985388
   anonymous@1:978652
   loadModuleImplementation@1:50272
   guardedLoadModule@1:49821
   metroRequire@1:49449
   anonymous@1:1022847
   loadModuleImplementation@1:50272
   guardedLoadModule@1:49821
   metroRequire@1:49449
   anonymous@1:987142
   loadModuleImplementation@1:50272
   guardedLoadModule@1:49821
   metroRequire@1:49449
   anonymous@1:973870
   loadModuleImplementation@1:50272
   guardedLoadModule@1:49821
   metroRequire@1:49449
   anonymous@1:972464
   loadModuleImplementation@1:50272
   guardedLoadModule@1:49821
   metroRequire@1:49449
   anonymous@1:971497
   loadModuleImplementation@1:50272
   guardedLoadModule@1:49821
   metroRequire@1:49449
   anonymous@1:967139
   loadModuleImplementation@1:50272
   guardedLoadModule@1:49821
   metroRequire@1:49449
   anonymous@1:591717
   loadModuleImplementation@1:50272
   guardedLoadModule@1:49821
   metroRequire@1:49449
   anonymous@1:56685
   loadModuleImplementation@1:50272
   guardedLoadModule@1:49778
   metroRequire@1:49449
   global@1:49024
   
   	at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:72)
   	at java.lang.reflect.Method.invoke(Native Method)
   	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
   	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
   	at com.facebook.jni.NativeRunnable.run(Native Method)
   	at android.os.Handler.handleCallback(Handler.java:942)
   	at android.os.Handler.dispatchMessage(Handler.java:99)
   	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
   	at android.os.Looper.loopOnce(Looper.java:226)
   	at android.os.Looper.loop(Looper.java:313)
   	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
   	at java.lang.Thread.run(Thread.java:1012)

Steps to reproduce

  1. Clone repo and use reanimated branch and install dependencies
  2. Run project with command: npx react-native run-android --variant=release

Snack or a link to a repository

https://github.com/pnthach95/KarthuriaApp/tree/reanimated

Reanimated version

2.14.1

React Native version

0.70.6

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

None

Build type

Release mode

Device

Real device

Device model

Samsung S20 Ultra

Acknowledgements

Yes

@pnthach95 pnthach95 added the Needs review Issue is ready to be reviewed by a maintainer label Jan 16, 2023
@github-actions github-actions bot added Repro provided A reproduction with a snippet of code, snack or repo is provided Platform: Android This issue is specific to Android labels Jan 16, 2023
@AronBe
Copy link

AronBe commented Jan 16, 2023

Also getting these crashes on startup after upgrading to 2.14.1

@jabirmhd
Copy link

Same here. Getting this crash after updating to 2.14.1

@tomekzaw tomekzaw added Reproducible 🎉 and removed Needs review Issue is ready to be reviewed by a maintainer labels Jan 16, 2023
@tomekzaw
Copy link
Member

tomekzaw commented Jan 16, 2023

Hey @pnthach95, thanks for submitting the issue. I was able to reproduce the issue on a fresh RN 0.70.6 app both with 2.14.1 and 3.0.0-rc.10. I will investigate this and keep you updated.

@ajiehatajie
Copy link

same issue

@idrissakhi
Copy link

same issue here

@tomekzaw
Copy link
Member

The issue seems to be gone after you add plugins: ['react-native-reanimated/plugin'] in babel.config.js.

@pnthach95 @AronBe @jabirmhd @ajiehatajie @idrissakhi Can you check if it helps?

@tomekzaw tomekzaw added the Build or config issue This issue is likely related to the reporter's specific project config label Jan 16, 2023
@AronBe
Copy link

AronBe commented Jan 16, 2023

@tomekzaw Not sure, I have always had react-native-reanimated/plugin in plugins array.

@idrissakhi
Copy link

@tomekzaw check my babel config, it's already present before and app crashes

  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    [
      '@babel/plugin-transform-react-jsx',
      {
        runtime: 'automatic',
      },
    ],
    [
      require.resolve('babel-plugin-module-resolver'),
      {
        root: ['.'],
        alias: {
          src: './src',
          tests: './tests',
          assets: './assets',
          server: './server',
        },
      },
    ],
    'react-native-reanimated/plugin',
    '@babel/plugin-proposal-export-namespace-from',
  ],
};```

@PrinceUBS
Copy link

Same, already bable config is up to date.

@pnthach95
Copy link
Author

@tomekzaw I already had it in reproduce repo during setup. App still crashes

@tomekzaw
Copy link
Member

Okay, so without plugins: ['react-native-reanimated/plugin'] in babel.config.js the app crashes on reanimated::ShareableSynchronizedDataHolder::get with the following stack trace:

pid: 5302, tid: 5330, name: mqt_js  >>> com.myapp <<<
2023-01-16 11:17:54.186  5339-5339  DEBUG                   pid-5339                             A      #00 pc 000000000003f404  /data/app/com.myapp-vnSG0Sk3Sog0AiT52MuOHQ==/lib/arm64/libreanimated.so (reanimated::ShareableSynchronizedDataHolder::get(facebook::jsi::Runtime&)+68)
2023-01-16 11:17:54.186  5339-5339  DEBUG                   pid-5339                             A      #01 pc 000000000003f318  /data/app/com.myapp-vnSG0Sk3Sog0AiT52MuOHQ==/lib/arm64/libreanimated.so (reanimated::NativeReanimatedModule::getDataSynchronously(facebook::jsi::Runtime&, facebook::jsi::Value const&)+72)
2023-01-16 11:17:54.186  5339-5339  DEBUG                   pid-5339                             A      #02 pc 000000000004b2a4  /data/app/com.myapp-vnSG0Sk3Sog0AiT52MuOHQ==/lib/arm64/libreanimated.so
2023-01-16 11:17:54.186  5339-5339  DEBUG                   pid-5339                             A      #03 pc 000000000007449c  /data/app/com.myapp-vnSG0Sk3Sog0AiT52MuOHQ==/lib/arm64/libreanimated.so
2023-01-16 11:17:54.186  5339-5339  DEBUG                   pid-5339                             A      #04 pc 000000000001d964  /data/app/com.myapp-vnSG0Sk3Sog0AiT52MuOHQ==/lib/arm64/libhermes-executor-release.so (std::__ndk1::__function::__func<facebook::jsi::DecoratedHostFunction, std::__ndk1::allocator<facebook::jsi::DecoratedHostFunction>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&)+68)
2023-01-16 11:17:54.186  5339-5339  DEBUG                   pid-5339                             A      #05 pc 0000000000078848  /data/app/com.myapp-vnSG0Sk3Sog0AiT52MuOHQ==/lib/arm64/libhermes.so (offset 0x6c000)
2023-01-16 11:17:54.186  5339-5339  DEBUG                   pid-5339                             A      #06 pc 00000000000781d0  /data/app/com.myapp-vnSG0Sk3Sog0AiT52MuOHQ==/lib/arm64/libhermes.so (offset 0x6c000)
...

Indeed, it's a different error than the one reported in the issue ("Exception in HostFunction: java.lang.UnsatisfiedLinkError: dlopen failed: library "libhermes-executor-debug.so" not found").

When I add plugins: ['react-native-reanimated/plugin'] the app works for me.

I will check out the @pnthach95's reproduction.

@walterholohan
Copy link

walterholohan commented Jan 16, 2023

I've have the below babel.confis.js and it crashes on update to 2.14.1. I am RN 0.70.6 too

  const path = require('path');

  module.exports = {
    presets: ['module:metro-react-native-babel-preset'],
    plugins: [
      [
        require.resolve('babel-plugin-module-resolver'), {
          root: [path.resolve('./')],
          alias: {
            '~': './src',
            ':': './assets',
          },
      }],
      'react-native-reanimated/plugin',
    ],
  };

@migueldaipre
Copy link
Contributor

Same issue here, I have react-native-reanimated/plugin in plugin array. I am RN 0.70.6 too

@4RGUS
Copy link

4RGUS commented Jan 16, 2023

Same issue for me too.
my version
"react-native-reanimated": "2.2.0"

@traxx10
Copy link

traxx10 commented Jan 16, 2023

Same issue here

@tomekzaw tomekzaw pinned this issue Jan 16, 2023
@tomekzaw
Copy link
Member

tomekzaw commented Jan 16, 2023

Okay, so the root cause of the issue is that when we build AAR for Reanimated 2 package, we run a task called assembleDebug instead of assembleRelease (there's a reason for doing so but we probably won't change it as we plan to drop v2 soon, v3 is the future). As a consequence, HERMES_ENABLE_DEBUGGER is set to 1 whereas the expected value is 0. Because of this, the result libreanimated.so links to libhermes-executor-debug.so which doesn't exist in release APK and causes the error from the issue description.

I've submitted a PR that resolves this issue: #3956. Once we merge it, we will release the fix with 2.14.2 or 2.15.0 (yet to be decided). Before the next release, here's what you can do:

  • you can still use 2.14.1 in release mode but you need to enable build from source by setting project.ext.reanimated.buildFromSource (this requires Android NDK to be installed and configured) – recommended ⭐
  • you can use 3.0.0-rc.10 that also includes the recent changes but is not affected because Reanimated 3 is always built from sources (there's no prebuilds) – also recommended, however, be aware that v3 has new implementation of shared values and layout animations, so please test your app thoroughly before the publish
  • unfortunately, you cannot simply use patch-package to apply the fix as you would need to rebuild the AARs (this can be done by running ./createNPMPackage.sh script)
  • once we merge the PR but before the next release, you can use a nightly build
  • obviously, you can wait until we release this fix as 2.14.2 or 2.15.0 (yet to be decided).

Sorry for the inconvenience.

@mrbrentkelly
Copy link
Contributor

you can still use 2.14.1 in release mode but you need to enable build from source by setting project.ext.reanimated.buildFromSource (this requires Android NDK to be installed and configured) – recommended ⭐

This workaround did the trick for me. Thanks @tomekzaw 👍

project.ext.reanimated = [ 
    buildFromSource: true 
]

@bhaktitud
Copy link

bhaktitud commented Jan 17, 2023

what about ios ? how do you add that snippet? because this actually happens in ios build too.
project.ext.reanimated = [ buildFromSource: true ]

what i mean is, similar workaround for ios, not adding that code in ios of course.

@efstathiosntonas
Copy link
Contributor

@bhaktitud you’re trolling, right?

@4RGUS
Copy link

4RGUS commented Jan 17, 2023

you can still use 2.14.1 in release mode but you need to enable build from source by setting project.ext.reanimated.buildFromSource (this requires Android NDK to be installed and configured) – recommended ⭐

This workaround did the trick for me. Thanks @tomekzaw 👍

project.ext.reanimated = [ 
    buildFromSource: true 
]

Worked for me too 👍

@bhaktitud
Copy link

@bhaktitud you’re trolling, right?

no, that work well for me on android, but ios it still crash on app launch.

@pnthach95
Copy link
Author

no, that work well for me on android, but ios it still crash on app launch.

My app runs just fine. Are you sure it is reanimated issue? Please provide more information: RN version, RN animated version, log crash...

@tomekzaw
Copy link
Member

Hey, I've just checked and iOS app in release mode works fine.

piaskowyk pushed a commit that referenced this issue Jan 17, 2023
…ge (#3956)

## Summary

Fixes #3952.

## Test plan

1. Build Reanimated 2 package on CI
2. Create a new RN 0.70.6 app with Reanimated
3. Copy BokehExample to App.js
4. Build the app in release mode for Android
5. Check if the runtime error is gone
piaskowyk pushed a commit that referenced this issue Jan 17, 2023
…ge (#3956)

## Summary

Fixes #3952.

## Test plan

1. Build Reanimated 2 package on CI
2. Create a new RN 0.70.6 app with Reanimated
3. Copy BokehExample to App.js
4. Build the app in release mode for Android
5. Check if the runtime error is gone
@walterholohan
Copy link

@piaskowyk any timeline on when you are going to release 2.14.2?

@tomekzaw
Copy link
Member

tomekzaw commented Jan 17, 2023

any timeline on when you are going to release 2.14.2?

Probably in 30 minutes

Edit: Reanimated 2.14.2 has just been published 🥳

@AliYar-Khan
Copy link

you can still use 2.14.1 in release mode but you need to enable build from source by setting project.ext.reanimated.buildFromSource (this requires Android NDK to be installed and configured) – recommended ⭐

This workaround did the trick for me. Thanks @tomekzaw 👍

project.ext.reanimated = [ 
    buildFromSource: true 
]

Worked for me too 👍

which build file i have to place this ?

@efstathiosntonas
Copy link
Contributor

efstathiosntonas commented Mar 29, 2023

@AliYar-Khan under /android/app/build.gradle:

project.ext.react = [
        enableHermes: true,
        bundleInDebug: true,
]

project.ext.reanimated = [
        buildFromSource: true
]

@Hajarat
Copy link

Hajarat commented May 16, 2023

I have react native version 0.71.8 and reanimated version 2.17.0. The solution:
project.ext.reanimated = [ buildFromSource: true ]
fixed the issue but gave me another problem when building my android app:
Could not find com.facebook.react:react-android:. Required by: project :react-native-reanimated
Any ideas what the cause of this is? any help would be greatly appreciated

fluiddot pushed a commit to wordpress-mobile/react-native-reanimated that referenced this issue Jun 5, 2023
…ge (software-mansion#3956)

## Summary

Fixes software-mansion#3952.

## Test plan

1. Build Reanimated 2 package on CI
2. Create a new RN 0.70.6 app with Reanimated
3. Copy BokehExample to App.js
4. Build the app in release mode for Android
5. Check if the runtime error is gone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build or config issue This issue is likely related to the reporter's specific project config Platform: Android This issue is specific to Android Repro provided A reproduction with a snippet of code, snack or repo is provided Reproducible 🎉
Projects
None yet