Skip to content

Commit fc5c8e1

Browse files
author
Riccardo
authored
Merge branch 'main' into cipolleschi/backport_hermes_logic
2 parents 37716fb + 1f8c0c8 commit fc5c8e1

File tree

49 files changed

+440
-323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+440
-323
lines changed

.circleci/config.yml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -710,34 +710,19 @@ jobs:
710710
- checkout
711711
- setup_artifacts
712712
- run_yarn
713-
714-
# Starting emulator in advance as it takes some time to boot.
715-
- run:
716-
name: Create Android Virtual Device
717-
command: source scripts/android-setup.sh && createAVD
718-
- run:
719-
name: Launch Android Virtual Device in Background
720-
command: source scripts/android-setup.sh && launchAVD
721-
background: true
722-
723713
- download_gradle_dependencies
724714

725715
- run:
726716
name: Build & Test React Native using Gradle
727717
command: ./gradlew buildAll
728718

729-
- run:
730-
name: Build RN Tester for Release using Gradle
731-
command: ./gradlew packages:rn-tester:android:app:assembleRelease
732-
733-
# Wait for AVD to finish booting before running tests
734-
- run:
735-
name: Wait for Android Virtual Device
736-
command: source scripts/android-setup.sh && waitForAVD
737-
738719
- report_bundle_size:
739720
platform: android
740721

722+
- store_artifacts:
723+
path: ~/react-native/packages/rn-tester/android/app/build/outputs/apk/
724+
destination: rntester-apk
725+
741726
# Optionally, run disabled tests
742727
- when:
743728
condition: << parameters.run_disabled_tests >>
@@ -779,10 +764,7 @@ jobs:
779764
command: |
780765
REPO_ROOT=$(pwd)
781766
node ./scripts/set-rn-template-version.js "file:$REPO_ROOT/build/$(cat build/react-native-package-version)"
782-
node cli.js init $PROJECT_NAME --directory "/tmp/$PROJECT_NAME" --template $REPO_ROOT --verbose --skip-install
783-
cd /tmp/$PROJECT_NAME
784-
yarn
785-
767+
node ./scripts/template/initialize.js --reactNativeRootPath $REPO_ROOT --templateName $PROJECT_NAME --templateConfigPath $REPO_ROOT --directory "/tmp/$PROJECT_NAME"
786768
- run:
787769
name: Build the template application for << parameters.flavor >> with Architecture set to << parameters.architecture >>, and using the << parameters.jsengine>> JS engine.
788770
command: |
@@ -799,6 +781,10 @@ jobs:
799781
fi
800782
./gradlew assemble<< parameters.flavor >> -PREACT_NATIVE_MAVEN_LOCAL_REPO=/root/react-native/maven-local
801783
784+
- store_artifacts:
785+
path: /tmp/$PROJECT_NAME/android/app/build/outputs/apk/
786+
destination: template-apk
787+
802788
# -------------------------
803789
# JOBS: Test iOS Template
804790
# -------------------------
@@ -862,13 +848,11 @@ jobs:
862848
PACKAGE=$(cat build/react-native-package-version)
863849
PATH_TO_PACKAGE="$REPO_ROOT/build/$PACKAGE"
864850
node ./scripts/set-rn-template-version.js "file:$PATH_TO_PACKAGE"
865-
node cli.js init $PROJECT_NAME --directory "/tmp/$PROJECT_NAME" --template $REPO_ROOT --verbose --skip-install
851+
node ./scripts/template/initialize.js --reactNativeRootPath $REPO_ROOT --templateName $PROJECT_NAME --templateConfigPath $REPO_ROOT --directory "/tmp/$PROJECT_NAME"
866852
- run:
867853
name: Install iOS dependencies - Configuration << parameters.flavor >>; New Architecture << parameters.architecture >>; JS Engine << parameters.jsengine>>; Flipper << parameters.flipper >>
868854
command: |
869-
cd /tmp/$PROJECT_NAME
870-
yarn install
871-
cd ios
855+
cd /tmp/$PROJECT_NAME/ios
872856
873857
bundle install
874858

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ package-lock.json
125125
/sdks/download
126126
/sdks/hermes
127127
/sdks/hermesc
128-
/sdks/hermes-engine/build_host_hermesc
129128

