Commit Graph
31057 Commits
Author SHA1 Message Date
Ruslan ShestopalyukandFacebook GitHub Bot 1e44cbe9f4 Migrate ErrorType.java to Kotlin (#43727)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43727

# Changelog:
[Internal] -

As in the title, converts this one particular Java file to Kotlin.

Reviewed By: arushikesarwani94

Differential Revision: D55574526

fbshipit-source-id: 04af5b870670a5560eaba7ab8c029c580032d09a
2024-04-01 12:37:48 -07:00
Tommy NguyenandFacebook GitHub Bot 489d9f6c62 fix: version checker not considering nightlies (#43712)
Summary:
Fix version checker not considering nightlies:

```
  WARNING: You should run npx react-native@latest to ensure you're always using the most current version of the CLI. NPX
 has cached version (0.74.0-nightly-20240214-b8ad91732) != current release (0.73.6)
```

## Changelog:

[GENERAL] [FIXED] - Fix version checker not considering nightlies

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

Test Plan: On a recent nightly version, run any cli command.

Reviewed By: rshest

Differential Revision: D55525055

Pulled By: zeyap

fbshipit-source-id: 6dd08e30e542d9ddd191bf95c968a26c0cc14e4e
2024-04-01 12:37:05 -07:00
Alexander EggersandFacebook GitHub Bot b9dad7fc0c fix: prevent error when react extension was already created (#43694)
Summary:
Currently the react-native-gradle-plugin does not allow the "react" plugin extension to already exist when running its apply block. I had a use-case where I wanted to create a new gradle plugin which would take care of applying the react plugin including setting some of its options. Without the change in this PR, this would currently turn into a build failure.

## Changelog:

[ANDROID] [FIXED] - prevent error when the "react" extension was already created by another gradle plugin

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

Reviewed By: rshest

Differential Revision: D55478611

Pulled By: zeyap

fbshipit-source-id: cc743a99cb72ed315d21c52597efd5ee92a3be62
2024-04-01 11:31:53 -07:00
Ruslan ShestopalyukandFacebook GitHub Bot 220588004b ImageResizeMethod/Mode to Kotlin (#43725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43725

## Changelog:
[Internal] -

Converts `react/views/image/ImageResizeMethod.java` and `react/views/image/ImageResizeMode.java` to Kotlin.

Grouped together, as it kind of makes sense.

Reviewed By: fabriziocucci

Differential Revision: D55574319

fbshipit-source-id: 5fb47425e1eb0fca1e06527e16e994d659a749a8
2024-03-31 16:14:53 -07:00
Rob HoganandFacebook GitHub Bot 8769378e0d Delete unused RCT_ENABLE_LOADING_FROM_PACKAGER (#43677)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43677

Remove `RCT_ENABLE_LOADING_FROM_PACKAGER` from `RCTDefines`, as it is not referenced anywhere and does nothing.

Changelog: [Internal]

Reviewed By: hoxyq, realsoelynn

Differential Revision: D55421282

fbshipit-source-id: ae29a8a421a6cc23d863b489eae2175392f684cd
2024-03-31 08:46:03 -07:00
Ramanpreet NaraandFacebook GitHub Bot fa4bfde630 Revert D55505416: Pull react instance method impls out of ReactContext
Differential Revision:
D55505416

Original commit changeset: ce1e3ab379eb

Original Phabricator Diff: D55505416

fbshipit-source-id: ae988ae3464f40923521922d4c3ac4a57846a3ef
2024-03-31 06:10:45 -07:00
Ramanpreet NaraandFacebook GitHub Bot 14fb1cc335 Pull react instance method impls out of ReactContext
Summary:
## Context
Prior, ReactContext used to implement bridge logic.

For bridgeless mode, we created BridgelessReactContext < ReactContext

## Problem

This could lead to failures: we could call bridge methods in bridgeless mode.

## Changes
Primary change:
- Make all the react instance methods inside ReactContext abstract.

Secondary changes: Implement react instance methods in concrete subclasses:
- **New:** BridgeReactContext: By delegating to CatalystInstance
- **New:** ThemedReactContext: By delegating to inner ReactContext
- **Unchanged:** BridgelessReactContext: By delegating to ReactHost

## Auxiliary changes
This fixes ThemedReactContext in bridgeless mode.

**Problem:** Prior, ThemedReactContext's react instance methods did not work in bridgeless mode: ThemedReactContext wasn't initialized in bridgeless mode, so all those methods had undefined behaviour.

**Solution:** ThemedReactContext now implements all react instance methods, by just forwarding to the initialized ReactContext it decorates (which has an instance).

Changelog: [Android][Removed] Delete ReactContext.initializeWithInstance(). ReactContext now no longer contains legacy react instance methods. Please use BridgeReactInstance instead.

 ---

Reviewed By: fkgozali

Differential Revision: D55505416

fbshipit-source-id: ce1e3ab379eb788d26130dd44a66544aada3db02
2024-03-30 16:53:30 -07:00
Rob HoganandFacebook GitHub Bot e05319cc87 Inspector proxy: catch and report errors in device message handling (#43697)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43697

Currently, messages from a device are handled by async handlers added to a promise chain.

If a handler rejects, the end of the chain becomes a rejected promise, picked up only asynchronously by Metro's global `unhandledRejection` handler.

This triggers a warning from Node.js, and worse, prevents any `then()` callback chained by subsequent messages from being invoked at all.

Handlers *should* attempt to gracefully deal with errors (as we do with source map fetching errors, for example), but this diff adds a catch-all fallback for anything we might've missed (in this case, a frontend socket disconnecting while we're busy fetching a source map). Errors are caught and logged to EventReporter.

**To follow**: Gracefully handle socket disconnections while an async handler is working or queued.

Changelog:
[General][Fixed] Inspector proxy: prevent errors proxying a device message from blocking the handler queue or spamming logs.

Reviewed By: EdmondChuiHW

Differential Revision: D55482735

fbshipit-source-id: bb726218495e105f9cb4f723a1d110c9815abdef
2024-03-30 15:29:47 -07:00
Christoph PurrerandFacebook GitHub Bot 04bf8cfb23 Clean up old Cxx TM member generation (#43710)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43710

As we had already cut a branch for RN 0.74
https://github.com/facebook/react-native/releases/tag/v0.74.0-rc.1

We can delete this code already

Changelog: [Internal]

Reviewed By: shwanton

Differential Revision: D55511382

fbshipit-source-id: 3ef15af338b5ad31b02e0a1eed7ac873566d9562
2024-03-29 14:39:24 -07:00
Alex Taylor (alta)andFacebook GitHub Bot 1b4a0cd9f2 Use hook syntax for builtin React hooks in xplat (1/2) (#43714)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43714

Migrate React builtin hooks to use the new React "hook" type. This diff converts all builtin hooks except for `useContext` which will be updated after the next flow release.

Details:
- Announcement: https://fb.workplace.com/groups/react.fyi/posts/7642294409114198
- Docs: https://www.internalfb.com/intern/wiki/Component_Syntax_Documentation/Hook_syntax_0/
- Support group: https://fb.workplace.com/groups/749069370011855

Changelog: [internal]

Reviewed By: SamChou19815

Differential Revision: D55500989

fbshipit-source-id: 8a13898b1d2e851dfc2afed3b41e0f1a6332b6bd
2024-03-29 14:24:01 -07:00
Nick GerlemanandFacebook GitHub Bot 3f88821167 Avoid TextInput example styles causing non-deterministic rendering on iOS (#43599)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43599

iOS E2E tests non-deterministic rendering happens around examples with a border set to `StyleSheet.hairlineWidth`. That value has special subpixel math, that doesn't seem to render consistently on iOS (this is its own bug).

To unblock adding some new E2E iOS TextInput tests, this removes usage of `hairlineWidth` in styles, and more generally, tries to unify TextInput styles in the examples.

This will break a whole bunch of RNTester Jest E2E baselines on different apps, which I will update from land-time runs or after continuous builds are available for different endpoints.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D55213090

fbshipit-source-id: 6d81b9355adc538a3ade6f50ef93c3ca08782ae7
2024-03-29 02:41:26 -07:00
78d6873b04 Don't Rethrow Errors at the Root (#28627)
Summary:
Stacked on top of #28498 for test fixes.

### Don't Rethrow

When we started React it was 1:1 setState calls a series of renders and
if they error, it errors where the setState was called. Simple. However,
then batching came and the error actually got thrown somewhere else.
With concurrent mode, it's not even possible to get setState itself to
throw anymore.

In fact, all APIs that can rethrow out of React are executed either at
the root of the scheduler or inside a DOM event handler.
If you throw inside a React.startTransition callback that's sync, then
that will bubble out of the startTransition but if you throw inside an
async callback or a useTransition we now need to handle it at the hook
site. So in 19 we need to make all React.startTransition swallow the
error (and report them to reportError).

The only one remaining that can throw is flushSync but it doesn't really
make sense for it to throw at the callsite neither because batching.
Just because something rendered in this flush doesn't mean it was
rendered due to what was just scheduled and doesn't mean that it should
abort any of the remaining code afterwards. setState is fire and forget.
It's send an instruction elsewhere, it's not part of the current
imperative code.

Error boundaries never rethrow. Since you should really always have
error boundaries, most of the time, it wouldn't rethrow anyway.

Rethrowing also actually currently drops errors on the floor since we
can only rethrow the first error, so to avoid that we'd need to call
reportError anyway. This happens in RN events.

The other issue with rethrowing is that it logs an extra console.error.
Since we're not sure that user code will actually log it anywhere we
still log it too just like we do with errors inside error boundaries
which leads all of these to log twice.
The goal of this PR is to never rethrow out of React instead, errors
outside of error boundaries get logged to reportError. Event system
errors too.

### Breaking Changes

The main thing this affects is testing where you want to inspect the
errors thrown. To make it easier to port, if you're inside `act` we
track the error into act in an aggregate error and then rethrow it at
the root of `act`. Unlike before though, if you flush synchronously
inside of act it'll still continue until the end of act before
rethrowing.

I expect most user code breakages would be to migrate from `flushSync`
to `act` if you assert on throwing.

However, in the React repo we also have `internalAct` and the
`waitForThrow` helpers. Since these have to use public production
implementations we track these using the global onerror or process
uncaughtException. Unlike regular act, includes both event handler
errors and onRecoverableError by default too. Not just render/commit
errors. So I had to account for that in our tests.

We restore logging an extra log for uncaught errors after the main log
with the component stack in it. We use `console.warn`. This is not yet
ignorable if you preventDefault to the main error event. To avoid
confusion if you don't end up logging the error to console I just added
`An error occurred`.

### Polyfill

All browsers we support really supports `reportError` but not all test
and server environments do, so I implemented a polyfill for browser and
node in `shared/reportGlobalError`. I don't love that this is included
in all builds and gets duplicated into isomorphic even though it's not
actually needed in production. Maybe in the future we can require a
polyfill for this.

### Follow Ups

In a follow up, I'll make caught vs uncaught error handling be
configurable too.

---------

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

Changelog:
[Internal]

Reviewed By: kassens

Differential Revision: D55408481

Pulled By: yungsters

fbshipit-source-id: 598aa306369e21cb3e93ad6041a87bfbaa9eef9e

Co-authored-by: Ricky Hanlon <rickhanlonii@gmail.com>
2024-03-29 01:42:24 -07:00
Tim YungandFacebook GitHub Bot e175912e7d RN: Fix Open Source Test Scripts
Summary:
Changelog:
[Internal]

Reviewed By: NickGerleman

Differential Revision: D55502889

fbshipit-source-id: aabba96bd816982f7bce9cbd752ba9eee409bbf6
2024-03-29 01:42:24 -07:00
TatianaKaposandFacebook GitHub Bot d0cac87c6e Fix [Windows]: Rename utils/jsi files (#43700)
Summary:
This PR: https://github.com/facebook/react-native/pull/42801/files#diff-ff466c93fb60f2b0e79ed187f492c9935349a2b2f2a7300b310e2bb30e31c33e creates a new jsi.h and jsi.cpp file in ReactCommon. On windows, even though the files have different paths, MSVC doesn't allow two files to have the same name in the same project. This PR changes the name of the new jsi.h and jsi.cpp files.

## Changelog:

[General][Fixed] - Rename utils/jsi files

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

Test Plan: tested on windows

Reviewed By: zeyap

Differential Revision: D55491700

Pulled By: arushikesarwani94

fbshipit-source-id: 2995c0602a9528ed0f8e8eb2230945cb6bd516e9
2024-03-28 20:03:38 -07:00
Viresh UmbreandFacebook GitHub Bot f7ec4694a6 Revert D53145010: Pull react instance method impls out of ReactContext
Differential Revision:
D53145010

Original commit changeset: 2405bc24afb0

Original Phabricator Diff: D53145010

fbshipit-source-id: 2d37cef8f6b6810f9b114ea633373668bcc805dc
2024-03-28 16:14:07 -07:00
Fabrizio BertoglioandFacebook GitHub Bot f6badca2f9 Fix Multiline TextInput with a fixed height scrolls to the bottom when prepending new lines to the text (#38679)
Summary:
### Please re-state the problem that we are trying to solve in this issue.

Multiline TextInput with a fixed height will scroll to the bottom of the screen when prepending new lines to the text.

### What is the root cause of that problem?

The issue is caused by iOS UITextView:
- The cursor moves to the end of the text when prepending new lines.
- Moving the cursor to the end of the text triggers the scroll to the bottom.

The behavior was reproduced on an iOS App (without react-native).
The example included below implements a Component RCTUITextView based on UITextView, which modifies the UITextView attributedText with the textViewDidChange callback (source code available in this [comment](https://github.com/Expensify/App/issues/19507#issuecomment-1595730348)).

Adding a new line on top of the UITextView on iOS results in:
Issue 1) The cursor moves to the end of TextInput text
Issue 2) The TextInput scrolls to the bottom

<details><summary>Reproducing the issue on an iOS App without react-native</summary>
<p>

<video src="https://user-images.githubusercontent.com/24992535/246601549-99f480f3-ce80-4678-9378-f71c8aa67e17.mp4" width="900" />

</p>
</details>

Issue 1) is already fixed in react-native, which restores the previous cursor position (on Fabric with  [_setAttributedString](https://github.com/fabriziobertoglio1987/react-native/blob/71e7bbbc2cf21abacf7009e300f5bba737e20d17/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L600-L610)) after changing the text.
Issue 2) needs to be fixed in react-native.

### What changes do you think we should make in order to solve the problem?

Setting the correct TextInput scroll position after re-setting the cursor.

## Changelog:

[IOS] [FIXED] - Fix Multiline TextInput with a fixed height scrolls to the bottom when changing AttributedText

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

Test Plan:
Fabric (reproduces on controlled/not controlled TextInput example):

| Before    | After |
| ----------- | ----------- |
| <video src="https://github.com/facebook/react-native/assets/24992535/e06b31fe-407d-4897-b608-73e0cc0f224a" width="350" />      | <video src="https://github.com/facebook/react-native/assets/24992535/fa2eaa31-c616-43c5-9596-f84e7b70d80a" width="350" />       |

Paper (reproduces only on controlled TextInput example):

```javascript
function TextInputExample() {
  const [text, setText] = React.useState('');

  return (
    <View style={{marginTop: 200}}>
      <TextInput
        style={{height: 50, backgroundColor: 'white'}}
        multiline={true}
        value={text}
        onChangeText={text => {
          setText(text);
        }}
      />
    </View>
  );
}
```

| Before    | After |
| ----------- | ----------- |
| <video src="https://github.com/facebook/react-native/assets/24992535/6cb1f2de-717e-4dce-be0a-644f6a051c08" width="350" />      | <video src="https://github.com/facebook/react-native/assets/24992535/dee6edb6-76c6-48b0-b78f-99626235d30e" width="350" />       |

Reviewed By: sammy-SC, cipolleschi

Differential Revision: D48674090

Pulled By: NickGerleman

fbshipit-source-id: 349e7b0910e314ec94b45b68c38571fed41ef117
2024-03-28 16:05:06 -07:00
Rob HoganandFacebook GitHub Bot fd1e5e7063 Inspector proxy: Fix "Buffer() is deprecated" warning (#43686)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43686

Under Node 20, the use of `new Buffer(string)` is deprecated and logs a warning. This replaces it with the recommended `Buffer.from(string)`.

Changelog:
[General][Fixed] FIx "Buffer() is deprecated" warning from debugger proxy.

Reviewed By: huntie

Differential Revision: D55472025

fbshipit-source-id: 8b5af9e2d7e026cbdf6aa68f71ff0f856fb164db
2024-03-28 15:17:02 -07:00
Samuel SuslaandFacebook GitHub Bot 164815a03b return correct isAccessibilityElement from RCTViewComponentView (#43698)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43698

changelog: [internal]

RCTViewComponentView was missing isAccessibilityElement override. Here I add it and use contentView to determine if element is accessible.

Reviewed By: rubennorte

Differential Revision: D55483944

fbshipit-source-id: f29c82a42d17140ae421f27871a3bf6f7f36bc12
2024-03-28 15:13:48 -07:00
Ramanpreet NaraandFacebook GitHub Bot f99dc486cd Pull react instance method impls out of ReactContext
Summary:
## Context
Prior, ReactContext used to implement bridge logic.

For bridgeless mode, we created BridgelessReactContext < ReactContext

## Problem

This could lead to failures: we could call bridge methods in bridgeless mode.

## Changes
Primary change:
- Make all the react instance methods inside ReactContext abstract.

Secondary changes: Implement react instance methods in concrete subclasses:
- **New:** BridgeReactContext: By delegating to CatalystInstance
- **New:** ThemedReactContext: By delegating to inner ReactContext
- **Unchanged:** BridgelessReactContext: By delegating to ReactHost

## Auxiliary changes
This fixes ThemedReactContext in bridgeless mode.

**Problem:** Prior, ThemedReactContext's react instance methods did not work in bridgeless mode: ThemedReactContext wasn't initialized in bridgeless mode, so all those methods had undefined behaviour.

**Solution:** ThemedReactContext now implements all react instance methods, by just forwarding to the initialized ReactContext it decorates (which has an instance).

Changelog: [Android][Removed] Delete ReactContext.initializeWithInstance(). ReactContext now no longer contains legacy react instance methods. Please use BridgeReactInstance instead.

Reviewed By: javache

Differential Revision: D53145010

fbshipit-source-id: 2405bc24afb00864117d3c504fc9c4cbffd7203a
2024-03-28 14:31:51 -07:00
Nicola CortiandFacebook GitHub Bot 5ceb92801e Flip explicitApi to True for everyone (#43696)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43696

This just sets explicitApi to true for every module inside ReactAndroid

Changelog:
[Internal] [Changed] - Flip explicitApi to True for everyone

Reviewed By: tdn120

Differential Revision: D55478674

fbshipit-source-id: c9aeba89ad5b0f88bca7fd480c6aa66e0152a456
2024-03-28 14:22:28 -07:00
Dmitry RykunandFacebook GitHub Bot 95a881b80c Set HERMES_RELEASE_VERSION correctly (#43699)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43699

This diff initializes `RELEASE_VERSION` with the value that is provided by the `get_react_native_version` job (it stores its output into `/tmp/react-native-version`).

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D55484988

fbshipit-source-id: f0b5bb473096f3691f50152beb3181a454916fdc
2024-03-28 14:17:31 -07:00
Edmond ChuiandFacebook GitHub Bot af309127a4 Add support for launch ID (#43585)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43585

Changelog: [internal]

Related PR: https://github.com/facebookexperimental/rn-chrome-devtools-frontend/pull/27

Reviewed By: hoxyq

Differential Revision: D55164646

fbshipit-source-id: 0f25f150603a24654020093697e76d85d0d8cc02
2024-03-28 13:48:30 -07:00
Dmitry RykunandFacebook GitHub Bot 07f38ea9f1 Move IOS_DEPLOYMENT_TARGET and MAC_DEPLOYMENT_TARGET to the command body
Summary:
This diff moves IOS_DEPLOYMENT_TARGET and MAC_DEPLOYMENT_TARGET definitions to the command body.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D55478563

fbshipit-source-id: bae327edbaf88a9e8b39b304d938389e3fc56f4f
2024-03-28 13:38:53 -07:00
Ruslan LesiutinandFacebook GitHub Bot ad9368068a fix[android]: fix bridgeless configuration to include DebuggingOverlay in react packages (#43661)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43661

# Changelog: [Internal]

1. Remove `BridgelessDebugReactPackage.java`, this was added in D43407534. Technically, its the same as `DebugCorePackage.java`.
2. `ReactInstance` to add `DebugCorePackage`, so `DebuggingOverlay` view manager will be included in the bridgeless build.
3. Fix `RNTesterApplication.kt` to NOT create `MyLegacyViewManager` for every possible viewManagerName, apart from `"RNTMyNativeView"`, return null instead.

Reviewed By: cortinico

Differential Revision: D55375350

fbshipit-source-id: 1d3cb6b5ad3c0248df1def9f37c8c49b308f4473
2024-03-28 11:06:17 -07:00
Ruslan LesiutinandFacebook GitHub Bot 4841373719 fix: defer ReactDevToolsOverlay import (#43690)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43690

# Changelog: [Internal]

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

The issue is that once `getInspectorDataForViewAtPoint` is imported, it should throw if RDT global hook was not injected. ReactDevTools overlay imports `getInspectorDataForViewAtPoint`, this is why it did throw in testing environment.

ReactDevToolsOverlay JSX-element is already gated with RDT global hook check, adding a deferred import, same as it was already implemented for Inspector.

Still unclear to me how this didn't throw all this time while using the Catalyst / RNTester.

Reviewed By: cortinico

Differential Revision: D55474774

fbshipit-source-id: 759e5e8227cc7534193e5b95616b6099c15f5cb5
2024-03-28 10:06:53 -07:00
Chiara MooneyandFacebook GitHub Bot 8e7263a415 Add forwardRef call to Button Component (#43666)
Summary:
When RN moved Button component from a class component to a function component (https://github.com/facebook/react-native/commit/07e8ae42bed71f54bbe0e786ccad88b2f14648a4) a forwardRef call was not added to the Button control. This caused a set of tests downstream in React Native for Windows to fail because they rely on being able to pass a ref through to the Button control.

## Changelog:
[GENERAL] [FIXED] - Adds forwardRef call to new functional component implementation of Button control.

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

Test Plan: Button render remains the same.

Reviewed By: fabriziocucci

Differential Revision: D55398765

Pulled By: zeyap

fbshipit-source-id: ba32c764c16cb529ab1c92cb7888f2bae0f16f5f
2024-03-28 09:40:48 -07:00
Rubén NorteandFacebook GitHub Bot 66634be13a Dispatch notifications from MutationObserver as microtasks if available (#43664)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43664

Changelog: [internal]

Now that we have the event loop, we can modify the implementation of `MutationObserver` (which is still not enabled by default) to dispatch the notifications as microtasks, making the API more spec-compliant.

Reviewed By: javache

Differential Revision: D55380178

fbshipit-source-id: f876ffba49f9744f6603053f1485e7c2f43cb230
2024-03-28 08:06:41 -07:00
Rubén NorteandFacebook GitHub Bot 5d0056b6e8 Move IntersectionObserver native module to common directory (#43672)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43672

Changelog: [internal]

Small cleanup to move the last C++ native module defined in a JS directory to the new directory in `react-native/ReactCommon/react/nativemodule`.

Reviewed By: javache

Differential Revision: D55384106

fbshipit-source-id: 3bf477c2aceab6838f7f8131174b6eb74e890a23
2024-03-28 08:06:41 -07:00
Rubén NorteandFacebook GitHub Bot 368130d77b Move MutationObserver native module to common directory (#43663)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43663

Changelog: [internal]

We have a new directory for built-in C++ native modules, but the native modules for `MutationObserver` and `IntersectionObserver` were created before we had it.

This moves the native module for `MutationObserver` to `react-native/ReactCommon/react/nativemodule/mutationobserver` to follow the convention.

Reviewed By: javache

Differential Revision: D55380179

fbshipit-source-id: 0c64acbec973f2e5b57a0e38a0992bba49a01a45
2024-03-28 08:06:41 -07:00
Rubén NorteandFacebook GitHub Bot 3da58585d0 Include native module for DOM APIs by default in all apps using the new architecture (#43653)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43653

Changelog: [internal]

This will allow us to clean up some code in `UIManager` (using methods in the native module instead) and prepare to use the DOM APIs in OSS behind a feature flag.

This doesn't enable the DOM APIs in OSS, only the native module.

Reviewed By: javache

Differential Revision: D55365252

fbshipit-source-id: 70ec0eb022df586ad554c5b8ce6915b8ceddef5f
2024-03-28 08:06:41 -07:00
szymonrybczakandFacebook GitHub Bot 32c2322668 Upgrade @react-native-community/cli to v14.0.0-alpha.2 (#43682)
Summary:
Upgrade `react-native-community/cli` to v14.0.0-alpha.2

## Changelog:

[GENERAL] [CHANGED] - Upgrade `react-native-community/cli` to v14.0.0-alpha.2

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

Test Plan: CI

Reviewed By: cortinico

Differential Revision: D55430957

Pulled By: zeyap

fbshipit-source-id: 5b715b4b1e79ee81df922be6ab2b5b8b2315456d
2024-03-28 07:40:16 -07:00
Arushi KesarwaniandFacebook GitHub Bot 41a966458c DisabledDevSupportManager -> ReleaseDevSupportManager (#43667)
Summary:
allow-large-files

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

Renaming `DisabledDevSupportManager` -> `ReleaseDevSupportManager` to avoid confusion since this is only initialized in Release variant
https://github.com/facebook/react-native/blob/bb02049a6af2c83c3fa633a5eb098bae1135b4a4/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java#L181-L187

Changelog:
[Internal] Internal

Reviewed By: fkgozali, cortinico

Differential Revision: D55388403

fbshipit-source-id: 984b54f1666ad39301cb94d2b8c19b7504c997f6
2024-03-28 05:46:41 -07:00
Rubén NorteandFacebook GitHub Bot 2af1da42ff Add legacy layout methods from Fabric to DOM native module (#43659)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43659

Changelog: [internal]

This adds an implementation for the legacy layout measurement methods in React Native (`measure`, `measureInWindow` and `measureLayout`) in the DOM native module, so we can clean up the API from the `nativeFabricUIManager` binding.

Reviewed By: javache

Differential Revision: D55368141

fbshipit-source-id: 196d4d29be3b78ffc22fdc136be6e0cf5ab9dd26
2024-03-27 13:04:34 -07:00
Dmitry RykunandFacebook GitHub Bot ff392b0156 Explicitly define IOS_DEPLOYMENT_TARGET and MAC_DEPLOYMENT_TARGET on CircleCI (#43683)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43683

This diff adds explicit definitions of IOS_DEPLOYMENT_TARGET and MAC_DEPLOYMENT_TARGET to `build_apple_slices_hermes` and `build_hermes_macos` jobs on CircleCI.
Eventually this will allow us to stop [interacting](https://github.com/facebook/react-native/blob/main/packages/react-native/sdks/hermes-engine/utils/build-apple-framework.sh#L28) with `hermes-engine.podspec` outside of the CocoaPods execution context, and make our CI jobs less error prone.

Changelog: [Internal]

Reviewed By: fkgozali, cortinico

Differential Revision: D55432703

fbshipit-source-id: dc1cc449ba60340d13db9e4d21970e4e3783f2da
2024-03-27 12:03:15 -07:00
Tomislav NovakandFacebook GitHub Bot 13265ad636 Preserve order of elements after BoundedConsumableBuffer::clear() (#43679)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43679

The current implementation of clear-with-predicate first copies unconsumed
elements and then all others. This works correctly when the buffer is full
(wraps around), but fails if size() < maxSize: add() may no longer insert
an element in the correct position (after the last unconsumed entry; see
new unit test).

Replace it with a loop that iterates over all entries in order, and adjusts
cursorStart and cursorEnd to point to the last numToConsume elements of the
vector.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D55273402

fbshipit-source-id: 647dc35faeb35c7fa99b8113cf85ce7f02f073e5
2024-03-27 11:39:06 -07:00
zhongwuzwandFacebook GitHub Bot b1047d49ff Fixes bundle url reset logic (#43680)
Summary:
Fixes bundle url reset logic

## Changelog:

[IOS] [FIXED] - [Fabric] Fixes bundle url reset logic

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

Test Plan: bundle url set works.

Reviewed By: philIip

Differential Revision: D55427061

Pulled By: arushikesarwani94

fbshipit-source-id: 2b26b1f7c51281b7555a8621b97c067eadcf2db3
2024-03-27 10:50:09 -07:00
Samuel SuslaandFacebook GitHub Bot 575507dd61 do not send onScroll event when ScrollView is reused (#43676)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43676

changelog: [internal]

calling super invalidates eventEmitter. EventEmitter should be invalidated before reseting contentOffset on `_scrollView. Otherwise, UIScrollView::setContentOffset is called and it calls delegate method: `scrollViewDidScroll`.

Reviewed By: javache

Differential Revision: D55375060

fbshipit-source-id: f697805eb1ca05d15cf498ff9e5e06e90eb7ac56
2024-03-27 09:39:01 -07:00
Pieter De BaetsandFacebook GitHub Bot 59a43e6d5d Unbreak oss build due to explicit API mode (#43660)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43660

Changelog: [Internal]

Reviewed By: cortinico, fabriziocucci

Differential Revision: D55375856

fbshipit-source-id: d1df4965549069979410d8b07bb2518264238c8c
2024-03-27 05:50:47 -07:00
Arushi KesarwaniandFacebook GitHub Bot b282e87729 React-Native-Restart in release (#43645)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43645

https://github.com/facebook/react-native/pull/43521 & https://github.com/facebook/react-native/pull/43588 aimed to fix `react-native-restart`, however in release `handleReloadJS()` is a no-op in [DisabledDevSupportManager](https://github.com/facebook/react-native/blob/ac714b1c3300d3a169bdcfec05d556e18a7b83ff/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DisabledDevSupportManager.java#L139) which is why this should not work. Fixing it by relying on `ReactHostImpl.reload()` instead for Bridgeless.

Adding implementation of `DisabledDevSupportManager.handleReloadJS()` won't work as it would mean introducing circular dependency `devsupport` -> `runtime`

Reviewed By: cortinico

Differential Revision: D55342296

fbshipit-source-id: ee6fba68586a2bdd1163522f75e6beb1b7736f6c
2024-03-26 19:54:50 -07:00
Kevin GozaliandFacebook GitHub Bot c35630998b Keep ES6Proxy enabled in bridgeless mode (#43538)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43538

The Hermes RuntimeConfig for bridgeless accidentally force-disabled ES6Proxy, resulting in https://github.com/facebook/react-native/issues/43523

Let's remove the incorrect override.

To test using RNTester, add the following change:

```
 diff --git a/packages/rn-tester/js/RNTesterAppShared.js b/packages/rn-tester/js/RNTesterAppShared.js
index 87cb6b69dfe..f2512d09c5a 100644
 --- a/packages/rn-tester/js/RNTesterAppShared.js
+++ b/packages/rn-tester/js/RNTesterAppShared.js
@@ -50,6 +50,8 @@ const RNTesterApp = ({
   );
   const colorScheme = useColorScheme();
+  new Proxy({}, {});
+
   const {
     activeModuleKey,
     activeModuleTitle,
```

Before this change, RNTester will get an error at start-up. After, the app loads correctly.

Changelog: [General][Fixed] Correctly keep ES6Proxy for bridgeless mode

Reviewed By: cortinico

Differential Revision: D55045780

fbshipit-source-id: 666b99712d35622f87d42f22a4611851df67d905
2024-03-26 19:08:07 -07:00
Alex HuntandFacebook GitHub Bot bfb0319ce0 Register CatalystInstanceImpl with modern CDP backend (2/2) (#43251)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43251

Integrates the modern CDP backend with `CatalystInstanceImpl` (the React Native instance implementation) on Android.

This complete the modern CDP integration for Bridge.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D51458010

fbshipit-source-id: 6f73868da9d0d4cc5d086a4569c78444cb1b83ec
2024-03-26 17:52:52 -07:00
Sam ZhouandFacebook GitHub Bot dd03513123 Deploy 0.232.0 to xplat (#43668)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43668

Changelog: [Internal]

Reviewed By: pieterv

Differential Revision: D55393289

fbshipit-source-id: 069bd01ed6cb772a97c4e581d30aae8b2fd7b0f3
2024-03-26 17:30:41 -07:00
Evert EtiandFacebook GitHub Bot b2ca41eef5 Fix possible deadlock in dispatchViewUpdates (#43643)
Summary:
In https://github.com/th3rdwave/react-native-safe-area-context/issues/448 it was noticed that from 0.72 (https://github.com/facebook/react-native/commit/bc766ec7f8b18ddc0ff72a2fff5783eeeff24857 https://github.com/facebook/react-native/pull/35889) it was possible to get a deadlock in dispatchViewUpdates. ([More details](https://github.com/th3rdwave/react-native-safe-area-context/issues/448#issuecomment-1871155936))

This deadlock resulted in a laggy experience for all users using https://github.com/th3rdwave/react-native-safe-area-context/ on Android.

To avoid this problem, the author of the original fix [proposed](https://github.com/th3rdwave/react-native-safe-area-context/issues/448#issuecomment-1872121172) this solution which was tested by Discord and many other users.

It would be great to have this backported to 0.72 and 0.73 because of the large userbase using react-native-safe-area-context since it's recommended by expo and react-navigation.

## Changelog:

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

Pick one each for the category and type tags:

[ANDROID] [FIXED] - Fixed possible deadlock in dispatchViewUpdates

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

[ANDROID] [FIXED] - Fixed possible deadlock in dispatchViewUpdates

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

Test Plan:
The original memory leak remains fixed, and can be verified in https://github.com/feiyin0719/RNMemoryLeakAndroid.

To verify the deadlock is gone, every app using https://github.com/th3rdwave/react-native-safe-area-context will work smoothly and not log any excessive `Timed out waiting for layout`
(https://github.com/17Amir17/SafeAreaContext)

Reviewed By: arushikesarwani94

Differential Revision: D55339059

Pulled By: zeyap

fbshipit-source-id: c067997364fbec734510ce99b9994e89d044384a
2024-03-26 15:48:19 -07:00
Nicola CortiandFacebook GitHub Bot bb02049a6a Fix header import inside ReactInstanceManagerInspectorTarget.h (#43657)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43657

This include is not correct and is breaking the OSS build

Changelog:
[Internal] [Changed] - Fix header import inside ReactInstanceManagerInspectorTarget.h

Reviewed By: rshest

Differential Revision: D55368321

fbshipit-source-id: 0530257ad5c548476beb882174d73842775b3726
2024-03-26 12:37:49 -07:00
Tomislav NovakandFacebook GitHub Bot 5ea947150e Fix name lookup in PerformanceEntryReporter (use-after-free) (#43646)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43646

PerformanceEntryReporter maintains a buffer of RawPerformanceEntry objects,
as well as a set of _pointers_ to elements within that buffer, used to find
entries by name.

However, those pointers aren't stable: BoundedConsumableBuffer internally uses
a vector, and there are a few cases where existing references get invalidated:

- When the vector's capacity changes (as new entries get inserted) [1]
- After calling clear-with-predicate, which copies elements into a new vector

This causes nameLookup to contain dangling pointers, and subsequent operations
on it can result in use-after-free.

Fix this by having BoundedConsumableBuffer reserve space for maxSize entries
up front (which ensures that existing pointers remain valid after adding new
elements) and by rebuilding nameLookup after clearing entries by name.

Note that reserve() causes the buffer's memory use to be higher than before in
case where the number of elements is small relative to the max size. Given the
(only) existing usage in PerformanceEntryReporter, as well as the property that
consumed elements remain in the buffer, that cost should be minor.

Changelog: [Internal]

[1] https://en.cppreference.com/w/cpp/container/vector/push_back

Reviewed By: rshest

Differential Revision: D55273403

fbshipit-source-id: c8f33203ae32685e29afa7f8e33edf1284d66e0f
2024-03-26 12:07:55 -07:00
Marc RousavyandFacebook GitHub Bot 73bf40607e fix: Fix typo in error message (#43650)
Summary:
Small typo I encountered while trying to build custom C++ type converters :)

## Changelog:

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

Pick one each for the category and type tags:

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

[INTERNAL] [FIXED] Fixed a small typo in the "unsupported type" error message

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

Reviewed By: zeyap

Differential Revision: D55364068

Pulled By: cortinico

fbshipit-source-id: 5a1bc9443c82f2473860f379c9ae063cd6e3ceb4
2024-03-26 10:47:58 -07:00
Ruslan ShestopalyukandFacebook GitHub Bot a4592fdc1d Expose ScrollView's persistentScrollIndicator and horizontal to the C++ side props (#43655)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43655

## Changelog:
[Internal] -

The corresponding prop `ScrollBar.persistentScrollIndicator` was only passed to the Android platform code an `ScrollBar.horizontal` wasn't passed to native at all.

On other platforms we need those props to be available on the C++ side, so this exposes them to the corresponding C++ ScrollViewProps.

Reviewed By: sammy-SC

Differential Revision: D55367445

fbshipit-source-id: e8abca3a2b56a8e7c03593a6c4297f90749ac8fd
2024-03-26 10:08:24 -07:00
Rubén NorteandFacebook GitHub Bot 3a0bf7d89e Improve signature of DOM APIs (#43652)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43652

This improves the signature of our existing DOM APIs in 2 ways:
1. It replaces the use of `tuples` in `DOM.{h,cpp}` with safer structs.
2. It removes some unnecessary optionals from the API, returning the default values from the C++ API directly when appropriate.

It still preserves the use of tuples in the native module because objects are not properly supported in the codegen.

Changelog: [internal]

Reviewed By: NickGerleman

Differential Revision: D55316654

fbshipit-source-id: 16ce5ef62ca427cdcd6b9757d77db040e0ccc8b1
2024-03-26 08:39:49 -07:00
Ramanpreet NaraandFacebook GitHub Bot e69f6755c8 Make ReactContext and ReactApplicationContext classes abstract (#43625)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43625

Changelog: [Android][Breaking] Make ReactApplicationContext and ReactContext abstract. Please instantiate BridgeReactContext instead (bridge mode). Or BridgelessReactContext instead (bridgeless mode).

Reviewed By: arushikesarwani94

Differential Revision: D55218590

fbshipit-source-id: d507cc47c67cb5cd6c548844c08aa9ed8fb74796
2024-03-26 07:15:29 -07:00
Ramanpreet NaraandFacebook GitHub Bot 8eb1bd1170 Scripted: Codemod ReactApplicationContext creators to BridgeReactContext (#43626)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43626

The things that create ReactApplicationContext should instead create BridgeReactContext.

Long-term, ReactApplicationContext will be abstract. This diff pulls noise out from that eventual diff.

Changelog: [Internal]

Reviewed By: arushikesarwani94

Differential Revision: D55218591

fbshipit-source-id: d359c794f3da4a1ecb2fa8edbed5eeeb620b137b
2024-03-26 07:15:29 -07:00