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

Add Hermes support to React Native on Android #25613

Closed
wants to merge 8 commits into from

Conversation

cpojer
Copy link
Contributor

@cpojer cpojer commented Jul 12, 2019

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

  • CI is green both on GitHub and at FB
  • Creating a new app from source can use Hermes on Android

@cpojer cpojer requested a review from hramos as a code owner July 12, 2019 12:05
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner RN Team labels Jul 12, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

Copy link

@analysis-bot analysis-bot left a 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. Run yarn lint --fix to automatically fix problems.

@pull-bot
Copy link

pull-bot commented Jul 12, 2019

Warnings
⚠️ 🔒 package.json - Changes were made to package.json. This will require a manual import by a Facebook employee.

Generated by 🚫 dangerJS against 50bbfca

@react-native-bot react-native-bot added Platform: Android Android applications. Type: Enhancement A new feature or enhancement of an existing feature. labels Jul 12, 2019
@@ -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")
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@hramos
Copy link
Contributor

hramos commented Jul 12, 2019

  • test_js failure appears to be a problem handling eslint's response (no errors found, but it returned a non-zero error code). We need to figure out what may have changed between master and the Hermes branch in terms of CI. I don't think this particular failure is merge-blocking, but I'd appreciate help fixing it should it continue appearing on master.
  • test_js_lts failure matches test_js's, same argument applies.
  • test_android failure needs to be looked at. Looks like the Hermes branch is missing some of the newer AndroidX changes.
  • test_docker failure is related to the same issue in test_android.

Copy link

@analysis-bot analysis-bot left a 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. Run yarn lint --fix to automatically fix problems.

Copy link

@analysis-bot analysis-bot left a 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. Run yarn lint --fix to automatically fix problems.

import {Writable} from 'stream';

import {GeneratedHeader} from './GeneratedHeader';
import {Property} from './Property';

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';

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.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@janicduplessis
Copy link
Contributor

janicduplessis commented Jul 15, 2019

@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.

@cpojer
Copy link
Contributor Author

cpojer commented Jul 15, 2019

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.

@janicduplessis
Copy link
Contributor

@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.

@cpojer
Copy link
Contributor Author

cpojer commented Jul 16, 2019

Buck problem is fixed, now we are actually down to the interesting issues.

@cpojer
Copy link
Contributor Author

cpojer commented Jul 17, 2019

Currently blocked on an issue that @mhorowitz is looking into.

@Minishlink
Copy link
Contributor

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)

@cpojer
Copy link
Contributor Author

cpojer commented Jul 18, 2019

@Minishlink we'll be making a new release soon.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@Minishlink
Copy link
Contributor

Thanks @cpojer 😃

@janicduplessis
Copy link
Contributor

janicduplessis commented Jul 19, 2019

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.

@cpojer
Copy link
Contributor Author

cpojer commented Jul 19, 2019

@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!

@janicduplessis
Copy link
Contributor

@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'
Copy link
Contributor

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.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @cpojer in d7f5153.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Jul 26, 2019
@cpojer
Copy link
Contributor Author

cpojer commented Jul 26, 2019

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 :)

KusStar pushed a commit to KusStar/react-native that referenced this pull request Oct 17, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Facebook Partner: Facebook Partner Platform: Android Android applications. RN Team Type: Enhancement A new feature or enhancement of an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.