130129
# Visual studio
131130
.vscode

Libraries/Animated/useAnimatedProps.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
3535
): [ReducedProps<TProps>, CallbackRef<TInstance | null>] {
3636
const [, scheduleUpdate] = useReducer<number, void>(count => count + 1, 0);
3737
const onUpdateRef = useRef<?() => void>(null);
38-
const cachedRef = useRef<TInstance | null>(null);
3938

4039
// TODO: Only invalidate `node` if animated props or `style` change. In the
4140
// previous implementation, we permitted `style` to override props with the
@@ -65,7 +64,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
6564
// NOTE: This may be called more often than necessary (e.g. when `props`
6665
// changes), but `setNativeView` already optimizes for that.
6766
node.setNativeView(instance);
68-
cachedRef.current = instance;
6967

7068
// NOTE: This callback is only used by the JavaScript animation driver.
7169
onUpdateRef.current = () => {
@@ -115,16 +113,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
115113
);
116114
const callbackRef = useRefEffect<TInstance>(refEffect);
117115

118-
useEffect(() => {
119-
// Call `setNativeView` any time `node` changes to make sure
120-
// `AnimatedProps._animatedView` is up to date.
121-
// This would not be necessary in an ideal world.
122-
// In React, anytime identity of function passed to `ref` changes,
123-
// the old function is called with null and the new function is called with value.
124-
// ScrollView does not behave like this and this workaround is necessary.
125-
node.setNativeView(cachedRef.current);
126-
}, [node]);
127-
128116
return [reduceAnimatedProps<TProps>(node), callbackRef];
129117
}
130118

