Skip to content

Commit

Permalink
Merging upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
mganandraj committed May 8, 2022
2 parents 01459b3 + 23a160e commit e1fb3ad
Show file tree
Hide file tree
Showing 46 changed files with 398 additions and 691 deletions.
183 changes: 117 additions & 66 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -881,33 +881,56 @@ jobs:
# -------------------------
prepare_hermes_workspace:
docker:
- image: debian:buster
- image: debian:bullseye
environment:
- HERMES_WS_DIR: *hermes_workspace_root
- HERMES_VERSION_FILE: "sdks/.hermesversion"
steps:
- checkout
- run:
name: Install dependencies
command: |
apt-get update
apt-get install -y wget git
apt update
apt install -y wget git
- checkout
- run:
name: Set up Hermes workspace
command: mkdir -p "$HERMES_WS_DIR/hermes" "$HERMES_WS_DIR/download"
name: Set up Hermes workspace and caching
command: |
mkdir -p "/tmp/hermes" "/tmp/hermes/download" "/tmp/hermes/hermes"
if [ -f "$HERMES_VERSION_FILE" ]; then
cat $HERMES_VERSION_FILE > /tmp/hermes/hermesversion
else
HERMES_TAG_SHA=$(git ls-remote https://github.com/facebook/hermes main | cut -f 1 | tr -d '[:space:]')
echo $HERMES_TAG_SHA > /tmp/hermes/hermesversion
fi
- restore_cache:
key: v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
- run:
name: Download Hermes tarball
command: |
HERMES_VERSION_FILE="sdks/.hermesversion"
HERMES_TARBALL_URL="https://github.com/facebook/hermes/archive/refs/heads/main.tar.gz"
HERMES_TARBALL_PATH="$HERMES_WS_DIR/download/hermes.tar.gz"
if [ -f "$HERMES_VERSION_FILE" ]; then
HERMES_TAG=$(cat $HERMES_VERSION_FILE | tr -d '[:space:]')
HERMES_TARBALL_URL="https://github.com/facebook/hermes/archive/refs/tags/$HERMES_TAG.tar.gz"
echo "Using Hermes version tagged $HERMES_TAG"
else
echo "Using Hermes latest version from trunk"
fi
wget --timestamping -O "$HERMES_WS_DIR/download/hermes.tar.gz" "$HERMES_TARBALL_URL"
if [ -f "$HERMES_TARBALL_PATH" ]; then
echo "Skipping download; $HERMES_TARBALL_PATH already present."
else
echo "Downloading Hermes tarball from $HERMES_TARBALL_URL"
wget -O "$HERMES_TARBALL_PATH" "$HERMES_TARBALL_URL"
fi
tar -xzf "$HERMES_WS_DIR/download/hermes.tar.gz" --strip-components=1 -C "$HERMES_WS_DIR/hermes"
- save_cache:
key: v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
paths:
- /tmp/hermes/download/
- /tmp/hermes/hermes/
- persist_to_workspace:
root: *hermes_workspace_root
paths:
Expand All @@ -928,22 +951,30 @@ jobs:
apt install -y git openssh-client cmake build-essential \
libreadline-dev libicu-dev zip python3
- *attach_hermes_workspace
- restore_cache:
key: v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
- run:
name: Set up workspace
command: |
mkdir -p /tmp/hermes/linux64-bin
- run:
name: Build HermesC for Linux
command: |
cd /tmp/hermes
cmake -S hermes -B build -DHERMES_STATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_CXX_FLAGS=-s -DCMAKE_C_FLAGS=-s \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
cmake --build build --target check-hermes -j 4
- run:
name: Package HermesC for Linux
command: |
cp /tmp/hermes/build/bin/hermesc /tmp/hermes/linux64-bin/.
if [ -f /tmp/hermes/linux64-bin/hermesc ]; then
echo 'Skipping; Clean "/tmp/hermes/linux64-bin" to rebuild.'
else
cd /tmp/hermes
cmake -S hermes -B build -DHERMES_STATIC_LINK=ON -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DCMAKE_CXX_FLAGS=-s -DCMAKE_C_FLAGS=-s \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
cmake --build build --target check-hermes -j 4
cp /tmp/hermes/build/bin/hermesc /tmp/hermes/linux64-bin/.
fi
- save_cache:
key: v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
paths:
- /tmp/hermes/linux64-bin/
- /tmp/hermes/hermes/destroot/
- store_artifacts:
path: /tmp/hermes/linux64-bin/
- persist_to_workspace:
Expand All @@ -957,6 +988,8 @@ jobs:
- HERMES_WS_DIR: *hermes_workspace_root
steps:
- *attach_hermes_workspace
- restore_cache:
key: v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
- run:
name: Set up workspace
command: |
Expand All @@ -968,13 +1001,20 @@ jobs:
- run:
name: Build HermesC for macOS
command: |
cd "$HERMES_WS_DIR/hermes"
./utils/build-mac-framework.sh
- run:
name: Package HermesC for macOS
command: |
cd "$HERMES_WS_DIR/hermes"
cp build_macosx/bin/hermesc /tmp/hermes/osx-bin/.
if [ -f /tmp/hermes/osx-bin/hermesc ]; then
echo 'Skipping; Clean "/tmp/hermes/osx-bin" to rebuild.'
else
cd "$HERMES_WS_DIR/hermes"
./utils/build-mac-framework.sh
cp build_macosx/bin/hermesc /tmp/hermes/osx-bin/.
fi
- save_cache:
key: v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
paths:
- /tmp/hermes/osx-bin/
- /tmp/hermes/hermes/destroot/
- /tmp/hermes/hermes/build_host_hermesc/
- /tmp/hermes/hermes/build_macosx/
- store_artifacts:
path: /tmp/hermes/osx-bin/
- persist_to_workspace:
Expand All @@ -993,6 +1033,8 @@ jobs:
- CMAKE_DIR: 'C:\Program Files\CMake\bin'
steps:
- *attach_hermes_workspace
- restore_cache:
key: v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "tmp/hermes/hermesversion" }}
- run:
name: Set up workspace
command: |
Expand All @@ -1001,53 +1043,57 @@ jobs:
New-Item -ItemType Directory $Env:HERMES_WS_DIR\deps
New-Item -ItemType Directory $Env:HERMES_WS_DIR\win64-bin
New-Item -ItemType SymbolicLink -Target tmp\hermes\hermes -Path $Env:HERMES_WS_DIR -Name hermes
- run:
name: Download ICU
command: |
cd $Env:HERMES_WS_DIR\icu
# If Invoke-WebRequest shows a progress bar, it will fail with
# Win32 internal error "Access is denied" 0x5 occurred [...]
$progressPreference = 'silentlyContinue'
Invoke-WebRequest -Uri "$Env:ICU_URL" -OutFile "icu.zip"
Expand-Archive -Path "icu.zip" -DestinationPath "."
- run:
name: Install dependencies
command: |
choco install --no-progress cmake --version 3.14.7
if (-not $?) { throw "Failed to install CMake" }
choco install --no-progress python3
if (-not $?) { throw "Failed to install Python" }
- run:
name: Assemble Windows runtime dependencies
command: |
cd $Env:HERMES_WS_DIR
Copy-Item -Path "icu\bin64\icu*.dll" -Destination "deps"
# Include MSVC++ 2015 redistributables
Copy-Item -Path "c:\windows\system32\msvcp140.dll" -Destination "deps"
Copy-Item -Path "c:\windows\system32\vcruntime140.dll" -Destination "deps"
Copy-Item -Path "c:\windows\system32\vcruntime140_1.dll" -Destination "deps"
- run:
name: Build HermesC for Windows
command: |
$Env:PATH += ";$Env:CMAKE_DIR;$Env:MSBUILD_DIR"
$Env:ICU_ROOT = "$Env:HERMES_WS_DIR\icu"
cd $Env:HERMES_WS_DIR
cmake -S hermes -B build_release -G 'Visual Studio 16 2019' -Ax64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DHERMES_ENABLE_WIN10_ICU_FALLBACK=OFF
if (-not $?) { throw "Failed to configure Hermes" }
cd build_release
cmake --build . --target hermesc --config Release
if (-not $?) { throw "Failed to build Hermes" }
- run:
name: Package HermesC for Windows
command: |
cd $Env:HERMES_WS_DIR
Copy-Item -Path "build_release\bin\Release\hermesc.exe" -Destination "win64-bin"
# Include Windows runtime dependencies
Copy-Item -Path "deps\*" -Destination "win64-bin"
if (-not(Test-Path -Path $Env:HERMES_WS_DIR\win64-bin\hermesc.exe)) {
choco install --no-progress cmake --version 3.14.7
if (-not $?) { throw "Failed to install CMake" }
choco install --no-progress python3
if (-not $?) { throw "Failed to install Python" }
cd $Env:HERMES_WS_DIR\icu
# If Invoke-WebRequest shows a progress bar, it will fail with
# Win32 internal error "Access is denied" 0x5 occurred [...]
$progressPreference = 'silentlyContinue'
Invoke-WebRequest -Uri "$Env:ICU_URL" -OutFile "icu.zip"
Expand-Archive -Path "icu.zip" -DestinationPath "."
cd $Env:HERMES_WS_DIR
Copy-Item -Path "icu\bin64\icu*.dll" -Destination "deps"
# Include MSVC++ 2015 redistributables
Copy-Item -Path "c:\windows\system32\msvcp140.dll" -Destination "deps"
Copy-Item -Path "c:\windows\system32\vcruntime140.dll" -Destination "deps"
Copy-Item -Path "c:\windows\system32\vcruntime140_1.dll" -Destination "deps"
$Env:PATH += ";$Env:CMAKE_DIR;$Env:MSBUILD_DIR"
$Env:ICU_ROOT = "$Env:HERMES_WS_DIR\icu"
cmake -S hermes -B build_release -G 'Visual Studio 16 2019' -Ax64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True -DHERMES_ENABLE_WIN10_ICU_FALLBACK=OFF
if (-not $?) { throw "Failed to configure Hermes" }
cd build_release
cmake --build . --target hermesc --config Release
if (-not $?) { throw "Failed to build Hermes" }
cd $Env:HERMES_WS_DIR
Copy-Item -Path "build_release\bin\Release\hermesc.exe" -Destination "win64-bin"
# Include Windows runtime dependencies
Copy-Item -Path "deps\*" -Destination "win64-bin"
}
else {
Write-Host "Skipping; Clean c:\tmp\hermes\win64-bin to rebuild."
}
- save_cache:
key: v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "tmp/hermes/hermesversion" }}
paths:
- C:\tmp\hermes\win64-bin\
- C:\tmp\hermes\hermes\icu\
- C:\tmp\hermes\hermes\deps\
- C:\tmp\hermes\hermes\build_release\
- store_artifacts:
path: c:\tmp\hermes\win64-bin\
path: C:\tmp\hermes\win64-bin\
- persist_to_workspace:
root: c:\tmp\hermes\
root: C:\tmp\hermes\
paths:
- win64-bin

