Commit Graph

12270 Commits

Author SHA1 Message Date
Dmitry Rykun 45f7e117ad Consume Hermes from local source directory (#38967)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38967

Changelog: [IOS][Added] - Now it is possible to build Hermes form local source directory. Just set REACT_NATIVE_OVERRIDE_HERMES_DIR to the path to that directory.

Known shortcoming: changes made to the Hermes source will not be reflected in the RN project. You should manually delete `Pods/hermes-engine` and rerun `pod install`.

Reviewed By: cipolleschi

Differential Revision: D48121314

fbshipit-source-id: 0389662396921bdf120d390de36a586c52eb47f1
2023-08-24 04:54:14 -07:00
Dmitry Rykun 4b664fc6c2 Refactor hermes-utils.rb (#38963)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38963

This diff refactors `hermes-utils.rb` in the following way:
- Explicitly define all the scenarios how `hermes-engine.podspec` can consume its source.
- Try to be explicit and verbose about when those scenarios take place.
- Split `compute_hermes_source` into two functions:
    - `hermes_source_type` that determines the podspec source type.
    - `podspec_source` that builds the podspec source based on the source type provided.

Also `hermes-engine.podspec` now uses source type returned by `hermes_source_type` instead of derived values `:git` and `:http`, which were not descriptive and granular enough.
This refactoring should make adding new cases and altering existing ones easier. Conditions, precedence and how to act for each scenario is much more explicit.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D48161239

fbshipit-source-id: 3d3d24aa1e05458e1f877153e43ebc2b437352e9
2023-08-24 03:45:24 -07:00
Xin Chen 970ba05127 Add example with side effect in render got triggered directly (#38830)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38830

Changelog:
[Internal] - Add example with side effect in render got triggered directly

Reviewed By: rshest

Differential Revision: D48055836

fbshipit-source-id: 8bf596165741bde93cf44cd96b93fb2efaea1b13
2023-08-23 15:02:10 -07:00
FabianSolheim 0b6e9bf0d8 Converted RNTesterReactHostDelegate.java to RNTesterReactHostDelegate.kt (#38978)
Summary:
This PR converts RNTesterReactHostDelegate into Kotlin as requested in https://github.com/facebook/react-native/issues/38825 .

## Changelog:

[INTERNAL] [CHANGED] - Convert to RNTesterReactHostDelegate.java => Kotlin

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

Test Plan:
Run yarn && yarn android
All tests should pass

Reviewed By: huntie, rshest

Differential Revision: D48598018

Pulled By: cortinico

fbshipit-source-id: f29eaa32c63835e090baf60bbde6c0c72b9041c2
2023-08-23 08:33:41 -07:00
Alex Hunt 8a21f41782 Add contributing note to dev server packages (#39127)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39127

Will be referenced in https://github.com/react-native-community/cli/pull/2055.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: motiz88

Differential Revision: D48603224

fbshipit-source-id: 0b31d765f912cf8efe4300f7490ccef3ac843a41
2023-08-23 08:10:09 -07:00
Alex Hunt f9e936e280 Update devtoolsFrontendUrl value in target list (#39122)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39122

Updates the `devtoolsFrontendUrl` value returned in the `/json/list` endpoint, to match the fixed DevTools frontend revision we set for `/open-debugger` — which now uses this as the source of truth.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48561005

fbshipit-source-id: 19409d013366f82782a071a0ec01d1ce8fab8c38
2023-08-23 04:17:12 -07:00
Phillip Pan 97efa25afa kill RCTRootViewIntegrationTests (#38871)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38871

Changelog: [Internal]

these tests are the last callsite where we are getting event emitter off of RCTRootView... these particular tests have been disabled and they're like 8 years old, sooooooo i think it's just easier for me to delete them

Reviewed By: cipolleschi

Differential Revision: D48179389

fbshipit-source-id: 9fe36323606f53c9b6fde8b4c20d51a2cb1f6c9c
2023-08-22 19:45:27 -07:00
Phillip Pan ab6349a0e4 delete unused selectors from hosting views (#39118)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39118

## Changelog:

[iOS][Breaking]- After [#38866](https://github.com/facebook/react-native/pull/38866) and [#38868](https://github.com/facebook/react-native/pull/38868), these are not needed anymore. instead of depending on the host view and overriding `createSurfaceWithBridge:` in a subclass create a specialized surface, we just rely on composition instead and provide a surface to the hosting view.

Reviewed By: christophpurrer

Differential Revision: D48577192

fbshipit-source-id: 8dbc96f1844d0ca1ed603cbe446575571c5f3e3b
2023-08-22 19:42:10 -07:00
Xin Chen 21e3e2f798 Add example to compare memoize expensive JS task (#38831)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38831

Changelog:
[Internal] - Add example to compare memoize expensive JS tasks

Reviewed By: NickGerleman

Differential Revision: D48048033

fbshipit-source-id: 6d60ea56a19a25ef2f136aba53ae417b441652ad
2023-08-22 17:21:23 -07:00
Xin Chen cd0ad935e4 Notify ReactMarker C++ from iOS when we log perf markers (#38326)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38326

This diff adds the iOS side of changes that the platform would notify `ReactMarker` in C++ for selected list of events. This helps us collect and send startup performance timing values via the `performance.reactNativeStartupTiming` API.

Changelog:
[iOS][Internal] - Notify ReactMarker in C++ from iOS platform for startup perf API

Reviewed By: rshest

Differential Revision: D43931719

fbshipit-source-id: 480ad8d53e541be6200cf8f7336f698a11d9600e
2023-08-22 16:53:00 -07:00
Dr. Sergey Pogodin a323249e0a A fix in Codegen for Windows build host (#36542)
Summary:
Android builds with new arch fail on Windows build host (https://github.com/facebook/react-native/issues/36475). This tiny correction fixes generation of `schema.json` (without it codegen failed to find any files, and generated empty schema). Unfortunately, does not fixes the issue with Windows host entirely, as builds still fail later (on ninja build step).

## Changelog:
[Android] [Fixed] - A bug fix for Android builds with new arch on Windows host.

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

Reviewed By: NickGerleman

Differential Revision: D48563587

Pulled By: cortinico

fbshipit-source-id: acd510308ce9768fb17d3a33c7927de3237748ac
2023-08-22 15:14:06 -07:00
Phillip Pan 57b86f7a87 delete hasBridge from root view api (#38870)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38870

## Changelog:

[iOS][Breaking] - hasBridge is removed from RCTRootView and RCTSurfaceHostingProxyRootView

i'm looking to limit callsites to the bridge in new architecture. in GH search i didn't see anyone using this method.

Reviewed By: cipolleschi

Differential Revision: D48175886

fbshipit-source-id: 367bfd549f658a64c5f9defac6eb66b92e681216
2023-08-22 14:59:52 -07:00
Vincent Riemer 269594ba92 Add basic active pointer tracking to the pointer event processor (#38865)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38865

Changelog: [Internal] - Add basic active pointer tracking to the pointer event processor

This diff lays the groundwork for keeping track of all the "active" pointers. The ActivePointer struct right now only contains a copy of the PointerEvent data but in future diffs this will be extended to include additional stateful metadata.

It's important to note that the code as written in this diff only "tracks" pointers when they are down and won't track pointers that are only hovering. I do want to include this in future diffs but I couldn't include that handling here as it requires changes to the iOS native pointer handling to stop deriving its own hover events which ends up snowballing even more changes. I will be making this change in (hopefully) the next diff where I refactor the hover event derivation to the fabric C++ layer.

Reviewed By: rozele

Differential Revision: D48167438

fbshipit-source-id: d1c7146e7b8d46b2f8defd4785618ee1cd54f155
2023-08-22 14:51:16 -07:00
Ruslan Shestopalyuk 6043960e11 Mitigate a corner case of ReactNativeFeatureFlags late initialization order (#39106)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39106

## Changelog:
[Internal] -

`ReactNativeFeatureFlags` are not guaranteed to be initialized before everything else, and one case popped up with this being a problem, in particular when creating `GlobalPerformanceLogger` instance (which may be created quite early on).

If the order of initialization of `ReactNativeFeatureFlags` and reading a value from there is flipped, then we'd just get a default value, without using any `MobileConfig` backing or anything.

This diff works this around for the particular case of `GlobalPerformanceLogger` initialization by making the corresponding flag tri-state (unititalized/true/false) and making sure that its value is only really taken into account after its initialized.

Reviewed By: ryancat

Differential Revision: D48559981

fbshipit-source-id: 7fa842d3b845866e15f89731c7e5c9036b83fb24
2023-08-22 14:47:14 -07:00
Neil Dhar 9edbd78363 Return the true size for ArrayBuffers (#39084)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39084

The current behaviour of `jsi::ArrayBuffer::size` with Hermes is to
return the value of the `byteLength` property. While this is
superficially more consistent with the behaviour for `Array`, which
reads the length property, it is a problem in practice since the
`byteLength` property is easily overridden in JS, making it unsafe
to use when indexing into the backing storage.

While this is a behaviour change, it should be fine because:

1. This is already the behaviour with JSC (the newly added test also
runs against the JSC implementation) and also seems to be the behaviour
of Microsoft's [V8 implementation](https://github.com/microsoft/v8-jsi/blob/db1ca30d6e5d39ee3a88a9f81b258c3825735917/src/V8JsiRuntime.cpp#L1239C48-L1239C58).
2. The current behaviour is counterintuitive and likely to lead to
bugs.

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D48226661

fbshipit-source-id: 043d60deeb9dc189705594415f4f262f7de1095a
2023-08-22 14:44:33 -07:00
Yupeng Li d4d323cbc2 Remove deprecated removeSubscription from the type of NativeEventEmitter (#39115)
Summary:
Removed deprecated function removeSubscription from the type of NativeEventEmitter, so that it lines up with its implementation. This is a fix for https://github.com/facebook/react-native/issues/39111 .

## 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] [Fixed] - Fix a type issue of NativeEventEmitter

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

Test Plan: Not applicable

Reviewed By: NickGerleman

Differential Revision: D48573676

Pulled By: lunaleaps

fbshipit-source-id: e70c951e230e0d236e0bf0a1ba02b450bdc98ac5
2023-08-22 13:54:39 -07:00
Riccardo Cipolleschi 4f7cdd5727 Make Glog defines modules (#39116)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39116

This changes updates the Glog pod to defines module.
This makes it easier to work with Glog using Swift and to work on React Native Modules

## Changelog:
[Internal] - Make Glog define modules

Reviewed By: dmytrorykun

Differential Revision: D48564026

fbshipit-source-id: 83bb45fa6387321d089528107517ffbf0874c70d
2023-08-22 13:00:18 -07:00
Alex Hunt 921cad6e59 Bump community-cli-plugin and dev-middleware, sync changes (#39074)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39074

Changelog: [Internal]

Publish new versions of `react-native/community-cli-plugin` and `react-native/dev-middleware` (which are now in a minimum viable state) for early integrators.

Also syncs final upstream changes from CLI:
- https://github.com/react-native-community/cli/pull/2035
- https://github.com/react-native-community/cli/pull/2052

#publish-packages-to-npm
bypass-github-export-checks

Reviewed By: motiz88

Differential Revision: D48465522

fbshipit-source-id: 987280996938af35b752b998969ea112a15deb57
2023-08-22 12:56:19 -07:00
Alex Hunt 13eda31d43 Simplify occupied port handling in start command (#39078)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39078

Simplifies and hardens behaviour for detecting other processes / dev server instances when running `react-native start`.

- New flow:
    - Exits with error message if port is taken by another process (*no longer suggests next port*).
    - Exits with info message if port is taken by another instance of this dev server (**unchanged**).
    - Continues if result unknown.
    - *(No longer logs dedicated message for another RN server running in a different project root.)*
- This now checks if the TCP port is in use before attempting an HTTP fetch.

Previous behaviour: [`handlePortUnavailable`](https://github.com/react-native-community/cli/blob/734222118707fff41c71463528e4e0c227b31cc6/packages/cli-tools/src/handlePortUnavailable.ts#L8). This decouples us from some lower-level `react-native-community/cli-tools` utils, which remain reused by the `android` and `ios` commands.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48433285

fbshipit-source-id: 7056001d5fe2f90faf52143f2777c9e2bdf0646e
2023-08-22 12:56:19 -07:00
Alex Hunt 5276599c45 Refactor CLI command entry points (#39075)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39075

Small refactor: reorganise command entry points and types into a consistent pattern.

Changelog: [Internal]

Reviewed By: blakef

Differential Revision: D48433284

fbshipit-source-id: 30f5780c8965e5a8a70603aec531fedcc82eeb73
2023-08-22 12:56:19 -07:00
Alex Hunt a002fbbd6c Upgrade CLI, restore prev status check value (#39077)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39077

Follow-up to https://github.com/facebook/react-native/pull/38988.

- Upgrade to RN CLI `12.0.0-alpha.11`.
- Restore previous value check against `/status` response in test scripts (restored in above CLI alpha).

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48432629

fbshipit-source-id: 175241ad75676281f4638e179873b2ce32f0ea3e
2023-08-22 12:56:19 -07:00
Moti Zilberman 8b62200605 Annotate debugger events with frontend User-Agent if available (#39110)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39110

TSIA.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D48560563

fbshipit-source-id: a268173e5e7b3e6e497ab79a8b362caa897afec6
2023-08-22 11:11:50 -07:00
Moti Zilberman cbbf169b06 Annotate debugger events with app ID, device name etc (#39108)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39108

TSIA

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D48484712

fbshipit-source-id: 3d875fdd098f2ef98b3bccb03f0053d0e5cc3be7
2023-08-22 11:11:50 -07:00
Moti Zilberman d10a8098b2 Log debugger command latency and status (#39107)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39107

Augments D48466760 to report debugger commands (request/response pairs) through `EventReporter`. With the appropriate backend integration, this can help validate the correctness/completeness of the CDP implementation (in the client, proxy and server) and measure the latency of debugger commands - more accurately, the time between the proxy receiving a command from the client and receiving the corresponding response from the server.

Most of the new logic here is in the `DeviceEventReporter` class, which is responsible for associating responses with requests. Requests are kept in a buffer with a 10s TTL which serves as a timeout in case of an unresponsive server.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D48480372

fbshipit-source-id: 55360a14bbea05ef8ad1622e0d54f18b47483809
2023-08-22 11:11:50 -07:00
Dmitry Rykun cd30bc3888 Fix PROJECT_ROOT for RNTester Xcode project (#39112)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39112

RNTester's `PROJECT_ROOT` should point to `packages/rn-tester` but for some reason it points to the `react-native` monorepo root.
Changelog: [iOS][Fixed] - RNTester's PROJECT_ROOT points to `packages/rn-tester`

Reviewed By: cipolleschi

Differential Revision: D48526552

fbshipit-source-id: 79047ddcbea96eb31f010a8f802aba8c6a2c403b
2023-08-22 09:09:35 -07:00
Samuel Susla 1708863711 Wire up enableDefaultAsyncBatchedPriority feature flag on iOS and Android
Summary:
changelog: [internal]

bypass-githubexport-checks

Reviewed By: NickGerleman

Differential Revision: D48522515

fbshipit-source-id: aaa184982094e006f4273468584d52b9b2cb5493
2023-08-22 09:00:56 -07:00
Michał Mąka 565e06f8d0 On setting the same state for ShadowNodeFamily, don't mark it as obsolete (#39095)
Summary:
During investigation of impact of PR https://github.com/facebook/react-native/pull/38706 on `reanimated` I found out that when:
- state reconciliation is turned on
- `progressState` in `ShadowTree::tryCommit` quite often returns a new pointer to updated shadow tree
- above happened due to `newState->getMostRecentStateIfObsolete()` returning precisely the same ptr as `newState` in `progressState`
- this is caused by calling `ShadowNodeFamily::setMostRecentState` with the same state as currently held and marking those states as obsolete

This PR adds additional check whether `ShadowNodeFamily::setMostRecentState` is called with the same `state` as currently set and skips setting obsolete flag if that happens.

## Changelog:

[INTERNAL][FIXED] Setting the same most recent state for ShadowNodeFamily, doesn't mark it as obsolete

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

Test Plan: None

Reviewed By: cipolleschi

Differential Revision: D48526395

Pulled By: sammy-SC

fbshipit-source-id: f77cea2364611a42a3363285b4732f33aae8a0a7
2023-08-22 08:50:47 -07:00
imalgrab 172e2d0c7e refactor: migrate MyLegacyViewManager to kotlin (#39014)
Summary:
Migrate MyLegacyViewManager to Kotlin (https://github.com/facebook/react-native/issues/38825)

## Changelog:

[INTERNAL] [CHANGED]  - Moved MyLegacyViewManager to Kotlin

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

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

Test Plan: Run `yarn && yarn android`

Reviewed By: rshest

Differential Revision: D48519780

Pulled By: cortinico

fbshipit-source-id: b43a2cfacad977c52b8552c464246b812de30855
2023-08-22 08:11:49 -07:00
Alex Hunt 3c943bbe3a Integrate dev-middleware into start command (#39059)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39059

## Context

RFC: Decoupling Flipper from React Native core: https://github.com/react-native-community/discussions-and-proposals/pull/641

## Changes

This change:
- Links the new `react-native/dev-middleware` endpoints into the recently migrated `react-native start` command.
- Adds `react-native/community-cli-plugin` (the migrated [`cli-plugin-metro`](https://github.com/react-native-community/cli/tree/main/packages/cli-plugin-metro)) as a dependency of `react-native`, and hooks in these versions of the `start`, `bundle`, and `ram-bundle` commands via `react-native.config.js`.

Functionally, this means that the new `/open-debugger` endpoint is available on the dev server started by `react-native start` (not yet linked into any UI).

After this PR is merged, the new `community-cli-plugin` package is "linked" and we can remove `cli-plugin-metro` from `react-native-community/cli`: https://github.com/react-native-community/cli/pull/2055.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D47226421

fbshipit-source-id: 123039961f93bd8183a32a2d3f30c447f7c0f132
2023-08-22 08:08:15 -07:00
Jesse Watts-Russell 211f3145db Fixing nested horizontal scrollview scrolling on Android (#39097)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39097

Changelog:
[Internal][Added] - Created mechanism to have nested horizontal scrollviews (or flatlists/sectionlists) by prioritizing scrolling on deeper nested scrollviews which have the enableNestedScroll prop equal to true.

Reviewed By: NickGerleman

Differential Revision: D48504762

fbshipit-source-id: 1a6d01f68e142d99ea494e2b5630979c7be2ecce
2023-08-22 07:30:44 -07:00
Jesse Watts-Russell 08f0cda867 Allow incremental payloads from Native->JS (#39109)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39109

Changelog:
[Internal][Added] - Allowed metro to also receive incremental data payloads from the native side bit by bit, offloading memory to the JS side (which would have been used anyways when the final copy was done).

Reviewed By: motiz88

Differential Revision: D48449495

fbshipit-source-id: 8cb2b43c35cce28e4b82d3f0e993c0f6d5f9c008
2023-08-22 07:29:19 -07:00
Samuel Susla 4d85e112a3 Delete use of folly::function (#39093)
Summary:
Changelog: [internal]

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

I was looking at Folly containers and found we were using folly::function. According to the compiler, we don't need it. It should fail during build time if its properties were needed.
Documentation for folly function: https://github.com/facebook/folly/blob/main/folly/docs/Function.md

Reviewed By: christophpurrer

Differential Revision: D48519164

fbshipit-source-id: 88002ca3a1302db2a397fc7f5e3cae354669a9ff
2023-08-22 06:35:14 -07:00
Intl Scheduler ccaae31a13 translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907940357720
Sandcastle Job Instance ID: 4503600652998134
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D48560682

fbshipit-source-id: 4d7f7e7c311f720c220e2fa6aef0f50223336f71
2023-08-22 05:57:36 -07:00
Lulu Wu a6b0984893 Upgrade OSS target sdk version to 34 (#39103)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39103

Changelog:
[Android][Changed] - Upgrade target sdk version to 34

Reviewed By: cortinico

Differential Revision: D48555585

fbshipit-source-id: 05a89fecdea52d73d35ba3fed8df76fc6bf51fe6
2023-08-22 05:25:40 -07:00
Pieter De Baets c22cc8f2d3 Optimize arg conversion in SurfaceRegistryBinding (#39094)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39094

We can construct the outer jsi::Object directly instead of going through `valueFromDynamic` for the whole thing.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D48519751

fbshipit-source-id: d3efd60472103ce7c9d13646d0a9bf4164bf73e2
2023-08-22 04:47:57 -07:00
Nick Gerleman 4f8a8ce316 Fix inverted contentOffset in scroll events in RTL (#39031)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39031

`UIScrollView` `contentOffset` is flow-relative, so `x` is relative to the right edge of the screen. This coordinate space disagrees with layout events, `scrollTo` coordinates, and other platforms.

This applies the same logic we use for inverting `scrollTo` coordinates to invert `contentOffset` in scroll events, in both Paper and Fabric. We then remove the iOS specific workaround we have in VirtualizedList.

I did not test `contentInset` as part of this, whose structure has explicit edges like `left` and `right`.

Changelog:
[iOS][Fixed] - Fix inverted `contentOffset` in scroll events in RTL

Reviewed By: rozele

Differential Revision: D48379915

fbshipit-source-id: 8a9cbb01608e79ef3b179a76fbe3997a0cd23845
2023-08-21 18:03:43 -07:00
Ramanpreet Nara 145659241a Introduce SampleLegacyModule example in RNTester (#38539)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38539

We will use this example to:
- Showcase legacy module support in the TurboModule system in RNTester
- E2E test legacy module support in the TurboModule system

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D47529295

fbshipit-source-id: b98e315741bed7740c36997d706f48e375b0c815
2023-08-21 17:58:46 -07:00
yardenPhy a384e076e0 Fix no support Schemes names contain spaces (#39009)
Summary:
i just moved to the new react native 0.72.1 with the new Architecture and I encountered a problem when tried to archive my develop version(i have 2 Schemes one for prod and one for dev).

so i did some digging and got to the problem that was found in script file named "generate-artifacts-executor.js".

i found that after generating lib content into the temp directory(tmpOutputDir)
it copy all the content into the real output directory(iosOutputDir).

the problem was that the real output directory(iosOutputDir) containing the selected scheme name and mine was with backspace(AppTest Develop) so the cp -r command was failing.

in order to fix that i wrapped the real output directory(iosOutputDir) with double quotes.

Also updated the related test ("executeNodes with the right arguments") to include the double quotes.

## Changelog:

[GENERAL] [FIXED] - Add support to archive Schemes names with backspaces

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

Test Plan:
1. After updating the related test ("executeNodes with the right arguments") to include the double quotes i run all tests by
run yarn test and yarn flow and All tests passed.

2. Also after i changed locally the script file in my project from the node_modules
    i successfully Archived both my Schemes dev and prod (one with backspace and one without).

Reviewed By: cipolleschi

Differential Revision: D48414256

Pulled By: NickGerleman

fbshipit-source-id: 829440b33799251fe5ef1c0f83d0fdef7a1cc254
2023-08-21 17:47:03 -07:00
Vincent Riemer 826e74fc72 Fix proper pointercancel/leave behavior when scrolling (#39081)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39081

Changelog: [Internal] - Fix pointer cancel/leave behavior when a child view scrolls

Reviewed By: lunaleaps

Differential Revision: D48472486

fbshipit-source-id: 9179cb5f897c2d36ab4df00b0462d2136a06b17d
2023-08-21 17:11:19 -07:00
Rob Hogan 3c323382fe Update Jest to ^29.6.3 (#39096)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39096

## React Native

Changelog:
[General][Changed]: Bump Jest version in the new project template from `^29.2.1` to `^29.6.3`

## Metro

[Internal]

Reviewed By: motiz88

Differential Revision: D48519694

fbshipit-source-id: 201f76402ac72da1f5c297a29a1212b167d1b7e4
2023-08-21 16:33:35 -07:00
Ramanpreet Nara f312d6eccd Ensure TM system has consistent view of interop flags (#39086)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39086

Our largest blocker for the TurboModule interop layer is a "module not found" issue.

**Hypothesis:** This is a gating-related bug.

## Changes
This diff tries to simplify the gating of the TurboModule interop layer: Instead of reading the flags again and again from two different classes (the module manager and its delegate), just read the flags once, when the module system is initialized:

https://www.internalfb.com/code/fbsource/[ae79b760626ec81ceadbf2829e1593199d4df031]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactInstance.java?lines=106-113%2C210-215%2C217-223%2C251

This will ensure that the TurboModule system has one consistent view of the interop layer flags, throughout its lifetime.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D48489274

fbshipit-source-id: 05eb64c5f7bd89dd65aac7390c3eb09234d87f96
2023-08-21 15:44:07 -07:00
Xin Chen 489d8903ab Add example to not render offscreen content (#38800)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38800

Changelog:
[General][Internal] - Add performance comparison example to not render offscreen content

Reviewed By: rshest

Differential Revision: D47892462

fbshipit-source-id: dd5bbd83c3baaf229c4b6fea89904cf4bb7b37de
2023-08-21 14:34:10 -07:00
Xin Chen 80685d52b8 Add systrace for event type when calling RCTDeviceEventEmitter (#39085)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39085

Adding arguments in systrace for event emitter event types. This is helpful to understand why sometimes JS render is triggered from native side.

Changelog:
[Internal] - Add event type information from native to js event emitter calls

Reviewed By: rshest

Differential Revision: D48448904

fbshipit-source-id: cbb4b86e781384d56205fec23931cd773e4a58a8
2023-08-21 13:25:31 -07:00
Ramanpreet Nara 606a92f0b3 Show RedBox when reloads fail
Summary:
When reloads fail, React Native currently just renders a blank screen.

We should provde some sort of feedback to the developer. Hence, this diff makes the RedBox show up.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D48335851

fbshipit-source-id: 0681cd40f8c83960f9133853481013765634f5cf
2023-08-21 12:43:42 -07:00
Ramanpreet Nara 80b665966f Clean up pre-rendered surfaces properly during teardowns (#39000)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39000

Whenever React Native tears down (including on logout), we need to drop unconsumed Pre-rendering surfaces.

D45012714 initially implemented this change, but this diff wasn't complete: it would only drop unconsumed pre-rendered surfaces when ***the Facebook infra* initiated** React Native to tear down. But, React Native could initiate tear down **by iteself** (e.g: via an uncaught exception on the Native Modules thread).

## Changes
In this diff, make the React Manager support an onBeforeDestroy listener. Then, integrate these listeners into the teardown/reload algorithms. That way, no matter how React Native tears down, we **alwasy** drop unconsumed pre-rendered surfaces.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D48323647

fbshipit-source-id: 28f99500eea457b0e3c420fed28c434f8794ac23
2023-08-21 12:43:42 -07:00
Ramanpreet Nara f437224042 Enhance/fix error reporting in reload and destroy
Summary:
The new reload/create/destroy methods work by chaining tasks together.

This task chain has the type Task<ReactInstance>.

**The problem:** If any step in the chain fails, task.getResult() actually returns null - not the ReactInstance. Many steps in the existing reload() and destroy() task chains don't account for this case. So:
- The reload() and destroy() task chains sometimes swallow errors.
- Sometimes steps in the reload() and destroy() task chains don't execute: they use .successTask

This diff makes two changes:
1. Ensure each step **always** executes (i.e: use .continueWith vs .success)
2. Ensure each step first checks if the Task<ReactInstance> isn't faulted/cancelled. If the task is faulted/cancelled, a soft exception gets reported, and the current ReactInstance gets returned.

Changelog: [Internal

Reviewed By: mdvacca

Differential Revision: D48080779

fbshipit-source-id: 22f03ef1a54b538d01eeb5ecde6d82a84d32f1f8
2023-08-21 12:43:42 -07:00
Ramanpreet Nara 1f0094e40a Fix: RedBoxes don't show up after teardowns (#38997)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38997

After React Native gets destroyed (e.g: via an exception), the ReactHost resets its current activity.

## Problem
React Native can display RedBoxes after React Native destruction (e.g: in the case of an exception).

Displaying RedBoxes requires the current activity, which gets nullified. So, the RedBox might not show up after destruction.

## Changes
This diff makes ReactHost keep a track of its last non-null activity in a WeakRef.
Then, the DevMenu just uses the last non-null activity to display RedBoxes (and everything else).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D48076893

fbshipit-source-id: 6baddf8f329c03efe92f93ef1bfc6eb9569c1b38
2023-08-21 12:43:42 -07:00
Ramanpreet Nara aec22574cc Refactor: Use get/setCurrentActivity in ReactHost (#38998)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38998

Instead of using the mActivity reference directly, let's just use getCurrentActivity() and setCurrentActivity().

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D48076896

fbshipit-source-id: d988deaf8778bf0e3726d13f96e9e6e480d8fdc0
2023-08-21 12:43:42 -07:00
Ramanpreet Nara 75c5d74ea2 Fix: React Native reloads after teardown render a "blank screen" (#38999)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38999

After React Native tears down, a RedBox can appear, prompting the user to reload.

**Problem:** After React Native reloads, the React Native screen wouldn't show up.

**Cause:** ReactContext.onHostResume() wasn't executed.

Why:
- React Native teardown moves the React manager into the **onHostDestroy()** state.
- During initialization, React Native only calls ReactContext.onHostResume(), if the React manager was *already* in the **onHostResume()** state.

https://www.internalfb.com/code/fbsource/[f82938c7cc9a0ee722c85c33d1027f326049d37c]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactHost.java?lines=924-925

**Question:** Why does React Native only call ReactContext.onHostResume(), **if the React manager was already in the onHostResume() state?**

In short, we want ReactContext.onHostResume() to be delayed until the user navigates to the first React Native screen. Please read the comments in the code to understand why.

## The fix
If we're initializing React Native during a reload, just always call ReactContext.onHostResume().

If React Native is reloading, it seems reasonable to assume that:
1. We must have navigated to a React Native screen in the past, or
2. We must be on a React Native screen.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D48076895

fbshipit-source-id: 6794105920ee30d62cebd745256bb5dea805e891
2023-08-21 12:43:42 -07:00
Ramanpreet Nara ecd2feeea0 Fix: React Native teardown crashes app
Summary:
During React Native teardown, we should stop all React surfaces. Otherwise, the app could crash with this error:

```
08-06 14:54:08.644 14843 14843 F DEBUG   : Abort message: 'xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp:171: function ~Scheduler: assertion failed (surfaceIds.empty() && "Scheduler was destroyed with outstanding Surfaces.")'
```

When can teardown occur? One case: an exception occurs on the NativeModules thread.

NOTE: This diff impacts the **new** Bridgeless mode lifecycle methods.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D47926966

fbshipit-source-id: 62be90eb49091773976dfb18db5c2a7c0668c382
2023-08-21 12:43:42 -07:00