Commit Graph

32758 Commits

Author SHA1 Message Date
Ramanpreet Nara 8c26048df6 ReactInstance: Remove redundant try/catch in loadScript (#45617)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45617

This isn't necessary.

RuntimeScheduler will catch and report via js error handler.

Changelog: [Internal]

Reviewed By: alanleedev

Differential Revision: D60139055

fbshipit-source-id: 511f384ede71d88b81ef5c031fa67b1fb03f7631
2024-08-14 20:43:11 -07:00
Ramanpreet Nara 7fce71709e Route fatal js errors caught in js through JsErrorHandler
Summary:
If a fatal error is caught in js, and the js pipeline isn't ready, route it through the c++ pipeline.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D60138414

fbshipit-source-id: 333e38e2b904d6434a88469816e39bf1b9d0bc3f
2024-08-14 20:43:11 -07:00
Ramanpreet Nara dd7be8de05 Route all js errors caught in C++ through JsErrorHandler
Summary:
If any fatal js error is caught in c++, just route it through js error handler.

Then, make js error handler call into the right pipeline:
1. After the js pipeline is ready: Route the errors through the js pipeline
2. Otherwise: Route errors through the c++ pipeline.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D60138417

fbshipit-source-id: 24c466ffadbd14a9e9a5571548f3d34d2f406a8d
2024-08-14 20:43:11 -07:00
Ramanpreet Nara bc930441cf Refactor: RuntimeScheduler: Make error hander configurable
Summary:
## History
1. Originally landed in D60138415
2. Reverted in D60232011 (it broke ios oss builds)

## Motivation
In bridgeless, we want to configure the error handling of runtime scheduler. So that we can route those errors to the C++ error handling pipeline, when necessary.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D60477342

fbshipit-source-id: f14e20d7aff39e0fee42918567ccc6e685674134
2024-08-14 20:43:11 -07:00
Bowen Xie 68c0720e34 - Change RawPropsParser logs to WARNING (#46025)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46025

Changelog:
[General][Fixed] - Change RawPropsParser logs from ERROR level to WARNING

Reviewed By: christophpurrer

Differential Revision: D61304854

fbshipit-source-id: bc16df4916a54cb7c1fa57f359eab3d9eed4e2f4
2024-08-14 19:27:20 -07:00
Devan Buggay 9bc32a0101 Fix minimize/restore crash (#46023)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46023

Minimizing and restoring a Mac Catalyst app causes an `interfaceOrientationDidChange` which causes a downstream crash on `application.delegate.window`.

There doesn't seem to be a clean way to get if an app is fullscreen in Mac Catalyst, so just no-oping for now.

Changelog: [Internal]

Reviewed By: shwanton

Differential Revision: D61253706

fbshipit-source-id: 73d260366adcc74e88f43f256cc5aff8a6e3ef71
2024-08-14 15:22:58 -07:00
Dawid 94407f56d1 fix(iOS): displaying irregular borders on iOS Fabric (#45973)
Summary:
This PR solves [issue](https://github.com/facebook/react-native/issues/45958) with displaying irregular borders on Fabric. The same issue appears on the old architecture, but I am having a problems there, so I am pushing this fix for now.

The problem is solved by decoupling `backgroundColor` from `borderLayer` and setting `zPosition` on `borderLayer` to `1024.0f`, so that the border is always in front of the layer. The `zPosition` is compared within a layer, so it shouldn't impact outside components. I would love to hear your opinion if there is a case in which this could break.

## Changelog:

[IOS] [FIXED] - changed border display

Pull Request resolved: https://github.com/facebook/react-native/pull/45973

Test Plan:
I've checked that on RNTester Images.

![border-issues-screen](https://github.com/user-attachments/assets/e12add82-8016-4c42-833d-f396307e9423)

Reviewed By: joevilches

Differential Revision: D61119409

Pulled By: cipolleschi

fbshipit-source-id: a88912061c7a8d72eec4f4092adb076dd6ae511e
2024-08-14 13:16:10 -07:00
Blake Friedman bd3a3e3de0 Remove @react-native-community/cli direct dependencies (#45927)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45927

This was attempted earlier in the year, and was unsuccessful because HelloWorld had a hidden dependency on this.

Changelog: [General][Breaking] Projects that intend to use the community CLI will now have to declare that dependency instead of transitively having the react-native package handle this.

Reviewed By: GijsWeterings

Differential Revision: D60898346

fbshipit-source-id: 1d62615f718e06caf684f48ecfaf610bf1f51f8e
2024-08-14 12:55:50 -07:00
Pieter De Baets e39b916966 Revert D60143747: Fix debug logging of IntBufferBatchMountItem
Differential Revision:
D60143747

Original commit changeset: 6f1a9ea1cf95

Original Phabricator Diff: D60143747

fbshipit-source-id: c07088c4591ca344dbdc31c9f86b1a44a575c0ae
2024-08-14 08:26:45 -07:00
Riccardo Cipolleschi 9f77287a0c Update changelog for 0.75.0 (#45814)
Summary:
Changelog for 0.75.0

## Changelog:

[Internal] - Changelog for 0.75.0

Pull Request resolved: https://github.com/facebook/react-native/pull/45814

Test Plan: N/A

Reviewed By: cortinico

Differential Revision: D60446949

Pulled By: cipolleschi

fbshipit-source-id: e26e3486e3c9d224678f3df913368fa280c2e431
2024-08-14 08:09:41 -07:00
Moti Zilberman 730885863d Collapse stack frames in new renderer error handling file (#45982)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45982

Changelog: [Internal]

Recently `src/private/renderer/errorhandling/ErrorHandlers.js` started showing up in some error stack traces, making LogBox less readable. This diff ensures we collapse these extra stack frames by default (as well as hide them in Fusebox, etc).

Reviewed By: hoxyq

Differential Revision: D61128294

fbshipit-source-id: 2ebcb47265aaf3281b669ed022c29978167f3e81
2024-08-14 06:56:51 -07:00
Pieter De Baets 59c1adbfdb Rethrow original exception in DefaultReactHostDelegate (#46016)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46016

Wrapping the JavaScriptException with a RuntimException means we lose JS specific metadata on the top-level exceptions, and can break categorization in crash-reporting tools.

We could also use the same logic as [DefaultJSExceptionHandler](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/DefaultJSExceptionHandler.java) but that doesn't seem to be required for Kotlin.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D61261515

fbshipit-source-id: fa85c8818834905759cbc984ea3c45403eb87e8c
2024-08-14 05:33:41 -07:00
Nicola Corti 5b761ff15c Move libmapbufferjni.so inside libreactnative.so (#46003)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46003

Another library going inside libreactnative.so

Changelog:
[Android] [Changed] - Move libmapbufferjni.so inside libreactnative.so

Reviewed By: cipolleschi

Differential Revision: D61211105

fbshipit-source-id: 38fce9ff9025fc6d2cd9eff3ee57303babed8852
2024-08-14 05:07:56 -07:00
Nicola Corti 0caf3e824d Move libreact_newarchdefaults.so inside libreactnative.so (#46004)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46004

This is the first library I'm moving over inside libreactnative.so

Changelog:
[Android] [Changed] - Move libreact_newarchdefaults.so inside libreactnative.so

Reviewed By: cipolleschi

Differential Revision: D61211104

fbshipit-source-id: 2526395a246df9ebf6387ca434e07b4ed4484f1e
2024-08-14 05:07:56 -07:00
Nicola Corti 6dc01dad09 Do not depend on OSS SoLoader anymore (#45873)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45873

I'm removing the Gradle dependency on OSS SoLoader and stubbing it with our own implementation.
This will allow us to implement merging of further .so libraries and

As Fresco also depends on SoLoader, I had to stub the `NativeLoader` dependency as well.

Changelog:
[Android] [Breaking] - Do not depend on OSS SoLoader anymore and do not expose Fresco `api` dependency.

Reviewed By: mdvacca

Differential Revision: D60652007

fbshipit-source-id: 6e70a5c37ba9337fbe8772e192b886ba4693c7f1
2024-08-14 05:07:56 -07:00
Daniel Strebinger 53969cb8d0 Enable third-party podspec sources to be fetched from mirrored git repositories (#45566)
Summary:
At OEBB we currently facing an issue we're not able to use our mirrored git repositories for third-party podspecs. This is due to the fact podspecs contain hardcoded git repository urls. With this change we could specify urls to our mirrored git repositories.

## Changelog:

[IOS] [ADDED] Enable third-party podspec sources to be fetched from mirrored git repositories

Pull Request resolved: https://github.com/facebook/react-native/pull/45566

Test Plan:
```bash
# Define env vars for git mirrors

export FMT_GIT_URL="https://my-git-host.com/my-mirrored-repo.git"
export GLOG_GIT_URL="https://my-git-host.com/my-mirrored-repo.git"
export FOLLY_GIT_URL="https://my-git-host.com/my-mirrored-repo.git"
export DOUBLE_CONVERSION_GIT_URL="https://my-git-host.com/my-mirrored-repo.git"
export BOOST_GIT_URL="https://my-git-host.com/my-mirrored-repo.git"

# Pod install command run from ios app folder
pod install
```

Reviewed By: cortinico

Differential Revision: D61209204

Pulled By: cipolleschi

fbshipit-source-id: b19f7b8262c860b5c4d553732da50c9bd0373397
2024-08-14 04:42:58 -07:00
Soe Lynn 7bb7a6037b Back out "Fixes NSDataBigString length calculation" (#46011)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46011

Backing out D58561775 in the meantime while we are trying to do proper fix in Hermes engine D61058869

Changelog: [Internal]
Temporarily revert this diff https://github.com/facebook/react-native/pull/44900 while we wait for https://github.com/facebook/react-native/pull/45966 to land

Reviewed By: makovkastar

Differential Revision: D61246120

fbshipit-source-id: 8c205efe9d29cd34f24676c4a48d55f0493d73ab
2024-08-13 20:12:48 -07:00
Devan Buggay f9abe96d19 Fix RCTDevLoadingView position (#46005)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46005

The RCTDevLoadingView is clipped in Mac Catalyst, hiding half of it under the toolbar. This change maintains the behavior on iOS of extending past the dynamic island.

{F1803665273}

Changelog: [Internal]

Reviewed By: shwanton

Differential Revision: D61209780

fbshipit-source-id: 6c9c572a9e47a8caf191c40fb53c4a7d43b64281
2024-08-13 16:23:15 -07:00
Alex Hunt bd90a076f7 Update debugger-frontend from 7b143e5...c98a122 (#46000)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46000

Changelog: [Internal] - Update `react-native/debugger-frontend` from 7b143e5...c98a122

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebookexperimental/rn-chrome-devtools-frontend/compare/7b143e5d05a102c8c9cc7e282bab7b0751f75d61...c98a12218022a329f39b30dc20cf4de34e459749).

Reviewed By: robhogan

Differential Revision: D61208000

fbshipit-source-id: 8884d7946f4f62bbfe48e3fddc6c873f952d826c
2024-08-13 16:00:25 -07:00
Thomas Nardone 66ff4d3515 Fully synchronize NativeViewHierarchyManager (#45984)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45984

A few methods were not synchronized, exposing members like `mTagsToViews` to potential out-of-sync access.
Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D61151447

fbshipit-source-id: 696dbec559968cdfc7c6d2e662f4c8f3471039e1
2024-08-13 13:16:41 -07:00
Sam Zhou a622a43764 Replace all exact React.Element type in react-native with ExactReactElement_DEPRECATED (#45998)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45998

The exact `React.Element` type is deprecated and will be removed in a future version of Flow.

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D61205640

fbshipit-source-id: a029a3a46c7d8d9f94b0b931b991b2ce461151b2
2024-08-13 09:08:44 -07:00
Pieter De Baets 5f88c659c8 Fix debug logging of IntBufferBatchMountItem (#45637)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45637

This breaks when `setAndroidLayoutDirection` is enabled.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60143747

fbshipit-source-id: 6f1a9ea1cf95f9be0451460201e49b4ce80ce204
2024-08-13 08:35:38 -07:00
Tommy Nguyen 3e084bc159 fix(react-native-codegen): scripts require yargs (#45994)
Summary:
Android fails to build in a pnpm monorepo setup because `yargs` cannot be found:

```
% yarn android
info Installing the app...

> Configure project :app
WARNING: The option setting 'android.jetifier.ignorelist=hermes-android' is experimental.
Signing config for 'release' build type not found; reusing debug config

> Task :react-native-webapis_web-storage:generateCodegenSchemaFromJavaScript FAILED
28 actionable tasks: 6 executed, 22 up-to-date

node:internal/modules/cjs/loader:1148
  throw err;
  ^

Error: Cannot find module 'yargs'
Require stack:
- /~/node_modules/.store/react-native-codegen-virtual-39ff8dcc54/package/lib/cli/combine/combine-js-to-schema-cli.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
```

## Changelog:

[GENERAL] [FIXED] - Fix codegen failing in a pnpm monorepo because of missing `yargs`

Pull Request resolved: https://github.com/facebook/react-native/pull/45994

Test Plan: Tested in https://github.com/microsoft/rnx-kit/pull/3290

Reviewed By: dmytrorykun

Differential Revision: D61201420

Pulled By: cortinico

fbshipit-source-id: aac3704ae7f200db827b14c8362f83a5e66ad08e
2024-08-13 06:31:42 -07:00
Riccardo Cipolleschi eb2d9852c7 Fix E2E tests on Template (#45974)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45974

This change fixes the E2E tests on the template on main.

There were two issues:
1. we were forcing the project on the 0.75 branch. We now use the current branch name
2. we were replacing all the versions for the dependencies that starts with `react-native` to the monorepo version. The problem is that also `react-native-community` packages starts with `react-native`. We now changes the versions if the dependency name starts with `react-native/`.

## Changelog:
[Internal] - Fix E2E tests on main

Reviewed By: cortinico

Differential Revision: D61122154

fbshipit-source-id: 07210fc9f63e99eac46894f13c7ca5359e186e6c
2024-08-13 05:05:56 -07:00
Devan Buggay 84fe531952 Fix RedBox crash
Summary:
`RCTSharedApplication().delegate.window.safeAreaInsets.bottom;` causes a crash in Mac Catalyst.

There is already precedent of a `#if TARGET_OS_MACCATALYST` in the same file. This just defaults it to 0 in that case, which looks fine.

## Changelog:

[iOS] [Fixed] - Mac Catalyst crash in RCTRedBox

Reviewed By: shwanton

Differential Revision: D61160503

fbshipit-source-id: 5771ebff88242d9dd4b892d8823e15d1f2307728
2024-08-12 22:36:22 -07:00
Nick Gerleman 6c0710620f Use BlurMaskFilter in outset shadows instead of Blur RenderEffect (#45986)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45986

This uses SkBlurMaskFilter under the hood, to draw geometry of a solid color with alpha blur, without going the route of full image filter/rasterization. It was not supported under hardware accelerated canvases for a while, but seems to fully work as of API 29.

Requiring Android 10 instead of 12 makes box shadows a lot more palatable (80% support vs 50%), and we see drastically better performance in one case with many large shadows, where creating many large hardware layers previously drastically hurt framerates.

{F1801807696}

At this point, the RenderNode may be redundant, though I think it can technically save us some work on redraws still. It is kept around for now. I simplified some of the math around here as well.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D61162637

fbshipit-source-id: 8f6ff486e655e64a0665c31391359c499c374c8f
2024-08-12 21:41:13 -07:00
Nick Gerleman 9e48976bc2 Do not implicitly convert parsed LengthPercentage to pixels (#45987)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45987

This is a confusing public API, because styles layer deals with DIPs, conversion only happens when parsing dynamic, and `POINT` (the `LengthPercentageType`) also maps to DIPs instead of physical pixels.

This moves conversion to physical pixels to drawing layer, so everything above `BackgroundStyleApplicator` works with `style` types which are all in DIPs.

To preserve compatibility with existing APIs using raw radii, we keep it so that (most) views operate in pixel units, while view managers operate under DIPs.

Changelog: [Android][Breaking] Do not implicitly convert parsed LengthPercentage to pixels

Reviewed By: rshest

Differential Revision: D60507151

fbshipit-source-id: b90066af7b221304aded374627fc0e2165dfc08f
2024-08-12 21:41:13 -07:00
Nick Gerleman 3ee94174b4 Clip to radii bounds in OutsetBoxShadowDrawable (#45947)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45947

This adjusts logic to be similar to InsetBoxShadowDrawable to keep the full ink within RenderNode bounds. This avoids a tiny bit of overdraw, but also means we get correct rendering if RenderNode is promoted to a compositing layer.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D60972085

fbshipit-source-id: 0916733c6abae37e30dd1f64a36c0e211e41917e
2024-08-12 21:41:13 -07:00
Nick Gerleman b4159576a2 Add Android RTL Coverage to ReactNativeCoreE2E tests (#45758)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45758

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D60345614

fbshipit-source-id: 17f638ef58c4f7a4ed807573b6f8a67bff9559e3
2024-08-12 18:50:09 -07:00
Danny Su 04932f2677 Add HeapSnapshotOptions for jsi::Instrumentation (#45963)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45963

https://chromedevtools.github.io/devtools-protocol/tot/HeapProfiler/#method-takeHeapSnapshot

As per `HeapProfiler.takeHeapSnapshot` documentation, there are a few
more configurable options to what is contained in the snapshot. Adding
a struct and the `captureNumericValue` bool to the interface since
that's what we need right now. In the future, there is the
`exposeInternals` parameters that's currently experimental for Chrome.

Changelog: [Internal]

Reviewed By: neildhar

Differential Revision: D60989352

fbshipit-source-id: fcd269f0db5b24983631206a1b738dea29566f0e
2024-08-12 18:44:10 -07:00
Phillip Pan 184646e491 remove cxx TM autolinking (#45967)
Summary:
Changelog: [iOS][Android][Breaking]

Pull Request resolved: https://github.com/facebook/react-native/pull/45967

this was a meaningful exploration, but since we have support in TM for jsi runtime access and that's been widely advertised and accepted, let's get rid of this. it's a bit hacky and hard to use (shown by no one using it), so i want to stop any possibility of its usage.

if interested in accessing jsi::Runtime via a native module, please consider the following options:
- [Android] BindingsInstaller: https://github.com/facebook/react-native/pull/44526
- [iOS] RCTTurboModuleWithJSIBindings: https://github.com/facebook/react-native/pull/44486
- C++ TurboModules (no autolinking): https://github.com/reactwg/react-native-new-architecture/blob/main/docs/turbo-modules-xplat.md

Reviewed By: christophpurrer

Differential Revision: D61059182

fbshipit-source-id: da5d74e2b6161ea7e8dd5f664ae0eb927bb1e2c3
2024-08-12 15:29:39 -07:00
Nicola Corti d01f1b3214 Add support for handling com.facebook.react.bridge.Dynamic as parameter type in TurboModules (#45944)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45944

This diff adds support having (Legacy) Native Modules with functions with parameters of type `Dynamic`.
This is currently blocking some libraries making it harder for them to migrate to New Architecture.

I've implemented it by adding a `DynamicNative` implementation of `Dynamic` which holds a reference of
the payload as a `folly::dynamic`.

Changelog:
[Android] [Added] - Add support for handling `com.facebook.react.bridge.Dynamic` as parameter type in TurboModules

Reviewed By: mdvacca, cipolleschi

Differential Revision: D60966684

fbshipit-source-id: 2e63bc53ede5277a9c12f1b19f05f6099f5f35f9
2024-08-12 12:56:38 -07:00
Thomas Nardone 471445eb17 Delete LongArray (#45736)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45736

This was an internally used class that was made irrelevant by Kotlin conversion.  Appears to be unused in OSS, no breakages expected.

Changelog:
[Android][Breaking] - Deleted LongArray

Reviewed By: sammy-SC

Differential Revision: D60292651

fbshipit-source-id: cebb3d41113ad9f3247c3189889337d6e3e4ebab
2024-08-12 10:54:33 -07:00
Jakub Grzywacz 010e0010a3 Make setPointerEvents public on ReactViewGroup.java (#45975)
Summary:
I maintain the `react-native-svg` library, where our elements extend `ReactViewGroup`. Currently, `ReactViewGroup` only exposes the getter for `mPointerEvents` publicly, so we cannot set it. To properly handle `pointerEvents`, we would have to duplicate all methods related to `mPointerEvents`, which results in maintaining a separate state. This duplication can lead to desynchronization between the state in our class and the state in the superclass.

PR with a workaround that we can avoid with this change https://github.com/software-mansion/react-native-svg/pull/2395

## Changelog:

[ANDROID] [CHANGED] - make `setPointerEvents` public

Pull Request resolved: https://github.com/facebook/react-native/pull/45975

Test Plan: This change was tested manually by making the field public, allowing dependent classes to override or reference it.

Reviewed By: cortinico

Differential Revision: D61124293

Pulled By: javache

fbshipit-source-id: 389d0a670375a8a68c975294f98c33c28ef41ffe
2024-08-12 10:36:57 -07:00
Jon Thysell c30e35fb44 Fix "C4715 not all control paths return a value" warning in MSVC (#45827)
Summary:
When integrating react-native into react-native-windows, we got the following build warning (which we treat as an error) when building ReactCommon: `C4715 not all control paths return a value`

This PR adds defaults to the switches to make sure every path returns a value.

See https://github.com/microsoft/react-native-windows/issues/13516

## Changelog:

[GENERAL] [FIXED] Fix "C4715 not all control paths return a value" warning in MSVC when building ReactCommon

Pull Request resolved: https://github.com/facebook/react-native/pull/45827

Test Plan: The switches are checking enums this code should never be hit unless new enum values are added.

Reviewed By: robhogan

Differential Revision: D61103286

Pulled By: NickGerleman

fbshipit-source-id: 2028cb60e0b438b9ac17a828f5e1b690052a0bec
2024-08-12 10:00:24 -07:00
Pieter De Baets d9d638c06b Pass unflattened styles to reconciler (#45345)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45345

When React diffs props, it can can short-circuit nested objects if their object identity hasn't changed. Whenever we use `flattenStyle` we prevent this optimization from taking place.

Changelog: [Internal]

Reviewed By: dmytrorykun

Differential Revision: D59518281

fbshipit-source-id: e88ca781ab4622b5342169f8f27b09f0515513b3
2024-08-12 08:13:17 -07:00
Håkon Knutzen 7e41ea4c9d Data race related to read/write on ReactMarker::logTaggedMarkerImpl (#45557)
Summary:
When using `TSan` while running the Unit tests of `RNTester`, there are a few data races picked up. One is described [here](https://github.com/facebook/react-native/issues/45280), while this PR deals with a race related to concurrent read/write of `ReactMarker::logTaggedMarkerImpl`. Here is the `TSan` output:

```
WARNING: ThreadSanitizer: data race (pid=5236)
  Read of size 8 at 0x00011a602690 by thread T34:
    #0 std::__1::__function::__value_func<void (facebook::react::ReactMarker::ReactMarkerId, char const*)>::operator bool[abi:ue170006]() const <null> (RNTesterUnitTests:arm64+0x18cd49c)
    https://github.com/facebook/react-native/issues/1 std::__1::function<void (facebook::react::ReactMarker::ReactMarkerId, char const*)>::operator bool[abi:ue170006]() const <null> (RNTesterUnitTests:arm64+0x18cd2bc)
    https://github.com/facebook/react-native/issues/2 facebook::react::JSIExecutor::initializeRuntime() <null> (RNTesterUnitTests:arm64+0x1c96818)
    https://github.com/facebook/react-native/issues/3 facebook::react::NativeToJsBridge::initializeRuntime()::$_0::operator()(facebook::react::JSExecutor*) <null> (RNTesterUnitTests:arm64+0x1a7a074)
    https://github.com/facebook/react-native/issues/4 decltype(std::declval<facebook::react::NativeToJsBridge::initializeRuntime()::$_0&>()(std::declval<facebook::react::JSExecutor*>())) std::__1::__invoke[abi:ue170006]<facebook::react::NativeToJsBridge::initializeRuntime()::$_0&, facebook::react::JSExecutor*>(facebook::react::NativeToJsBridge::initializeRuntime()::$_0&, facebook::react::JSExecutor*&&) <null> (RNTesterUnitTests:arm64+0x1a79fbc)
    https://github.com/facebook/react-native/issues/5 void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ue170006]<facebook::react::NativeToJsBridge::initializeRuntime()::$_0&, facebook::react::JSExecutor*>(facebook::react::NativeToJsBridge::initializeRuntime()::$_0&, facebook::react::JSExecutor*&&) <null> (RNTesterUnitTests:arm64+0x1a79e5c)
    https://github.com/facebook/react-native/issues/6 std::__1::__function::__alloc_func<facebook::react::NativeToJsBridge::initializeRuntime()::$_0, std::__1::allocator<facebook::react::NativeToJsBridge::initializeRuntime()::$_0>, void (facebook::react::JSExecutor*)>::operator()[abi:ue170006](facebook::react::JSExecutor*&&) <null> (RNTesterUnitTests:arm64+0x1a79d84)
    https://github.com/facebook/react-native/issues/7 std::__1::__function::__func<facebook::react::NativeToJsBridge::initializeRuntime()::$_0, std::__1::allocator<facebook::react::NativeToJsBridge::initializeRuntime()::$_0>, void (facebook::react::JSExecutor*)>::operator()(facebook::react::JSExecutor*&&) <null> (RNTesterUnitTests:arm64+0x1a75250)
    https://github.com/facebook/react-native/issues/8 std::__1::__function::__value_func<void (facebook::react::JSExecutor*)>::operator()[abi:ue170006](facebook::react::JSExecutor*&&) const <null> (RNTesterUnitTests:arm64+0x1abac9c)
    https://github.com/facebook/react-native/issues/9 std::__1::function<void (facebook::react::JSExecutor*)>::operator()(facebook::react::JSExecutor*) const <null> (RNTesterUnitTests:arm64+0x1aba9d0)
    https://github.com/facebook/react-native/issues/10 facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>&&)::$_8::operator()() const <null> (RNTesterUnitTests:arm64+0x1aba8d4)
    https://github.com/facebook/react-native/issues/11 decltype(std::declval<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>&&)::$_8&>()()) std::__1::__invoke[abi:ue170006]<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>&&)::$_8&>(facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>&&)::$_8&) <null> (RNTesterUnitTests:arm64+0x1aba6d4)
    https://github.com/facebook/react-native/issues/12 void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ue170006]<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>&&)::$_8&>(facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>&&)::$_8&) <null> (RNTesterUnitTests:arm64+0x1aba4f8)
    https://github.com/facebook/react-native/issues/13 std::__1::__function::__alloc_func<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>&&)::$_8, std::__1::allocator<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>&&)::$_8>, void ()>::operator()[abi:ue170006]() <null> (RNTesterUnitTests:arm64+0x1aba45c)
    https://github.com/facebook/react-native/issues/14 std::__1::__function::__func<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>&&)::$_8, std::__1::allocator<facebook::react::NativeToJsBridge::runOnExecutorQueue(std::__1::function<void (facebook::react::JSExecutor*)>&&)::$_8>, void ()>::operator()() <null> (RNTesterUnitTests:arm64+0x1ab4918)
    https://github.com/facebook/react-native/issues/15 std::__1::__function::__value_func<void ()>::operator()[abi:ue170006]() const <null> (RNTesterUnitTests:arm64+0x3ce2e4)
    https://github.com/facebook/react-native/issues/16 std::__1::function<void ()>::operator()() const <null> (RNTesterUnitTests:arm64+0x3cdfd0)
    https://github.com/facebook/react-native/issues/17 facebook::react::tryAndReturnError(std::__1::function<void ()> const&) <null> (RNTesterUnitTests:arm64+0x4af18c)
    https://github.com/facebook/react-native/issues/18 facebook::react::RCTMessageThread::tryFunc(std::__1::function<void ()> const&) <null> (RNTesterUnitTests:arm64+0x51595c)
    https://github.com/facebook/react-native/issues/19 facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1::operator()() const <null> (RNTesterUnitTests:arm64+0x529df0)
    https://github.com/facebook/react-native/issues/20 decltype(std::declval<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&>()()) std::__1::__invoke[abi:ue170006]<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&>(facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&) <null> (RNTesterUnitTests:arm64+0x529b54)
    https://github.com/facebook/react-native/issues/21 void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ue170006]<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&>(facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1&) <null> (RNTesterUnitTests:arm64+0x529978)
    https://github.com/facebook/react-native/issues/22 std::__1::__function::__alloc_func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1, std::__1::allocator<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1>, void ()>::operator()[abi:ue170006]() <null> (RNTesterUnitTests:arm64+0x5298dc)
    https://github.com/facebook/react-native/issues/23 std::__1::__function::__func<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1, std::__1::allocator<facebook::react::RCTMessageThread::runOnQueue(std::__1::function<void ()>&&)::$_1>, void ()>::operator()() <null> (RNTesterUnitTests:arm64+0x524518)
    https://github.com/facebook/react-native/issues/24 std::__1::__function::__value_func<void ()>::operator()[abi:ue170006]() const <null> (RNTesterUnitTests:arm64+0x3ce2e4)
    https://github.com/facebook/react-native/issues/25 std::__1::function<void ()>::operator()() const <null> (RNTesterUnitTests:arm64+0x3cdfd0)
    https://github.com/facebook/react-native/issues/26 invocation function for block in facebook::react::RCTMessageThread::runAsync(std::__1::function<void ()>) <null> (RNTesterUnitTests:arm64+0x515384)
    https://github.com/facebook/react-native/issues/27 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ <null> (CoreFoundation:arm64+0x8dc0c)
    https://github.com/facebook/react-native/issues/28 __NSThread__start__ <null> (Foundation:arm64+0x645c60)

  Previous write of size 8 at 0x00011a602690 by main thread:
    #0 std::__1::__function::__value_func<void (facebook::react::ReactMarker::ReactMarkerId, char const*)>::swap[abi:ue170006](std::__1::__function::__value_func<void (facebook::react::ReactMarker::ReactMarkerId, char const*)>&) <null> (RNTesterUnitTests:arm64+0x43b078)
    https://github.com/facebook/react-native/issues/1 std::__1::function<void (facebook::react::ReactMarker::ReactMarkerId, char const*)>::swap(std::__1::function<void (facebook::react::ReactMarker::ReactMarkerId, char const*)>&) <null> (RNTesterUnitTests:arm64+0x433100)
    https://github.com/facebook/react-native/issues/2 std::__1::function<void (facebook::react::ReactMarker::ReactMarkerId, char const*)>& std::__1::function<void (facebook::react::ReactMarker::ReactMarkerId, char const*)>::operator=<registerPerformanceLoggerHooks(RCTPerformanceLogger*)::$_1, void>(registerPerformanceLoggerHooks(RCTPerformanceLogger*)::$_1&&) <null> (RNTesterUnitTests:arm64+0x432d50)
    https://github.com/facebook/react-native/issues/3 registerPerformanceLoggerHooks(RCTPerformanceLogger*) <null> (RNTesterUnitTests:arm64+0x4170fc)
    https://github.com/facebook/react-native/issues/4 -[RCTCxxBridge initWithParentBridge:] <null> (RNTesterUnitTests:arm64+0x416504)
    https://github.com/facebook/react-native/issues/5 -[RCTBridge setUp] <null> (RNTesterUnitTests:arm64+0x3bf6f4)
    https://github.com/facebook/react-native/issues/6 -[RCTBridge initWithDelegate:bundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x3bc540)
    https://github.com/facebook/react-native/issues/7 -[RCTBridge initWithBundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x3bc124)
    https://github.com/facebook/react-native/issues/8 -[RCTImageLoaderTests testImageLoaderUsesImageURLLoaderWithHighestPriority] <null> (RNTesterUnitTests:arm64+0x7de8)
    https://github.com/facebook/react-native/issues/9 __invoking___ <null> (CoreFoundation:arm64+0x13371c)

  Location is global 'facebook::react::ReactMarker::logTaggedMarkerImpl' at 0x00011a602678 (RNTesterUnitTests+0x438a690)

  Thread T34 (tid=11229216, running) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_iossim_dynamic.dylib:arm64+0x2bee4)
    https://github.com/facebook/react-native/issues/1 -[NSThread startAndReturnError:] <null> (Foundation:arm64+0x6458f0)
    https://github.com/facebook/react-native/issues/2 -[RCTBridge setUp] <null> (RNTesterUnitTests:arm64+0x3bf748)
    https://github.com/facebook/react-native/issues/3 -[RCTBridge initWithDelegate:bundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x3bc540)
    https://github.com/facebook/react-native/issues/4 -[RCTBridge initWithBundleURL:moduleProvider:launchOptions:] <null> (RNTesterUnitTests:arm64+0x3bc124)
    https://github.com/facebook/react-native/issues/5 -[RCTImageLoaderTests testImageLoaderUsesImageDecoderWithHighestPriority] <null> (RNTesterUnitTests:arm64+0xbe8c)
    https://github.com/facebook/react-native/issues/6 __invoking___ <null> (CoreFoundation:arm64+0x13371c)
```

The proposed solution is to wrap `logTaggedMarkerImpl` in a class that has a static getter and setter wherein a read/write lock is employed. It is my understanding that `logTaggedMarkerImpl` is read several times, but only assigned rarely, and thus it seems appropriate with a read/write lock. The getter and setter functions are also inlineable, such that one should not need to make an extra function call when obtaining the `logTaggedMarkerImpl` instance.

In order to reproduce my findings and verify fix:

* Clone this branch
* Run setup code as described in README
* Execute `git revert -n 65998835c2198b9d626160a6883744801fa056a9 83a2a3c9b4e5ea588a6cc3a9281ad385a388b84a`
* Enable TSan for both `RNTester` and its test scheme.
* Enable Runtime issue breakpoint for TSan
* Run unit tests
* Observe the `TSan` breakpoint is hit (possibly other places in the codebase as well) when accessing `logTaggedMarkerImpl`. Continue execution if other breakpoints are hit before this breakpoint.
* Execute `git revert --abort`
* Run the tests again and observe the `TSan` breakpoint does _not_ hit said code again.

## Changelog:

[iOS][Fixed] Data race related to read/write on `ReactMarker::logTaggedMarkerImpl`

Pull Request resolved: https://github.com/facebook/react-native/pull/45557

Test Plan: I believe there are existing tests that will cover the proposed changes.

Reviewed By: cipolleschi

Differential Revision: D60525080

Pulled By: dmytrorykun

fbshipit-source-id: 78b0ce2a660af0e29909ff68c018698a9a1e29f8
2024-08-12 05:06:05 -07:00
Riccardo Cipolleschi 4faafb0aa4 Remove _shouldEmitEvent guardrails (#45837)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45837

Some Internal tests in the old architecture were failing after landing [#45414](https://github.com/facebook/react-native/pull/45414) because the `RCTNativeAnimatedModule` in the old architecture was not declaring the event.

This change fixes it by declaring the event that is never fired in the Old Architecture as it is not needed.

## Changelog
[iOS][Added] - Declare the `onUserDrivenAnimationEnded` in the old Architecture

Reviewed By: sammy-SC

Differential Revision: D60499584

fbshipit-source-id: 581a30a88dbd6d8d67078a11699157c55ed19e58
2024-08-12 03:52:51 -07:00
Riccardo Cipolleschi a8786fc1df React to onUserDrivenAnimationEnded event in JS (#45839)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45839

Pull Request resolved: https://github.com/facebook/react-native/pull/45414

This change completes the fix for broken pressable when animations were applied to components with native driven animations.

When creating the AnimatedProps, if they are natively drive animation, we look for the AnimatedValue involved and we register a listener. This is needed to make sure that the NativeModule will send te updated value upon calling the `update` function.

Then, when observing the props lifecycle, it register a listener to the new `OnUserAnimationEnded` event, fired by the NativeAnimation module.

When the `OnUserAnimationEnded` event is fired, the AnimatedProps will update the props that depends on the user driven animation.

## Changelog
[General][Fixed] - reallign the shadow tree and the native tree when the user finishes interacting with the app.

Reviewed By: sammy-SC

Differential Revision: D60499583

fbshipit-source-id: 02d25e7ca31b91f4d6e4ec1654350e2d84117eda
2024-08-12 03:52:51 -07:00
David Vacca 175943f15b Fix Fabric logging when ReactNativeFeatureFlags.setAndroidLayoutDirection is enabled (#45953)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45953

Fabric logging was broken when ReactNativeFeatureFlags.setAndroidLayoutDirection is enabled, I'm fixing it here

changelog: [internal] internal

Reviewed By: NickGerleman, bvanderhoof

Differential Revision: D61002408

fbshipit-source-id: bff76ce145d4619635a4b55a4750c3e51bb4d8d7
2024-08-10 00:01:24 -07:00
Nick Gerleman d3bd4254cf Fix OutsetBoxShadowDrawable offseting (#45954)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45954

Fixes offset issue after CSSBackgroundDrawable decoupling.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D61003916

fbshipit-source-id: e23faf7f9bae89f2f77a448ba3d99f29c89eb621
2024-08-09 19:05:16 -07:00
shubhamguptadream11 603eb94dd9 feat(android): height issue fixed with keyboard avoiding component in new architecture (#45928)
Summary:
Fixes this issue: https://github.com/facebook/react-native/issues/45880

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID] [CHANGED] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[ANDROID] [CHANGED] - Replaced `mLastHeight` with `mVisibleViewArea.height()` since mLastHeight value is not getting updated. For `width` we are already using `mVisibleViewArea.width()`

Pull Request resolved: https://github.com/facebook/react-native/pull/45928

Test Plan: - Tested the fix in new and old architecture both

Reviewed By: christophpurrer

Differential Revision: D61023998

Pulled By: cortinico

fbshipit-source-id: df67616330effb7b9e6724d94b3be92c0dbd6190
2024-08-09 12:23:09 -07:00
Gijs Weterings f2aa3fe0ec Revert D61014834: Substitute babel-preset-fbjs for metro-transform-plugins
Differential Revision:
D61014834

Original commit changeset: 26bd1cacf890

Original Phabricator Diff: D61014834

fbshipit-source-id: 6879dc6e1dae7fdb59cfc3bd63ac090cffca26b0
2024-08-09 09:39:26 -07:00
Alex Hunt 82795715ae Substitute babel-preset-fbjs for metro-transform-plugins (#45959)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45959

Addresses TODO comment. I noticed this lone reference to `babel-preset-fbjs` (last published 3y ago) while attempting to upgrade our Babel Flow syntax plugin.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D61014834

fbshipit-source-id: 26bd1cacf8907550a5c318d4daf70359fb4f5700
2024-08-09 06:28:29 -07:00
Oskar Kwaśniewski 58a8fa69b4 ci: add xcbeautify for xcodebuild actions (#45957)
Summary:
This PR adds `xcbeautify` for xcodebuild actions.

Installing `xcodebuild` is not required as its included in every macos runner image: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#tools

## Changelog:

[INTERNAL] [ADDED] - add xcbeautify for xcodebuild actions

Pull Request resolved: https://github.com/facebook/react-native/pull/45957

Test Plan: CI Green

Reviewed By: cortinico

Differential Revision: D61012286

Pulled By: cipolleschi

fbshipit-source-id: d0ef3df18963c0ebfc1c856816a63b1cc0259ba5
2024-08-09 06:12:15 -07:00
Gabriel Donadel 5ced5f8363 Add shared-testutil folder to NPM files to be published (#45936)
Summary:
React-native 0.75 RC7 gradle sync is currently broken due to the fact that the `shared-testutil` folder is missing from the `react-native/gradle-plugin` npm package

## Changelog:

[INTERNAL] [ADDED] - Add shared-testutil folder to NPM files to be published

Pull Request resolved: https://github.com/facebook/react-native/pull/45936

Test Plan: N/A

Reviewed By: cipolleschi

Differential Revision: D60969631

Pulled By: cortinico

fbshipit-source-id: 850edfe0cf6b0e8174a1df9ea962d207d2ce0112
2024-08-09 05:50:16 -07:00
Oskar Kwaśniewski e4e461c9cf feat: implement automicallyAdjustsKeyboardInsets for new architecture on iOS (#45939)
Summary:
This PR implements the missing `automicallyAdjustsKeyboardInsets` for new architecture. It's a fixed version of reverted: https://github.com/facebook/react-native/issues/45819

We now check if the view intersects with the keyboard's end frame and if it doesn't we just do nothing.

Here is the app running on new arch:

https://github.com/user-attachments/assets/673f0587-6a67-47e3-8050-d6ee33a45724

## Changelog:

[IOS] [FIXED] - implement automicallyAdjustsKeyboardInsets for new arch

Pull Request resolved: https://github.com/facebook/react-native/pull/45939

Test Plan:
1. Test out ScrollViewKeyboardInsets example
2. See if it works the same with old and new arch

Reviewed By: cortinico

Differential Revision: D60958475

Pulled By: cipolleschi

fbshipit-source-id: 8650064af84bc79b6b89e07293640e5d010154c2
2024-08-09 05:22:23 -07:00
Nicola Corti ee25081d20 Fix typo in workflow name (#45956)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45956

Fix typo in workflow name

Changelog:
[Internal] [Changed] - Fix typo in workflow name

Reviewed By: cipolleschi

Differential Revision: D61007940

fbshipit-source-id: 62f8e15503ed1d9668c097e8a4c2c552a6458a83
2024-08-09 04:21:20 -07:00
Joe Vilches 7b36c0204f Fix crash when you layout multiple absolute nodes in the same static subtree (#45952)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45952

X-link: https://github.com/facebook/yoga/pull/1686

https://en.wikipedia.org/wiki/Short-circuit_evaluation 🫠

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60997231

fbshipit-source-id: 11d70086eecfb5481c578477f288138370016a83
2024-08-08 22:41:29 -07:00
Nick Gerleman 0273123dde Gate off % translate on Android Paper (#45946)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45946

This code is forked on iOS, where we have been, as a policy, avoiding Paper-specific changes. This code is shared between renderers on Android, but it is confusing developer experience to have it work on Android Paper, to then fail on iOS unless it is on new arch.

This change disables support on Android Paper for consistency.

Changelog:
[Android][Removed] - Gate off % translate on Android Paper

Reviewed By: joevilches

Differential Revision: D60970266

fbshipit-source-id: 5df73b948464f5093941528b0af2e694827a9460
2024-08-08 19:44:49 -07:00