Libraries/BatchedBridge/MessageQueue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class MessageQueue {
207207
});
208208
warnOnce(
209209
'excessive-number-of-pending-callbacks',
210-
`Please report: Excessive number of pending callbacks: ${
210+
`Excessive number of pending callbacks: ${
211211
this._successCallbacks.size
212212
}. Some pending callbacks that might have leaked by never being called from native code: ${stringifySafe(
213213
info,

Libraries/Events/EventPolyfill.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class EventPolyfill implements IEvent {
159159
// data with the other in sync.
160160
_syntheticEvent: mixed;
161161

162-
constructor(type: string, eventInitDict?: Event$Init): void {
162+
constructor(type: string, eventInitDict?: Event$Init) {
163163
this.type = type;
164164
this.bubbles = !!(eventInitDict?.bubbles || false);
165165
this.cancelable = !!(eventInitDict?.cancelable || false);

Libraries/Lists/FlatList.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
187187
* _renderItem = ({item}) => (
188188
* <TouchableOpacity onPress={() => this._onPress(item)}>
189189
* <Text>{item.title}</Text>
190-
* <TouchableOpacity/>
190+
* </TouchableOpacity>
191191
* );
192192
* ...
193193
* <FlatList data={[{title: 'Title Text', key: 'item1'}]} renderItem={this._renderItem} />

ReactAndroid/build.gradle

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ final def preparePrefab = tasks.register("preparePrefab", PreparePrefabHeadersTa
144144
new Pair(new File(buildDir, "third-party-ndk/boost/boost_1_76_0/").absolutePath, ""),
145145
new Pair(new File(buildDir, "third-party-ndk/double-conversion/").absolutePath, ""),
146146
new Pair(new File(buildDir, "third-party-ndk/folly/").absolutePath, ""),
147+
new Pair(new File(buildDir, "third-party-ndk/glog/exported/").absolutePath, ""),
147148
new Pair("../ReactCommon/butter/", "butter/"),
148149
new Pair("../ReactCommon/callinvoker/", ""),
149150
new Pair("../ReactCommon/react/bridging/", "react/bridging/"),
@@ -152,13 +153,16 @@ final def preparePrefab = tasks.register("preparePrefab", PreparePrefabHeadersTa
152153
new Pair("../ReactCommon/react/nativemodule/core/platform/android/", ""),
153154
new Pair("../ReactCommon/react/renderer/componentregistry/", "react/renderer/componentregistry/"),
154155
new Pair("../ReactCommon/react/renderer/components/root/", "react/renderer/components/root/"),
156+
new Pair("../ReactCommon/react/renderer/core/", "react/renderer/core/"),
157+
new Pair("../ReactCommon/react/renderer/debug/", "react/renderer/debug/"),
155158
new Pair("../ReactCommon/react/renderer/leakchecker/", "react/renderer/leakchecker/"),
156159
new Pair("../ReactCommon/react/renderer/mapbuffer/", "react/renderer/mapbuffer/"),
157160
new Pair("../ReactCommon/react/renderer/mounting/", "react/renderer/mounting/"),
158161
new Pair("../ReactCommon/react/renderer/runtimescheduler/", "react/renderer/runtimescheduler/"),
159162
new Pair("../ReactCommon/react/renderer/scheduler/", "react/renderer/scheduler/"),
160163
new Pair("../ReactCommon/react/renderer/telemetry/", "react/renderer/telemetry/"),
161164
new Pair("../ReactCommon/react/renderer/uimanager/", "react/renderer/uimanager/"),
165+
new Pair("../ReactCommon/react/debug/", "react/debug/"),
162166
new Pair("../ReactCommon/react/utils/", "react/utils/"),
163167
new Pair("src/main/jni/react/jni", "react/jni/"),
164168
]
@@ -174,6 +178,29 @@ final def preparePrefab = tasks.register("preparePrefab", PreparePrefabHeadersTa
174178
"rrc_image",
175179
new Pair("../ReactCommon/react/renderer/components/image/", "react/renderer/components/image/")
176180
),
181+
// This prefab target is used by Expo & Reanimated to load a new instance of Hermes
182+
new PrefabPreprocessingEntry(
183+
"hermes-executor",
184+
// "hermes-executor" is statically linking agaisnt "hermes-executor-common"
185+
// and "hermes-inspector". Here we expose only the headers that we know are needed.
186+
new Pair("../ReactCommon/hermes/inspector/", "hermes/inspector/")
187+
),
188+
new PrefabPreprocessingEntry(
189+
"react_render_uimanager",
190+
new Pair("../ReactCommon/react/renderer/uimanager/", "react/renderer/uimanager/"),
191+
),
192+
new PrefabPreprocessingEntry(
193+
"react_render_scheduler",
194+
new Pair("../ReactCommon/react/renderer/scheduler/", "react/renderer/scheduler/"),
195+
),
196+
new PrefabPreprocessingEntry(
197+
"react_render_mounting",
198+
new Pair("../ReactCommon/react/renderer/mounting/", "react/renderer/mounting/"),
199+
),
200+
new PrefabPreprocessingEntry(
201+
"reactnativejni",
202+
new Pair("src/main/jni/react/jni", "react/jni/"),
203+
),
177204
]
178205
)
179206
it.outputDir.set(prefabHeadersDir)
@@ -402,12 +429,12 @@ android {
402429
"-DANDROID_TOOLCHAIN=clang",
403430
"-DANDROID_PLATFORM=android-21"
404431

405-
targets "reactnativejni",
406-
"jscexecutor",
432+
targets "jscexecutor",
407433
"jsijniprofiler",
408434
"reactnativeblob",
409435
"reactperfloggerjni",
410436
// prefab targets
437+
"reactnativejni",
411438
"react_render_debug",
412439
"turbomodulejsijni",
413440
"runtimeexecutor",
@@ -426,32 +453,18 @@ android {
426453
"yoga",
427454
"folly_runtime",
428455
"react_nativemodule_core",
429-
"react_render_imagemanager"
456+
"react_render_imagemanager",
457+
"react_render_uimanager",
458+
"react_render_scheduler",
459+
"react_render_mounting",
460+
"hermes-executor"
430461
}
431462
}
432463
ndk {
433464
abiFilters(*reactNativeArchitectures())
434465
}
435466
}
436467

437-
buildTypes {
438-
debug {
439-
externalNativeBuild {
440-
cmake {
441-
targets "hermes-executor-debug"
442-
}
443-
}
444-
}
445-
446-
release {
447-
externalNativeBuild {
448-
cmake {
449-
targets "hermes-executor-release"
450-
}
451-
}
452-
}
453-
}
454-
455468
externalNativeBuild {
456469
cmake {
457470
path "src/main/jni/CMakeLists.txt"
@@ -549,6 +562,21 @@ android {
549562
react_render_imagemanager {
550563
headers(new File(prefabHeadersDir, "react_render_imagemanager").absolutePath)
551564
}
565+
react_render_uimanager {
566+
headers(new File(prefabHeadersDir, "react_render_uimanager").absolutePath)
567+
}
568+
react_render_scheduler {
569+
headers(new File(prefabHeadersDir, "react_render_scheduler").absolutePath)
570+
}
571+
react_render_mounting {
572+
headers(new File(prefabHeadersDir, "react_render_mounting").absolutePath)
573+
}
574+
reactnativejni {
575+
headers(new File(prefabHeadersDir, "reactnativejni").absolutePath)
576+
}
577+
"hermes-executor" {
578+
headers(new File(prefabHeadersDir, "hermes-executor").absolutePath)
579+
}
552580
}
553581

554582
publishing {

ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ rn_android_library(
1717
react_native_target("java/com/facebook/hermes/instrumentation:instrumentation"),
1818
react_native_target("java/com/facebook/hermes/instrumentation:hermes_samplingprofiler"),
1919
react_native_target("java/com/facebook/react/bridge:bridge"),
20+
react_native_target("java/com/facebook/react/common:common"),
2021
react_native_target("jni/react/hermes/reactexecutor:jni"),
2122
":runtimeconfig",
2223
],

ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.facebook.jni.HybridData;
1111
import com.facebook.react.bridge.JavaScriptExecutor;
12+
import com.facebook.react.common.build.ReactBuildConfig;
1213
import com.facebook.soloader.SoLoader;
1314
import javax.annotation.Nullable;
1415

@@ -23,11 +24,11 @@ public static void loadLibrary() throws UnsatisfiedLinkError {
2324
if (mode_ == null) {
2425
// libhermes must be loaded explicitly to invoke its JNI_OnLoad.
2526
SoLoader.loadLibrary("hermes");
26-
try {
27-
SoLoader.loadLibrary("hermes-executor-debug");
27+
SoLoader.loadLibrary("hermes-executor");
28+
// libhermes-executor is built differently for Debug & Release so we load the proper mode.
29+
if (ReactBuildConfig.DEBUG == true) {
2830
mode_ = "Debug";
29-
} catch (UnsatisfiedLinkError e) {
30-
SoLoader.loadLibrary("hermes-executor-release");
31+
} else {
3132
mode_ = "Release";
3233
}
3334
}

ReactAndroid/src/main/jni/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ endif(CCACHE_FOUND)
1717

1818
# Make sure every shared lib includes a .note.gnu.build-id header
1919
add_link_options(-Wl,--build-id)
20-
add_compile_options(-Wall -Werror -std=c++1y)
20+
add_compile_options(-Wall -Werror -std=c++17)
2121

2222
function(add_react_android_subdir relative_path)
2323
add_subdirectory(${REACT_ANDROID_DIR}/${relative_path} ReactAndroid/${relative_path})

0 commit comments

Comments
 (0)