Expand Down Expand Up @@ -1120,6 +1166,11 @@ jobs:
# END: Stables and nightlies

- run: node ./scripts/publish-npm.js << parameters.publish_npm_args >>
- run:
name: Zip Hermes Native Symbols
command: zip -r /tmp/hermes-native-symbols.zip ~/react-native/ReactAndroid/hermes-engine/build/intermediates/cmake/
- store_artifacts:
path: /tmp/hermes-native-symbols.zip

# START: Commitlies
# Provide a react-native package for this commit as a Circle CI release artifact.
Expand Down
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ untyped-import
untyped-type-import

[version]
^0.176.3
^0.177.0
2 changes: 1 addition & 1 deletion .flowconfig.android
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ untyped-import
untyped-type-import

[version]
^0.176.3
^0.177.0
2 changes: 1 addition & 1 deletion BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ rn_library(
"//xplat/js:node_modules__react_19shallow_19renderer",
"//xplat/js:node_modules__regenerator_19runtime",
"//xplat/js:node_modules__stacktrace_19parser",
"//xplat/js:node_modules__use_19subscription",
"//xplat/js:node_modules__use_19sync_19external_19store",
"//xplat/js:node_modules__whatwg_19fetch",
"//xplat/js/RKJSModules/Libraries/Polyfills:Polyfills",
"//xplat/js/RKJSModules/Libraries/React:React",
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/AsyncStorageTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class AsyncStorageTest extends React.Component<{...}, $FlowFixMeState> {
this.setState({done: true}, () => {
TestModule.markTestCompleted();
});
updateMessage = msg => {
updateMessage = (msg: string) => {
this.setState({messages: this.state.messages.concat('\n' + msg)});
DEBUG && console.log(msg);
};
Expand Down
1 change: 1 addition & 0 deletions Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,7 @@ class ScrollView extends React.Component<Props, State> {
keyboardNeverPersistTaps &&
this._keyboardIsDismissible() &&
e.target != null &&
// $FlowFixMe[incompatible-call]
!TextInputState.isTextInput(e.target)
) {
return true;
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Image/Image.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export type ImageComponentStatics = $ReadOnly<{|
*
* See https://reactnative.dev/docs/image
*/
let Image = (props: ImagePropsType, forwardedRef) => {
const BaseImage = (props: ImagePropsType, forwardedRef) => {
let source = resolveAssetSource(props.source);
const defaultSource = resolveAssetSource(props.defaultSource);
const loadingIndicatorSource = resolveAssetSource(
Expand Down Expand Up @@ -221,11 +221,11 @@ let Image = (props: ImagePropsType, forwardedRef) => {
);
};

Image = React.forwardRef<
let Image = React.forwardRef<
ImagePropsType,
| React.ElementRef<typeof TextInlineImageNativeComponent>
| React.ElementRef<typeof ImageViewNativeComponent>,
>(Image);
>(BaseImage);

if (ImageInjection.unstable_createImageComponent != null) {
Image = ImageInjection.unstable_createImageComponent(Image);
Expand Down
7 changes: 4 additions & 3 deletions Libraries/Image/Image.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export type ImageComponentStatics = $ReadOnly<{|
*
* See https://reactnative.dev/docs/image
*/
let Image = (props: ImagePropsType, forwardedRef) => {
const BaseImage = (props: ImagePropsType, forwardedRef) => {
const source = resolveAssetSource(props.source) || {
uri: undefined,
width: undefined,
Expand Down Expand Up @@ -158,11 +158,12 @@ let Image = (props: ImagePropsType, forwardedRef) => {
);
};

Image = React.forwardRef<
const ImageForwardRef = React.forwardRef<
ImagePropsType,
React.ElementRef<typeof ImageViewNativeComponent>,
>(Image);
>(BaseImage);

let Image = ImageForwardRef;
if (ImageInjection.unstable_createImageComponent != null) {
Image = ImageInjection.unstable_createImageComponent(Image);
}
Expand Down
10 changes: 7 additions & 3 deletions Libraries/Lists/VirtualizeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ export function elementsThatOverlapOffsets(
offset: number,
...
},
zoomScale: number,
): Array<number> {
const out = [];
let outLength = 0;
for (let ii = 0; ii < itemCount; ii++) {
const frame = getFrameMetrics(ii);
const trailingOffset = frame.offset + frame.length;
const trailingOffset = (frame.offset + frame.length) * zoomScale;
for (let kk = 0; kk < offsets.length; kk++) {
if (out[kk] == null && trailingOffset >= offsets[kk]) {
out[kk] = ii;
Expand Down Expand Up @@ -104,6 +105,7 @@ export function computeWindowedRenderLimits(
offset: number,
velocity: number,
visibleLength: number,
zoomScale: number,
...
},
): {
Expand All @@ -115,7 +117,7 @@ export function computeWindowedRenderLimits(
if (itemCount === 0) {
return prev;
}
const {offset, velocity, visibleLength} = scrollMetrics;
const {offset, velocity, visibleLength, zoomScale} = scrollMetrics;

// Start with visible area, then compute maximum overscan region by expanding from there, biased
// in the direction of scroll. Total overscan area is capped, which should cap memory consumption
Expand All @@ -136,7 +138,8 @@ export function computeWindowedRenderLimits(
);
const overscanEnd = Math.max(0, visibleEnd + leadFactor * overscanLength);

const lastItemOffset = getFrameMetricsApprox(itemCount - 1).offset;
const lastItemOffset =
getFrameMetricsApprox(itemCount - 1).offset * zoomScale;
if (lastItemOffset < overscanBegin) {
// Entire list is before our overscan window
return {
Expand All @@ -150,6 +153,7 @@ export function computeWindowedRenderLimits(
[overscanBegin, visibleBegin, visibleEnd, overscanEnd],
itemCount,
getFrameMetricsApprox,
zoomScale,
);
overscanFirst = overscanFirst == null ? 0 : overscanFirst;
first = first == null ? Math.max(0, overscanFirst) : first;
Expand Down
Loading

0 comments on commit e1fb3ad

Please sign in to comment.