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

RN 0.63.1 + enableHermes -> very slow launch performances #318

Closed
imranMnts opened this issue Aug 6, 2020 · 15 comments
Closed

RN 0.63.1 + enableHermes -> very slow launch performances #318

imranMnts opened this issue Aug 6, 2020 · 15 comments
Labels
need more info Awating additional info before proceeding

Comments

@imranMnts
Copy link

Bug Description

I recently updated RN version of my project from 0.59.10 to 0.63.1. It works properly, I didn't detect any issue but when I turn on Hermes to benefice its advantages, my app takes 2 times longer to be launched in release mode.

Versions:
Hermes version: 0.5.0
React Native version: 0.63.1
Android version: Android 8.0
Device: Samsung J3

Launch times (to see the first screen of the app):

  • without hermes: ~7s
  • with hermes: ~20s

If anyone has had to face this problem, your help is welcome 🙂
Thank you.

@avp
Copy link
Contributor

avp commented Sep 3, 2020

Thanks for the report. It's easier to debug these sorts of issues with some code to look at - without it, we're in the dark regarding the actual problem.

A few things to try:

@Huxpro Huxpro added the need more info Awating additional info before proceeding label Dec 8, 2020
@Huxpro
Copy link
Contributor

Huxpro commented Dec 8, 2020

@imranMnts any updates? Have you tried what @avp suggested (especially making sure you were in the release mode)?

@peterkuiper
Copy link

I have seen this as well. We use react-native-sodium and the decrypt function itself takes about 7s. Due to this (and maybe other packages hit by this issue), the startup time is about 15-20s (we have to load encrypted data into redux). After disabling Hermes, the startup time is about 4-7s. We are using RN 0.63.4 and testing on low end Android devices (these seem to be affected the most).

@Huxpro
Copy link
Contributor

Huxpro commented Jun 3, 2021

Besides of what @avp had mentioned, there is also possibility that you are not using pre-compiled bytecode. You can check if the main.jsbundle looks like JS source or bytecode. The bytecode is compiled in react-native-xcode.sh and we've seen people/codebase (e.g. Mattermost) has their own copy of react-native-xcode.sh hence the app doesn't use bytecode and fallback to Hermes's on-device lazy compilation.

@tmikov
Copy link
Contributor

tmikov commented Jun 3, 2021

FWIW, startup time of 4-7s doesn't sound that great either. Perhaps the lesson here is that JavaScript, even with a JIT, is just not that suitable for high intensity computation like decryption. It would work much better if the decryption was implemented in C++.

@imranMnts
Copy link
Author

@Huxpro
Sorry for the late response, we had some other urgent topics

I double-checked and I'm sure I'm in release mode.
I updated RN's version to 0.64.1, Hermes working fine on iOS but we have still the speed issue during the startup on android.

Hermes version: 0.7.2
RN version: 0.64.1

@imranMnts
Copy link
Author

imranMnts commented Jul 2, 2021

Thanks all

I fixed the issue on my side.

It was due to the bundle generated in the APK, it was in JS and to beneficiate from Hermes' improvements it should be bytecode.

@Huxpro
Copy link
Contributor

Huxpro commented Jul 3, 2021

@imgraham thanks for reporting back!

As I mentioned before, this is often the cause:

You can check if the main.jsbundle looks like JS source or bytecode.

Would you mind sharing with us how did you find it and what was the improvements?

@devjaw
Copy link

devjaw commented Jul 11, 2021

@imranMnts how did you fix it ?

@imranMnts
Copy link
Author

we generated the bundle manually via
react-native bundle --platform android \ ...

I removed it and added

project.ext.react = [
    enableHermes: true,
]
apply from: "../../node_modules/react-native/react.gradle"

in my app/build.gradle
which generate the bundle during the compilation automatically and fix the bundle which was in js

@aemre
Copy link

aemre commented Nov 1, 2021

we generated the bundle manually via react-native bundle --platform android \ ...

I removed it and added

project.ext.react = [
    enableHermes: true,
]
apply from: "../../node_modules/react-native/react.gradle"

in my app/build.gradle which generate the bundle during the compilation automatically and fix the bundle which was in js

so manually creating bundle solve the issue?

@CloudCityxx
Copy link

I also encountered this problem。 very very slow.

@CloudCityxx
Copy link

we generated the bundle manually via react-native bundle --platform android \ ...
I removed it and added

project.ext.react = [
    enableHermes: true,
]
apply from: "../../node_modules/react-native/react.gradle"

in my app/build.gradle which generate the bundle during the compilation automatically and fix the bundle which was in js

so manually creating bundle solve the issue?

I tried this solution, but it didn't solve, it was still very slow

@imranMnts
Copy link
Author

@CloudCityxx Did you unzip your apk to check if your bundle contains bytecode or js? (in assets folder)

@upngo
Copy link

upngo commented Jan 24, 2023

For anyone who stumbles upon this with RN 0.71.0
Upgrade to 0.71.1 as there was an issue with hermes and debug (didn't affect release builds)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Awating additional info before proceeding
Projects
None yet
Development

No branches or pull requests

9 participants