Commit Graph

38536 Commits

Author SHA1 Message Date
Sam Zhou 28c375fb53 Make use of ref-as-prop support in Switch (#51353)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51353

Make use of the React 19 feature so that we can remove the remaining `forwardRef` in react native.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D74809899

fbshipit-source-id: aaa4ef65ea4d4a20c9d9315ae95957e67484c2d8
2025-05-15 08:24:58 -07:00
Sam Zhou 83401b5d44 Make use of ref-as-prop support in Button (#51354)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51354

Make use of the React 19 feature so that we can remove the remaining `forwardRef` in react native.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D74808349

fbshipit-source-id: a359278b5d516eb04fc88ea14c21b628f1053fec
2025-05-15 08:18:30 -07:00
Riccardo Cipolleschi 84c5f294e5 Fix Maestro E2E Tests (#51347)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51347

The new warnings on RNTester for the imports are covering the New Architecture list item, as you can see from the video.

This prevents maestro from clicking on the list item, and therefore the test fails.

{F1977997600}

## Changelog:
[Internal] - Fix E2E Tests

Reviewed By: cortinico

Differential Revision: D74803709

fbshipit-source-id: 747af57d04c96ba9b0ee642eb70ebf84bca3a3fa
2025-05-15 08:15:26 -07:00
Sam Zhou 34c9612f93 Make use of ref-as-prop support in DebuggingOverlay (#51352)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51352

Make use of the React 19 feature so that we can remove the remaining `forwardRef` in react native.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D74808254

fbshipit-source-id: 2f5f8d8dbe1bd5fcaba179bea5deed1592dc900c
2025-05-15 08:07:21 -07:00
Rubén Norte ca764bb511 Fix Fantom tests to avoid logging errors to test output (#51346)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51346

Changelog: [internal]

I saw that this test was logging errors to the console, which is considered a bad practice in Jest tests.

This prevents the logs from being printed in the test output and also adds assertions to verify what should be logged.

Reviewed By: rshest

Differential Revision: D74803463

fbshipit-source-id: 9c840a51e0e616a6bb15b7a40b3a6937fcb88b64
2025-05-15 05:27:02 -07:00
Chi Tsai bf26cf9c31 Add Hermes Root API in all other versions of Hermes (#51082)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51082

Introduces the `IHermesRootAPI` interface and a class implementation.
This root API will contain the previously static methods on
`HermesRuntime`.

The root API will serve as an entry point for users to create the Hermes
runtime and invoke methods that do not necessarily require a runtime.

Diff also moves all usages of the static methods on `HermesRuntime` to
getting the methods from the root API.

Multiple places are depending on Hermes, Hermes snapshot, and Shermes,
so this diff will also update all of these verions of Hermes at once.

Changelog: [Internal]

Reviewed By: neildhar

Differential Revision: D71132855

fbshipit-source-id: fddda83517682779b4aef062efe84e29fd027fae
2025-05-14 17:14:47 -07:00
Nick Gerleman 0455f8ff53 Use PreparedLayoutTextViewManager when Enabled by Gating (#51182)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51182

Wires up the logic to use Facsimile View Manager when flags for prepared layout enabled.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D73161911

fbshipit-source-id: dc8824ecf8a712d5ff52cb8e2d63e85646297d40
2025-05-14 16:10:08 -07:00
Nick Gerleman 9394813689 Update PreparedLayoutTextView for new state type (#51301)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51301

The type of the state we pass has changed, since the original prototype. Need to update the Java side to reflect this.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D74417253

fbshipit-source-id: 9159689e07d6f00504b5116a647c7afdf79005f4
2025-05-14 16:10:08 -07:00
Nick Gerleman 729b5ae7d9 Send prepared layouts in Android ParagraphState updates (#51184)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51184

This change adds prepared layouts to `ParagraphState` on Android, for us to send to the client when gating is enabled

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D74356128

fbshipit-source-id: bd1dd5a457869075c561173de398ae1954a20ab5
2025-05-14 16:10:08 -07:00
Nick Gerleman 88de631d05 RN_SERIALIZABLE_STATE (#51185)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51185

Was running into issues with split Android ParagraphState, because a lot of code is tied to `#ifdef ANDROID`, which also builds for react-native-cxx.

This does that spliitting, and also introduces `RN_SERIALIZABLE_STATE` to replace previous ANDROID checks related to state serialization, so we can cofine that to just the Android platform. These changes are dependent on each other.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D74374376

fbshipit-source-id: ffb246ea2e16773f85de12209f2d88a95f8bb792
2025-05-14 16:10:08 -07:00
Nick Lefever 09832198cc Add role and screenReaderFocusable to prop diffing for View component (#51332)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51332

See title

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D74747715

fbshipit-source-id: dc0380b0402d6023971a902f22d44b87bad0edde
2025-05-14 15:43:33 -07:00
Nick Lefever b6d7451291 Add missing borderEndColor prop diffing for View component (#51331)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51331

See title

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D74744566

fbshipit-source-id: dc70310e47dfd5e29070519fa29b7af7ce6ffeab
2025-05-14 15:43:33 -07:00
Nick Lefever c301a25251 Add hitSlop prop diffing to View component (#51329)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51329

See title

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D74741639

fbshipit-source-id: da7317c8800d2f25c69ecd7d3aca9b75350c2a56
2025-05-14 15:43:33 -07:00
Nick Lefever 07c64ba341 Add mixBlendMode prop diffing to View component (#51326)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51326

See title

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D74739648

fbshipit-source-id: 3123f001cf7520d39bc3e92cee79b1baa17bd7cf
2025-05-14 15:43:33 -07:00
Nick Lefever d4ee62793d Add filter prop diffing to View component (#51325)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51325

See title

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D74738361

fbshipit-source-id: 71c704b1a977327c05d06e48f5572753c2847b38
2025-05-14 14:33:53 -07:00
Nick Lefever 37ad315ebc Add outline prop diffing to View component (#51321)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51321

See title

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D74734893

fbshipit-source-id: f9b96c7bbfc791fa601dd8e4d8c1a4a27b94e36c
2025-05-14 14:33:53 -07:00
Joe Vilches 14e53e4845 Allow links in facsimile to be keyboard focusable (#51305)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51305

tsia, there is a lot of TextView specific API calls and instance checks in the delegate that need to be modified. Additionally, facsimile has some custom focusing logic we do not need if we have a delegate

I opted to just do a lot of instance specific logic using `is` . That seems easier for the time being with this text view that should replace our other text view over time.

I also expose a new way of focusing a span on facsimile, which may not be the best way to do that, lmk

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D74104419

fbshipit-source-id: 87c2259bb1698d93afad88ed91cb6322b90714f0
2025-05-14 14:24:21 -07:00
Ramanpreet Nara 99505e0c74 RuntimeExecutor: Make executeSynchronouslyOnSameThread_CAN_DEADLOCK more readable (#51324)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51324

This diff just renames the mutexes, so that the method is more understandable.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D74692506

fbshipit-source-id: 3e928ee0465ebed90f9c95ba3eaf28ea148b0e60
2025-05-14 14:22:59 -07:00
Chi Tsai 6766cf6285 Used shared_ptr<Runtime> in jsi testlib (#51081)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51081

After introducing the interfaces, runtime should be managed through a
shared pointer instead of a unique pointer.

This diff will change the usage in JSI testlib. Later diffs will
actually change the HermesRuntime usages.

Changelog: [Internal]

Reviewed By: lavenzg

Differential Revision: D70113190

fbshipit-source-id: ea831dd8f79750851fd626afe0f1f5550142ac05
2025-05-14 13:44:49 -07:00
Chi Tsai f7f60dc794 Add castInterface API in JSI (#49604)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49604

Add JSI castInterface API. This provides a structured way to provide
optional APIs that may or may not be supported in all engines.

Every interface will have its own set of APIs. For instance, Hermes
will provide an interface (`IHermes`) containing Hermes-specific
APIs. In the future, an interface may be created to expose optional
APIs.

A runtime will inherit the interfaces of which the APIs are supported by
the runtime. Users who want to access a specific API may call
castInterface with the UUID of interface containing the API.

For backwards compatibility, the current `jsi::Runtime` will remain as
an object, and its functionalities will not be described by an
interface. However, this may be revisited later.

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D68964360

fbshipit-source-id: 3efe61c5bc1a0fa113a192f4abad6d0f135b4301
2025-05-14 13:44:49 -07:00
Ramanpreet Nara e275da45ea Migrate surface view off RCTSurface (#51328)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51328

RCTSurface is a legacy class. We might be able to kill it off.

Let's decouple RCTSurfaceView from RCTSurface.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D72582309

fbshipit-source-id: 0ffb6c2d08c5ee1eda6ae90955ccbc14f57036b7
2025-05-14 13:10:41 -07:00
Ramanpreet Nara 70eeb9f541 Migrate display link off RCTModuleData (#51327)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51327

RCTModuleData is a legacy class. We might be able to kill it off.

Let's deocuple bridgeless from RCTModuleData.

Changelog: [ios][Breaking] - Migrate RCTDisplayLink's API from RCTModuleData

Reviewed By: cipolleschi

Differential Revision: D72582306

fbshipit-source-id: 3e06f8b2036e1f65425c8312644cc92c076e958e
2025-05-14 13:10:41 -07:00
Nick Gerleman 2fe6c1a947 Include fallback line spacing in BoringLayout Metrics (#51304)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51304

A potential source of truncation we previously experienced with D65171352 is difference in how TextView calculates line spacing with StaticLayout.

As of Android 13, this also appies to how TextView creates the metrics of BoringLayout. Oddly, this is not also applied to `BoringLayout.make()` (I think it ends up only impacting metrics), so we don't pass the flag there. See https://cs.android.com/android/_/android/platform/frameworks/base/+/78c774defb238c05c42b34a12b6b3b0c64844ed7

This could cause some theoretical truncation of simple single line text, so let's match TextView expectations.

Changelog:
[Android][Fixed] - Include fallback line spacing in BoringLayout

Reviewed By: javache, joevilches

Differential Revision: D74694483

fbshipit-source-id: 76dd980b827824f19ac755b3a9a1ec8912cd6ff1
2025-05-14 12:03:44 -07:00
Ruslan Lesiutin 3148f0fb2b Deduplicate strings and provide std::string_view (#51098)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51098

# Changelog: [Internal]

Depending on the sampling rate, there could be lots of samples recorded. Right now, React Native requests the rate to be 10kHz. In reality, Hermes will be slower. How exactly slower will depend on the platform, because sampling profiler implementation is platform-specific. Windows peaks at ~500Hz, whereas iOS and Android that are using signals can reach up to 5kHz, based on my observations. This means that we could record sample approximately every 0.5ms.

For 30 seconds of sampling, we can get around 150k samples, every one of which may have up to 500 call frames (it is a custom limitation on Hermes side). Previously, every call frame could have a unique copy of function name string and url string.

This diff changes the approach to deduplicate strings, keeping a single copy for every unique string. A new abstraction `StringEntry` is added that will keep a const pointer to the string storage and an offset to the entry in this storage.

On React Native side, we are going to re-use these `std::string_view` and keep Hermes' `Profile` alive as long as they are used. We are going to achieve this by keeping unique pointer to the Hermes' `Profile` in React Native's Profile abstraction - `RuntimeSamplingProfile`, which is agnostic to the runtime.

Reviewed By: fbmal7

Differential Revision: D73106068

fbshipit-source-id: bdc7026e19c2677e39e20f14c8532080c5842026
2025-05-14 11:34:14 -07:00
Zeya Peng 2d7342f8b4 Remove native animation fabric sync in JS and infinite animation loop workaround (#51264)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51264

## Changelog:

[General] [Changed] - Remove native animation fabric sync in JS and infinite animation loop workaround, when cxxNativeAnimated is enabled

when cxxNativeAnimated is enabled, we'll sync native animation props back to Fabric in native, when that happens we can remove the code in JS for same purpose

Reviewed By: lenaic

Differential Revision: D74198568

fbshipit-source-id: 5b313a5e8c07058f939134e9a6d60dcfa3b45842
2025-05-14 11:31:11 -07:00
Nick Lefever 109fe1394a Add missing view events to View prop diffing (#51318)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51318

Adding parsing and diffing for
- `onClickCapture`
- `onPointerOutCapture`
- `onPointerOverCapture`

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D74732872

fbshipit-source-id: 458f476f645970e2bee608e020b63c14e7affafe
2025-05-14 10:25:28 -07:00
Nick Lefever 85994c9f62 Add boxShadow prop diffing to View component (#51314)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51314

See title

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D74726605

fbshipit-source-id: 4a26d05af51a7d77f3aade9fbea3dff47b2ea4ed
2025-05-14 10:25:28 -07:00
Riccardo Cipolleschi 8d634267f8 Add E2E test for FabricInteropLayer (#51269)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51269

This adds an E2E Tests for the fabric interop layer in RNTester, so we can make sure that we don't break the mechanism to add children after the view is rendered

## Changelog:
[Internal] - Add E2E test for FabricInteropLayer

Reviewed By: sammy-SC

Differential Revision: D74590458

fbshipit-source-id: 9483d1ac648d923a8494d6402b9b2f971b9b2547
2025-05-14 10:11:03 -07:00
Christian Falch d53a60dd23 fix adding children (#51213)
Summary:
See https://github.com/facebook/react-native/issues/51212 - children aren't updated correctly in an old arch native view using the interop layer under Fabric.

This is caused by the mountChildComponentView method not updating the view, only adding the new view to a list that will be used on the next update to mount the child.

This commit fixes this by adding the same pattern as in unmountChildComponentView where children are inserted directly if the underlying paperview is available in the adapter - otherwise it uses the mounting list as before.

#Closes 51212

bypass-github-export-checks

## Changelog:

[IOS] [FIXED] - fixed adding child views to a native view using the interop layer

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

Test Plan:
**Previous output**:

<image src="https://github.com/user-attachments/assets/472b95e7-0921-46c9-be6a-f31759c0cd26" width="200px" />

**After fix**:

<image src="https://github.com/user-attachments/assets/554387cd-c264-483e-9c52-d9cd40b42601" width="200px" />

Reviewed By: sammy-SC

Differential Revision: D74471278

Pulled By: cipolleschi

fbshipit-source-id: 798f9e7be389359bd6e3aa1b6a6e9fb799fcb369
2025-05-14 10:11:03 -07:00
Riccardo Cipolleschi e9c8fee4ef Add Example for InteropLayer on RNTester (#51260)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51260

This is a preparatory change that adds an example to RNTester for the Fabric interop layer on iOS.
This example is needed to create a Jest E2E tests that will make sure that the Fabric Interop Layer can properly add views as subviews.

We discovered the bug thanks to react-native-maps.

## Changelog:
[Internal] - Add Example for the Fabric Interop Layer to RNTester iOS

Reviewed By: cortinico

Differential Revision: D74579737

fbshipit-source-id: 0c1bbb06790b01313cd98aa4b7152d8aba0cded3
2025-05-14 10:11:03 -07:00
Vitali Zaidman 337ae3bacb improve the message displayed when opening devtools while bundle builds (#51315)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51315

Changelog: [General][Internal] improve the message displayed when opening devtools while bundle builds

Reviewed By: motiz88

Differential Revision: D74718454

fbshipit-source-id: 8b0cc9ca08dc98d766ddd5a3685d60b5d2800119
2025-05-14 09:11:34 -07:00
Pieter De Baets 039a333df5 Remove any props set by default on View (#51225)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51225

We process a number of props by default in View, so we can provide some amount of compatibility with web API's. The way we then pass these to React means we end up setting a number of props with 'undefined' values. These props need to be diffed, sent to native (so string keys copied via JSI) and serialized to folly::dynamic (on Android) which is just wasteful.

Instead we can mutate the destructured props object and update/insert keys only as necessary to reduce the props payload size.

Changelog: [General][Breaking] View no longer sets any default accessibility props, which should not result in visible changes in behaviour but may affect snapshot tests.

Reviewed By: yungsters

Differential Revision: D74472767

fbshipit-source-id: 462a4495c0672d4bf1752a532acff49b14598e8e
2025-05-14 09:02:00 -07:00
Jakub Piasecki ee9bd851ac Add a custom Jest resolver to opt out from handling "exports" in tests (#51307)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51307

D72228547 added the `exports` field to the main `react-native` package, in which all imports from `./src/*` are explicitly disallowed. This was expected to be a breaking change and to limit the surface area of it, this diff will allow using all imports in jest tests.

Changelog: [General][Added] Added a custom Jest resolver to opt out from handling "exports" in tests

Reviewed By: huntie

Differential Revision: D74708701

fbshipit-source-id: 9a2714f4e6f78ffbad9e56b5bb92657c9ea908ef
2025-05-14 08:01:15 -07:00
Dawid Małecki 4d0f2b2ca7 Align ImageStyle overflow prop type and compose function type (#51285)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51285

The `composeStyles` function should correctly determine the type of the input styles (`ViewStyle`, `ImageStyle`, `TextStyle`) base on the output type:

```ts
const combinedStyle8: StyleProp<ImageStyle> = StyleSheet.compose(
  // ts-expect-error
  composeTextStyle,
  composeTextStyle,
);
```

This diff adds generic type checking for `compose` function and fixes `ImageStyle` overflow prop type which accepted `scroll` property (which wasn't previously accepted in manual types) and which enables type system to distinguish `ImageStyle` from `ViewStyle` and `TextStyle`:

previous:
```ts
overflow?: 'visible' | 'hidden' | 'scroll'
```

current:
```t
overflow?: 'visible' | 'hidden'
```

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D74574293

fbshipit-source-id: 751a44f2d3cd43055d93031343995f16ef87b185
2025-05-14 07:44:05 -07:00
Vitali Zaidman b817b1a75b Update debugger-frontend from 3d17e0f...f5506e6 (#51316)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51316

Changelog: [Internal] - Update `react-native/debugger-frontend` from 3d17e0f...f5506e6

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebook/react-native-devtools-frontend/compare/3d17e0fd462dc698db34586697cce2371b25e0d3...f5506e62112464952f4ca3f19878a18cdebc7d77).

Reviewed By: motiz88

Differential Revision: D74727700

fbshipit-source-id: b0923b7fd1a7c1d721b9b4322270507c07fcedaf
2025-05-14 07:23:45 -07:00
Vitali Zaidman 46f91fd34d Improved the description of the error shown when a previous debugger is closed when a new one is opened (#51296)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51296

Changelog: [General][Internal] Improved the description of the error shown when a previous debugger is closed when a new one is opened

Corresponding DevTools PR:
https://github.com/facebook/react-native-devtools-frontend/pull/162

Reviewed By: hoxyq

Differential Revision: D74657572

fbshipit-source-id: fa601aab22099bbf957e5e66420f94752f03b6f3
2025-05-14 07:23:45 -07:00
Nick Lefever 169525d33b Fix nativeID and testID prop diffing for View component (#51312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51312

The nativeID and testID prop mapping on the native Java side use full caps `ID` in the setter mapping. Fixing the props diffing result to use the right key in the result for both.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D74724759

fbshipit-source-id: 4291a72cd3081981f4a25f16f8f2bef17230da54
2025-05-14 06:02:37 -07:00
Samuel Susla 4c0607ee36 add test for ViewCulling when sibling in FLatList resizes (#51311)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51311

changelog: [internal]

add a test case for view culling to cover a crash observed in production.

Reviewed By: lenaic, rubennorte

Differential Revision: D74720814

fbshipit-source-id: ed1246ccbaa0d0ab51a6073f20642c1c78872f30
2025-05-14 05:38:49 -07:00
Rubén Norte 7776122e2e Move playground tests to their own directory (#51310)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51310

Changelog: [internal]

Just a bit of separation between these and Fantom own tests.

Reviewed By: lenaic

Differential Revision: D74717487

fbshipit-source-id: f9d8667c823fcda7b1f3222803367c6b15d9309d
2025-05-14 04:01:31 -07:00
Ritesh Shukla 68d6ada448 Fixed borderBottomEndRadius on RTL (#51229)
Summary:
Fixes https://github.com/facebook/react-native/issues/51193
## Changelog:
[ANDROID][FIXED] Wrong borderBottomEndRadius on RTL

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

Test Plan:
Tested with Arabic (RTL) and English(LTR)

English
<img src="https://github.com/user-attachments/assets/5bd1eca9-194c-4d83-b75f-689bc13d827b" width=200>

Arabic
<img src="https://github.com/user-attachments/assets/459320a0-6bb2-4585-97bb-bd4ded6ec399" width=200>

Reviewed By: cortinico

Differential Revision: D74709219

Pulled By: NickGerleman

fbshipit-source-id: 885bb84d97d73324983d044fd2874a457b40f646
2025-05-14 03:54:04 -07:00
meg 777397667c fix issue #51297 which addresses allWarningsAsErrors type error (#51300)
Summary:
Resolved a build error [issue https://github.com/facebook/react-native/issues/51297](https://github.com/facebook/react-native/issues/51297) caused by assigning a Boolean to a Property<Boolean>.
Switched from direct assignment to using .set(...) to correctly configure allWarningsAsErrors from project properties.

## Changelog:

- Gradle fix: assign allWarningsAsErrors using .set() for Property<Boolean>

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - [ANDROID] [FIXED]

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

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

Test Plan:
Fixes build failure with React Native v0.79.2 and Gradle v8.0.
```
npm run start
npm run android
```
no more build errors

Reviewed By: cortinico

Differential Revision: D74706741

Pulled By: rshest

fbshipit-source-id: 31ec923f49a6da63fb5abb464bc38b99b1e8650a
2025-05-14 02:54:02 -07:00
Nick Gerleman 7f8b6566c4 Resubmit: Ensure that ShadowNode measure functions respect constraints (#51299)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51299

## Resubmit

This change was backed out, due to the WinUI Fabric TextLayoutManager not respecting minimum size constraints, causing early debug assert. D74494087 was confirmed to fix this.

For more safety, we limit fatal debug assertsions to `ParagraphShadowNode`, and only log a native error for other ShadowNodes.

## Original

Android's TextLayoutManager may return widths greather than the max measure constraint.

Yoga will clamp these, but this sort of issue points to a logic bug, and creates issues when we are looking at caching text measurements based on constraint reuse.

Let's debug assert that we don't do that, and fix a case of rounding up at a pixel boundary, to ensure that it doesn't go above max width. This should theoretically be safe, since Yoga is already doing this clamping, which is what dictates final size of the TextView.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D74674460

fbshipit-source-id: 807d6629bb799a3b1a55e378a3243065055ce219
2025-05-13 19:49:20 -07:00
Nick Gerleman 1fe3ff86c3 Fix more text rounding bugs (#51303)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51303

We do a lot of incorrect `cei()` in text measurement, compensated later by other incorrect bits.

There are a couple of interesting bits here:

A "desired width" is how large a hypothetical text layout would like to be. It is a floating point value, and to avoid truncation, a container must be larger than the desired width. So ceiling this is correct.

We are also passed available width, which may be an exact specification, not at a subpixel boundary. Ceiling this is totally incorrect, since Yoga will disregard our ceiled version, and we just created a layout, larger than our actual measure will be.

We must instead floor `availableWidth`, and we create our layout based off of that, to not give an extra physical pixel, that may not be given to us, if later layout rounding doesn't go our way. We then ceil `desiredWidth` earlier.

Finally, when we have an exact measuremode, we create the layout so that it uses guaranteedWidth`, but act as if it takes the full available space, per-contract, which may be a subpixel size larger. This means we cannot create layouts which cause truncation.

I used this change as an opportunity to clean up `createLayout()`, since we are gating anyways, to remove the duplicated paths, and to avoid the unnecessary `TextDirectionHeuristic` work for BoringLayout case, and since `StaticLayoutBuilder` already defaults to the heuristic we are manually setting.

Changelog:
[Android][Fixed] - Fix more text rounding bugs

Reviewed By: joevilches

Differential Revision: D74685353

fbshipit-source-id: 3700df657958c6efb46bfbbe674051d16a2b7c26
2025-05-13 19:49:20 -07:00
Nick Gerleman 3391959fd8 Resubmit: Expose Unsnapped Dimensions (#51298)
Summary:
X-link: https://github.com/facebook/yoga/pull/1811

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

## Resubmit

This was backed out due to being up the stack from another change that was backed out, but should be safe by itself.

## Original

We want to know if an artifact created during measurement can fully be reused after final layout, but the final layout is allowed to be slightly larger due to pixel grid rounding (while still allowing reuse). It's hard to tell after the fact, whether it is larger because of this rounding (though the measure is used), or if it may be a pixel larger for valid reasons.

We can expose the unsnapped dimensions of a node to give us this information, and to correlate measurement artifacts.

This is most of the time the same as the layout's measured dimension, though I don't think it's safe to use this, since anything else measuring the node after could clobber this (I think `YGNodeLayoutGetOverflow` may also be prone to this as a bug).

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D74673119

fbshipit-source-id: 06d2eb21e28b76458ec88f4dfcaec809707d0390
2025-05-13 18:21:04 -07:00
Joe Vilches 79c47987b7 Fix issue where text inputs cannot blur on <= Android 8.1 (#51302)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51302

We got https://github.com/facebook/react-native/issues/51072#issue-3035616801 which demonstrates that if we have 2 text inputs on a screen we cannot blur them. If you try to blur any, focus jumps to the first one.

This seems to be a bug with Android's `clearFocus` per https://developer.android.com/reference/android/view/View#clearFocus(), this behavior is intended when we are not in touch mode, yet it happens regardless of what mode we are in on this version.

I modified this a bit to swallow `requestFocus` calls if we are in touch mode. This should be fine as no JS focus calls will go through this path. On hardware keyboard focus and focus from `clearFocus`

Changelog: [Android] [Fixed] - Fix bug where focus would jump to top text input upon clearing a separate text input.

Reviewed By: mlord93

Differential Revision: D74678847

fbshipit-source-id: 12dcaf0c9c350d3ed697ff81e8dfb205b7942119
2025-05-13 17:56:46 -07:00
Rubén Norte 5dd489190c Handle platform objects in structuredClone (#51257)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51257

Changelog: [internal]

Fixes the semantics for `structruredClone` when dealing with platform objects (cloning the supported ones and throwing exceptions for the rest).

Reviewed By: hoxyq

Differential Revision: D74574857

fbshipit-source-id: 71b99e9659cf3fb4bed8f431e9b54d2f9f514706
2025-05-13 14:29:01 -07:00
Rubén Norte 6454d2f0db Introduce concept of platform objects and serialization (#51256)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51256

Changelog: [internal]

This is just in preparation for `structuredClone` handling the cloning (or not) of platform objects correctly.

It marks all existing Web platform objects in RN as such, and defines the clone method for `DOMRectReadOnly`, `DOMRect` and `DOMException`.

Reviewed By: hoxyq

Differential Revision: D74574856

fbshipit-source-id: 9e9647fcaafcc1d32fb36e5ee40167871572c544
2025-05-13 14:29:01 -07:00
Rubén Norte 1bb8546698 Introduce better mechanism for non-serializable built-ins in structuredClone (#51255)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51255

Changelog: [internal]

Just a small refactor of how we handle non-serializable built-ins in structuredClone

Reviewed By: hoxyq

Differential Revision: D74398113

fbshipit-source-id: 26211920fcd4cf11c5da278e213eaa2b6b9aa1b5
2025-05-13 14:29:01 -07:00
Rubén Norte caaa5c93fb Optimize structuredClone (#51250)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51250

Changelog: [internal]

Optimizes the implementation of `structuredClone`.

Before:
| (index) | Task name                | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | ------------------------ | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'clone a string'         | '955.81 ± 1.45%'     | '902.00'            | '1095925 ± 0.01%'          | '1108647'                 | 1046239 |
| 1       | 'clone a basic array'    | '7684.79 ± 0.76%'    | '7542.00'           | '131980 ± 0.02%'           | '132591'                  | 130128  |
| 2       | 'clone a basic object'   | '6286.35 ± 0.53%'    | '6179.00'           | '161179 ± 0.02%'           | '161838'                  | 159075  |
| 3       | 'clone a complex object' | '22446.96 ± 0.32%'   | '22223.00'          | '44819 ± 0.03%'            | '44998'                   | 44550   |

After:

| (index) | Task name                | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | ------------------------ | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'clone a string'         | '793.81 ± 0.09%'     | '781.00'            | '1270316 ± 0.01%'          | '1280410'                 | 1259755 |
| 1       | 'clone a basic array'    | '5079.81 ± 2.13%'    | '4798.00'           | '206235 ± 0.03%'           | '208420'                  | 196858  |
| 2       | 'clone a basic object'   | '3823.37 ± 1.60%'    | '3636.00'           | '271030 ± 0.03%'           | '275028'                  | 261550  |
| 3       | 'clone a complex object' | '13095.13 ± 2.04%'   | '12499.00'          | '79701 ± 0.03%'            | '80006'                   | 76365   |

Reviewed By: hoxyq

Differential Revision: D74576514

fbshipit-source-id: f452dcfca6398dbfa40c5a41b77b0157777fa59b
2025-05-13 14:29:01 -07:00
Rubén Norte f7327bddb5 Add benchmark for structuredClone (#51249)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51249

Changelog: [internal]

This adds a basic benchmark for `structuredClone`, so we can optimize it in the following diff.

Baseline:

| (index) | Task name                | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | ------------------------ | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'clone a string'         | '955.81 ± 1.45%'     | '902.00'            | '1095925 ± 0.01%'          | '1108647'                 | 1046239 |
| 1       | 'clone a basic array'    | '7684.79 ± 0.76%'    | '7542.00'           | '131980 ± 0.02%'           | '132591'                  | 130128  |
| 2       | 'clone a basic object'   | '6286.35 ± 0.53%'    | '6179.00'           | '161179 ± 0.02%'           | '161838'                  | 159075  |
| 3       | 'clone a complex object' | '22446.96 ± 0.32%'   | '22223.00'          | '44819 ± 0.03%'            | '44998'                   | 44550   |

Reviewed By: hoxyq

Differential Revision: D71407319

fbshipit-source-id: ee1c89d6ba3fd2484b2f4115cc58dc4b08e04fa7
2025-05-13 14:29:01 -07:00