Commit Graph
31000 Commits
Author SHA1 Message Date
Tomislav NovakandFacebook GitHub Bot 00725fadff Fix use-after-free in AsyncEventBeat (#43618)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43618

Both common and Android implementations of AsyncEventBeat use weak_ptrs
to determine if the object is still valid before invoking the callback.
Move the write to `isBeatCallbackScheduled_` down so it's protected by
that same check.

Changelog: [Internal]

Reviewed By: javache, NickGerleman

Differential Revision: D55226529

fbshipit-source-id: 9e2a34369346d11dcea69d120dfa5935320f9ba1
2024-03-25 17:07:53 -07:00
Rob HoganandFacebook GitHub Bot ac714b1c33 Inspector proxy: preserve ordering of messages from device (#43639)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43639

Currently, the `react-native/dev-middleware` inspector proxy intercepts `Debugger.scriptParsed` notifications from the target and replaces `sourceMapURL` with a data uri, via an async fetch from Metro. During this async fetch, other notifications from the debugger may pass through the proxy, which results in the frontend receiving them before `Debugger.scriptParsed`.

This reordering causes problems in breakpoint resolution and pausing, because `Debugger.breakpointResolved` and `Debugger.paused` events may reference `scriptId`s unknown to the frontend while the corresponding `Debugger.scriptParsed` is delayed.

In particular, breakpoint UI state and backend state can fall out of sync, and breakpoints hit may open to the incorrect source location.

This diff modifies the proxy to use a simple per-target promise queue to ensure messages are handled in the order they were received from the target.

Changelog:
[General][Fixed] Fix breakpoints opening to incorrect location or disappearing from debugger frontend UI.

Reviewed By: motiz88

Differential Revision: D55200617

fbshipit-source-id: 27c95f822266875ed668d0bf8a525da49554cafd
2024-03-25 13:02:00 -07:00
Rubén NorteandFacebook GitHub Bot 152f5f4a47 Back out "Add onUserLeaveHint support to ReactActivityDelegate #43488" (#43642)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43642

Changelog: [internal]

This change broke some apps at Meta. Reverting until we figure out a safe way to land this.

Reviewed By: rshest

Differential Revision: D55324557

fbshipit-source-id: 684d3dc3780fc41e2e91f367d97fa5cd392e6638
2024-03-25 12:26:55 -07:00
Andrew CoatesandFacebook GitHub Bot dbf8e3f5ba Add @types/react as optional peerDependency on packages that use it (#43509)
Summary:
Now that RN is providing TS type information, many of those .d.ts files depend on types from react.  In modern packagemanagers (Ex: pnpm) types/react will not be available to RN since it does not declare it as a dependency.

I also noticed that the types for react-native-popup-menu-android appear to be pointing to the wrong location.

Add types/react as a peerDependency on the packages that have .d.ts files that import from React.
Add types/react to peerDependencyMeta with optional:true to prevent users not using TS from requiring types/react.

## Changelog:

[GENERAL] [ADDED] Added types/react as an optional peerDependency

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

Reviewed By: cortinico

Differential Revision: D55225940

Pulled By: NickGerleman

fbshipit-source-id: 4cbab071928cb925baec45f55461559acc9a54e6
2024-03-25 12:23:16 -07:00
Rubén NorteandFacebook GitHub Bot 8a2cf6866d Disable shadow tree introspection by default (#43578)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43578

Changelog: [internal]

We have a feature to do some validation of the mount operations when committing new trees in Fabric. That's very slow but it was ok before because we were only doing this in debug mode and in the JS thread. We're moving some of this work to the UI thread instead and we're seeing an impact on scroll performance.

This disables this feature by default but leaves it in code to enable it when necessary for debugging.

Reviewed By: NickGerleman, sammy-SC

Differential Revision: D55138795

fbshipit-source-id: 45ca47ae2562cecb070691bf33d95c9108a9eca3
2024-03-25 09:50:21 -07:00
Rubén NorteandFacebook GitHub Bot f446cf6464 Enable synchronous state update dispatching behind a flag (#43580)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43580

Changelog: [internal]

This introduces a new feature flag to commit state updates synchronously from the UI thread (generally) instead of dispatching them to the JS thread to be processed there. We can do this now because we introduced a UI consistency mechanism in D55024832 to JS would see a consistent revision during the execution of a specific task.

Reviewed By: sammy-SC

Differential Revision: D55083029

fbshipit-source-id: 8aa84ddaee383f098252fa679cfb07012ba29bf8
2024-03-25 09:50:21 -07:00
Rubén NorteandFacebook GitHub Bot 04562dd48a Implement UI consistency in legacy RN layout APIs (#43579)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43579

Changelog: [internal]

This updates all the legacy layout APIs in React Native to make use of the UI consistency mechanism introduced in Fabric (if available, otherwise the behavior is the same we have now — we consume the latest version of the tree available).

Reviewed By: sammy-SC

Differential Revision: D55077309

fbshipit-source-id: f6ff2a4f6cd1a2040f0cfeffb1e68f4ec0240f91
2024-03-25 09:50:21 -07:00
Rubén NorteandFacebook GitHub Bot 67d6d09bce Implement UI consistency in DOM methods (#43577)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43577

Changelog: [Internal]

This updates all the DOM APIs in React Native (defined in the `NativeDOM` native module) to make use of the UI consistency mechanism introduced in Fabric (if available, otherwise the behavior is the same we have now — we consume the latest version of the tree available).

As part of that work, this creates a new `DOMMethods` class that implements all methods using purely C++ APIs (not JSI), moves a lot of logic that was specific for this functionality from `UIManager` to `DOMMethods` and modifies `NativeDOM` to use this new class.

This should make it easier to add unit tests for `DOMMethods` in the future.

Reviewed By: NickGerleman

Differential Revision: D55077311

fbshipit-source-id: f96bf5f3a97236fd24dbd2315256de4ce979e151
2024-03-25 09:50:21 -07:00
Rubén NorteandFacebook GitHub Bot 332355e80f Implement UI consistency mechanism for JS thread (#43581)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43581

Changelog: [internal]

This implements a mechanism to ensure that JavaScript tasks have a consistent view of the state of the UI during their execution.

## Context

Fabric allows committing new revisions of the ShadowTree from any thread, but we don't make use of this capability and instead always commit them from the JS thread (e.g.: when we schedule Fabric state updates to update the offset of a list on scroll). This was done to make sure that JS work didn't see changes in the state of the tree at random points during its execution. E.g.:

```
useEffect(() => {
  const rect = ref.current.getBoundingClientRect();
  // do something
  const newRect = ref.current.getBoundingClientRect();
  // `rect` and `newRect` should always be the same
}, []);
```

This isn't used by Reanimated at the moment, which means JS can inadvertently see the result of animations in non-specific times during execution.

You can find additional context about this in the [RFC for DOM Traversal & Layout APIs in RN](https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0607-dom-traversal-and-layout-apis.md#consistency-and-updates).

This works correctly at the moment, but we introduce a limitation in the execution model to prevent updating the tree synchronously from the main thread. One of the main problems this introduces is that computing intersections (for `IntersectionObserver`) relies on the information in the shadow tree, but this is updated asynchronously on scroll.

There are 2 potential solutions for that problem:
1) Send the timestamp of the scroll even with the state update to backdate the timestamps of the intersections. This could work but introduces more complexity and possibly accuracy problems due to batching those state updates with other changes (e.g.: what happens if we update the state and commit another tree in the same task? should we use the backdated timestamp or wait for mount?).
2) (**Preferred**/ this diff) Allow committing new revisions from any thread, but lock the JS thread into seeing a specific revision, which would only update/progress in specific moments when it's safe. Some of those moments would be:
    1) When we start a new JS task.
    2) When we commit a new tree from React (JS).

## Changes

This implements the solution outlined in 2), creating a few abstractions to handle what's the current tree that should be visible to JS and to lock/unlock it in specific moments.

More specifically:
* Creates `ShadowTreeRevisionProvider` as an abstract class for APIs consuming the visible revision of the ShadowTree (mainly DOM APIs and layout methods like `measure`, etc.).
* Creates `ShadowTreeRevisionConsistencyManager` as an abstract class to handle what trees are visible (with a `lockRevision` and `unlockRevision` to be called from `RuntimeScheduler` at the beginning and end of each JS task).
* Creates 2 different implementations of these abstractions:
  * One that preserves the current behavior (`LatestShadowTreeRevisionProvider`, which just returns the last committed revision at the time of the call).
  * One that locks revisions lazily (the first time they're accessed) (`LazyShadowTreeRevisionConsistencyManager`).

Reviewed By: sammy-SC

Differential Revision: D55024832

fbshipit-source-id: b59985bc83714ae7ec915baba72bf92b3d6fa140
2024-03-25 09:50:21 -07:00
CatStudioAppandFacebook GitHub Bot 1c8751a16a Update package.json to fix ccache_enabled option, fixes #43633 (#43634)
Summary:
I found in 0.74.0-rc.x, `ccache_enabled` is introduced. However, it is not being delivered via npm.

fixes https://github.com/facebook/react-native/issues/43633

Changelog: [iOS] [Fixed] - Adding ccache_clang wrapper scripts to package.json for distribution

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

Reviewed By: cortinico

Differential Revision: D55308743

Pulled By: blakef

fbshipit-source-id: e89a4bb3a1fbf8562d880b4c9d25dc9083717ba6
2024-03-25 09:41:12 -07:00
kassens (Meta Employee)andFacebook GitHub Bot 1fe26a181d Use declare const instead of declare var (#28599)
Summary:
Use `declare const` instead of `declare var`

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

Changelog: [Internal]

Reviewed By: rickhanlonii

Differential Revision: D55245665

Pulled By: kassens

fbshipit-source-id: 44cb1130a23f46bb5caf33e05c828d92e0344efc
2024-03-25 09:14:33 -07:00
Pieter De BaetsandFacebook GitHub Bot ee3d5f510c Fix retain cycle in ComponentNameResolverManager (#43611)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43611

Storing a global_ref to `jThis` in a JNI hybrid object leads to a reference cycle which cannot be cleaned up by Java GC. The Java object will keep the C++ object alive and vice versa.

In this class, we didn't seem to need this reference anyway.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D55240490

fbshipit-source-id: 9ba6f5b4b958cb273ad1923332b7b29a75630aea
2024-03-25 08:57:07 -07:00
Pieter De BaetsandFacebook GitHub Bot 12d22e5ff1 Avoid global_ref to javaPart in TurboModuleManager (#43613)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43613

Storing a global_ref to `jThis` in a JNI hybrid object leads to a reference cycle which cannot be cleaned up by Java GC. The Java object will keep the C++ object alive and vice versa.

We can replace the reference in this class by using the this pointer passed in when `installJSIBindings` is invoked.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D55241235

fbshipit-source-id: 64883752a87f363a52a9f6661d6ddaa24a56fe62
2024-03-25 07:46:45 -07:00
Moti ZilbermanandFacebook GitHub Bot 4cc3ed8b2c Update INTERNAL_CALLSITES_REGEX (#43604)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43604

Changelog: [Internal]

Syncs the internal and OSS versions of `INTERNAL_CALLSITES_REGEX` in the default RN Metro config.

Reviewed By: robhogan

Differential Revision: D55237394

fbshipit-source-id: 8986a69f8beeafccbab3548d8a2137c0bf19e0b3
2024-03-25 07:12:18 -07:00
Moti ZilbermanandFacebook GitHub Bot c6bc0b090f Add internal call sites to x_google_ignoreList (#43605)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43605

Changelog: [Internal]

Leverages https://developer.chrome.com/docs/devtools/x-google-ignore-list to mark more internal files as "third party", thus collapsing them by default in stack traces in modern versions of Chrome DevTools. The list of modules to collapse is the same one used by LogBox.

This likely only affects Meta usage, since Metro's default for [`isThirdPartyModule`](https://metrobundler.dev/docs/configuration/#isthirdpartymodule) already excludes all `node_modules`, but I'm making this change across Meta and OSS for consistency and to signal intent.

Reviewed By: huntie

Differential Revision: D55236653

fbshipit-source-id: d777ea31fb3d65608a487247924885c887ebbd94
2024-03-25 07:12:18 -07:00
Samuel SuslaandFacebook GitHub Bot 95a8c99f3f introduce experimental mechanism to subscribe to synchronous onScroll (#43593)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43593

changelog: [internal]

Introduce experimental mechanism to subscribe to synchronous onScroll from outside of ScrollView.

Reviewed By: yungsters

Differential Revision: D55066385

fbshipit-source-id: b7cc173cb32e736f49496c1e0ba37de782ca02aa
2024-03-25 06:32:29 -07:00
chenlong12580andFacebook GitHub Bot 274faf4b39 Delete useless local-cli dir (#43602)
Summary:
local-cli seems to have not been used, so we request to delete it

## Changelog:

[INTERNAL] [REMOVED] - Delete useless local-cli dir

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

Reviewed By: cortinico

Differential Revision: D55281532

Pulled By: blakef

fbshipit-source-id: 8109222dbf643f1b1c3de491b4f42c07d09d8e13
2024-03-25 04:27:54 -07:00
Jeff BahrandFacebook GitHub Bot 4c8e253d83 Migrate google java format from 1.7 -> 1.21.0 (#42754)
Summary:
X-link: https://github.com/facebookexternal/OculusManufacturing/pull/524

X-link: https://github.com/facebookexternal/fbpay/pull/3

X-link: https://github.com/facebook/screenshot-tests-for-android/pull/324

X-link: https://github.com/pytorch/executorch/pull/1771

X-link: https://github.com/facebook/igl/pull/68

X-link: https://github.com/facebook/mariana-trench/pull/153

X-link: https://github.com/facebook/fresco/pull/2757

X-link: https://github.com/facebook/litho/pull/974

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

X-link: https://github.com/facebook/hhvm/pull/9431

X-link: https://github.com/WhatsApp/eqwalizer/pull/52

X-link: https://github.com/facebookincubator/spectrum/pull/1858

X-link: https://github.com/fbsamples/metapay/pull/1

X-link: https://github.com/facebookincubator/fbjni/pull/95

X-link: https://github.com/facebookincubator/Battery-Metrics/pull/30

X-link: https://github.com/facebook/ktfmt/pull/440

X-link: https://github.com/facebook/flipper/pull/5456

X-link: https://github.com/facebook/hermes/pull/1290

X-link: https://github.com/facebook/TextLayoutBuilder/pull/35

X-link: https://github.com/facebook/SoLoader/pull/122

allow-large-files

This diff migrates google java format form 1.7 to 1.21.0. This update will allow for new language features from java 17 and 21. This diff also formats all necessary files.

 Changelog:
    [Internal][Changed] - Updated format from google-java-format 1.7 -> 1.21.0

Reviewed By: IanChilds

Differential Revision: D52786052

fbshipit-source-id: b675ae215084f340b93dfe628e329e696ca0616e
2024-03-23 16:07:04 -07:00
Sam ZhouandFacebook GitHub Bot 37e3626994 Fix some cyclic types (#43630)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43630

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D55271602

fbshipit-source-id: cb93fae6231ade6e5865dd7e0756a12568dece12
2024-03-23 13:42:20 -07:00
Phillip PanandFacebook GitHub Bot 38be5e35e6 decouple RCTBridge+Private from jsinspector-modern
Summary:
Changelog: [Internal]

fix for part of https://github.com/facebook/react-native/issues/43204

RCTBridge+Private is transitively bringing in boost in 0.74, which is causing build errors for some libs that were originally depending on it. this is because boost is a special pod that needs separate handling to link correctly.

let's simplify this problem by decoupling this header and moving the inspector specific logic into it's own category.

Reviewed By: motiz88, dmytrorykun

Differential Revision: D55228474

fbshipit-source-id: 28dacaf464b98fe1c164418934ab8101b47d7efb
2024-03-22 20:50:52 -07:00
Sam ZhouandFacebook GitHub Bot 9112c5b56d Fix hidden type error in react-native ahead of next flow release (#43629)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43629

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D55264363

fbshipit-source-id: f9908e28f0416c9c8ed05e0b097d887eddfee5f3
2024-03-22 19:18:48 -07:00
Soe LynnandFacebook GitHub Bot a1b318c18b Convert TouchableWithoutFeedback to a functional component (#43596)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43596

## Changelog: [Internal]

- Convert TouchableWithoutFeedback to a functional component.

Reviewed By: philIip

Differential Revision: D55115080

fbshipit-source-id: c288af8f60c6c2330e80966a78288c433a0d2be1
2024-03-22 18:44:16 -07:00
Moti ZilbermanandFacebook GitHub Bot b13e9f8f75 Add --create-diff mode to debugger-frontend sync script (#43621)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43621

Changelog: [Internal]

TSIA

Reviewed By: huntie

Differential Revision: D55244550

fbshipit-source-id: 5d3f408c51369d44e8dda1dc3768cac1125a21a4
2024-03-22 12:11:48 -07:00
Moti ZilbermanandFacebook GitHub Bot a45d6eafcc Update debugger-frontend from 0beb10c...a96803a (#43622)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43622

Changelog: [Internal] - Update `react-native/debugger-frontend` from 0beb10c...a96803a

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

Reviewed By: huntie

Differential Revision: D55245226

fbshipit-source-id: 662ed3e25ce68c0ed4a4e3332158fa36209ba24b
2024-03-22 12:08:49 -07:00
Jakub PiaseckiandFacebook GitHub Bot ad9f0b0ab8 Include boost headers needed by rrc_text and rrc_textinput (#43608)
Summary:
Updates `PreparePrefabHeadersTask` to copy more headers from `boost`, specifically those required by `rrc_text` and `rrc_textinput`.

## Changelog:

[ANDROID] [CHANGED] - Copy boost headers needed by `rrc_text` and `rrc_textinput`

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

Reviewed By: rshest

Differential Revision: D55241345

Pulled By: cortinico

fbshipit-source-id: e92164676ba78ee15b3678a55c9098b0c6214b69
2024-03-22 07:58:49 -07:00
Samuel SuslaandFacebook GitHub Bot e90b97553f add missing dependency of core library to cmake (#43606)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43606

changelog: [internal]

D54805494 broke CircleCI because it didn't list all of the required dependencies in CMakeList.txt

Reviewed By: cortinico

Differential Revision: D55240313

fbshipit-source-id: 7a27b1379831582556ddd72007f17cbd2d507b19
2024-03-22 06:42:55 -07:00
Nicola CortiandFacebook GitHub Bot c835f91457 Fix build from source for hermes-engine (#43609)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43609

When users are building from source for React Native they don't have an ndkVersion variable specified. So we want to fallback to the global NDK version we set for the whole build here.

Changelog:
[Android] [Fixed] - Fix build from source for hermes-engine

Reviewed By: dmytrorykun

Differential Revision: D55240603

fbshipit-source-id: 3c725a164b40e176548af8ada9fcb13d391ef017
2024-03-22 05:35:46 -07:00
Nicola CortiandFacebook GitHub Bot 84c1c6ea9b Follow-up with Review Feedback on RCTAppDelegate from #43526 (#43607)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43607

PR #43526 was accidentally merged with several changes excluded. I'm following up on those here.

Changelog:
[Internal] [Changed] - Follow-up with Review Feedback on RCTAppDelegate from #43526

Reviewed By: dmytrorykun

Differential Revision: D55240435

fbshipit-source-id: c296a1e14b7032b211551334ca7b5a6824e8d45c
2024-03-22 05:09:34 -07:00
zhongwuzwandFacebook GitHub Bot 0a125579f8 Invalidate displaylink when invalidate instance in bridgeless mode (#43603)
Summary:
`RCTDisplayLink` retains itself because of `CADisplayLink`, let's call `invalidate` to break the retain cycle. cc philIip

## Changelog:

[IOS] [FIXED] - [Fabric] Invalidate displaylink when invalidate instance in bridgeless mode

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

Test Plan: After instance invalidate, `RCTDisplayLink` deallocated .

Reviewed By: fabriziocucci

Differential Revision: D55239145

Pulled By: javache

fbshipit-source-id: d9ceb9cd3a2cd91700e917c909d7097dacba240b
2024-03-22 03:44:04 -07:00
Samuel SuslaandFacebook GitHub Bot 223e6dc898 introduce EventEmitter::experimental_flushSync (#43592)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43592

changelog: [internal]

Exposing experimental API EventEmitter::experimental_flushSync to trigger synchronous event from native. The API will be changed in the future, this is exposed only for experimentation.

Reviewed By: javache

Differential Revision: D54805494

fbshipit-source-id: fb395588cf1dc944a920ec4a2257390552850263
2024-03-22 02:33:16 -07:00
Gabriel DonadelandFacebook GitHub Bot 15a5638c62 Implement multiple view manager lookup for the interop layer on Android (#43595)
Summary:
When running with the new architurece and using the renderer interop layer on Android, view managers don't work if their names start with `RCT`. This happens because the `RCT` prefix is automatically removed from the component name, and inside the internal `mViewManagers` we store view managers with the `RCT` prefix.

Using the `RCT` pattern as a prefix works fine with the old architecture and is actually used on the [Android Native UI Components](https://reactnative.dev/docs/next/native-components-android) tutorial in the docs, making me believe that this same patterns is used across many community libraries.

This diff adds a secondary lookup logic for view managers:

1. We look for the XXXViewManager.
2. If not found, we look for RCTXXXViewManager.

Quite similar to the iOS implementation introduced in  https://github.com/facebook/react-native/pull/38093

 ---

With this change we can also remove most of the entries from FabricNameComponentMapping (I can address this in a follow up PR)

https://github.com/facebook/react-native/blob/4e6eba7a2dedaa855af0bff5df3bec73a95f0fc4/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/FabricNameComponentMapping.java#L22-L45

## Changelog:

[ANDROID] [ADDED] - Implement multiple view manager lookup for the interop layer

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

Test Plan:
Tested installing a library such as [react-native-fbsdk-next](https://github.com/thebergamo/react-native-fbsdk-next) that names its view managers starting with `RCT`

<table>
<tr>
  <th>Before</th>
  <th>After</th>
</tr>
<tr>
<td>
<img width="519" alt="image" src="https://github.com/facebook/react-native/assets/11707729/123de1d6-f018-424b-b6ce-38221af9d83e">
</td>
<td><img width="519" alt="image" src="https://github.com/facebook/react-native/assets/11707729/0f35b369-e2e4-4bbf-b880-6471fbc05d38">
</td>
</tr>
</table>

Reviewed By: cortinico

Differential Revision: D55208396

Pulled By: arushikesarwani94

fbshipit-source-id: a1fb1f4cee8483cf91ebededd1d7c4ba7021f9d9
2024-03-21 18:22:21 -07:00
Nicola CortiandFacebook GitHub Bot 24a3dade29 Fix InteropUIBlockListener to support react-native-view-shot on Bridgeless (#43594)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43594

I've been migrating `react-native-view-shot` to Fabric by using the `InteropUiBlockListener`
and I've realized that the interop layer doesn't work well.

1. FabricUIManager needs to implement `UIBlockViewResolver` in order for the interop layer to work correctly.
2. We need to hook `addUIBlock` to the `didDispatchMountItems` callback otherwise the UIBlocks won't be executed at all.

Changelog:
[Android] [Fixed] - Fix InteropUIBlockListener to support react-native-view-shot on Bridgeless

Reviewed By: javache

Differential Revision: D55187939

fbshipit-source-id: d048b4b5eed77fa856fdfac17c0df5f23fd44844
2024-03-21 16:18:28 -07:00
Oskar KwaśniewskiandFacebook GitHub Bot 9d79f05e68 fix(iOS): add missing forward blocks to RCTRootViewFactory (#43526)
Summary:
This PR adds missing forwarding blocks to RCTRootViewFactory, currently when a user tries to override `sourceURLForBridge` in AppDelegate it isn't overridden.

## Changelog:

[IOS] [FIXED] - add missing forward blocks to RCTRootViewFactory

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

Test Plan: Override: `extraModulesForBridge`, `extraLazyModuleClassesForBridge`, `bridge didNotFindModule`,  `sourceURLForBridge:` methods in AppDelegate and check if they are called on old architecture

Reviewed By: philIip

Differential Revision: D55186872

Pulled By: cortinico

fbshipit-source-id: 5988c7bab1439ccc4885b7337336c1e120ba9ea6
2024-03-21 15:29:25 -07:00
Nick GerlemanandFacebook GitHub Bot 1021448d7c Warn users during "pod install" if XCode is too old (#43583)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43583

Fail during `pod install` if user's version of XCode is too old to avoid cryptic errors (e.g. https://github.com/reactwg/react-native-releases/issues/163).

I reused existing mechanism for version detection, though it may not be reliable for future versions of XCode.

Changelog:
[iOS][Changed] - Warn users during "pod install" if XCode is too old

Reviewed By: dmytrorykun

Differential Revision: D55149636

fbshipit-source-id: 78387ff19a6eb10f3ca0d4aa78e6b934ae3b0711
2024-03-21 13:55:11 -07:00
Nick GerlemanandFacebook GitHub Bot 7d180d7127 Fix Android HorizontalScrollView fling when content length less than ScrollView length (#43563)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43563

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

## Sumary

D9405703 added some custom logic for Flings, to support FlatList scenarios where content is being added on the fly, during Fling animation. This works by allowing start Fling to not have bounds, then correcting/cancelling Fling when overscroll happens over a bound that would normally be allowed.

This has some math to try to determine max content length, and will clamp to this when scrolling over it. This logic is incorrect when content length is less than scrollview length, and we end up snapping to a negative offset.

This change adds clamping, so that we don't snap to negative position in horizontal scroll view. This clamping was already indirectly present on vertical scroll view. https://www.internalfb.com/code/fbsource/[b43cdf9b2fec71f5341ec8ff2d47e28a066f052e]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java?lines=609

## Test Plan

Above issue no longer reproes. Flinging while content is being added to horizontal FlatList still works correctly.

Changelog:
[Android][Fixed] - Fix Android HorizontalScrollView fling when content length less than ScrollView length

Reviewed By: javache

Differential Revision: D55108818

fbshipit-source-id: 7cf0065f9f92832cc2606d1c7534fc150407b9c9
2024-03-21 12:55:51 -07:00
Jakub PiaseckiandFacebook GitHub Bot 623bbe6bd6 Fix prefab header paths for rrc_text and rrc_textinput (#43591)
Summary:
- `rrc_textinput` at the moment points to a wrong subdirectory and needlessly adds a prefix path
- `rrc_text` is missing headers for `attributedstring` which it depends on

## Changelog:

[ANDROID] [FIXED] - Fixed prefab header paths for `rrc_text` and `rrc_textinput`

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

Reviewed By: fkgozali

Differential Revision: D55199580

Pulled By: cortinico

fbshipit-source-id: 85126c00943f82e908a52e05587661597761852e
2024-03-21 11:37:13 -07:00
Moti ZilbermanandFacebook GitHub Bot 511f29b8a7 Detect non-Fusebox frontends and log a message (#43574)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43574

Changelog: [Internal]

Once we start rolling out the Fusebox backend, users might still try to use the debugger frontends they're used to, for which we can't guarantee reliability. Let's detect this and log a message letting them know about the supported Fusebox launch flows.

Reviewed By: huntie

Differential Revision: D55122115

fbshipit-source-id: a17c0c6b9140059f489e0852fe673306fb6ef8f5
2024-03-21 10:39:33 -07:00
Moti ZilbermanandFacebook GitHub Bot bdd1fb5e05 Add helpers to allow HostAgent/InstanceAgent to send simple console messages (#43575)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43575

Changelog: [Internal]

Adds the `HostAgent::sendConsoleMessage` and `InstanceAgent::sendConsoleMessage` helper methods, allowing the agent implementations to send simple, text-only console messages (using `Runtime.consoleAPICalled`) from the inspector thread, without involving the Runtime (and the JS thread).

We also update the tests to ignore such messages by default, since otherwise we would encounter a lot of unexpected mock calls.

## Context

We currently use `Log.entryAdded` messages for logs generated by the CDP backend itself. This cleanly separates backend-generated messages from app-generated `Runtime.consoleAPICalled` messages (including in tests), and avoids the need to provide an `executionContextId` for protocol compliance.

However, it turns out that frontends don't consistently support the `Log` domain - in particular, `chrome://inspect` doesn't show `Log` messages for targets of type `node` (which is how RN lists itself in the `/json` endpoint). For the majority of our `Log.entryAdded` use cases, this doesn't matter. But it does mean that if we want a log message to be visible regardless of the frontend, we need to send `Runtime.consoleAPICalled` messages instead.

The one concrete use case for this at the moment is detecting non-Fusebox clients and logging an explanatory message to point users to Fusebox. We can likely refactor most *existing* uses of `Log.entryAdded` in our code to use `sendConsoleMessage`, but I've opted not to do that here. Those are primarily useful within our team and can be deleted once Fusebox is out of testing.

Reviewed By: huntie

Differential Revision: D55130368

fbshipit-source-id: 4bc6a91efe63db6753250a3d383fd497c9f5f7b5
2024-03-21 10:39:33 -07:00
Arushi KesarwaniandFacebook GitHub Bot 62ebe557b8 Expose ReactDelegate for react-native-restart (#43588)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43588

Supported `reload()` in Bridgeless through ReactDelegate in https://github.com/facebook/react-native/pull/43521 in order to unblock react-native-restart

https://github.com/avishayil/react-native-restart/blob/134cabd5b3f355ffe551e5dd1be1dd46d870fe13/android/src/main/java/com/reactnativerestart/RestartModule.java#L54

which can access React Delegate through :
```
if(currentActivity instanceof ReactActivity) {
    ReactActivity reactActivity = (ReactActivity) currentActivity;
    ReactDelegate reactDelegate = reactActivity.getReactDelegate();
    reactDelegate.reload()
}
```

Changelog:
[Android][Added] Expose ReactDelegate in ReactActivity

Reviewed By: cortinico

Differential Revision: D55166962

fbshipit-source-id: 5d8dfd7ad61edbcb5233014800eb66a538842ca5
2024-03-21 09:40:32 -07:00
Samuel SuslaandFacebook GitHub Bot c574ca59dc refactor metrics for ScrollViewEventEmitter (#43532)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43532

changelog: [internal]

- use designated initializers.
- make ScrollViewMetrics a struct.
- move ScrollViewMetrics inside of ScrollViewEventEmitter.

This is to be more consistent with other event emitters.

Reviewed By: rubennorte

Differential Revision: D54896331

fbshipit-source-id: 01aecd1835b23bdaccff1355d33eb7b4c5ba8d92
2024-03-21 08:11:49 -07:00
Moti ZilbermanandFacebook GitHub Bot 1c52d385de Create a universal way to force-enable Fusebox at Buck build time (#43589)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43589

Changelog: [Internal]

Adds a way of enabling the Fusebox backend in React Native regardless of the corresponding feature flags. This is only supported in the Buck build and not intended for use in OSS.

Reviewed By: huntie

Differential Revision: D55144502

fbshipit-source-id: 116cd30464acfbd3fafc503300f94cb238adeda8
2024-03-21 04:04:04 -07:00
Rubén NorteandFacebook GitHub Bot 0267ca0a40 Move DOM APIs to native module (#43512)
Summary:
Changelog: [internal]

This moves all the new methods that were added to implement the DOM traversal and layout APIs (as per this RFC: https://github.com/react-native-community/discussions-and-proposals/pull/607) to a separate C++ native module to avoid bloating the UIManager interface, initialize lazily, provide automatic caching of methods, simplify the API for implementors, etc.

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

Reviewed By: sammy-SC

Differential Revision: D54903376

fbshipit-source-id: 69daa84c886d1c65dbb0b223dbb7c9077502c6ad
2024-03-20 11:25:03 -07:00
Joe VilchesandFacebook GitHub Bot 21b008ed40 Convert FilterHelper.java to Kotlin (#43535)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43535

tsia

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D54914028

fbshipit-source-id: 78d3dd20a8e98b4d4a2335b5542e4879a4cf3e41
2024-03-20 10:43:09 -07:00
Moti ZilbermanandFacebook GitHub Bot 9c48121b4e Update debugger-frontend from 622246a...0beb10c (#43576)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43576

Changelog: [Internal]

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebookexperimental/rn-chrome-devtools-frontend/compare/622246a3aeff4b1b47e55153a7c89be37fd14e59...0beb10c594a2847ec696e3b7f6e26a01a849c799
).

Reviewed By: robhogan

Differential Revision: D55136910

fbshipit-source-id: 77e2a283999a63bfba98939f878b752694be3c74
2024-03-20 10:36:06 -07:00
Wojciech DróżdżandFacebook GitHub Bot 6450d08187 Add onUserLeaveHint support to ReactActivityDelegate #43488 (#43567)
Summary:
This PR adds `onUserLeaveHint` support into the `ReactActivityDelegate`. It allows modules to receive an event every time user moves the app into the background. This is slightly different than `onPause` - it's called only when the user intentionally moves the app into the background, e.g. when receiving a call `onPause` should be called but `onUserLeaveHint` shouldn't.

This feature is especially useful for libraries implementing features like Picture in Picture (PiP), where using `onUserLeaveHint` is the [recommended way of auto-entering PiP](https://developer.android.com/develop/ui/views/picture-in-picture#:~:text=You%20might%20want%20to%20include%20logic%20that%20switches%20an%20activity%20into%20PiP%20mode%20instead%20of%20going%20into%20the%20background.%20For%20example%2C%20Google%20Maps%20switches%20to%20PiP%20mode%20if%20the%20user%20presses%20the%20home%20or%20recents%20button%20while%20the%20app%20is%20navigating.%20You%20can%20catch%20this%20case%20by%20overriding%20onUserLeaveHint()%3A) for android < 12.

This is a re-submission of https://github.com/facebook/react-native/pull/42741 and https://github.com/facebook/react-native/pull/43488 without problematic asserts, which were unnecessary (`onUserLeaveHint` is not critical to the lifecycle of the app), but were causing problems in some apps.

## Changelog:

[ANDROID] [ADDED] - Added `onUserLeaveHint` support into `ReactActivityDelegate`

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

Test Plan: Tested in the `rn-tester` app - callbacks are correctly called on both old and new architecture.

Reviewed By: javache

Differential Revision: D55123632

Pulled By: cortinico

fbshipit-source-id: 144a1d84b691af9cf3c0cffad446e674b4b68927
2024-03-20 09:19:35 -07:00
Cedric van PuttenandFacebook GitHub Bot 652c74104a fix(dev-middleware): create custom message handler for synthetic page (#43559)
Summary:
This is a follow-up bugfix for expo/expo#27425, related to:
 - https://github.com/facebook/react-native/issues/43291
 - https://github.com/facebook/react-native/issues/43307
 - https://github.com/facebook/react-native/issues/43310
 - https://github.com/facebook/react-native/issues/43364

The middleware API works as intended and can run our extended CDP events. Unfortunately, this only applies to an actual `Page` from the device, not for the `React Native Experimental (Improved Chrome Reloads)` synthetic / virtual page.

That's because the middleware instantiation gets aborted when the page can't be found in `this.#pages.get(pageId)`, which always returns `null` for this synthetic page.

## Changelog:

[GENERAL] [FIXED] Create custom message handler for synthetic page

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

Test Plan: See added test case.

Reviewed By: motiz88

Differential Revision: D55129412

Pulled By: huntie

fbshipit-source-id: 9679d8fe68f3cb4104f4a042f93612b995baddc9
2024-03-20 08:59:46 -07:00
Alex HuntandFacebook GitHub Bot d03b5dca74 Adjust version parsing in release scripts, fix release dry runs in CI (#43568)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43568

Fixes to restore passing CI checks on main after D55027120.

- Widen validation checks in version utils to accept `0.x.x` (as opposed to `0.[not-'0'].x`).
- Use `tag: test` instead of `tag: latest` for dry run job params.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D55123739

fbshipit-source-id: 9f76dced4e7aa3ce87d6680cd7687ae443305331
2024-03-20 08:07:36 -07:00
Moti ZilbermanandFacebook GitHub Bot 1fe82671e8 Update debugger-frontend from 9ceb0ad...622246a (#43571)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43571

Changelog: [Internal]

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebookexperimental/rn-chrome-devtools-frontend/compare/9ceb0ade8033ec165bbfbd41c08ac1fcd9f89a46...622246a3aeff4b1b47e55153a7c89be37fd14e59
).

Reviewed By: huntie

Differential Revision: D55125722

fbshipit-source-id: e2998d3ec75e39f744d20672b9cee76ccac27964
2024-03-20 06:54:31 -07:00
Moti ZilbermanandFacebook GitHub Bot b7c1bd4e89 Remove console logs from Metro when native debugger console is available
Summary:
Changelog: [Internal] Remove console logs from Metro when native Fusebox debugger console is available

React Native currently sends all `console.log` messages to Metro, which prints them to the terminal. This feature has been in place since 2019 (D15559151) but is pretty limited when compared to what's available in modern browsers. Most of the limitations can't really be fixed within the constraints of Metro's relatively simple terminal infrastructure.

With the new React Native debugger (codenamed "Fusebox") we aim to fundamentally elevate the debugging experience by shipping a well-tested version of Chrome DevTools with React Native. Chrome DevTools has a rich, interactive console, as well as a host of other debugging features we want developers to notice and use.

To that end, we plan to **strongly nudge users towards the Fusebox console from day 1**. Specifically, if we detect that Fusebox is available and is using an engine which implements CDP `console` support ( = Hermes only for now), we'll no longer send logs to Metro, and will instead display an explanatory message directing users to Fusebox.

Reviewed By: huntie

Differential Revision: D54829811

fbshipit-source-id: 2b1cdb666094f901ff4e7f42b123271be4ce7d10
2024-03-20 06:31:34 -07:00
Moti ZilbermanandFacebook GitHub Bot b79e488cc5 Log a message identifying Fusebox based on a handshake with the frontend (#43565)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43565

Changelog: [Internal]

Uses https://github.com/facebookexperimental/rn-chrome-devtools-frontend/pull/24 to identify the Fusebox frontend and show a corresponding message in the logs.

Also tweaks the wording and formatting of other messages logged by the Fusebox backend - including removing the "you are using the modern CDP backend" one.

Reviewed By: huntie

Differential Revision: D55075645

fbshipit-source-id: c82670570c79b61efd399f26684139ce97f017ef
2024-03-20 06:12:58 -07:00