Commit Graph

38536 Commits

Author SHA1 Message Date
Thomas Nardone f15fe4b8a1 Convert WebSocketModule to Kotlin (#47491)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47491

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D65502519

fbshipit-source-id: fa75416a27f809701837e8e1b96d7fe3a1ea040a
2024-12-06 09:22:30 -08:00
Kræn Hansen acecf99c38 Update build-hermes-xcode.sh to fail faster (#47894)
Summary:
While debugging an error building hermes from source in a React Native app, I kept getting this weird error:

> Building for 'iOS-simulator', but linking in dylib ({redacted}/ios/Pods/hermes-engine/destroot/Library/Frameworks/ios/hermes.framework/hermes) built for 'macOS'

The root cause was a call to `cmake` failing, but `/sdks/hermes-engine/utils/build-hermes-xcode.sh` didn't exit on the error and instead continued building the hermes.framework from the dummy frameworks created by `./sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh`.

I suggest fixing this by introducing a `set -e` call similar to that used in `build-hermesc-xcode.sh`:
https://github.com/facebook/react-native/blob/2f523f0acf3b589bf962d5d20d2c04e453baf1da/packages/react-native/sdks/hermes-engine/utils/build-hermesc-xcode.sh#L7

## Changelog:

[Internal] - Ensure building hermes from source exits early on failures

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

Test Plan:
I followed https://github.com/facebook/hermes/blob/main/doc/ReactNativeIntegration.md getting to a state of building a React Native app with Hermes built from source. I then introduced an error in `hermes/API/hermes/hermes.cpp` (I simply typed `asd` in the top of the file) and built the app from Xcode:

![Screenshot 2024-11-22 at 15 13 04](https://github.com/user-attachments/assets/c8c4a1e2-3bf1-4d08-b9f9-583dba3df159)

If you scroll up, you can see the failed cmake build, but it just continues trying to build the framework, effectively hiding the error:

![Screenshot 2024-11-22 at 15 14 19](https://github.com/user-attachments/assets/3accf7b1-1667-42fc-b9c0-01fd9b1c2d8f)

When applying this patch and cleaning the build folder, the error is more prominent and actionable:

![Screenshot 2024-11-22 at 15 18 27](https://github.com/user-attachments/assets/f01afd6c-c1bb-4e87-9d28-dcdea41feb3e)

Reviewed By: andrewdacenko

Differential Revision: D66494603

Pulled By: dmytrorykun

fbshipit-source-id: dbeeba17b4cc1101001c9628914135bea6006d4a
2024-12-06 09:08:58 -08:00
Blake Friedman ae775aff5d Danger shouldn't warn for package.json changes (#48148)
Summary:
Someone always has to merge in from Meta, so this is just noise.
Refactored some of this older code.

Changelog: [Internal]

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

Test Plan:
This PR, but this doesn't build a lot of confidence:

 {F1973526183}

Reviewed By: rubennorte

Differential Revision: D66876722

Pulled By: blakef

fbshipit-source-id: 52e1f15577f8f057ceee9427af65df43f152bffa
2024-12-06 08:48:55 -08:00
Rubén Norte c54ba09d2e Add package.json script to run Fantom tests (#48144)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48144

Changelog: [internal]

Adds package.json script to run Fantom tests:

```
yarn fantom
```

NOTE: At the moment, this only works on Meta's infra. We're working on making this available in OSS/Github CI.

Reviewed By: javache

Differential Revision: D66874962

fbshipit-source-id: d9746428b618a31ce0bf96c3233828cdba501dd6
2024-12-06 05:24:31 -08:00
Rubén Norte 81fbd18410 Move remaining Fantom files to react-native-fantom (#48143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48143

Changelog: [internal]

Just a small cleanup to move `jest/integration/*` to `packages/react-native-fantom`, so everything related to Fantom (config, runner, runtime, etc.) is in the same directory.

Reviewed By: javache

Differential Revision: D66874763

fbshipit-source-id: 8b87d7320c7704f7ce6cd58761508193784f5ce2
2024-12-06 05:24:31 -08:00
Rubén Norte 923b194e47 Rename ReactNativeTester as just Fantom (#48142)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48142

Changelog: [internal]

This is the default export from the `react-native/fantom` package and it makes sense to be called that way. Also, this is similar to the `jest` global.

Reviewed By: javache

Differential Revision: D66874225

fbshipit-source-id: 8b43a637ebb42b5b1acb9ea5a6dbedd4c1a4f9e0
2024-12-06 05:24:31 -08:00
Rubén Norte 3fafc9f9cf Rename FantomRenderedOutput as getFantomRenderedOutput to follow convention (#48141)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48141

Changelog: [internal]

This just aligns the file name with the common convention to name modules with the same name as their default export (if any).

Reviewed By: javache

Differential Revision: D66874227

fbshipit-source-id: 2a619b434c26a29f1774cba1c32ba711b1a7af46
2024-12-06 05:24:31 -08:00
Rubén Norte ba8d184b77 Move render output tests to ReactNativeTester (#48140)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48140

Changelog: [internal]

These tests test an API that's part of `ReactNativeTester` (will be renamed as `Fantom`) so it makes sense that they're in the same test file as the tests for the rest of the API.

Reviewed By: javache

Differential Revision: D66874226

fbshipit-source-id: f17e14c83cb5ca95ac619c5398c49ad84a27cfa5
2024-12-06 05:24:31 -08:00
Rubén Norte b253b0fe94 Create @react-native/fantom package (#48125)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48125

Changelog: [internal]

This just moves the runtime modules for Fantom to its own package.

Reviewed By: javache

Differential Revision: D66825478

fbshipit-source-id: ac4dbc23b86895f09abc46345d497c1c53737ae2
2024-12-06 05:24:31 -08:00
Riccardo Cipolleschi 8d3c9ec3a1 Exclude mapping generation of core component (#48145)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48145

While writing the docs for 0.77, I found an edge case in the generation of the RCTThirdPartyComponentProvider:
* If the app has the `codegenConfig` field set in the `package.json`
* And it does not have the `ios.componentProvider` field is not provided

Codegen was generating the mapping for the react-native core components. That's not expected as, in that case, it should only generate components that are declared in the app or in libraries.

This change fixes this edge case.

## Changelog:
[Internal] - Exclude mapping generation of core component

Reviewed By: blakef

Differential Revision: D66875080

fbshipit-source-id: 65fe10381729ec7808efec70feacf2a55f0056e9
2024-12-06 05:05:48 -08:00
hyochan 3efbe33ce0 Add pointerEvents support to Text component (#48081)
Summary:
This PR adds `pointerEvents` to the `TextProps` type.

### Motivation:
The `pointerEvents` property is already supported in `Text` components internally, but it was missing from the TypeScript definitions. By adding it to `TextProps`, developers can now use this property with full type safety and without TypeScript errors.

This is a type-only change and does not introduce any functional modifications.

## Changelog:

[GENERAL] [ADDED] - Added `pointerEvents` to `TextProps` type.

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

Test Plan:
As this is a type-only update:
- Verified that the `pointerEvents` property is now recognized when used with `Text` components in TypeScript projects.
- Ensured there are no runtime changes or regressions by testing existing `Text` components for expected behavior.

Reviewed By: cipolleschi

Differential Revision: D66753454

Pulled By: javache

fbshipit-source-id: c8f21b11daa6001a309b1d29fd6259101d11f5d2
2024-12-06 03:56:14 -08:00
Pieter De Baets 4134b1c60d Pass around parentTag instead of parentShadowView (#48062)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48062

We never need the full ShadowView representation of `parent` and this is significantly cheaper to construct and pass around.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D66656411

fbshipit-source-id: 0b20e04c6beb95c498350085ec06fd57d1c11237
2024-12-06 03:31:04 -08:00
Zeya Peng 87ec0965a2 Allow setting debugID on AnimatedValue and TimingAnimation (#48106)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48106

This could make it easier to locate and debug AnimatedValue and driver from native - so far on the native side of animated, the only way to identify an Animation driver or AnimatedNode is integer IDs and the type, which made it difficult to debug when surface gets complicated

Here I only enabled it for AnimatedValue and TimingAnimation, because
* TimingAnimation is most commonly used
* all the animation drivers (frames, spring, decay) can only drive Value type of AnimatedNode on the native side, so it's the primitive component of AnimatedNode

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D66790298

fbshipit-source-id: ddd64a5728120f061aa902f25c93b1701617031b
2024-12-06 02:40:30 -08:00
Chi Tsai c6f12254d1 Add default getStringData/getPropNameIdData implementation (#47530)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47530

Adds the default implementation for `getStringData`/`getPropNameIdData`
for VMs that do not provide their own implementation

Changelog: [Internal]

Reviewed By: neildhar

Differential Revision: D65638889

fbshipit-source-id: 0a97569433c09ffafbd08fec5d9c9fbf5639b778
2024-12-06 01:35:18 -08:00
Christoph Purrer e9f279117e Allow to provide a custom ImageManager for cxx platform (#48109)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48109

[Changelog] [Internal] -  Allow to provide a custom ImageManager for cxx platform

This change allows target platforms to pass a platform specific or app specific ImageManager implementation

Reviewed By: javache

Differential Revision: D66788794

fbshipit-source-id: d7e99cae5de0a4c60047763dce368271dd191b9c
2024-12-05 19:00:39 -08:00
Rubén Norte 7a81fd7a8a Migrate all feature flags to pragmas (#48098)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48098

Changelog: [internal]

TSIA. No more manual feature flag overrides in Fantom tests :D

Reviewed By: sammy-SC

Differential Revision: D66760120

fbshipit-source-id: a0493d6ca57f4fdad33a0667e3af99ed0f0b66ca
2024-12-05 17:06:11 -08:00
Rubén Norte be9b076087 Add support for specifying feature flags in pragmas (#48097)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48097

Changelog: [internal]

As per title, this allows us to specify both common and JS-only feature flags for tests in the docblock as pragmas (in the same pragma separated by spaces, or in different pragmas). E.g.:

```
/**
 * fantom_flags commonTestFlag:true
 * fantom_flags jsOnlyTestFlag:true
 */
```

The feature flags are overridden automatically for us before the tests start.

Reviewed By: javache

Differential Revision: D66760121

fbshipit-source-id: 7e227e0035a170dab81b1e6ce39600a01a748867
2024-12-05 17:06:11 -08:00
Rubén Norte db70b791ba Add ReactNativeFeatureFlagsDynamicProvider to allow configuration in C++ using dynamic values (#48093)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48093

Changelog: [internal]

We're going to add support for specifying feature flags in Fantom tests in pragmas. E.g.:

```
/**
 * fantom_flags commonTestFlag:true
 */
```

Users will be able to specify any feature flags in their tests, so we need a way to pass that information from the test file to the runner, and the runner has to be able to apply this dynamic configuration.

Because the API is statically typed in C++, we need to define a method for every possible feature flag configurable through this API. We could do it in userland, but we'd have to manually add a method every time there was a new feature flag we wanted to support.

Instead of doing that, this introduces a new abstraction in the feature flag system that codegens it for you.

The API is basically:

```
  folly::dynamic values = folly::dynamic::object();

  values["commonTestFlag"] = true;

  ReactNativeFeatureFlags::override(
      std::make_unique<ReactNativeFeatureFlagsDynamicProvider>(values));

  EXPECT_EQ(ReactNativeFeatureFlags::commonTestFlag(), true);
```

Then we can use this abstraction in Fantom to pass all the configured flags as `folly::dynamic` through this API.

Reviewed By: javache

Differential Revision: D66760118

fbshipit-source-id: c32329e5ca76923c3e0b9c0eb1fe8c3268e1f57b
2024-12-05 17:06:11 -08:00
Rubén Norte da6d089305 Extract logic to get Fantom test config to a standalone module (2nd attempt) (#48119)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48119

Changelog: [internal]

This is a re-land of https://github.com/facebook/react-native/pull/48092

Reviewed By: rshest

Differential Revision: D66820309

fbshipit-source-id: 6b07edcca6988eeb014f6b51ec82296d451bee14
2024-12-05 17:06:11 -08:00
Rubén Norte 1243679fe2 Export existing Fantom tests (2nd attempt) (#48118)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48118

Changelog: [internal]

This is a re-land of https://github.com/facebook/react-native/pull/48085

Reviewed By: rshest

Differential Revision: D66820308

fbshipit-source-id: b0ccd4b52965988015422ebdb8cd1172d1f5e9db
2024-12-05 17:06:11 -08:00
Pieter De Baets 18ebea533d Convert com.facebook.react.modules.network.ReactCookieJarContainer to Kotlin (#48089)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48089

Planning to make some changes here for perf, but converting to Kotlin first

Changelog: [Android][Removed] Made ReactCookieJarContainer internal.

Reviewed By: tdn120

Differential Revision: D66724567

fbshipit-source-id: bf96f8df8a5c901b47c371c7ed16b7a81de22ee7
2024-12-05 16:29:37 -08:00
Pieter De Baets e750059d98 Convert com.facebook.react.modules.network.ForwardingCookieHandler to Kotlin (#48088)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48088

Planning to make some changes here for perf, but converting to Kotlin first

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D66724321

fbshipit-source-id: dec7f7123abdcd5792b3d589269b40ad42b3d307
2024-12-05 16:29:37 -08:00
Richard Barnes e7b9d70e0a Remove unused-variable in ../xplat/js/react-native-github/packages/react-native/React/CxxLogUtils/RCTDefaultCxxLogFunction.mm +2 (#48105)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48105

LLVM-15 has a warning `-Wunused-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code or (b) qualifies the variable with `[[maybe_unused]]`.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Changelog: [Internal]

Reviewed By: palmje

Differential Revision: D66777665

fbshipit-source-id: fadf71fd37c2b95f87419acf9d5a7765fe031905
2024-12-05 14:14:21 -08:00
Nicola Corti 13900d75b8 Remove replaceAll from RNTester sample code (#48099)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48099

This is currently breaking the Sample Module screen on RN-Tester. Let's remove it.

Changelog:
[Internal] [Changed] - Remove replaceAll from RNTester sample code

Reviewed By: cipolleschi

Differential Revision: D66764656

fbshipit-source-id: acd123374d23b37977d5506f70f29da7f5d6311f
2024-12-05 09:54:47 -08:00
Ramanpreet Nara 2f0977d8e4 Also report non-fatal non-warning errors (#48104)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48104

Just porting over the logic after D28815228.

Changelog: [Internal]

Reviewed By: mlord93

Differential Revision: D66563226

fbshipit-source-id: 41e21812dd0b2104fa66b970212f51bbb77d910b
2024-12-05 09:42:44 -08:00
Riccardo Cipolleschi 00d5caee99 Do not install CMake on Windows machine (#48122)
Summary:
GHA to build HermesC for windows are failing because the machines comes with a different CMake version already.
Let's try not to install Cmake and use the one provided by the machine.

## Changelog:
[Internal] -

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

Test Plan: GHA {F1973187648}

Reviewed By: alanleedev

Differential Revision: D66825216

Pulled By: cipolleschi

fbshipit-source-id: 9a9376a5409e192195a6b6cc25b4d58cb47f15da
2024-12-05 09:19:58 -08:00
Nikita Rubilov ea84bc666c Revert D66599197: Delete tests migrated to Fantom and unnecessary mocks for FabricUIManager, DOM, etc.
Differential Revision:
D66599197

Original commit changeset: 33822588c217

Original Phabricator Diff: D66599197

fbshipit-source-id: 00891602920f84a04ea9eac32758d2af08f3d4c7
2024-12-05 06:46:15 -08:00
Nikita Rubilov ca908c0681 Revert D66702625: Export existing Fantom tests
Differential Revision:
D66702625

Original commit changeset: e136ea5ea42c

Original Phabricator Diff: D66702625

fbshipit-source-id: 43600daaf46e5c1522758d721b0d2f2c9abc7e25
2024-12-05 06:46:15 -08:00
Nikita Rubilov eee5d2ec3c Revert D66760119: Extract logic to get Fantom test config to a standalone module
Differential Revision:
D66760119

Original commit changeset: e955e8f59669

Original Phabricator Diff: D66760119

fbshipit-source-id: ef77a5cdc87efd81bbe503a2a943b1deef4a7e15
2024-12-05 06:46:15 -08:00
zhongwuzw efd57d681c Fabric: Post RCTInstanceDidLoadBundle notification after bundle loaded (#48082)
Summary:
Fixes https://github.com/facebook/react-native/issues/47949

## Changelog:

[IOS] [FIXED] - Fabric: Post RCTInstanceDidLoadBundle notification after bundle loaded

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

Test Plan: Post RCTInstanceDidLoadBundle notification after bundle loaded

Reviewed By: philIip

Differential Revision: D66754060

Pulled By: cipolleschi

fbshipit-source-id: d30f0ed73e127936082e6f91e137b9b4013c6651
2024-12-05 06:00:34 -08:00
Rubén Norte bc0b5ca5df Extract logic to get Fantom test config to a standalone module (#48092)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48092

Changelog: [internal]

This is just in preparation to expand the scope of that function to include configuration for feature flags.

Reviewed By: javache

Differential Revision: D66760119

fbshipit-source-id: e955e8f596697ac6a0a87013bec3fc3e09caf19d
2024-12-05 05:18:08 -08:00
Rubén Norte f6aae38e52 Export existing Fantom tests (#48085)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48085

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D66702625

fbshipit-source-id: e136ea5ea42c1e1942e4c22e65855e91ad96e3f8
2024-12-05 05:18:08 -08:00
Rubén Norte 2e7e065d09 Delete tests migrated to Fantom and unnecessary mocks for FabricUIManager, DOM, etc. (#48087)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48087

Changelog: [internal]

Now that we have Fantom tests for these unit tests that use mocks, we can remove the JS tests and the mocks :)

Reviewed By: sammy-SC

Differential Revision: D66599197

fbshipit-source-id: 33822588c2176ffe2f2631da56c671b299f8058d
2024-12-05 05:18:08 -08:00
Rubén Norte b487e65869 Add support for expect() .toBeLessThan and .toBeGreaterThan (#48086)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48086

Changelog: [internal]

Just adding a bit of coverage for the `expect` API adding `toBeLessThan` and `toBeGreaterThan`.

Reviewed By: sammy-SC

Differential Revision: D66753268

fbshipit-source-id: 6a26f558f985ccbb5eb0daacecd93759841149e9
2024-12-05 05:18:08 -08:00
Rubén Norte ff934cd249 Extract definitions for expect and mocks from generic test setup to standalone modules (#48083)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48083

Changelog: [internal]

Just a small refactor to have a better code organization for the testing runtime infra.

Reviewed By: sammy-SC

Differential Revision: D66753269

fbshipit-source-id: e68727fe45fabe0be3528e21d5a60cef3045c252
2024-12-05 05:18:08 -08:00
Rubén Norte 118c18f3bb Allow async functions in ReactNativeTester and add tests (#48063)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48063

Changelog: [internal]

This allows async functions to be passed to `runTask` (just a type change really) and adds tests for ReactNativeTester. Error handling isn't currently set up correctly, so those tests are disabled for now.

Reviewed By: sammy-SC

Differential Revision: D66698547

fbshipit-source-id: 41d1fccc80f90cdf764f6fa3d3d34365eeef8ec6
2024-12-05 05:18:08 -08:00
Wojciech Lewicki e7f943de2f fix: long not implemented on native side (#48017)
Summary:
Handling `long` values is not implemented in Writables. I added it on the native side.

## Changelog:

<!-- 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] - Message

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

[ANDROID] [FIXED] - Support Long values in WritableMap and WritableArray

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

Test Plan: Run https://github.com/WoLewicki/reproducer-react-native/tree/%40wolewicki/long-in-writeable-map and see it doesn't work without those changes.

Reviewed By: javache

Differential Revision: D66754194

Pulled By: cortinico

fbshipit-source-id: 7f8d4eb3c4069f890460525ddffdf9f4324550b0
2024-12-05 04:46:28 -08:00
jodeppo 8aac234ce2 Remove Trigger E2E Tests on Comment (#47923)
Summary:
This action is no longer necessary and we can remove it

## Changelog:

[Internal] [Fixed] - Use `refs/pulls` namespace in trigger action

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

Reviewed By: NickGerleman

Differential Revision: D66578573

Pulled By: cortinico

fbshipit-source-id: 87cdbc1544873a2669e82c7763c78d18ff7881fd
2024-12-05 03:23:52 -08:00
Kacper Kafara f402ed17fa Fix handling removal of transitioning views (#47634)
Summary:
Related PR in `react-native-screens`:

* https://github.com/software-mansion/react-native-screens/pull/2495

Additional context:
   * [my detailed explanation of **one of the issues**](https://github.com/software-mansion/react-native-screens/pull/2495#issuecomment-2478915818)
   * [Android Developer: ViewGroup.startViewTransition docs](https://developer.android.com/reference/android/view/ViewGroup#startViewTransition(android.view.View))

### Background

On Android view groups can be marked as "transitioning" with a `ViewGroup.startViewTransition` call. This effectively ensures, that in case a view group is marked with this call and its children are removed, they will be still drawn until `endViewTransition` is not called.

This mechanism is implemented in Android by [keeping track of "transitioning" children in auxiliary `mTransitioningViews` array](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewGroup.java#7178). Then when such "transitioning" child is removed, [it is removed from children array](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewGroup.java#5595) but it's [parent-child relationship is not cleared](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewGroup.java#5397) and it is still retained in the auxiliary array.

Having that established we can proceed with problem description.

### Problem

https://github.com/user-attachments/assets/d0356bf5-2f17-4b06-ba53-bfca659a1071

<details>
<summary>Full code</summary>

```javascript
import { NavigationContainer } from 'react-navigation/native';
import React from 'react';
import { createNativeStackNavigator } from 'react-navigation/native-stack';
import { enableScreens } from 'react-native-screens';
import {
  StyleSheet,
  Text,
  View,
  FlatList,
  Button,
  ViewProps,
  Image,
  FlatListProps,
  findNodeHandle,
} from 'react-native';

enableScreens(true);

function Item({ children, ...props }: ViewProps) {
  return (
    <View style={styles.item} {...props}>
      <Image source={require('../assets/trees.jpg')} style={styles.image} />
      <Text style={styles.text}>{children}</Text>
    </View>
  );
}

function Home({ navigation }: any) {
  return (
    <View style={styles.container}>
      <Button title="Go to List" onPress={() => navigation.navigate('List')} />
    </View>
  );
}

function ListScreenSimplified({secondVisible}: {secondVisible?: (visible: boolean) => void}) {
  const containerRef = React.useRef<View>(null);
  const innerViewRef = React.useRef<View>(null);
  const childViewRef = React.useRef<View>(null);

  React.useEffect(() => {
    if (containerRef.current != null) {
      const tag = findNodeHandle(containerRef.current);
      console.log(`Container has tag [${tag}]`);
    }
    if (innerViewRef.current != null) {
      const tag = findNodeHandle(innerViewRef.current);
      console.log(`InnerView has tag [${tag}]`);
    }
    if (childViewRef.current != null) {
      const tag = findNodeHandle(childViewRef.current);
      console.log(`ChildView has tag [${tag}]`);
    }
  }, [containerRef.current, innerViewRef.current, childViewRef.current]);

  return (
    <View
      ref={containerRef}
      style={{ flex: 1, backgroundColor: 'slateblue', overflow: 'hidden' }}
      removeClippedSubviews={false}>
      <View ref={innerViewRef} removeClippedSubviews style={{ height: '100%' }}>
        <View ref={childViewRef} style={{ backgroundColor: 'pink', width: '100%', height: 50 }} removeClippedSubviews={false}>
          {secondVisible && (<Button title='Hide second' onPress={() => secondVisible(false)} />)}
        </View>
      </View>
    </View>
  );
}

function ParentFlatlist(props: Partial<FlatListProps<number>>) {
  return (
    <FlatList
      data={Array.from({ length: 30 }).fill(0) as number[]}
      renderItem={({ index }) => {
        if (index === 10) {
          return <NestedFlatlist key={index} />;
        } else if (index === 15) {
          return <ExtraNestedFlatlist key={index} />;
        } else if (index === 20) {
          return <NestedFlatlist key={index} horizontal />;
        } else if (index === 25) {
          return <ExtraNestedFlatlist key={index} horizontal />;
        } else {
          return <Item key={index}>List item {index + 1}</Item>;
        }
      }}
      {...props}
    />
  );
}

function NestedFlatlist(props: Partial<FlatListProps<number>>) {
  return (
    <FlatList
      style={[styles.nestedList, props.style]}
      data={Array.from({ length: 10 }).fill(0) as number[]}
      renderItem={({ index }) => (
        <Item key={'nested' + index}>Nested list item {index + 1}</Item>
      )}
      {...props}
    />
  );
}

function ExtraNestedFlatlist(props: Partial<FlatListProps<number>>) {
  return (
    <FlatList
      style={styles.nestedList}
      data={Array.from({ length: 10 }).fill(0) as number[]}
      renderItem={({ index }) =>
        index === 4 ? (
          <NestedFlatlist key={index} style={{ backgroundColor: '#d24729' }} />
        ) : (
          <Item key={'nested' + index}>Nested list item {index + 1}</Item>
        )
      }
      {...props}
    />
  );
}

const Stack = createNativeStackNavigator();

export default function App(): React.JSX.Element {
  return (
    <NavigationContainer>
      <Stack.Navigator screenOptions={{ animation: 'slide_from_right' }}>
        <Stack.Screen name="Home" component={Home} />
        <Stack.Screen name="List" component={ListScreenSimplified}/>
      </Stack.Navigator>
    </NavigationContainer>
  );
}

export function AppSimple(): React.JSX.Element {
  const [secondVisible, setSecondVisible] = React.useState(false);

  return (
    <View style={{ flex: 1, backgroundColor: 'lightsalmon' }}>
      {!secondVisible && (
        <View style={{ flex: 1, backgroundColor: 'lightblue' }} >
          <Button title='Show second' onPress={() => setSecondVisible(true)} />
        </View>
      )}
      {secondVisible && (
        <ListScreenSimplified secondVisible={setSecondVisible} />
      )}
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  nestedList: {
    backgroundColor: '#FFA07A',
  },
  item: {
    flexDirection: 'row',
    alignItems: 'center',
    padding: 10,
    gap: 10,
  },
  text: {
    fontSize: 24,
    fontWeight: 'bold',
    color: 'black',
  },
  image: {
    width: 50,
    height: 50,
  },
});

```

</details>

Explanation (copied from [here](https://github.com/software-mansion/react-native-screens/pull/2495#issuecomment-2478915818)):

I've debugged this for a while now & I have good understanding of what's going on. This bug is caused by our usage of `startViewTransition` and its implications. We use it well, however React does not account for case that some view might be in transition. Error mechanism is as follows:

1. Let's have initially simple stack with two screens: "A, B". This is component rendered under "B":

```javascript
    <View //<-- ContainerView (CV)
      removeClippedSubviews={false}
      style={{ flex: 1, backgroundColor: 'slateblue', overflow: 'hidden' }}>
      <View removeClippedSubviews style={{ height: '100%' }}> // <--- IntermediateView (IV)
        <View removeClippedSubviews={false} style={{ backgroundColor: 'pink', width: '100%', height: 50 }} /> // <--- ChildView (ChV)
      </View>
    </View>
```

2. We press the back button.
3. We're on Fabric, therefore subtree of B gets destroyed before B itself is unmounted -> in our commit hook we detect that the screen B will be unmounted & we mark every node under B as transitioning by calling `startViewTransition`.
4. React Mounting stage starts, view hierarchy is disassembled in bottom-up fashion (leafs first).
5. ReactViewGroupManager receives MountItem to detach ChV from IV.
6. A call to [`IV.removeView(ChV)` is made](https://github.com/facebook/react-native/blob/9c11d7ca68c5c62ab7bab9919161d8417e96b28b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactClippingViewManager.kt#L58-L73), which effectively removes ChV from `IV.children`, ***HOWEVER*** it does not clear `ChV.parent`, meaning that after the call, `ChV.parent == IV`. This happens, due to view being marked as in-transition by our call to `startViewTransition`. If the view is not marked as in-transition this parent-child relationship is removed.
7. IV has `removeClippedSubviews` enabled, therefore a [call to `IV.removeViewWithSubviewsClippingEnabled(ChV)` is made](https://github.com/facebook/react-native/blob/9c11d7ca68c5c62ab7bab9919161d8417e96b28b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactClippingViewManager.kt#L68). [This function](https://github.com/facebook/react-native/blob/9c11d7ca68c5c62ab7bab9919161d8417e96b28b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java#L726-L744) does effectively two things:
    1. if the ChV has parent (interpretation: it has not yet been detached from parent), we compute it's index in `IV.children` (Android.ViewGroup's state) and remove it from the array,
    2. remove the ChV from `mAllChildren` array (this is state maintained by ReactViewGroup for purposes of implementing the "subview clipping" mechanism".

The crash happens in 7.1, because ChV has been removed from `IV.children` in step 6, but the parent-child relationship has not been broken up there. Under usual circumstances (this is my hypothesis now, yet unconfirmed) 7.1 does not execute, because `ChV.parent` is nulled in step no. 6.

### Rationale for `startViewTransition` usage

Transitions. On Fabric, when some subtree is unmounted, views in the subtree are unmounted in bottom-up order. This leads to uncomfortable situation, where our components (react-native-screens), who want to drive & manage transitions are notified that their children will be removed after the subtrees mounted in screen subviews are already disassembled. **If we start animation in this very moment we will have staggering effect of white flash** [(issue)](https://github.com/software-mansion/react-native-screens/issues/1685) (we animate just the screen with white background without it's children). This was not a problem on Paper, because the order of subtree disassembling was opposite - top-down. While we've managed to workaround this issue on Fabric using `MountingTransactionObserving` protocol on iOS and a commit hook on Android (we can inspect mutations in incoming transaction before it starts being applied) we still need to prevent view hierarchy from being disassembled in the middle of transition (on Paper this has also been less of an issue) - and this is where `startViewTransition` comes in. It allows us to draw views throughout transition after React Native removes them from HostTree model. On iOS we exchange subtree for its snapshot for transition time, however this approach isn't feasible on Android, because [snapshots do not capture shadows](https://stackoverflow.com/questions/42212600/android-screenshot-of-view-with-shadow).

### Possible solutions

[Android does not expose a method to verify whether a view is in transition](https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewGroup.java#7162) (it has `package` visibility), therefore we need to retrieve this information with some workaround. I see two posibilities:

* first approach would be to override `startViewTransition` & `endViewTransition` in ReactViewGroup and keep the state on whether the view is transitioning there,
* second possible approach would be as follows: we can check for "transitioning" view by checking whether a view has parent but is not it's parent child (this **should** be reliable),

Having information on whether the view is in transition or not, we can prevent multiple removals of the same view in every call site (currently only in `removeViewAt` if `parent.removeClippingSubviews == true`).

Another option would be to do just as this PR does: having in mind this "transitioning" state we can pass a flag to `removeViewWithSubviewClippingEnabled` and prevent duplicated removal from parent if we already know that this has been requested.

I can also add override of this method:

```java
  /*package*/ void removeViewWithSubviewClippingEnabled(View view) {
    this.removeViewWithSubviewClippingEnabled(view, false);
  }
```

to make this parameter optional.

## Changelog:

[ANDROID] [FIXED] - Handle removal of in-transition views.

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

Test Plan: WIP WIP

Reviewed By: javache

Differential Revision: D66539065

Pulled By: tdn120

fbshipit-source-id: cf1add67000ebd1b5dfdb2048461a55deac10b16
2024-12-04 15:24:35 -08:00
Nicola Corti 734730df75 Re-introduce the deprecated constructor on ReactModuleInfo (#48090)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48090

This alleviates a breaking change on `ReactModuleInfo` constructor.
While the ctor was deprecated, we realized that there are more than 250 usages in OSS.
We'll need to properly communicate this removal before we do it.

Changelog:
[Android] [Fixed] - Re-introduce the deprecated constructor on ReactModuleInfo

Reviewed By: cipolleschi

Differential Revision: D66755541

fbshipit-source-id: 3673d8f2af278d55491cea89f1594d368513e3d8
2024-12-04 11:03:03 -08:00
Mateo Guzmán 50d0157f0c test(network): [android] ResponseUtil unit tests (#48075)
Summary:
Currently the class `ResponseUtil` is still in Java, I'm adding some unit tests so it is safer to migrate it to Kotlin.

## Changelog:

[INTERNAL] - `ResponseUtil` unit tests

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

Test Plan:
```bash
yarn test-android
```

Reviewed By: cortinico

Differential Revision: D66727736

Pulled By: lunaleaps

fbshipit-source-id: 9c89c75905b4e0c9c4820a556245a07e135e0f17
2024-12-04 10:26:04 -08:00
Andrew Datsenko 2e444d2b40 Add ReactNativetester#getRenderedOutput() API (#47970)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47970

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D65617491

fbshipit-source-id: 49369b694a81b7dfb541c75d9e24b62fc141d980
2024-12-04 09:55:56 -08:00
Nick Gerleman 366270e742 Update requirements in README (#48079)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48079

We updated these in 0.76, and should update them in the README as well. https://reactnative.dev/blog/2024/10/23/release-0.76-new-architecture#updates-to-minimum-ios-and-android-sdk-requirements

Changelog: [Internal]

Reviewed By: lunaleaps, philIip

Differential Revision: D66735446

fbshipit-source-id: c9145bab14e4956ed070fb906dd1c1676905bfb6
2024-12-04 09:45:46 -08:00
Soe Lynn 469978f170 Fix Interop code for having unsync ViewManager between ModuleRegistry and BridgeProxy (#48069)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48069

Changelog [Internal]:
Fix Interop code for having unsync ViewManager between ModuleRegistry and BridgeProxy

Reviewed By: RSNara

Differential Revision: D66137400

fbshipit-source-id: ace3f60b6b972f17c7124ec33f0d3e8d035e966c
2024-12-04 09:40:16 -08:00
Rob Hogan 7ee7e69cdf Update changelog for v0.77.0-rc.1 (#48084)
Summary:
Changelog for v0.77.0-rc.1

https://github.com/facebook/react-native/compare/v0.77.0-rc.0...v0.77.0-rc.1

## Changelog:
[Internal]

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

Reviewed By: cipolleschi

Differential Revision: D66753599

Pulled By: robhogan

fbshipit-source-id: 9a02df5cb7174270b4d293c48c6b0468a4042c87
2024-12-04 09:40:07 -08:00
zhongwuzw efcfe5dcd6 Fabric: Fixes insets not adjust when keyboard disappear (#47924)
Summary:
Fixes https://github.com/facebook/react-native/issues/47731 .

## Changelog:

[IOS] [FIXED] - Fabric: Fixes insets not adjust when keyboard disappear

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

Test Plan: Demo in https://github.com/facebook/react-native/issues/47731

Reviewed By: blakef

Differential Revision: D66651865

Pulled By: cipolleschi

fbshipit-source-id: a75afbd1a7651f0c77022d913f910821c482fcf7
2024-12-04 07:49:12 -08:00
Rob Hogan b5b9e032c2 Fix Android JSC compatibility - replaceAll -> replace (#48076)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48076

JSC for Android does not implement `String.prototype.replaceAll`:

 {F1971791988}

https://github.com/facebook/react-native/pull/47466 introduced a use of it into runtime code, breaking JSC compatibility.

This.. replaces it.. with `replace`. Since the argument is already a regex with a `g` modifier, `replaceAll` wasn't necessary anyway.

Changelog:
[ANDROID][FIXED] Fix JSC by avoiding use of unavailable `str.replaceAll()`

Reviewed By: javache

Differential Revision: D66712312

fbshipit-source-id: 534b6db6834a2fda46ae8457437de3caa24f4eb0
2024-12-04 06:07:21 -08:00
Rubén Norte 4c62d46525 Remove legacy versions of the native methods for performance.mark and performance.measure (#48067)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48067

Changelog: [internal]

We don't need to keep these versions for backwards compatibility anymore.

Reviewed By: rshest

Differential Revision: D65423761

fbshipit-source-id: 59046a577c1de4aedb2593a12a45d9deb3bb4260
2024-12-04 04:38:54 -08:00
Phillip Pan 0217d7e19c have RCTInstance decorate non-app provided turbomodules with bridgeless APIs (#48053)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48053

Changelog: [Internal]

`getModuleInstanceFromClass:` is a delegate method intended to be implemented by the product layer to provide modules. if it is not implemented to return a module for a given key, `RCTTurboModuleManager` will simply call `new` on the TM class.

however, these two paths differentiate - for `getModuleInstanceFromClass:`, we will call `_attachBridgelessAPIsToModule:` which provides objects like surfacePresenter to the native module.

if we fallback to calling `new`, then this attachment does not happen, even if the app has already been migrated to bridgeless modules.

thus, the fix in the case is to lift the fallback into RCTInstance as well, and decorate the APIs onto the new fallback.

Reviewed By: cipolleschi

Differential Revision: D66675034

fbshipit-source-id: 1ab89a4006d05f744f5d42b5de786ccea4d4a55d
2024-12-03 22:23:04 -08:00
Joe Vilches 74f3ab7d40 Properly camelcase mainAxisownerSize in FlexLine (#48077)
Summary:
X-link: https://github.com/facebook/yoga/pull/1762

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

OCD strikes again. Grepped this time to make sure we didn't miss any cases for this specific param name

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66715777

fbshipit-source-id: 3e881a15b3b2836a4a55b11d7ec621541b92a05d
2024-12-03 19:16:56 -08:00