Commit Graph

12270 Commits

Author SHA1 Message Date
Ruslan Lesiutin 53b7f0e764 upgrade React Native on a new RDT backend (#46669)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46669

# Changelog: [Internal]

In React DevTools 6.0.0, settings manager is [no longer used](https://github.com/facebook/react/pull/30986), because the host of the Backend is responsible for settings persistance.

Also, `installHook()` call was removed from the top level of the JavaScript module and now we need to call `initialize()` explicitly.

The logic for persisting settings will be added in one of the next diffs at the top.

Reviewed By: huntie

Differential Revision: D62967059

fbshipit-source-id: 5022546aab02540f38c8d2e2f2e7dfeb82863f3f
2024-09-27 08:12:45 -07:00
Ruslan Lesiutin 6173d6ca42 Update debugger-frontend from e8c7943...87b2feb (#46673)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46673

Changelog: [Internal] - Update `react-native/debugger-frontend` from e8c7943...87b2feb

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

Reviewed By: huntie

Differential Revision: D63455520

fbshipit-source-id: 07776c17f368e895a2d526cbb9abb8e1104bb29c
2024-09-27 08:12:45 -07:00
Ruslan Lesiutin ed4f6d6891 upgrade[react-devtools-core]: 6.0.0 (#46670)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46670

# Changelog:
[General] [Changed] - upgrade React DevTools to 6.0.0.

allow-large-files

Reviewed By: huntie

Differential Revision: D63460308

fbshipit-source-id: 159b0a0a074aae52c3710730a4fc2cbccb04970d
2024-09-27 08:12:45 -07:00
Nicola Corti 1bdae07d89 Add Android implementation for DevMenu Module (#46694)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46694

The DevMenu module was never implemented on Android. This adds its implementation by mirroring the iOS implementation.

Fixes https://github.com/facebook/react-native/issues/46679

Changelog:
[Android] [Fixed] - Add missing Android implementation for DevMenu Module

Reviewed By: cipolleschi

Differential Revision: D63535172

fbshipit-source-id: 791e72b46b7d3264b98e85a73f2d9025dc3a2c7d
2024-09-27 07:49:52 -07:00
zhongwuzw 8bfd7e1039 Fixes Appearance getColorScheme sync method UI thread issue (#46344)
Summary:
If the module sets the method queue to the main queue, we should call it on the main queue if it contains some UI operations, otherwise it may lead to some undefined behavior.

## Changelog:

[IOS] [FIXED] - Fixes the exported synchronous method not being called on the method queue when it's the main queue

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

Test Plan: The sync method should be called on the main queue if the module's method queue is main queue.

Reviewed By: cipolleschi

Differential Revision: D63532525

Pulled By: javache

fbshipit-source-id: 55baaa60af96bb1355d3641174f23bccd8eb9344
2024-09-27 06:47:53 -07:00
Blake Friedman 8237e237ce cli: fix init when called as npx react-native init (#46677)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46677

Since removing `react-native-community/cli` as a dependency in 0.76 the `npx react-native init` command isn't working.  This is the deprecated way to run this command, but users should still expect it to work for now.

This now forks this kind of request to `npx react-native-community/cli init <args>` as described in the warning logs to the user.

Changelog: [Internal]

Issue: reactwg/react-native-releases#508

Reviewed By: cortinico

Differential Revision: D63467046

fbshipit-source-id: 84560bdae8d6f62629dee61da3cbbf544b9a83b2
2024-09-27 03:38:19 -07:00
Nicola Corti 12dda31bc1 fix: ReactDelegate crashing New Architecture apps by invoking setContentView (#46671)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46671

Fixes https://github.com/facebook/react-native/issues/46566

Currently `ReactFragment` and `ReactDelegate` don't work in OSS + New Architecture because we call `Activity.setContentView`
on the host activity.

That result on us replacing the whole activity layout, even when the user wants to use a Fragment.
As we do have `ReactActivityDelegate` that already does this:
https://github.com/facebook/react-native/blob/94b77938435693792e57c96d76691d58d7361530/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java#L138

So this call is unncessary.

I've also updated the relative documentation here:
https://github.com/facebook/react-native-website/pull/4232

Changelog:
[Android] [Fixed] - fix: ReactDelegate/ReactFragment crashing on New Architecture apps

Reviewed By: rozele

Differential Revision: D63464367

fbshipit-source-id: acbfbf7d68eb79657b811a5a9a0d3f72660ec94a
2024-09-27 01:49:38 -07:00
Nicola Corti 7176d11ce4 ReactFragment should properly instantiate ReactDelegate on Bridgeless (#46623)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46623

I've just noticed that ReactFragment is not properly instantiating the `ReactDelegate` with a ReactHost
when on Bridgeless. This causes Fragments to crash when the app is on bridgeless mode.

Fixes https://github.com/facebook/react-native/issues/46566

Changelog:
[Android] [Fixed] - ReactFragment should properly instantiate ReactDelegate on Bridgeless

Reviewed By: mdvacca

Differential Revision: D63319977

fbshipit-source-id: 08256e35b2769e18df2d24f870ec5d98e5574f85
2024-09-27 01:49:38 -07:00
Nicola Corti ecd660984c Gradle to 8.10.2 (#46656)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46656

This contains the fix for:
- https://github.com/gradle/gradle/issues/30472

Changelog:
[Internal] [Changed] - Gradle to 8.10.2

Reviewed By: tdn120

Differential Revision: D63457979

fbshipit-source-id: 1439a9ce198c1df0dafa8f5088c079c3fb3d1543
2024-09-27 00:43:25 -07:00
Sam Zhou c2c9b78e49 Pre-suppress errors ahead of v0.247 release
Summary:
drop-conflicts

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D63506234

fbshipit-source-id: 186d60e42a8a2a3604058692ed844ba764d6ad3f
2024-09-26 22:25:21 -07:00
David Vacca d93e67d02c Enable Microtasks, ModernRuntimeScheduler and NativeViewConfigsInBridgelessMode by default only for New Architecture (#46683)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46683

Enabling these Microtask, ModernRuntimeScheduler and NativeViewConfigsInBridgelessMode in BridgeMode is risky and leads to bugs.  In this diff I'm ensuring we only enable these flags when newArchitecture is enabled

changelog: [internal] internal

Reviewed By: shwanton

Differential Revision: D63503519

fbshipit-source-id: 4ef757834b8f7fba595b3394735f4b91335d7c98
2024-09-26 22:02:42 -07:00
Nick Gerleman 3f880991aa Back out "Redo "[RN][Android] Convert ReactViewManager, ReactClippingViewManager to Kotlin""
Summary: Backing out the stack since a same crash that previously effected many apps appeared again, and there are changes soon landing that will add more conflicts.

Reviewed By: Abbondanzo

Differential Revision: D63493332

fbshipit-source-id: 4423bf41c793e00a0aa22d12a77bca69d3b1ae77
2024-09-26 15:50:26 -07:00
Nick Gerleman 8d22e3b249 Back out "Redo "[RN][Android] Convert ReactViewGroup to Kotlin""
Summary: Backing out the stack since a same crash that previously effected many apps appeared again, and there are changes soon landing that will add more conflicts.

Reviewed By: Abbondanzo

Differential Revision: D63493331

fbshipit-source-id: 44658ffc99eb4ebc947f95bb6e6bde105ac88c93
2024-09-26 15:50:26 -07:00
Nick Gerleman a886a2fa05 Back out "ReactViewGroup post-conversion cleanup"
Summary: Backing out the stack since a same crash that previously effected many apps appeared again, and there are changes soon landing that will add more conflicts.

Reviewed By: Abbondanzo

Differential Revision: D63493334

fbshipit-source-id: 175fc7b5b69aa2874c867e460ab102bb077a7cd8
2024-09-26 15:50:26 -07:00
Eric Rozell 1dcaf823f5 Fix conflicting assertions for click events (#46633)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46633

There is an assertion in the "basic click test" that [checks](https://github.com/facebook/react-native/blob/d6e0bc7/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventClickTouch.js#L36-L40) that `isPrimary` is set to false. The same assertion suite also does a mouse event [validation](https://github.com/facebook/react-native/blob/d6e0bc7/packages/rn-tester/js/examples/Experimental/W3CPointerEventPlatformTests/PointerEventSupport.js#L201-L204) that `isPrimary` is set to true.

This fixes the conflicting assertions, favoring the behavior observed on Firefox, which appears to be more closely aligned with the W3C spec.

## Changelog

[General][Fixed] Fixed issues with W3C PointerEvents testsx

Reviewed By: vincentriemer

Differential Revision: D63336622

fbshipit-source-id: adbfe5e1bc2a5fd7db18ae067f39e719c19c8cda
2024-09-26 14:45:44 -07:00
David Vacca fc9fcb5976 Fix initialization of FeatureFlags in DefaultNewArchitectureEntryPoint (#46681)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46681

Fix initialization of FeatureFlags in DefaultNewArchitectureEntryPoint

D60364016 introduced a bug, disabling Fabric and TurboModules when DefaultNewArchitectureEntryPoint is initialized with bridgless disabled

changelog: [internal] internal

Reviewed By: shwanton

Differential Revision: D63474698

fbshipit-source-id: 8b5aaeeda564d3463d13448b0adc7e964015000e
2024-09-26 14:23:04 -07:00
Thomas Nardone 9cd83fa9ab ReactViewGroup post-conversion cleanup (#46668)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46668

Small tweaks post-Kotlin-conversion:
- Make `overflow` a var
- Replace `+ -` with `-`
- Clean up properties and move up init block
- Iterate over entire allChildren array to clean up listeners

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D63343964

fbshipit-source-id: 2e9022e2d7e54ac338d1003419d8959771f7f270
2024-09-26 13:11:07 -07:00
Thomas Nardone be5e2b5827 Redo "[RN][Android] Convert ReactViewGroup to Kotlin" (#46672)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46672

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D63129923

fbshipit-source-id: 0734f564b38e3adba704edffe45511e671ae74ac
2024-09-26 13:11:07 -07:00
Thomas Nardone f775f6919f Redo "[RN][Android] Convert ReactViewManager, ReactClippingViewManager to Kotlin" (#46667)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46667

Pre-req for converting ReactViewGroup without affecting API visibility.
Changelog: [Internal]

Reviewed By: javache

Differential Revision: D63129925

fbshipit-source-id: 3b31df7b5450adcc961bb677114fb94d944f1ce4
2024-09-26 13:11:07 -07:00
Pieter De Baets 3fbf5c72f3 Fix ReactSurfaceView-backed roots not reporting the end of pending transactions correctly (#46676)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46676

Changelog: [internal]

## Context

We recently "fixed" a problem in `MountingCoordinator` on Android where it would report that it doesn't have any pending transactions when, in fact, it does. The fix introduces a new method in that class to delay marking transactions as done until a mount hook is invoked for that surface.

That fixed the issue... by always reporting that there were pending transactions accidentally.

The reason for this bug is that the mount hook doesn't have access to the mounting coordinator of the surface if the surface is registered through some of the methods in `Binding.cpp` that don't add the surface to a registry. In that case, we can never mark the transactions as done and the mounting coordinator for those surfaces always report pending transactions incorrectly.

NOTE: this bug only affects apps that have the `fixMountingCoordinatorReportedPendingTransactionsOnAndroid` feature flag enabled.

## Changes

This fixes the issue by making sure that surfaces are always registered in the registry and that we can access their mounting coordinators in the mount hook to report the transactions as done.

Reviewed By: rubennorte

Differential Revision: D63466672

fbshipit-source-id: a621a12cda89a3ab7331d3c6a16c6cdfa9341821
2024-09-26 11:32:00 -07:00
Pieter De Baets 04da3d784b Error in reportMount when surface is not found (#46678)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46678

I'm investigating some issues with surface management and noticed `surfaceHandlerRegistry_` is not updated in the bridgeless path when using ReactSurfaceView.

Adding a warning to help us validate this is resolved when we do eventually fix it.

Changelog: [Internal]

Reviewed By: fabriziocucci

Differential Revision: D63463521

fbshipit-source-id: 38995924588f1d71b9fc517c76a6e0c572fd0699
2024-09-26 11:32:00 -07:00
hoxyq (Meta Employee) 633ad4933e fix: use public instance in Fiber renderer and expose it from getInspectorDataForViewAtPoint (#31068) (#46674)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46674

bypass-github-export-checks

React DevTools no longer operates with just Fibers, it now builds its
own Shadow Tree, which represents the tree on the Host (Fabric on
Native, DOM on Web).

We have to keep track of public instances for a select-to-inspect
feature. We've recently changed this logic in
https://github.com/facebook/react/pull/30831, and looks like we've been
incorrectly getting a public instance for Fabric case.

Not only this, turns out that all `getInspectorData...` APIs are
returning Fibers, and not public instances. I have to expose it, so that
React DevTools can correctly identify the element, which was selected.

Changes for React Native are in
[D63421463](https://www.internalfb.com/diff/D63421463)

DiffTrain build for commit https://github.com/facebook/react/commit/d66fa02a303fc53d901bdb0d7bbdaec3e6774b19.

Test Plan: Sandcastle tests

Reviewed By: poteto

Differential Revision: D63453667

Pulled By: hoxyq

fbshipit-source-id: 21b1d5d4cd68b42748d4a785e0f28eaf5db57f21
2024-09-26 09:58:18 -07:00
Robert Pasiński 38b3b2195c New implementation of PerformanceObserver and related APIs (fixes #45122) (#45206)
Summary:
Changelog: [internal]

(this functionality hasn't been enabled in OSS yet, so no changelog necessary).

Fix https://github.com/facebook/react-native/issues/45122.

performance.mark is currently O(1) but performance.clearMark is O(n) (being n the number of entries in the buffer), which makes this operation very slow.

### Changes overview

 - Created new `PerformanceEntryBuffer` abstraction with the following subtypes, that differ on how entries are stored:
   - `PerformanceEntryCircularBuffer` - stores them in a ring buffer that was already implemented, removed key lookup cache (`BoundedConsumableBuffer`)
   - `PerformanceEntryKeyedBuffer` - stores them in a `unordered_map`, allowing for faster retrieval by type
   - `PerformanceEntryLinearBuffer` - a simple infinite buffer based on `std::vector`, currently used in a `PerformanceObserver`
 - Created `PerformanceObserver` abstraction on native side.
 - Created `PerformanceObserverRegistry` that collects active observers and forwards entries to observers that should retrieve them
 - Moved some method implementations to `.cpp` files to reduce potential compilation time slowdown. As the `PerformanceEntryReporter` can be included from anywhere in the code, it will be beneficial to make header files as light as possible.
 - Add comments to methods that note which standard is the method from/for.
 - Added some `[[nodiscard]]` attributes
 - Since the logic of routing entries to observers is moved to native side, JS side of the code got much simplified
 - If ever needed, `PerformanceObserver` can be created from native-side

Standards covered:

 - https://www.w3.org/TR/performance-timeline
 - https://www.w3.org/TR/event-timing/
 - https://w3c.github.io/timing-entrytypes-registry
 - https://w3c.github.io/user-timing/

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

Test Plan:
I've tested this e2e on IGVR and in the RNTester playground for the performance APIs. Everything works as expected.
There are also new unit tests for this.

C++ test results: https://www.internalfb.com/intern/testinfra/testconsole/testrun/8725724513169247/

Reviewed By: rshest

Differential Revision: D63101520

Pulled By: rubennorte

fbshipit-source-id: 5970b5c14692ff33ffda44a9f09067f6a758bdbe
2024-09-26 09:16:03 -07:00
tutejsy 19d468fed9 Fix applying of tintColor and progressViewOffset props for RefreshControl component (#46628)
Summary:
While developing my project with New Architecture enabled I've found out that properties `tintColor` and `progressViewOffset` of component `RefreshControl` don't apply on iOS.  This happens due to the lack of handling of these properties in the `RCTPullToRefreshViewComponentView.mm` class.

The bug can be easily reproduced in RNTester app on RefreshControlExample.js screen, since it has property `tintColor="#ff0000"` (Red color), but RefreshControl renders with gray color:

<img width="300" alt="RefreshControlExample.js" src="https://github.com/user-attachments/assets/10931204-dbe8-4cbd-9adc-d0f38319febd">

<img width="300" alt="gray Refresh Control" src="https://github.com/user-attachments/assets/e5d088e8-b3f5-46b8-9284-9b452232ad10">

<br />
<br />

This PR is opened to fix that by applying `tintColor` and `progressViewOffset` props to `_refreshControl` in `RCTPullToRefreshViewComponentView.mm` class.

Fixes https://github.com/facebook/react-native/pull/46628

## Changelog:

[IOS][FIXED] - Fix applying of tintColor and progressViewOffset props for RefreshControl component with New Architecture enabled

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

Test Plan:
1. Run rn-tester app with New Architecture enabled on iOS
2. Open screen of RefreshControl component:

<img width="300" alt="Снимок экрана 2024-09-24 в 19 48 49" src="https://github.com/user-attachments/assets/94a2d02d-f3e3-4e18-a345-87c22d4a2620">

3. Open `/packages/rn-tester/js/examples/RefreshControl/RefreshControlExample.js` file and change properties `tintColor` and `progressViewOffset` of  RefreshControl components on the line 85:

<img width="300" alt="Снимок экрана 2024-09-24 в 22 01 19" src="https://github.com/user-attachments/assets/425826a6-d34c-4316-8484-e65f125a8b28">

4. check that your changes applied:

<img width="300" alt="Снимок экрана 2024-09-24 в 19 54 46" src="https://github.com/user-attachments/assets/b97621f1-b553-48c9-bc81-e04a99a7e099">

Reviewed By: cortinico

Differential Revision: D63381050

Pulled By: cipolleschi

fbshipit-source-id: 4f3aed8bd7a1e42ce2a75aa19740fd8be1623c86
2024-09-26 05:58:54 -07:00
Oskar Kwaśniewski 391680fe84 feat: improve RCTAppDelegate usage for brownfield (#46625)
Summary:
This PR improves the usage of `RCTAppDelegate` for brownfield scenarios.

Currently, when we want to integrate React Native with a brownfield app users might not want to initialize React Native in the main window. They may want to create it later.

Example usage:

```swift
class AppDelegate: RCTAppDelegate {
   override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
      // Disable automatically creating react native window
      self.automaticallyLoadReactNativeWindow = false

      return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
```

```swift
import Foundation
import React
import React_RCTAppDelegate

class SettingsViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    self.view = (RCTSharedApplication()?.delegate as? RCTAppDelegate)?.rootViewFactory .view(withModuleName: "Settings", initialProperties: [:])
  }
}
```

## Changelog:

[IOS] [ADDED] - improve RCTAppDelegate usage for brownfield, add `automaticallyLoadReactNativeWindow` flag

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

Test Plan: CI Green

Reviewed By: cortinico

Differential Revision: D63325397

Pulled By: cipolleschi

fbshipit-source-id: 1361bda5fcd91f4933219871c64a84a83c281c34
2024-09-26 05:39:01 -07:00
David Vacca 10a33e0479 Migrate ReactFeatureFlags.enableFabricRenderer -> ReactNativeFeatureFlags (#46493)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46493

Migrate:
- ReactFeatureFlags.enableFabricRenderer -> ReactNativeFeatureFlags.enableFabricRenderer()
- ReactFeatureFlags.useTurboModules -> ReactNativeFeatureFlags.useTurboModules()
- Rename ReactFeatureFlags.enableBridgelessArchitecture -> ReactNativeFeatureFlags.enableBridgelessArchitecture()

changelog: [Android][Breaking] Delete useTurboModules, enableFabricRenderer and enableBridgelessArchitecture fields from ReactFeatureFlags class

Reviewed By: rubennorte

Differential Revision: D60364016

fbshipit-source-id: e10a44fc08deb8969104b5cb0bd426dfb0a45d30
2024-09-26 04:29:27 -07:00
Vitali Zaidman 23e738fb6d allow waiting for metro to be torn down (#46620)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46620

The following error was thrown when the test `packages/metro/src/integration_tests/__tests__/server-test.js` was running on Metro:
{F1816961963}

It led me to investigate why don't we wait for Metro to be torn down.

Currently we close metro by closing the http server that it launches.
```
const httpServer = await Metro.runServer(/* ... */);
httpServer.close(callback);
```
While we can listen to the callback fired when the server is closed, it only covers one of the systems running internally in metro. The systems that are not covered are:
* File watchers
* File map workers
* Dependency graph
* Bundler

And many systems that were themselves listening to the above like "eslint file map" or the "dependency analysis".

**These systems are closed by us _after_ the server is closed.** This means that a listener to `server.on('close'` would only get the indication where these systems has started to close rather than actually got closed.
https://www.internalfb.com/code/fbsource/[17e03bc6bd86]/xplat/js/tools/metro/packages/metro/src/index.flow.js?lines=359-361

This diff introduces a way to wait for all of metro to be closed.

In this diff I use that new way of listening to Metro closure to get rid of the jest test warning mentioned above in `packages/metro/src/integration_tests/__tests__/server-test.js`:
```
  let serverClosedPromise;

  beforeEach(async () => {
    config = await Metro.loadConfig({
      config: require.resolve('../metro.config.js'),
    });

    let onCloseResolve;
    serverClosedPromise = new Promise(resolve => (onCloseResolve = resolve));
    httpServer = await Metro.runServer(config, {
      reporter: {update() {}},
      onClose: () => {
        onCloseResolve();
      },
    });
  });

  afterEach(async () => {
    httpServer.close();
    await serverClosedPromise;
  });
```

Changelog: [Feature] add `onClose` to `Metro.runServer` configuration allowing to wait for metro and all associated processes to be closed.

Reviewed By: huntie

Differential Revision: D61594124

fbshipit-source-id: e3c50ef986077503bce0caa42a9f9430efc65272
2024-09-26 03:42:49 -07:00
Michael Troger 7dcb10b6e7 Fix YogaConfig getting garbage collected #1678 (#46651)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46651

Fixes [https://github.com/facebook/yoga/issues/1678](https://github.com/facebook/yoga/issues/1678)

As described in the linked Issue, the problem is that the `YogaConfig` can get garbage collected by the JVM, while a `YogaNode` is still referring to it. This at some point leads to unexpected behaviour (0 values for `layoutWidth`/`layoutHeight`). The change coming with this PR makes sure the `YogaConfig` can not get garbage collected while it's used by a `YogaNode`.

Demo project to confirm the fix https://github.com/michaeltroger/yogabug

Kudos to rtPag, who helped identifying the issue.

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

Reviewed By: mdvacca

Differential Revision: D63416127

Pulled By: NickGerleman

fbshipit-source-id: efd87dac897e44d3664c228c40cda90f1e11c4f6
2024-09-25 23:53:17 -07:00
Shawn Dempsey 256adcab7b Add a new playground component to rntester (#46632)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46632

Changelog: [General][Added] Add Playground to RNTester for testing out features & submitting reproducers.

**Context**

- Adding the Playground from Catalyst to RNTester
- This should help folks test React Native features for a particular version

**Change**

- Add a new playground component to RNTester
- Add a new reducer action for opening an example from navbar press
- Fixed typing issues
- Add icon from this fb asset pack: https://www.internalfb.com/assets/set/facebook_icons/nucleus-beaker/variant_outline-size_24?q=beaker
- Matched background color using this imagemagick script

**dark**
```
convert input.png -fill 'rgb(178,180,186)' -colorize 100% output.png
```
**light**
```
convert input.png -fill 'rgb(81,82,84)' -colorize 100% output.png
```

Reviewed By: NickGerleman

Differential Revision: D61972594

fbshipit-source-id: 4a5523a84a6ef09d3266d5f56825907bd3fbe4b5
2024-09-25 23:29:11 -07:00
Rick Hanlon e9ec9fbde4 Refactor LogBox tests to spies (#46638)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46638

This is annoying, but in the next diff that fixes a bug I need to test using the default warning filter instead of a mock (really, all this mocking is terrible, idk why I did it this way).

Unfortunately, in Jest you can't just reset mocks from `jest.mock`, `restoreMocks` only resets spies and not mocks (wild right).

So in this diff I converted all the `jest.mock` calls to `jest.spyOn`. I also corrected some of the mocks that require `monitorEvent: 'warning',` like the warning filter sets.

I also added a test that works without the fix.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D63349615

fbshipit-source-id: 4f2a5a8800c8fe1a10e3613d3c2d0ed02fca773e
2024-09-25 19:28:05 -07:00
Rick Hanlon 2f85e28cde Add integration tests for console errors + ExceptionManager (#46636)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46636

Adds more integration tests for LogBox (currently incorrect, but fixed in a later diff).

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D63349614

fbshipit-source-id: 8f5c6545b48a1ed18aea08d4ecbecd7a6b9fa05a
2024-09-25 19:28:05 -07:00
Rick Hanlon 1787726bf9 Re-enable integration tests (#46639)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46639

These tests were skipped when we were switching to component stacks, which also hid a bug later in the stack. Re-enable them.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D63349616

fbshipit-source-id: ccde7d5bb3fcd9a27adf4af2068a160f02f7432a
2024-09-25 19:28:05 -07:00
Joe Vilches 8eadb84d32 Expose box sizing getters and setters in Yoga (#46630)
Summary:
X-link: https://github.com/facebook/yoga/pull/1701

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

I would like to write some tests for box sizing that will drive a lot of my development as I implement content box. To do that, I need this publicly exposed. Obviously not that ideal since this currently does not do anything. Maybe we can name the value in such a way that its clear it is in development?

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63135970

fbshipit-source-id: 7520823bf925364eae45341531e012e80ec92284
2024-09-25 15:46:55 -07:00
Joe Vilches 9ee5fffae0 Small perf fix for new iOS view clipping (#46629)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46629

If we clipped and had no border or corner radius we would end up hitting this path every time. We can optimize this a bit to avoid that.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63299597

fbshipit-source-id: 90031f964b7669049a4a2efe00a553c888d28cd7
2024-09-25 13:35:56 -07:00
Hailey 99ab845a5c convert NSNull to nil before checking type in readAsDataURL (#46635)
Summary:
This issue original arose out of https://github.com/bluesky-social/social-app/issues/5100. Copying the description (with my general understanding of the problem) from the patch PR to here as well.

There's a crash that comes up in the following, pretty specific scenario:

- Have a response that has an empty body
- Do not include a `content-type` header in the response
- Set the `x-content-type-options` header to `nosniff`

RN handles the response for a request in this block of code: https://github.com/facebook/react-native/blob/303e0ed7641409acf2d852c077f6be426afd7a0c/packages/react-native/Libraries/Blob/RCTBlobManager.mm#L314-L326

Here, we see that values of `nil` - which `[response MIMEType]` will return when no `content-type` is provided in the response and the actual type cannot be determined (https://developer.apple.com/documentation/foundation/nsurlresponse/1411613-mimetype) - gets converted to `NSNull` by `RCTNullIfNil`.

When we get back over to `readAsDataURL`, we see that we grab the type from the dictionary and check if its `nil` before calling `length` on the string. https://github.com/facebook/react-native/blob/303e0ed7641409acf2d852c077f6be426afd7a0c/packages/react-native/Libraries/Blob/RCTFileReaderModule.mm#L74-L77

However, this check is dubious, because the value will never actually be `nil`. It will always either be `NSString` or `NSNull` because of the `RCTNullIfNil` call made above and `[RCTConvert NSString]` seems to just return the input if it is `NSNull`.

## Changelog:

[IOS] [FIXED] - Convert `NSNull` to `nil` before checking `type` in `readAsDataURL`

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

Test Plan:
This is a little awkward to test, but essentially this comes up in the following scenario that is described (and "tested" as being fixed by tweaking) in https://github.com/bluesky-social/social-app/issues/5100. I have personally tested by using Cloudflare rules to add/remove that particular header from an empty body response. You could also test this with a little local web server if you want.

### Before

https://github.com/user-attachments/assets/deb86c68-2251-4fef-9705-a1c93584e83e

### After

https://github.com/user-attachments/assets/9ffab11b-b2c8-4a83-afd6-0a55fed3ae9b

Reviewed By: dmytrorykun

Differential Revision: D63381947

Pulled By: cipolleschi

fbshipit-source-id: b2b4944d998133611592eed8d112faa6195587bd
2024-09-25 04:47:54 -07:00
Oskar Kwaśniewski 65575e8399 feat: get react-native package name from package.json in codegen script (#46604)
Summary:
This PR fixes the retrieval of react native package name to retrieve it from package.json.

This fixes the annoying message in codegen that poped up when installing pods:

```
[Codegen] Found react-native-macos
[Codegen] CodegenConfig Deprecated Setup for react-native-macos.
    The configuration file still contains the codegen in the libraries array.
    If possible, replace it with a single object.

BEFORE:
    {
      // ...
      "codegenConfig": {
        "libraries": [
          {
            "name": "libName1",
            "type": "all|components|modules",
            "jsSrcsRoot": "libName1/js"
          },
          {
            "name": "libName2",
            "type": "all|components|modules",
            "jsSrcsRoot": "libName2/src"
          }
        ]
      }
    }

    AFTER:
    {
      "codegenConfig": {
        "name": "libraries",
        "type": "all",
        "jsSrcsRoot": "."
      }
    }
```

## Changelog:

[GENERAL] [CHANGED] - get react-native package name from package.json in codegen script

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

Test Plan: Install pods

Reviewed By: cortinico

Differential Revision: D63335543

Pulled By: arushikesarwani94

fbshipit-source-id: 0470e54f0fc7aa962918c889855c52648d11e32d
2024-09-25 01:28:23 -07:00
Eric Rozell 68a6b69b27 Fix PointerOverOut test (#46634)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46634

The PointerEventPointerOverOut.js test case is broken due to a changed assumption about the name of the native tag property (`_nativeTag` vs. `__nativeTag`). This fixes the broken assumption.

## Changelog

[General][Fixed] Fixed issue with W3C PointerEvents tests

Reviewed By: NickGerleman

Differential Revision: D63336621

fbshipit-source-id: b54270f1c1232de6845ef73cac52f06b9a85539c
2024-09-24 19:49:34 -07:00
Pieter De Baets 0cb32d5ac9 Cleanup Fresco SystraceRequestRequestListener (#46626)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46626

Remove `!!` by reusing lookup result.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D63316175

fbshipit-source-id: 1abfb20490831f26819aef4393c9629253d33ec6
2024-09-24 13:40:47 -07:00
Riccardo Cipolleschi 303e0ed764 Fix Increment and Decrement accessibility actions (#46617)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46617

This changes fixes the Increment/Decrement accessibility actions on iOS with the New Architecture.

## Changelog
[iOS][Fixed] - Make sure that the Increment and Decrement accessibility actions works on iOS

Reviewed By: javache

Differential Revision: D63263830

fbshipit-source-id: 99dca14a002e098db2d3b0e268af32cdab6ce786
2024-09-24 09:24:24 -07:00
Pieter De Baets a9551641b4 Cleanup Modal test code (#46603)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46603

Was debugging this test for the mounting instruction changes, and found some opportunities to clean this up.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D63258342

fbshipit-source-id: f7e6be58474f112993232ce5859ccb160f050ae8
2024-09-24 05:34:01 -07:00
Nicola Corti c005609b01 Properly set REACTNATIVE_MERGED_SO for autolinked libraries. (#46606)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46606

This fixes this issue reported here:
https://github.com/react-native-community/discussions-and-proposals/discussions/816#discussioncomment-10673136

reported by both SWM and Expo.

The problem is that `REACTNATIVE_MERGED_SO` is not properly set for autolinked libraries so they can't access it
to understand if the version of ReactNative has merged so libraries or not.
This fixes it, I've tested against
https://github.com/tomekzaw/repro-reactnative-merged-so
reproducer provided by tomekzaw

Changelog:
[Android] [Fixed] - Properly set `REACTNATIVE_MERGED_SO` for autolinked libraries

Reviewed By: rubennorte

Differential Revision: D63262687

fbshipit-source-id: c505dce9036bb4cd0366b7ab99412368963273af
2024-09-24 03:35:15 -07:00
Nick Gerleman fc8224036b Fix measuring text with incorrect hyphenationFrequency
Summary:
A typo means TextLayoutManager will incorrectly measure text as if `LineBreaker.HYPHENATION_FREQUENCY_NORMAL` is set, instead of the correct default of `LineBreaker.HYPHENATION_FREQUENCY_NONE` which we use to display the `TextView`. This causes truncation if hyphenation would have caused text to be shorter than if not hyphenated. Fix the typo.

Changelog: [Android][Fixed] - Fix measuring text with incorrect hyphenationFrequency

Reviewed By: mellyeliu

Differential Revision: D63293027

fbshipit-source-id: baaf2ae2676548cf0815ae96e324af273be6f99e
2024-09-23 17:52:30 -07:00
Jorge Cabiedes Acosta 7ab0002799 Disable outline props on old architecture (#46608)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46608

tsia

Changelog: [Android][Changed] - Disabling `outline` props on Android to stay consistent with iOS

Reviewed By: NickGerleman

Differential Revision: D63143626

fbshipit-source-id: 3eafe5beeb54b1619d94fe3d886ab19d445a0b09
2024-09-23 13:46:32 -07:00
Jorge Cabiedes Acosta 8ad4b7d0cf Fix outline drawing 1px width when outlineWidth = 0 (#46586)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46586

When Paint.strokeWidth is set to 0 its not actually 0 but "hairline mode" so  the fix is just to make outline not draw at all when outlineWidth = 0 {F1879399325}

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D63136220

fbshipit-source-id: 81ef7ce0b72158c6b7c332191d332008c5a919b4
2024-09-23 11:57:39 -07:00
Dmitry Rykun 6e0e712c2a Bring back shouldSkipStateUpdatesForLoopingAnimations feature flag (#46598)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46598

Changelog: [General][Changed] - Bring back shouldSkipStateUpdatesForLoopingAnimations feature flag

Facebook
Also bring back `skip_state_updates_for_looping_animations` MC. This will allow the experiment to participate in a holdout properly.

Reviewed By: GijsWeterings

Differential Revision: D63252185

fbshipit-source-id: 89bc9321b12f07bd9b3b52c4fc1021d34594ebc0
2024-09-23 10:56:06 -07:00
Pieter De Baets b846f94b1c Refactor FabricMountingManager to enable reuse of IntBuffer methods (#46600)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46600

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D63150556

fbshipit-source-id: 039a88d6444df53767be52b9e70c20ef2ffd99be
2024-09-23 09:08:00 -07:00
Renaud Chaput 3c54e1ee45 Fix <KeyboardAvoidingView> with floating keyboard on iPad (#44859)
Summary:
On iPadOS, users can change the kind of keyboard displayed onscreen, going from normal keyboard, to split keyboard (one half on the left of the screen, one half on the right), or a floating keyboard that you can move around the screen.

When a non-normal kind of keyboard is used, `<KeyboardAvoidingView>` calculations are all wrong and, depending on the `behavior` prop, can make your screen completely hidden.

This PR attempts to detect that the keyboard is not the "normal displayed-at-bottom-of-screen" keyboard, and forces `enable={false}` if this happens.

The approach of comparing the keyboard width with the window width comes from this comment: https://github.com/facebook/react-native/issues/29473#issuecomment-696658937

A better fix might be to detect the kind of keyboard used, but this involves native code changes and I do not know iOS enough to do that. In addition, I have not found an easy way to do it using iOS APIs after a quick search.

I also chose to cache the window width as a class attribute. Maybe this is not needed as `Dimensions.get('window').width` is very fast and can be called on every keyboard event?

This fixes https://github.com/facebook/react-native/issues/44068 and https://github.com/facebook/react-native/issues/29473

## Changelog:

[IOS] [FIXED] - Fix `<KeyboardAvoidingView>` with floating keyboard on iPadOS

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

Test Plan:
Tested using RNTester and the "Keyboard Avoiding View with different behaviors" example.

Before:

https://github.com/facebook/react-native/assets/42070/111598a3-286c-464d-8db8-73afb35cd7f9

After:

https://github.com/facebook/react-native/assets/42070/0b3bc94f-8b67-4f42-8a83-e11555080268

Reviewed By: cortinico

Differential Revision: D62844854

Pulled By: cipolleschi

fbshipit-source-id: 577444be50019572955a013969d78178914b5b8d
2024-09-23 07:59:33 -07:00
Pieter De Baets a6fcad7e27 Move ShadowNodePair to Differentiator (#46590)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46590

This API should not be part of the ShadowView header, since the class is only used by Differentiator. The ShadowView header should contain public API's that the mounting layer can consume.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D63148522

fbshipit-source-id: 0545777fd311424ccd2d66de8b47b5591e8175f7
2024-09-23 07:12:09 -07:00
Pieter De Baets 300db67b27 Remove unused FabricComponents mapping (#46591)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46591

This is a duplicate of FabricNameComponentMapping, which is not exposed. Checking GitHub codesearch, this API is not referenced elsewhere.

This component should be cleaned, with the mappings moved to a generic translation layer (eg in [ViewManagerRegistry](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java#L55)) or by fixing the JS callers.

Changelog: [Android][Removed] FabricComponents is removed from public API

Reviewed By: fabriziocucci

Differential Revision: D63099721

fbshipit-source-id: 7018deadc919e21cdf3482ae454baca72937611f
2024-09-23 07:12:09 -07:00
Pieter De Baets 9eafec48f3 Unbreak RN_SHADOW_TREE_INTROSPECTION flag (#46589)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46589

This is a useful too for debugging ShadowTree mutations, but was broken due to some recent build changes.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D63099720

fbshipit-source-id: 9ae5ee062ef9a6a99b2517e4eedd286cd6259fbe
2024-09-23 04:57:17 -07:00