Commit Graph

12270 Commits

Author SHA1 Message Date
David Vacca 118e651bc2 Delete LazyReactPackage.getReactModuleInfoProviderViaReflection (#41096)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41096

LazyReactPackage.getReactModuleInfoProviderViaReflection was deprecated in 0.72, I'm just deleting it.
There are no usages internally or externally

changelog: [Android][Breaking] Delete deprecated method LazyReactPackage.getReactModuleInfoProviderViaReflection

Reviewed By: arushikesarwani94

Differential Revision: D50338302

fbshipit-source-id: 02fe91d5da8d6f01b8d3852aced90034a1a5c8e8
2023-10-27 11:13:09 -07:00
David Vacca bfc64f444e Mark LazyReactPackage as Deprecated in the new architecture of React Native (#41097)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41097

LazyReactPackage is beig replaced by TurboReactPackage / BaseReactPackage, that's why I'm docummenting LazyReactPackage as Deprecated

changelog: [internal] internal

Reviewed By: arushikesarwani94

Differential Revision: D50338301

fbshipit-source-id: 6093772400ccaf928a549c078791845513dcb56a
2023-10-27 11:13:09 -07:00
Oskar Kwaśniewski e08a1973f6 feat(iOS): migrate deprecated UIMenuController to UIEditMenuInteraction (#41125)
Summary:
The goal of this PR is to migrate deprecated `UIMenuController` to `UIEditMenuInteraction`. `UIMenuController` has been deprecated in iOS 16 and for that reason it's not available for VisionOS.

## Recording

https://github.com/facebook/react-native/assets/52801365/fed994be-d444-462a-9ed0-39b50531425d

bypass-github-export-checks

## Changelog:

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

Pick one each for the category and type tags:

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

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[IOS] [CHANGED] - Migrate RCTTextView to UIEditMenuInteraction

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

Test Plan: Launch RNTester and check for "Selectable Text" example and check that it works for iOS 16/17.

Reviewed By: javache

Differential Revision: D50551016

Pulled By: cipolleschi

fbshipit-source-id: 558ecc5a04a5daa9c4360fabddcab28fba72a323
2023-10-27 11:11:19 -07:00
Rob Hogan 7853b06929 Update Metro to ^0.80.0 - don't pin to exact version (#41219)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41219

Bump to the latest Metro release. This includes minor breaking changes to Metro subpackages that should *not* be visible to RN users.

Metro release notes: https://github.com/facebook/metro/releases/tag/v0.80.0

## Moving to unpinned versioning
Metro is a multi-package project, and not pinning to an exact version means multiple versions of `metro*` packages may appear in an RN project.

This isn't unusual in the NPM ecosystem and *shouldn't* be a problem, but historically has caused issues (eg https://github.com/facebook/react-native/issues/34714, https://github.com/facebook/metro/issues/1017). The root cause of all of these issues, as far as we know, was fixed in https://github.com/facebook/metro/commit/6d46078e74ae9a43aa90bed46dbd6610e2696cd0, a bug where Node hierarchical resolution was effectively sidestepped via a relative worker path, resulting in a mismatch between transformer and host process.

In addition, the fact that `react-refresh`, `metro-react-native-babel-transformer` and `metro-react-native-babel-preset` are now fully moved into the `react-native/` scope and versioned with React Native means there are no circular dependencies between React Native and Metro, explicit or implicit, and we're much more clearly decoupled.

So, we're moving to caret versioning to allow React Native users to pick up Metro fixes and features without requiring React Native releases and user upgrades.

Changelog:
[General][Changed] - Update Metro to ^v0.80.0, stop pinning to an exact version

Reviewed By: GijsWeterings

Differential Revision: D50731999

fbshipit-source-id: 57b07bf73c0b31f392c4d36376ca48b48a8bd598
2023-10-27 10:42:46 -07:00
Krystof Woldrich 7612e6601a feat(tm-android): Reject Promise if Turbo Module method throws an Error (#37484)
Summary:
### [iOS change here](https://github.com/facebook/react-native/pull/40764)

This PR builds upon the previous work done in https://github.com/facebook/react-native/pull/36925, which introduced native stack traces to the JSError for synchronous functions.

The current modifications concentrate on functions that return Promises. Prior to this PR, errors within Promise-returning functions would be thrown at the platform layer crashing the app without a link to the JS stack.

After the implementation of this PR, errors thrown within Promise-returning functions are now captured and transformed into rejected Promises. These rejected Promises contain a JS Error object that contains both the JS stack trace and the cause, along with the platform stack trace.

Additionally, this PR ensures that rejections from native functions are now linked to the JS stack trace, providing a more comprehensive view of the rejection flow.

## Changelog:

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

Pick one each for the category and type tags:

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

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

[GENERAL][ADDED] - Turbo Modules Promise-returning functions reject with JS and platform stack traces information

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

Test Plan:
| Android |
|--------|
| ![function_promise_android](https://github.com/krystofwoldrich/react-native/assets/31292499/1d1a3adf-986a-47b4-b98b-9e766176b7ae) |

Example of intentionally rejected promise on Android:

```
{
  "name": "Error",
  "message": "Exception in HostFunction: intentional promise rejection",
  "stack": "[native code]\ntryCallTwo@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:25844:9\ndoResolve@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:25975:25\nPromise@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:25863:14\n[native code]\nrejectPromise@http://10.0.2.2:8081/js/examples/TurboModule/SampleTurboModuleExample.bundle?platform=android&lazy=true&app=com.facebook.react.uiapp&modulesOnly=true&dev=true&minify=false&runModule=true&shallow=true:42:70\nonPress@http://10.0.2.2:8081/js/examples/TurboModule/SampleTurboModuleExample.bundle?platform=android&lazy=true&app=com.facebook.react.uiapp&modulesOnly=true&dev=true&minify=false&runModule=true&shallow=true:242:71\n_performTransitionSideEffects@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:51896:22\n_receiveSignal@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:51852:45\nonResponderRelease@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:51715:34\ninvokeGuardedCallbackProd@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:2962:21\ninvokeGuardedCallback@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:3048:42\ninvokeGuardedCallbackAndCatchFirstError@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:3051:36\nexecuteDispatch@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:3115:48\nexecuteDispatchesInOrder@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:3132:26\nexecuteDispatchesAndRelease@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:4856:35\nforEach@[native code]\nforEachAccumulated@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:3574:22\nrunEventsInBatch@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:4874:27\nrunExtractedPluginEventsInBatch@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:4896:25\nhttp://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:4914:42\nbatchedUpdates$1@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:14750:20\nbatchedUpdates@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:4845:36\ndispatchEvent@http://10.0.2.2:8081/js/RNTesterApp.android.bundle?platform=android&dev=true&lazy=true&minify=false&app=com.facebook.react.uiapp&modulesOnly=false&runModule=true:4907:23",
  "cause": {
    "nativeStackAndroid": [
      {
        "lineNumber": 173,
        "file": "SampleTurboModule.java",
        "methodName": "getValueWithPromise",
        "class": "com.facebook.fbreact.specs.SampleTurboModule"
      },
      {
        "lineNumber": -2,
        "file": "NativeRunnable.java",
        "methodName": "run",
        "class": "com.facebook.jni.NativeRunnable"
      },
      {
        "lineNumber": 942,
        "file": "Handler.java",
        "methodName": "handleCallback",
        "class": "android.os.Handler"
      },
      {
        "lineNumber": 99,
        "file": "Handler.java",
        "methodName": "dispatchMessage",
        "class": "android.os.Handler"
      },
      {
        "lineNumber": 27,
        "file": "MessageQueueThreadHandler.java",
        "methodName": "dispatchMessage",
        "class": "com.facebook.react.bridge.queue.MessageQueueThreadHandler"
      },
      {
        "lineNumber": 201,
        "file": "Looper.java",
        "methodName": "loopOnce",
        "class": "android.os.Looper"
      },
      {
        "lineNumber": 288,
        "file": "Looper.java",
        "methodName": "loop",
        "class": "android.os.Looper"
      },
      {
        "lineNumber": 228,
        "file": "MessageQueueThreadImpl.java",
        "methodName": "run",
        "class": "com.facebook.react.bridge.queue.MessageQueueThreadImpl$4"
      },
      {
        "lineNumber": 1012,
        "file": "Thread.java",
        "methodName": "run",
        "class": "java.lang.Thread"
      }
    ],
    "userInfo": null,
    "message": "intentional promise rejection",
    "code": "code 1"
  }
}
```

How I logged out the Errors:

```js
console.log('Error in JS:', JSON.stringify({
  name: e.name,
  message: e.message,
  stack: e.stack,
  ...e,
}, null, 2));
```

Reviewed By: RSNara

Differential Revision: D50613349

Pulled By: javache

fbshipit-source-id: b49c469118c8d8d27c43164f110dfe57ddd592d9
2023-10-27 10:20:40 -07:00
Riccardo Cipolleschi daedbe6e3e Make the interop-layer work with components with custom name (#41207)
Summary:
This should fix
https://github.com/facebook/react-native/issues/37905#issuecomment-1774851214

When working on react-native-fast-image, we realized that the interop layer does not work for components where the exported name is different from the iOS class.

To fix this, we can use the Bridge to retrieve the actual view manager, given the component name.

This solution should be much more robust than making assumptions on the ViewManager name, given the ComponentName.

On top of that, we realized tha the interop layer was not calling `didSetProps` after setting the props, so we are invoking that.

bypass-github-export-checks

## Changelog:
[iOS][Fixed] - Add support for Components with custom names in the interop layer.

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

Test Plan: Tested locally on an app created in 0.72 and 0.73 in Bridge and Bridgeless mode.

Reviewed By: cortinico

Differential Revision: D50698172

Pulled By: cipolleschi

fbshipit-source-id: 49aee905418515b0204febbbe6a67c0114f37029
2023-10-27 08:03:04 -07:00
Pieter De Baets 3648886ff0 Use AsyncCallback in RCTTurboModule (re-land) (#41049)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41049

Similarly to D50319914, simplify the careful logic we have with CallbackWrapper and RCTBlockGuard and instead rely on bridging's `AsyncCallback` so safely handle jsi::Function for us.

The underlying issue causing memory corruption has been addressed in D50286876.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D50319913

fbshipit-source-id: e422518b9a647b7daa0b75eae529a8b04ce1c22b
2023-10-27 04:10:21 -07:00
Isabel Chai 8ac47faf32 Back out "setup test to use custom queue for RCTNetworking operations instead of module queue"
Summary:
Reverting D50588308 (GH commit: [1e21b5b08c](https://github.com/facebook/react-native/commit/1e21b5b08c165742d378a96b9321bc8a58f4df33)) as it is causing trouble to internal apps

bypass-github-export-checks

## Changelog:
[Internal] - Reverting [1e21b5b08c](https://github.com/facebook/react-native/commit/1e21b5b08c165742d378a96b9321bc8a58f4df33)

Differential Revision: D50730742

fbshipit-source-id: fc657fa9152894c47b134ca35effb7e67955966f
2023-10-27 03:53:20 -07:00
Isabel Chai 4e04ff5610 Back out "fix missed callsites for RCTNetworker requestQueue"
Summary:
Reverting D50680549 (GH commit: [0699347324](https://github.com/facebook/react-native/commit/069934732482bf35f717a5b451f83d5012220d55)) as it is causing trouble to internal apps

bypass-github-export-checks

## Changelog:
[Internal] - Reverting [0699347324](https://github.com/facebook/react-native/commit/069934732482bf35f717a5b451f83d5012220d55)

Differential Revision: D50730707

fbshipit-source-id: 30a475395318d37c5c7e6a182c4006bfa9d077fe
2023-10-27 03:53:20 -07:00
Phillip Pan 3f621df189 migrate RCTActionSheetManager to handle synchronous void method execution
Summary:
Changelog: [Internal]

in the future, all void native module methods will execute synchronously.

currently, many modules override the methodQueue selector to return the main queue so their async methods will be executed on the main thread by our infra. now that void methods are executing synchronously, this override will be ignored, thus causing unpredictable behavior for those methods that do depend on being run on main thread to behave correctly.

the migration in this stack will prevent bugs caused by this behavioral change by explicitly dispatching execution onto the main thread.

Reviewed By: mdvacca

Differential Revision: D50635827

fbshipit-source-id: 384ee2f0237a49dc4f50e4171092c864f2f55327
2023-10-26 21:44:40 -07:00
David Vacca ac7b158b3b Migrate ReactInstanceEventListener to kotlin (#41098)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41098

Migrate ReactInstanceEventListener to kotlin

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D50338295

fbshipit-source-id: 805b4ef65b8d88e9cde3f77f791d3a8d6f2e0a3c
2023-10-26 18:33:02 -07:00
Lulu Wu 6b3289bc73 Fall back to eager view manage loading (#41165)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41165

Currently Bridgeless forces lazy view manager loading, each ReactPackage must implement ```ViewManagerOnDemandReactPackage```. This can bring extra hassle for OSS users in migration.

This diff add backward compatibility by falling back to eager view manage loading, after detecting any ReactPackage of current application NOT a subclass of ```ViewManagerOnDemandReactPackage```.

Changelog:
[Android][Changed] - Fall back to eager view manage loading for Bridgeless

Reviewed By: cortinico

Differential Revision: D50556405

fbshipit-source-id: 32357d1934068d0fa0f2b7cb46b54f2f41b3e24f
2023-10-26 08:31:48 -07:00
Nicola Corti 1a7a677a90 Do not attempt to query Maven Central if project has react.internal.mavenLocalRepo (#41175)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41175

This will make sure that if you specify a maven local folder with `react.internal.mavenLocalRepo`
you're not attempting to fetch artifacts from Maven Central.

Changelog:
[Internal] [Changed] - Do not attempt to query Maven Central if project has react.internal.mavenLocalRepo

ignored-github-export-checks
bypass-github-export-checks

Reviewed By: mdvacca

Differential Revision: D50600815

fbshipit-source-id: f429c2ae9d7204e4aa2cb29357983c0dc3a1aab6
2023-10-26 07:46:51 -07:00
David Vacca dffd9d2170 Replace usages of deprecated class TurboReactPackage (#41197)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41197

As part of https://github.com/facebook/react-native/pull/40775 we marked TurboReactPackage as DeprecatedInNewArchitecture introducing the new class BaseReactPackage.
In this diff I'm replacing usages of TurboReactPackage by BaseReactPackage to make sure new usages of BaseReactPackage work as expected.

changelog: [internal] internal

Reviewed By: arushikesarwani94

Differential Revision: D50611382

fbshipit-source-id: 867c5949463cb5537960a346099e687379baeb73
2023-10-25 23:50:45 -07:00
David Vacca 93f6970618 EZ cleanup of ReactInstanceManager (#41196)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41196

cleanup of ReactInstanceManager to remove some lint warns

changelog: [internal] internal

Reviewed By: arushikesarwani94

Differential Revision: D50610673

fbshipit-source-id: d27684e0bc91dc9b137ac9dc412bfa8761774a37
2023-10-25 23:50:45 -07:00
David Vacca a05a705202 Mark ReactInstanceManager and ReactInstanceManagerBuilder as Stable (#41099)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41099

Mark ReactInstanceManager and ReactInstanceManagerBuilder as Stable

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D50338305

fbshipit-source-id: 6b35c675048170c9dfd9d8aee02d40f34c4d3eb4
2023-10-25 23:42:23 -07:00
Phillip Pan 0699347324 fix missed callsites for RCTNetworker requestQueue (#41195)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41195

Changelog: [Internal]

in PR 41183 , i introduced a new method to retrieve the RCTNetworker's execution queue. i missed updating a few of these asserts

Reviewed By: fkgozali

Differential Revision: D50680549

fbshipit-source-id: ac88382e13ade4434abbb7d6cbca168117df492e
2023-10-25 23:14:09 -07:00
Gabriel Donadel 13ae11152a Ensure namespace is specified for all the 3rd party libraries (#41085)
Summary:
As stated here https://github.com/react-native-community/discussions-and-proposals/issues/671 React Native 0.73 will depend on Android Gradle Plugin (AGP) 8.x  which requires all libraries to specify a namespace in their build.gradle file, even though this issue was raised many months ago, lots of libraries have not been updated and don't specify a `namespace` inside their build.gradle files

## Changelog:

[ANDROID] [CHANGED] - Ensure namespace is specified for all the 3rd party libraries

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

Test Plan:
Run RNGP tests and test building rn-tester after doing the following procedure

1. Remove `namespace "com.facebook.react"` from react-native/packages/react-native/ReactAndroid/build.gradle
2. Add `package="com.facebook.react"` to react-native/packages/react-native/ReactAndroid/src/main/AndroidManifest.xml
3. Build rn-tester

Also tested this using [BareExpo](https://github.com/expo/expo/tree/main/apps/bare-expo) with AGP 8.1.1 and all libraries that were missing the `namespace` compiled correctly

Reviewed By: cipolleschi

Differential Revision: D50556667

Pulled By: cortinico

fbshipit-source-id: 3d75ec0a8b82427ff0ede89aa7bc58b28b288945
2023-10-25 12:11:21 -07:00
Rubén Norte 8809392d87 Add Systrace sections for async TurboModule calls on Android and iOS (#41192)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41192

We currently don't have visibility on what the native module thread is doing when it's busy (on Android). This adds Systrace blocks to at least know the native module and the method we're running there.

Changelog: [internal]

Reviewed By: ryancat

Differential Revision: D50645557

fbshipit-source-id: 5cb6a7f1166bfd50c28f0aba634552c35a34c941
2023-10-25 11:49:00 -07:00
Oskar Kwaśniewski bf408a409b chore: remove unused RNTester assets (#41186)
Summary:
This PR removes some unused RNTester assets that were left during removal of slider and removal of Bookmarks feature in RNTester.

## Changelog:

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

Pick one each for the category and type tags:

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

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[INTERNAL] [REMOVED] - Removed unused images from RNTester

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

Test Plan: Not needed

Reviewed By: shwanton

Differential Revision: D50649244

Pulled By: cortinico

fbshipit-source-id: 5203b446108c04619c8cc57ec56f2d5e8455df2b
2023-10-25 11:28:26 -07:00
Nicola Corti dca81e6172 Bump Fresco to 3.1.3 (#41190)
Summary:
Bumping Fresco to the latest version (3.1.3)

## Changelog:

[ANDROID] [FIXED] - Bump Fresco to 3.1.3

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

Test Plan: CI Should be green

Reviewed By: lunaleaps

Differential Revision: D50650250

Pulled By: cortinico

fbshipit-source-id: ab8151e882300849ef27ec14c4adc77fdf8503e6
2023-10-25 11:14:48 -07:00
Lulu Wu b67bc3ffd3 Fix RNTester not showing Redbox when Metro is not connected (#41191)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41191

In dev mode, display a Redbox for the first fatal error during RN initialization. So if the first fatal error is Metro not connected that will be displayed via Redbox.

Changelog:
[Android][Changed] - Fix RNTester not showing Redbox when Metro is not connected

Reviewed By: cortinico

Differential Revision: D50600631

fbshipit-source-id: f269091c1745a76b49e72d9051c4836a39fded12
2023-10-25 10:23:29 -07:00
Phillip Pan 1e21b5b08c setup test to use custom queue for RCTNetworking operations instead of module queue (#41183)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41183

Changelog: [Internal]

in my quest to get rid of all synthesized methodQueues, we have RCTNetworking which uses it internally as well as exposes its underlying execution queue. in this diff, i add a config that replaces that queue with one that is managed by the module itself instead of the one generated by the infra.

this is the last one!

Reviewed By: cipolleschi

Differential Revision: D50588308

fbshipit-source-id: 98fa54a2b5851898a4514b1fb7feaf586cfdbb0c
2023-10-25 09:13:06 -07:00
Phillip Pan 7093a45b1c setup test to use custom queue for RCTBlobManager operations instead of module queue (#41182)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41182

Changelog: [Internal]

in my quest to get rid of all synthesized methodQueues, we have RCTBlobManager which exposes its underlying execution queue. in this diff, i add a config that replaces that queue with one that is managed by the module itself instead of the one generated by the infra.

Reviewed By: cipolleschi

Differential Revision: D50587693

fbshipit-source-id: 993a13c617afe48c3989d8cd5ad5fbda050603f4
2023-10-25 09:13:06 -07:00
Gabriel Donadel Dall'Agnol 7e26e0270b Fix createAnimatedStyle when providing undefined transform style (#41176)
Summary:
https://github.com/facebook/react-native/pull/35198 introduced a regression where if an `{transform: undefined}` style is provided to an Animated View a `Cannot read property 'map' of undefined` type error is thrown

<img src="https://github.com/facebook/react-native/assets/11707729/bb87781e-1ba7-40ec-879d-a57cef3e10d9" height="200" />

## Changelog:

[GENERAL] [FIXED] - Fix `createAnimatedStyle` when providing an undefined transform style

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

Test Plan:
<details>
  <summary>Render an `Animated.View` passing `style={{transform: undefined}}`</summary>

E.g.

```
const UndefinedTransform = () => {
  return (
    <View>
      <Animated.View style={{transform: undefined}} />
    </View>
  );
};
```
</details>

### RNTester
1. Open the RNTester app and navigate to the Animated page
2. Navigate to the Transform Styles page
3. App should not throw any errors

<table>
    <tr><th>Before</th><th>After</th></tr>
    <tr>
        <td><video src="https://github.com/facebook/react-native/assets/11707729/92ba9c3b-60b0-4805-8080-0e7fb7c00345"/></td>
        <td><video src="https://github.com/facebook/react-native/assets/11707729/80e2bba8-6ff6-4cf5-bcb8-26de0b869036"/></td>
    </tr>
</table>

Reviewed By: fabriziocucci

Differential Revision: D50638415

Pulled By: javache

fbshipit-source-id: 0ee949f019a77b8bef557888694e0e8404810105
2023-10-25 05:59:19 -07:00
zhongwuzw b1e92d6e0d RNTester enable concurrent root when using Fabric (#41166)
Summary:
RNTester's `AppDelegate` override `prepareInitialProps` method of super class `RCTAppDelegate` https://github.com/facebook/react-native/blob/70acd3f7d9edae9e40cc4603bede9778da281a85/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm#L152, so we missed `concurrentRoot` initial prop.

![image](https://github.com/facebook/react-native/assets/5061845/12af5815-afe6-46f0-8107-54ca443b4962)

cc javache cipolleschi

## Changelog:

[IOS] [FIXED] - RNTester enable concurrent root when using Fabric

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

Test Plan: Warning disappear.

Reviewed By: cipolleschi

Differential Revision: D50596693

Pulled By: javache

fbshipit-source-id: d73a17cd137b3088405f86b739cb0ed7b5a9839e
2023-10-25 04:53:10 -07:00
zhongwuzw e167ac9eab Fabric: clean up oldChildShadowView when handle Insert mount (#41155)
Summary:
We don't need to get oldChildShadowView when we handle the insert mount. So we can remove it.

## Changelog:

[IOS] [CHANGED] - Fabric: clean up oldChildShadowView when handling Insert mount

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

Test Plan: None.

Reviewed By: sammy-SC

Differential Revision: D50554037

Pulled By: javache

fbshipit-source-id: 3250b6bbe119d800f05f39f790dc6949357d4f27
2023-10-25 03:43:34 -07:00
Kevin Gozali 586de42d90 iOS: Export RCTConvert+Transform.h header (#41179)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41179

Some libraries need to import it, e.g.:
https://github.com/software-mansion/react-native-svg/blob/f9c7d8a807c8dc5b21e8ac0358a9bf7a820a1f61/apple/ViewManagers/RNSVGNodeManager.mm#L12

But depending on the build configuration, `#import "RCTConvert.h"` may not be able to find the header properly, so let's move it to `<React/RCTConvert.h>`

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D50586352

fbshipit-source-id: a770008acec311a498cf667545bf899f9a8cbef9
2023-10-24 22:26:09 -07:00
David Vacca c999535fe6 Refactor LazyTurboModuleManagerDelegate to avoid holding references to TurboModules (#41181)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41181

The goal of this refactor is to ensure that LazyTurboModuleManagerDelegate doesn't hold references to TurboModules.

EveryTime that LazyTurboModuleManagerDelegate.getModule is called, it will create a new TurboModule. This 'should' be fine because the references to already created TurboModules are held on
TurboModuleManager.mModuleHolders.

As part of this diff I'm also throwing an exception when the method LazyTurboModuleManagerDelegate.unstable_isModuleRegistered is called. This should be fine because I ensured that
"LazyTurboModuleManagerDelegate.unstable_isModuleRegistered' is not called for this experiment.

changelog: [internal] internal

Reviewed By: RSNara

Differential Revision: D50610163

fbshipit-source-id: 8d9d808b9b637c8e9bc3fd9c2502793161cac42c
2023-10-24 21:12:55 -07:00
Phillip Pan 833d589a68 setup test to use custom queue for RCTImageStoreManager operations instead of module queue (#41178)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41178

Changelog: [Internal]

in my quest to get rid of all synthesized `methodQueue`s, we have `RCTImageStoreManager` which uses this throughout. in this diff, i add a config that uses a queue that is managed by the module itself instead of the one generated by the infra.

Reviewed By: cipolleschi

Differential Revision: D50585904

fbshipit-source-id: a33f8a4844fe3ef861bf1c3a7b87a9ed4b24d13f
2023-10-24 14:54:04 -07:00
Rubén Norte b5dae017f7 Implement atomic reporting of UI changes in Runtime Scheduler (#41157)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41157

This is internal until we're ready to test this outside of Meta.
Changelog: [internal]

## Context

In the new architecture, every time we commit a new tree in React we send a transaction to the host platform to make all the necessary mutations in the underlying native views.

This can be bad for user experience, because the user might see quick changes to the UI in succession for related changes. It also breaks the semantics of things like layout effects and ref callbacks, which are core to the React programming model and should work across all platforms.

The main semantic that this behavior breaks in React Native is that layout effects are supposed to be blocking for paint. That means that any state updates (or UI mutations) done in layout effects should be applied to the UI atomically with the original changes that triggered them, so users see a single update where the final state is applied. This doesn't work in React Native as none of the commits coming from React are blocked waiting for effects, and instead they're all mounted/applied as they come.

This isn't only a problem for React, but also for future Web-like APIs that rely on microtasks. Those are also assumed to block paint in browsers, and we don't support that behavior either.

## Changes

Now that we're adding support for a well-defined event loop in React Native, we can add a new step to notify UI changes to the host platform in specific points in time, after macrotasks and microtasks are done (the "Update the rendering" step defined on the [Web specification](https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model)).

This implements that step in the new `RuntimeScheduler`. This works by batching all the notifications from the `UIManager` to `MountingCoordinator` and calling all those methods from `RuntimeScheduler` at the right time.

There will be cases where the notifications will be to mount the same tree multiple times, but the mounting coordinator already handles this correctly (would mount the last version of the tree for each surface ID the first time, and be a no-op the other times).

This change will reduce the amount of mount operations we do on the main thread, which means that we could potentially remove the push model from Android if performance is acceptable with this.

NOTE: This only works with the modern runtime scheduler, and only makes sense when used with microtasks enabled too and background executor disabled.

Reviewed By: javache

Differential Revision: D49536327

fbshipit-source-id: fabcbd6a6fb89a851f4c2b4ebefbb330a6ad3a18
2023-10-24 09:52:58 -07:00
David Vacca 0f8227df63 Clenaup ReactPackageHelper (#41100)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41100

Fix lint warnings

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: arushikesarwani94

Differential Revision: D50338306

fbshipit-source-id: 07623821bb3a684bf70575af80530c1616fd949b
2023-10-24 09:46:07 -07:00
Pieter De Baets 98e7ecd280 Remove ReactCallback interface (#41168)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41168

This API is just used to send callbacks from C++ to Java and is completely internal.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D50226596

fbshipit-source-id: f521ae1f35cc31e8e8aeab66b41fd3e95d9467cb
2023-10-24 05:15:09 -07:00
Janic Duplessis 9666814750 Fix autoscrollToTopThreshold on iOS old arch (#38245)
Summary:
Currently `autoscrollToTopThreshold` does not work correctly, it will scroll to top even when the scroll position is past the `autoscrollToTopThreshold` value.

The value of x/y is taken before we adjust the scroll position so we do not need to subtract the delta.

Note that this was already fixed when I ported this code to fabric, so this fix is only needed in the old arch code.

bypass-github-export-checks

## Changelog:

[IOS] [FIXED] - Fix autoscrollToTopThreshold on iOS old arch

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

Test Plan:
In RNTester example, threshold is set to 10, so it should not scroll to top if we are further than 10px from the top of the list.

Before:

https://github.com/facebook/react-native/assets/2677334/13723787-1bc4-4263-9bcb-91ddf7454de3

After:

https://github.com/facebook/react-native/assets/2677334/a8cfdaac-59fc-40de-970a-ff992366e25f

Reviewed By: rshest

Differential Revision: D50447644

Pulled By: cipolleschi

fbshipit-source-id: b21f1836db293120a7a795c8f8f6dd54887495a7
2023-10-24 04:33:21 -07:00
Pieter De Baets 31cf4c4ead Fix AppDelegate not passing props in bridgeless and rename getBundleURL (#41169)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41169

* `initialProperties` should be based on `prepareInitialProps`, not `launchOptions` (which don't seem to have an equivalent in bridgeless)
* `getBundleURL` is not idiomatic Objective-C (eg https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html), so rename to `bundleURL`

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D50595790

fbshipit-source-id: b718ebf2590b1d4512bcbd4846c8d11200f486e4
2023-10-24 04:26:48 -07:00
Samuel Susla 70acd3f7d9 remove folly hash from codebase (#41148)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41148

changelog: [internal]

RN moved away from using folly::hash. These are a few places missed during the migration.

Reviewed By: cipolleschi

Differential Revision: D50540176

fbshipit-source-id: 497c13032c23c5b2dfab9e3d6f226f596b90761e
2023-10-23 20:30:55 -07:00
David Vacca 2c900242c1 Extract NativeMethod out of NativeModule (#41101)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41101

The goal of this diff is to move NativeMethod out of NativeModule, in this case I'm moving it to JavaModuleWrapper.
We could also do a bigger refactor and just remove it, but since the usages of NativeMethod are not part of public API and these classes will dissapear in the new architecture, I opted for reducing risk a do a minor refactor.
Why I'm doing this: because I'm migrating NativeModule to kotlin and don't want to expose NativeMethod in the kotlin public API

This is not a breakage of compatibility because NativeMethod has package visibility.

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: luluwu2032

Differential Revision: D50294833

fbshipit-source-id: 1c7933e666c24df662649a01e1251c74414b5345
2023-10-23 20:02:38 -07:00
David Vacca abe5d2d697 Mark Mapbuffer classes and interfaces as Stable (#41102)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41102

Mark Mapbuffer classes and interfaces as Stable

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: luluwu2032

Differential Revision: D50294829

fbshipit-source-id: be665eb84e62ca6a57c9747503468a0f320c1c67
2023-10-23 20:02:38 -07:00
David Vacca d7d4989bdb Update javadoc on BaseJavaModule (#41103)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41103

Update javadoc on BaseJavaModule to remove references to bridge classes

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: luluwu2032

Differential Revision: D50294832

fbshipit-source-id: bca7be9e2e6a9ebee3e040b4b7e0d5c320627e26
2023-10-23 20:02:38 -07:00
Joe Vilches 60297d50dc Add errata supporting changes to position: static (#41130)
Summary:
X-link: https://github.com/facebook/yoga/pull/1434

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

I will use this errata to gate my changes that actually make position: static behave like the web. We have future plans to make position: relative the default again but users could still have declared certain nodes as position: static, so I think this is needed regardless.

Reviewed By: NickGerleman

Differential Revision: D50506915

fbshipit-source-id: b0d9e6883167de6ff002352c9288053324464cb9
2023-10-23 18:20:24 -07:00
Saad Najmi 755a7dbf56 Move iOS/Android specific prop types appropriate types (#40978)
Summary:
I wanted to add a new iOS prop, but noticed this, got distracted, fixed it up, and here we are 😅

There are a few Android/iOS specific props that have been added to `ViewProps` instead of `ViewPropsAndroid` or `ViewPropsIOS`. Let's just move around some props to clean that up, in both Flow and TypeScript.Specifically:

- Moved `needsOffscreenAlphaCompositing` to shared as it's implemented on both iOS and Android
- Moved `accessibilityLiveRegion` / `aria-live` / `accesbilityLabelledBy` / `aria-labelledBy` to Android
  - While at it, I also updated the comment definition so that `accessibilityLabelledBy` and `aria-labelledBy` because it just maps to the same thing in native code.
- Moved `accessibilityLanguage` to iOS only

## Changelog:

[GENERAL] [FIXED] - Move iOS/Android specific prop types appropriate types

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

Test Plan: CI should pass

Reviewed By: NickGerleman

Differential Revision: D50372564

Pulled By: vincentriemer

fbshipit-source-id: ba947c15ffdd4d84d3424b4274afdcbf130adad4
2023-10-23 16:58:43 -07:00
Arushi Kesarwani 85356fdf55 Inline DefaultJSIModulePackage (#41094)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41094

Inlining the `DefaultJSIModulePackage` in `DefaultReactNativeHost` for simplification

Changelog:
[Internal] internal

Reviewed By: mdvacca

Differential Revision: D50468945

fbshipit-source-id: 9c458044518db1db38cdac590da542be497cecaf
2023-10-23 16:15:14 -07:00
Eric Rozell 9b6e2d21d1 Eliminate const qualifier from MutationRecord (#41162)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41162

"The C++ standard forbids containers of const elements because allocator<const T> is ill-formed."

We have a few other callsites for std::vector<const ...>, but the const values are always const pointers, which I guess are okay?

Suffice to say, this doesn't compile with Microsoft STL headers unless you remove const.

## Changelog

[Internal]

Reviewed By: javache

Differential Revision: D50563174

fbshipit-source-id: 96053baedc41237d8d27a1e01ac94ce5abd6c768
2023-10-23 15:52:06 -07:00
Phillip Pan 7503dbd784 remove unused methodQueue from RCTHTTPRequestHandler (#41136)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41136

Changelog: [iOS][Breaking] You cannot call methodQueue on RCTHTTPRequestHandler

the `synthesize methodQueue` API is confusing, it looks like an API only for use within native module implementation, but it's actually needed to create a selector that corresponds to the property declared in the `RCTBridgeModule` public protocol.

no one is using the `methodQueue`  on `RCTHTTPRequestHandler`, so let's get rid of the public access to it.

Reviewed By: javache, cipolleschi

Differential Revision: D50525900

fbshipit-source-id: f83738491d0eadc71a6dc3194ee16fe7c8748263
2023-10-23 14:27:20 -07:00
Rubén Norte 1923a4e2ff Wire up configuration to use microtasks in RuntimeScheduler, Hermes and React (#41090)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41090

This propagates to enable the use of microtasks in the React reconciler, Runtime Scheduler and Hermes.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D50177355

fbshipit-source-id: 6cf23cf72b63d19f50453d3e4cc4ac1b056dbd92
2023-10-23 12:11:11 -07:00
Rubén Norte 04042decaf Implement support for microtasks in RuntimeScheduler (#41084)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41084

Adds support for executing microtasks in `RuntimeScheduler`, the same way we did in `JSIExecutor` before (removed in D49536251 / https://github.com/facebook/react-native/pull/40870) but now after each actual task in the scheduler.

When we use microtasks in the scheduler, we ignore calls to execute expired tasks (which was used to call "React Native microtasks" that we had before). Those should now be regular microtasks in the runtime.

This is gated behind a feature flag until we've tested this broadly.

This is going to be tested in Hermes but we need to add support for microtasks in JSC (which has a no-op in its JSI interface).

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D49536262

fbshipit-source-id: 8f7ce54c266d1f25312a641abc4ef073d019281f
2023-10-23 12:11:11 -07:00
Rubén Norte 4bf96f15be Pass reactNativeConfig to HermesInstance when not using the native module version (#41082)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41082

We're testing a method to access `ReactNativeConfig` without a dependency on native modules, so we can access it before that infra is initialized in places like Hermes or RuntimeScheduler.

When we're in that variant, this passes the configuration to Hermes so we can use it to set flags in the runtime (like enabling microtasks in D50177355).

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D50450488

fbshipit-source-id: 77f0369f93bb7175c569d51b0569669552a13acf
2023-10-23 12:11:11 -07:00
Pieter De Baets e5a91d77d8 Fix concurrentRoot warning in bridgeless for Logbox
Summary:
When creating the react root for Logbox, we do not pass the concurrentRoot option leading to a warning because it is using Fabric.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D50558855

fbshipit-source-id: ed4399293ca4001bf4e0e059a0eb73481bcf4832
2023-10-23 12:06:03 -07:00
Gijs Weterings d4ad19c969 Revert D49370200: Migrate codegen to shared build setup, remove package build pre-step from RNTester
Differential Revision:
D49370200

Original commit changeset: 992913155169

Original Phabricator Diff: D49370200

fbshipit-source-id: e8232c97c22065fb54ac940ee2351b2155eb51e0
2023-10-23 12:00:54 -07:00
Nicola Corti 79d620dff7 Remove unnecessary unstable_useRuntimeSchedulerAlways Feature Flag (#41158)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41158

This feature flag was just a killswitch for OSS. As we don't need it anymore, I'm removing it.
I've also discussed with Expo so they remove any usages of this in their codebase.

Changelog:
[Internal] [Changed] - Remove unnecessary unstable_useRuntimeSchedulerAlways Feature Flag

Reviewed By: rubennorte

Differential Revision: D50554334

fbshipit-source-id: b2346654ad543c1350f2f2cae078900abf39d41c
2023-10-23 09:58:54 -07:00