-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Add Hermes support to React Native on Android #25613
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
@@ -146,6 +165,10 @@ dependencies { | |||
// Build React Native from source | |||
implementation project(':ReactAndroid') | |||
|
|||
def hermesPath = '$projectDir/../../../../node_modules/hermesvm/android/' | |||
debugImplementation files(hermesPath + "hermes-debug.aar") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be wrapped in an if (enableHermes)
? We don't need both hermes and jsc.
// JSC from node_modules | ||
if (useIntlJsc) { | ||
implementation 'org.webkit:android-jsc-intl:+' | ||
if (enableHermes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about moving this to react.gradle
so all apps don't have to manually do this? we'd need to be able to infer if a variant requires the release or debug aar. There's already hermesFlagsRelease
/hermesFlagsDebug
so we could build on that concept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is really large, I prefer to land it and then hope the community will help improve it. Right now this is following what JSC is doing already.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
eslint
found some issues. Runyarn lint --fix
to automatically fix problems.
import {Writable} from 'stream'; | ||
|
||
import {GeneratedHeader} from './GeneratedHeader'; | ||
import {Property} from './Property'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no-unused-vars: 'Property' is defined but never used.
'use strict'; | ||
|
||
import fs from 'fs'; | ||
import {Writable} from 'stream'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no-unused-vars: 'Writable' is defined but never used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@cpojer Looks like there is a missing BUCK config for hermes.reactexecutor, which then needs to be imported in ReactAndroid/src/main/java/com/facebook/react/BUCK. |
Thanks @janicduplessis. I didn’t have time to work on it yet. Any chance you could create the buck file so I can amend it into this PR? I’d love to merge this PR this week but not sure I’ll have the time. |
@cpojer Is the hermes executor used internally at fb? I'd be surprised if the buck file doesn't already exist. Anyway I'll look into adding it and see if I can get this PR building with BUCK later today. |
Buck problem is fixed, now we are actually down to the interesting issues. |
Currently blocked on an issue that @mhorowitz is looking into. |
34e9993
to
13ad3aa
Compare
Hi @cpojer, would you mind releasing a 0.60.4 please? The last two commits enables to use Sentry and also reduce the APK size (since it doesn't include sourcemaps anymore) |
@Minishlink we'll be making a new release soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Thanks @cpojer 😃 |
Got another patch to fix proguard support janicduplessis@aa4dd9e. I guess if this is about to land we can wait and I'll open a new PR. |
@janicduplessis currently working on getting CI working at FB. I'll manually pick your change into the internal version of this PR. Thanks for linking it! |
@cpojer Oups I just noticed I missed adding @DoNotStrip on the first method. janicduplessis@aa4dd9e is the fixed version. |
pickFirst '**/arm64-v8a/libc++_shared.so' | ||
pickFirst '**/x86_64/libc++_shared.so' | ||
pickFirst '**/x86/libjsc.so' | ||
pickFirst '**/armeabi-v7a/libjsc.so' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious if the pickFirst for libjsc.so is needed?
IMO, even the pickFirst for libc++_shared.so getting some risk.
I knew that Hermes AAR includes libc++_shared.so, so we need the pickFirst here.
Hermes libc++_shared.so should be from NDK r13b and RN's is from NDK r17c or r19c.
This works because NDK maintains good ABI compatibility.
However, if user have other 3rd party gradle dependencies, gradle may pick to the 3rd party libc++_shared.so which is not what we expected.
This kind of problem is hard to troubleshoot because gradle pickFirst is really undeterministic.
Recommend if Hermes could remove libc++_shared.so from AAR and we could remove the pickFirst from template.
This pull request was successfully merged by @cpojer in d7f5153. When will my fix make it into a release? | Upcoming Releases |
It landed thanks to @willholen who helped patch everything up at FB. I hope this isn't going to cause internal issues and has to be reverted – we should know more about that at the end of the day. If you are having suggestions on how to improve Hermes integration, please send PRs to make it incrementally better :) |
Summary: Yesterday we shipped hermesengine.dev as part of the current 0.60 release. This PR brings those changes to master. [General] [Added] - Added support for Hermes Pull Request resolved: facebook#25613 Test Plan: * CI is green both on GitHub and at FB * Creating a new app from source can use Hermes on Android Reviewed By: cpojer Differential Revision: D16221777 Pulled By: willholen fbshipit-source-id: aa6be10537863039cb666292465ba2e1d44b64ef
Summary
Yesterday we shipped hermesengine.dev as part of the current 0.60 release. This PR brings those changes to master.
Changelog
[General] [Added] - Added support for Hermes
Test Plan