Commit Graph

7308 Commits

Author SHA1 Message Date
Rob Hogan 784819d935 Enable RN DevTools Android OSS debug builds
Summary:
Enable React Native Devtools in Android OSS debug builds

Changelog:
[Android][Added] Enable React Native DevTools in OSS debug builds

Reviewed By: huntie

Differential Revision: D62376708
2024-09-09 05:20:45 -07:00
Alex Hunt d55efe8953 Fix HERMES_ENABLE_DEBUGGER define for jsinspector-modern under CocoaPods (#46393)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46393

> [!Note]
> Replaces https://github.com/facebook/react-native/pull/46282.

We intended to enable Fusebox on `main` since https://github.com/facebook/react-native/pull/45469 — this worked when building under Buck, however was not working for builds under Xcode. This is because the `HERMES_ENABLE_DEBUGGER` preprocessor flag was missing for the `React-jsinspector` Podspec.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D62375148

fbshipit-source-id: 5d4d243d0a2cb7796fdf59d57086a0cb966639c7
2024-09-09 04:38:32 -07:00
Alex Hunt f220bde4d7 Remove Inspector Panel perf + network tabs under New Arch (#46307)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46307

Changelog:
[General][Breaking] - Remove Inspector Panel perf + network tabs  under New Arch (see https://github.com/react-native-community/discussions-and-proposals/pull/777)

Reviewed By: christophpurrer

Differential Revision: D62123634

fbshipit-source-id: 44ecc476943ccb33f8de96dcefa3e233e954841a
2024-09-09 04:31:17 -07:00
Vojtech Novak 7041ed28f0 fix(android): ensure Appearance change listener does not skip events (#46017)
Summary:
I'm able to reproduce a case when Appearance module methods are called in the following order:

starting point: dark mode enabled
1. call `setColorScheme` light
2. call `getColorScheme`, which sets `colorScheme` to light [here](https://github.com/facebook/react-native/blob/7bb7a6037bd78bbfa6d9e8499973ea921e9c70e1/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.kt#L57)
3. [onConfigurationChanged](https://github.com/facebook/react-native/blob/7bb7a6037bd78bbfa6d9e8499973ea921e9c70e1/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.kt#L82) is called but `if (colorScheme != newColorScheme)` does not evaluate to true, so no event is dispatched to JS. That means JS is not in sync with the native state.

The issue was the `getColorScheme` had a side-effect of setting `colorScheme` private member (not sure what its use was). The fix remembers the last emitted color scheme value and emits event if new value is different.

## Changelog:

[ANDROID] [FIXED] - ensure Appearance change listener does not skip events

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

Test Plan: tested locally with RN tester

Reviewed By: NickGerleman

Differential Revision: D62016949

Pulled By: cipolleschi

fbshipit-source-id: b7b5755d38becda655cf376749d9a996daff7e07
2024-09-09 04:30:50 -07:00
Riccardo Cipolleschi 148066e8f9 Bump CLI to 15 (#46394)
Summary:
Bumps the CLI to the next version

## Changelog:
[General][Changed] - Bump cli dependencies to 15.0.0-alpha.2

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

Test Plan: CI

Reviewed By: huntie

Differential Revision: D62375405

Pulled By: cipolleschi

fbshipit-source-id: fec99216bc7ad6decfd83840091d807f603184da
2024-09-09 03:54:43 -07:00
Oskar Kwaśniewski 3621606c44 feat(iOS): expose newArchEnabled, deprecate separate methods (#46228)
Summary:
This PR exposes the `newArchEnabled` flag and deprecates all of the separate methods to enable new architecture.

As discussed with cipolleschi here: https://github.com/react-native-community/template/pull/45#discussion_r1732522705

## Changelog:

[IOS] [DEPRECATED] - Deprecate turboModuleEnabled, fabricEnabled, bridgelessEnabled
[IOS] [ADDED] - Add newArchEnabled method to RCTAppDelegate

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

Test Plan: Test if switching newArchEnabled flag from AppDelegate works.

Reviewed By: cortinico

Differential Revision: D61849385

Pulled By: cipolleschi

fbshipit-source-id: 8acf718386882679f00d2d5000b4432a523b34ac
2024-09-09 03:15:19 -07:00
Alan Lee 97b661c3f0 add inset based margins to RedBox (#46391)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46391

**Issue:**
RedBox displays early error before JS Error handling is properly setup.
On Android 15, targetSdk 35 (forced edge-to-edge), dialog overlaps with system bars making it difficult to use.

**Solution**
Add inset based margins so content does not overlap with system bars.

Changelog:
[Android][Fixed] - RedBox content overlapping with system bars on Android 15 forced edge-to-edge

Reviewed By: fkgozali

Differential Revision: D62362105

fbshipit-source-id: 57f60222914d407ebdcfd0359dbdf3ac36bde8f5
2024-09-09 01:15:18 -07:00
Alan Lee 3244a5ee74 code cleanup for depreacted OS version (#46390)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46390

As React Native's minSdkVersion is not 24, clean up version checks and code that is using deprecated version from OSS

Changelog:
[Internal] - code cleanup for minSdkVersion 24

Reviewed By: philIip

Differential Revision: D62362059

fbshipit-source-id: a851d0908d4175269524f41955acca5f2da69cad
2024-09-09 00:25:54 -07:00
dirkpostma d687d38987 Fix duplicate entries in HEADER_SEARCH_PATHS when running react_native_post_install script (#46262)
Summary:
In a react native project where USE_FRAMEWORKS is not nil, every time when running `pod install`, duplicate lines are added to `HEADER_SEARCH_PATHS` section of `project.pbxproj`:

```
" ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
" ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
" ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
" ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
```

Note: a popular library that needs `use_frameworks` is react-native-firebase.
See https://rnfirebase.io/#altering-cocoapods-to-use-frameworks

## Analyse

- `react_native_post_install` calls `ReactNativePodsUtils.update_search_paths(installer)`
- when `ENV['USE_FRAMEWORKS'] != nil` then `update_search_paths` calls `add_search_path_if_not_included`
- `add_search_path_if_not_included` checks if `"#{new_search_path}"` is already there
- if not found it adds `" #{new_search_path}"` _with an extra space_
- next time, it can't find `"#{new_search_path}"` because of the extra space, and adds `" #{new_search_path}"` again

## Changelog:

[IOS] [FIXED] - react_native_post_install script no longer adds duplicate entries to HEADER_SEARCH_PATHS

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

Test Plan:
- create a react native project
- add `use_frameworks! :linkage => :static` to `ios/Podfile` (just before `use_react_native`)
- run `pod install`
- assert no duplicate lines are added to HEADER_SEARCH_PATHS of file `project.pbxproj`

Reviewed By: cipolleschi

Differential Revision: D61982680

Pulled By: shwanton

fbshipit-source-id: 61b566893c551d0813edd6eec2f8352c041c748f
2024-09-07 06:27:23 -07:00
Oskar Kwaśniewski 9cc6f007ba chore(iOS): bump socket rocket to 0.7.1 (#46300)
Summary:
This PR bumps Socket Rocket to 0.7.1, this release brings some new improvements and visionOS support. I've also moved the version to a constant.

## Changelog:

[INTERNAL] [CHANGED] - Bump SocketRocket to 0.7.1

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

Test Plan: CI Green

Reviewed By: cortinico, cipolleschi

Differential Revision: D62294833

Pulled By: blakef

fbshipit-source-id: 0e45c7de041710fb1f500b0ac23898b68a8a8936
2024-09-07 02:56:51 -07:00
Alan Lee 77b3a8bdd6 Modal bugfix for statusBarTranslucent prop and Android 15 (#46359)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46359

Remove unneeded code around size calculation and old arch support
- updateState was getting called unnecessarily in multiple places --> only call from onSizeChanged()
    - this is a reliable source for getting the content size area of the dialog used for Modal
     - remove code checking duplicated update
- Old architecture cleanup
    - Remove Java implementation of ShadowNode
      - we already have logic to set the node size via UIManagerModule::updateNodeSize(). This  code is now group together in updateState() for both new and old architecture

This fixes issues with resulting from wrong size calculation:
- having gaps at bottom when we set `statusBarTranslucent` to `true`
- Modal cut off at bottom on Android 15 (drawn under bottom nav bar)

Changelog:
[Android][Fixed] - Modal statusBarTranslucent bug, Modal at bottom being cut off in Android 15 (without forced edge-to-edge)
[Android][Deprecation] - Deprecating ModalHostShadowNode and ModalHostHelper classes

Reviewed By: mdvacca

Differential Revision: D62286026

fbshipit-source-id: 03b64a7783c12bebd1457c86a9a2657adc882c79
2024-09-07 00:59:47 -07:00
Alan Lee 79e4ed2b09 Refactor/ bugfix for ReactModalHostView (#46326)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46326

- renaming variabled to make intent more clear
    - `dialog` -> `dialogWindow` to distinguish with `activity.window`
    - `hostView` -> `dialogRootViewGroup` as name was confusing.
        - `ReactModalHostView` creates and manages `DialogRootViewGroup` but it used as contentView for the Dialog.
- bug fixes

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D62177564

fbshipit-source-id: f81b167c1a234c02617ec2a3d63979628e01063b
2024-09-06 19:07:04 -07:00
Shawn Dempsey 17d0345fdf Migrate FlatList/SectionList E2E testss from Catalyst to RNTester (#46274)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46274

changelog: [General][Add] - Add E2E test cases for Flat/SectionList to RNTester

Reviewed By: philIip

Differential Revision: D62002065

fbshipit-source-id: 038907cd7afd33505b7599e390cb9f366b7b32f6
2024-09-06 15:13:33 -07:00
Marc Rousavy e629a8552d fix: Bring back Cxx TurboModule autolinking via registerCxxModuleToGlobalModuleMap (#46360)
Summary:
Reverts the PR https://github.com/facebook/react-native/pull/45967 from philIip to bring back the `registerCxxModuleToGlobalModuleMap(..)` function, which I use in Nitro Modules and MMKV.

Ontop of that, this also removes the "experimental" `RCT_EXPORT_CXX_MODULE_EXPERIMENTAL` macro, which I think was the original intent of this PR as this macro is a bit unsafe.

I also added some small docs to `registerCxxModuleToGlobalModuleMap` while I'm at it.

## Changelog:

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

Pick one each for the category and type tags:

[GENERAL] [CHANGED] - Bring back CxxTurboModule autolinking function, but remove `RCT_EXPORT_CXX_MODULE_EXPERIMENTAL` macro

[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/46360

Test Plan: Build Nitro Modules. Worked for me! :)

Reviewed By: realsoelynn

Differential Revision: D62310637

Pulled By: philIip

fbshipit-source-id: 2caa2b8ea094dda5e13c81431a9a645cbcf8f807
2024-09-06 15:11:03 -07:00
Benoit Girard 1bd4a11736 Add Fusebox support for saving traces to disk (#46370)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46370

Add a function to write the current trace contents to a file. To be used by the upcoming Perfetto data source while we wait for devtools to work in a profiling build.

Reviewed By: rubennorte

Differential Revision: D62262985

fbshipit-source-id: 04789f5312721434c773e51b3da333498bf0e786
2024-09-06 12:40:42 -07:00
Tim Yung 2f8676924d Animated: Store Listeners w/ Map
Summary:
Currently, `AnimatedNode.prototype.getListeners` creates an array with `Object.keys()` to determine the number of listeners.

This is a relatively hot code path for animation-intensive user interfaces. Although `Object.keys()` is fast, every unnecessary memory allocation is an unnecessary opportunity to create garbage that requires collection.

Using an object as a dictionary performs worst than using a `Map` anyway, so this switches `AnimatedNode` to use a `Map`.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D62267352

fbshipit-source-id: 8629861a64109a3a711c0f66a345029d0bfcd440
2024-09-06 12:15:21 -07:00
Tim Yung d1ebe02c19 Animated: Optimize Traversals in Nodes (#46286)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46286

Optimizes the runtime performance of `Animated` by using memoization to avoid repetitive traversals of `props` (and `style`) values.

Changelog:
[General][Changed] - Improved runtime performance of `Animated`

Reviewed By: javache

Differential Revision: D62037506

fbshipit-source-id: b0202f02c87466e1cef61b841de7e861a0ecae4e
2024-09-06 12:15:21 -07:00
Tim Yung 9e35dffcf1 Animated: Refactor NativeAnimatedHelper (#46312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46312

Refactors `NativeAnimatedHelper` to make it easier to read, reduce runtime overhead, and no longer export `queueOperation` (which was not useable externally anyway).

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D62139993

fbshipit-source-id: ce75e530887da6290f26060ecfe36049cf81879a
2024-09-06 12:15:21 -07:00
Dmitry Rykun 1063de3c27 Instrumentation for SurfaceMountingManager (#46366)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46366

This diff adds a Systrace section to the `SurfaceMountingManager::createViewUnsafe` method.
This will allow us to see more detail within the `MountItemDispatcher::mountViews preMountItems` that was previously almost blank.
Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D62247235

fbshipit-source-id: 3765c15e3e24e3231a30294938c725e82d100542
2024-09-06 11:05:15 -07:00
Pieter De Baets 0c90cfc7d4 Remove some Tasks overhead (#46348)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46348

`continueWithTask` skips an extra invocation layer that `onSuccess` adds. Switch to Task<Void> as the task can already represent failure or success without needing a boolean.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D62213722

fbshipit-source-id: 631d741bd2ec4917eab69a20978ab2ace737c459
2024-09-06 10:32:47 -07:00
Alan Lee 3bd3d7687d handle InspectorPanel overlap with system bars (#46340)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46340

**Issue:**
InspectorPanel is hidden behind 3 button nav bar on Android 15 forced edge-to-edge

**Solution:**
Apply SafeAreaView to avoid overlap with system bars
(CAUTION: SafeAreaView here is for internal RN Core usage only and should not be used elsewhere)

Changelog:
[Internal]

Reviewed By: cortinico, mdvacca

Differential Revision: D62225374

fbshipit-source-id: e762288386d4f1d210bd26b8f28e73c652c7ba4e
2024-09-06 09:39:01 -07:00
Alan Lee 206d0085f9 handle LogBox Notification overlap with nav bar (#46341)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46341

Issue: LogBox Notification (or toast) is partly hidden behind 3 button nav bar on Android 15 targetSdk 35 build

Solution: surround with SafeAreaView to avoid overlap with system bars
(CAUTION: SafeAreaView here is for internal RN Core usage only and should not be used elsewhere)

Changelog:
[Internal]

Reviewed By: cortinico, mdvacca

Differential Revision: D62224584

fbshipit-source-id: 0662b1be9822bf51dadec2dd4879c915a47dfc65
2024-09-06 09:39:01 -07:00
Nicola Corti aca31eb610 Bump AGP to 8.6.0 (#46368)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46368

This bumps AGP to the latest stable.
Release notes are here https://developer.android.com/build/releases/gradle-plugin

No relevant changes for React Native, other than the requirement on minimum Gradle version.

Changelog:
[Android] [Changed] - Bump AGP to 8.6.0

Reviewed By: tdn120

Differential Revision: D62296897

fbshipit-source-id: c34a18ab15dbacd6e5d69003b9e192d7f76d9f8f
2024-09-06 09:28:13 -07:00
Nicola Corti d0a5f8ff51 Gradle to 8.10 (#46369)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46369

This bumps Gradle to the latest stable ahead of the 0.76 branch cut.

Changelog:
[Android] [Changed] - Gradle to 8.10

Reviewed By: tdn120, Abbondanzo

Differential Revision: D62296898

fbshipit-source-id: 59fc119dd6fad3b6b0ebbfcd8166da4cad9b8633
2024-09-06 09:28:13 -07:00
Pieter De Baets 31abc5d51b Simplify preMountItems frame time check (#46347)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46347

Calculate a frame deadline, and compare the current time against that.

This will also allow us to make frame timing more dynamic in the future, based on the display's frame rate.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D62213710

fbshipit-source-id: 1c7fc4b67d08c1eda4f3b9612a4506b33c44f626
2024-09-06 09:19:01 -07:00
Richard Barnes 194b642633 Fix using namespace issues in xplat
Differential Revision: D62242159

fbshipit-source-id: b95e0ece2f55b3df3310ac84cde34d7f40b2706c
2024-09-06 09:06:49 -07:00
Dmitry Rykun 5e777848ed Cleanup the useDebouncedEffect experiment
Summary:
This diff cleans up the `use_debounced_effects_for_animated` experiment. It is not shipped because it breaks semantics of Animated.

It also removes the implementation of now unused `useDebouncedEffect` hook.

bypass-github-export-checks

Facebook
Details here https://fb.workplace.com/groups/3611662615830335/permalink/3666119690384627/

Changelog: [Internal]

Reviewed By: bvanderhoof

Differential Revision: D62188361

fbshipit-source-id: ce215cf7dd57e41e02c33760e91808d774bbd919
2024-09-06 05:27:01 -07:00
Samuel Susla 8ebddf3715 listen to onUserDrivenAnimationEnded in passive effects versions of useAnimatedPropsLifecycle (#46361)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46361

changelog: [internal]

to support onScroll native animated event, subscribe to onUserDrivenAnimationEnded event in passive effects version of useAnimatedPropsLifecycle.

Reviewed By: javache

Differential Revision: D62236130

fbshipit-source-id: 850e6cb5544eb0377492fd030f735b159f24ab8d
2024-09-06 04:30:17 -07:00
Samuel Susla 4c55e94dc5 remove unnecessary useRef (#46351)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46351

changelog: [internal]

useRef here is not needed, let's remove it.

Reviewed By: yungsters

Differential Revision: D62235850

fbshipit-source-id: 77d50152f5423e8806cc28c18bcaf4803076e813
2024-09-06 04:30:17 -07:00
Alan Lee 5fe7660439 Set inset based margins on LogBox (#46338)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46338

**Issue:**
With forced edge-to-edge on Android 15, LogBox bottom tab bar is hidden behind 3 button nav bar and is unusable.

**Solution:**
LogBox is using Android Dialog so update it to set margins based on inset values. With this change we can get rid of android header logic from JS.

Changelog:
[Android][Changed] - Modify LogBox to be usable on Android 15

Reviewed By: mdvacca

Differential Revision: D62224124

fbshipit-source-id: 4721753bf340bd813bcd560052c52b63fa58ad4b
2024-09-05 17:23:14 -07:00
Alan Lee f7479e6a1c set inset based padding to RNTester (#46354)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46354

**Issue:**
With forced edge-to-edge on Android 15, RNTester title at top overlaps with the status bar and bottom tab bar overlaps with bottom nav bar

**Solution:**
Add margins based on inset values to the ReactRootView which is the contentView for RNTesterActivity which acts as global padding within RNTester

Changelog:
[Android][Changed] - Adding padding for RNTester on Android 15 forced edge-to-edge

Reviewed By: mdvacca

Differential Revision: D62247910

fbshipit-source-id: 7b35d0c2016b6897b5de436a4245c9e910559541
2024-09-05 15:56:54 -07:00
Pieter De Baets 46fc9d9a2d Fix DispatchUIFrameCallback invoked multiple times per frame (#46346)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46346

Noticed that we could sometimes have multiple instances of DispatchUIFrameCallback in a single frame, which would cause us to execute more view preallocations or other work scheduled by Fabric. Root cause for this is on the new architecture, onHostResume seems to be invoked multiple times.

Make this code more resilient by explicitly tracking the state of the frame callback and avoiding multiple subscriptions. Longer-term we should consider having ReactChoreographer support repeating FrameCallbacks, since most of them are.

Changelog: [Android][Fixed] Fixed multiple Fabric dispatch callbacks being executed in a single Android frame

Reviewed By: sammy-SC

Differential Revision: D62213721

fbshipit-source-id: ac6fa5483ea38d9a15824af233fd23f1f6f3c891
2024-09-05 10:28:09 -07:00
Vitali Zaidman b37101486b update babel and fix tests accordingly (#46295)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46295

X-link: https://github.com/facebook/metro/pull/1343

Updated all **babel** packages in all `package.json` across the repo and ran `npx yarn-deduplicate yarn.lock --scopes babel`. Afterwards, fixed the following issues appearing as a result of that (squashed the following initially separate diffs to make this packages update work atomically):
### (D61336392) updated jest snapshot tests failing
### (D61336393) updated babel types and corrected typings accordingly
The latest babel 7 introduces the following features we need to adjust our types to:
* `JSXNamespacedName` is removed from valid `CallExpression` args ([PR](https://github.com/babel/babel/pull/16421))
  * `JSXNamespacedName` is used for namespaced XML properties in things like `<div namespace:name="value">`, but `fn(namespace:name)` doesn't make any sense.
* Dynamic imports are enabled behind a new flag `createImportExpressions` ([PR](https://github.com/babel/babel/pull/15682)), introducing calls such as `import(foo, options)`. These complicate the expected values passed to `import` to be more than just strings.
  * Since these are behind a flag that is not expected to be enabled, we can throw an error for now and whoever uses it can add a support to it if needed later.

### Added a new metro ENV ignore
`BROWSERSLIST_ROOT_PATH` is set to `""` explicitly in `xplat/js/BUCK`
and then ignored in
`js/tools/metro-buck-transform-worker/src/EnvVarAllowList.js`

Reviewed By: robhogan

Differential Revision: D61543660

fbshipit-source-id: abbcab72642cf6dc03eed5142eb78dbcc7f63a86
2024-09-05 07:11:17 -07:00
Pieter De Baets 3df0f3b9ff Skip transform invalidation if unchanged (#46345)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46345

Deriving transforms can be expensive on Android. When using NativeAnimated with transforms, especially with an EventBasedDriver, we may update the transform every frame, even if it's unchanged. Ideally, we'd fix this in Animated, and diff the previous and next values, but this closes the gap somewhat in the short-term.

Both JavaOnlyArray and ReadableNativeArray implement equals, but will not compare equality correctly with each other. That's not an issue, as it just means we'll redo the transform once more than necessary.

Changelog: [Android][Fixed] Optimize BaseViewManager#setTransform to ignore duplicate values

Reviewed By: NickGerleman

Differential Revision: D62213726

fbshipit-source-id: 5df026030c66e31eb6a5fe6353de3706b5b7b799
2024-09-05 04:48:15 -07:00
Mohamed Alsadek f1031be3e2 Enable Multiple Sheet Presentation in React Native (#46333)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46333

This pull request introduces enhancements to the view controller presentation logic in React Native, allowing for multiple sheets to be presented on top of each other. The current implementation restricts the presentation to a single view at a time, which limits the flexibility needed in complex applications.
The proposed changes modify the presentation behavior to always utilize the top-most view controller for presentations. This adjustment ensures that multiple sheets can be managed more effectively, without disrupting the existing application flow.
Key changes include:
Modification of the presentation logic to reference the top-most view controller.
Utilization of a recursive method to determine the top-most controller.
The changes have been thoroughly tested with both old and new interfaces and have shown to work seamlessly across different scenarios
Changelog: [Internal] Allow multiple sheets to be presented on top of each other

Reviewed By: jessebwr

Differential Revision: D62202475

fbshipit-source-id: daa0cf95edb23ea52a26441337f9a16f5475b211
2024-09-04 20:43:58 -07:00
Sam Zhou 62ee5c9b81 Replace final $ObjMap in react-native with mapped type (#46335)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46335

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D62208265

fbshipit-source-id: f7c72f7239b49fbaee626c3572c116e26b698300
2024-09-04 18:33:20 -07:00
Sam Zhou 464a202ba6 Replace $ObjMap in EventEmitter with mapped type (#46332)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46332

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D62199703

fbshipit-source-id: 24abf39b01d5ba8a90e03ce837a887d4b4f4ade8
2024-09-04 13:52:02 -07:00
Qi Zhao e8646630a4 fix broken test due to error message change (#46329)
Summary:
## Context
The error message in folly dynamic has been updated in D62136190. Updating related tests to reflect the change.

## Diff
Only test code is changed. No business logic change.

## Changelog:
[Internal] [Fixed] - Fix broken unit test due to folly error message change

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

```
Shows details about the selected run from the run history
Run result
java.lang.AssertionError: Test failure
Test Case RecoverableError
* Running RecoverableError.RunRethrowingAsRecoverableRecoverTest
* Running RecoverableError.RunRethrowingAsRecoverableFallthroughTest
2/2 tests passed.
Test Case JsArgumentHelpersTest
* Running JsArgumentHelpersTest.args
***** Failure in xplat/js/react-native-github/packages/react-native/ReactCommon/cxxreact/tests/jsarg_helpers.cpp:108
Expected equality of these values:
  ex.what()
    Which is: "Error converting javascript arg 4 to C++: TypeError: expected dynamic type 'int/double/bool/string', but had type 'array'"
  std::string("Error converting javascript arg 4 to C++: " "TypeError: expected dynamic type `int/double/bool/string', but had type `array'")
    Which is: "Error converting javascript arg 4 to C++: TypeError: expected dynamic type `int/double/bool/string', but had type `array'"

0/1 tests passed.
Test Case JSBigFileString
```

Reviewed By: yfeldblum

Differential Revision: D62184078

fbshipit-source-id: 6ae0a33f58e0e10f14166084b80a997e59a008ec
2024-09-04 12:19:00 -07:00
Tim Yung 320963c7cb RN: Enable Hermes Parser in Default Metro Config (#46318)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46318

Configures the Metro by default to use the Hermes parser so that React Native can fully leverage all modern Flow language syntax.

NOTE: This does not affect `*.ts` and `*.tsx` files which will continue to use Babel. Metro has logic to enforce this regardless of the transform options.

Changelog:
[General][Changed] - Changed Metro default config to use Hermes parser, enabling the use of advanced Flow syntax in React Native.

Reviewed By: robhogan

Differential Revision: D62161923

fbshipit-source-id: 0f4c069d429517be16abcc6a2187cd23c6bd52d4
2024-09-04 11:04:32 -07:00
Pieter De Baets b4b0c1d475 Avoid list allocation in scroll path (#46324)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46324

For listener sets that change infrequently, `CopyOnWriteArrayList` is a better trade-off compared to copying the list to iterate on it, especially in perf-sensitive paths like scrolling. Using `WeakReference` is also significantly simpler than `Collections.newSetFromMap(WeakHashMap`.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D62178024

fbshipit-source-id: bfc4f7389683b15be673dd7731094d52199d1c66
2024-09-04 10:51:48 -07:00
Tim Yung dda3397545 Animated: Make NativeAnimatedHelper Private (#46311)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46311

A straightforward move of `NativeAnimatedHelper` into the private directory, so that it does not impact our Public API.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D62142349

fbshipit-source-id: c93979e26e290d13e2a19fbe40d8f460ebea15fd
2024-09-04 02:54:57 -07:00
Mohamed Alsadek dea5a6ca60 Enable Multiple Sheet Presentation in React Native (#46316)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46316

This pull request introduces enhancements to the view controller presentation logic in React Native, allowing for multiple sheets to be presented on top of each other. The current implementation restricts the presentation to a single view at a time, which limits the flexibility needed in complex applications.

The proposed changes modify the presentation behavior to always utilize the top-most view controller for presentations. This adjustment ensures that multiple sheets can be managed more effectively, without disrupting the existing application flow.

Key changes include:
Modification of the presentation logic to reference the top-most view controller.
Utilization of a recursive method to determine the top-most controller.

The changes have been thoroughly tested with both old and new interfaces and have shown to work seamlessly across different scenarios

Changelog: [Internal] Allow multiple sheets to be presented on top of each other

Reviewed By: cipolleschi

Differential Revision: D62143463

fbshipit-source-id: 53667cf1a75e4514156780574bf604aee6b3fefc
2024-09-04 02:54:32 -07:00
Tim Yung 0a1ba02273 Animated: Remove Validation from Production Builds (#46287)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46287

Changes `Animated` to avoid validating certain values in production builds to improve performance.

In order to maintain consistent behavior between development and production builds (so that we reduce the likelihood of bugs that only appear in one of the environments), this also changes the validation errors to use `console.error` instead of error throwing.

Changelog:
[General][Changed] - Changed `Animated` props validation to soft errors instead of thrown errors

Reviewed By: sammy-SC

Differential Revision: D62055674

fbshipit-source-id: 8e5732d00ab06e14ba8562f5190ce79ca240e374
2024-09-03 19:02:12 -07:00
Chiara Mooney c722ec7c37 Upstream Fixes from React Native Windows Platform (#46315)
Summary:
The following fixes were needed to restore a clean build of React Native Windows downstream.

- LayoutableShadowNode.cpp: Value must be cast to a float to avoid type conversion error.
- ValueUnit.h: Must add a default return statement. Switch statement alone produces compiler error that function may end with no return value.

## Changelog:

[GENERAL] [FIXED] - Upstream fixes for build errors in React Native Windows

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

Test Plan: React Native Windows CI runs clean.

Reviewed By: javache, alanleedev

Differential Revision: D62149228

Pulled By: realsoelynn

fbshipit-source-id: 0d85455a22fbc0066076a50adee6b2d4409cd628
2024-09-03 17:10:56 -07:00
Pieter De Baets db375ab449 Do not disable AllocInYoung for Hermes by default (#46314)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46314

In Bridgeless's version of the Hermes JVM init path, we defaulted an internal GC option to allocate memory in Hermes' OldGen, and revert that behaviour once an internal API was called which marked the app as loaded.

This is an unsuitable default behaviour, since we can't rely on that internal API to be called on every launch. We're also moving to implicit performance instrumentation, which makes it harder to reliably call this API at the right time.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D61937427

fbshipit-source-id: 95e43fc093b56aee6362f43b6b0832d1f439fb3f
2024-09-03 16:01:30 -07:00
Pieter De Baets 83489de271 Fix perfetto integration iOS build (#46313)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46313

Changelog: [Internal]

Reviewed By: Abbondanzo

Differential Revision: D61937428

fbshipit-source-id: cceaa7ffb2be3fbd80ce450f2e35ddbdddbd19cc
2024-09-03 16:01:30 -07:00
Tomasz Żelawski c16defaff2 fix(TypeScript): Allow readonly arrays in transform (#46310)
Summary:
Currently readonly arrays aren't allowed in components' style, but readonly objects are accepted. This becomes evident in such case:

```ts
import { View } from 'react-native';

interface AppProps {
  transform: readonly ({ translateX: number } | { translateY: number })[];
  shadowOffset: Readonly<{ width: number; height: number }>;
}

export default function App({ transform, shadowOffset }: AppProps) {
  return (
    <>
      {/* TypeScript error with transform */}
      <View style={{ transform }} />
      {/* No errors with shadowOffset */}
      <View style={{ shadowOffset }} />
    </>
  );
}
```

## Changelog:

[GENERAL] [FIXED] - Allow readonly array type for transform property

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

Test Plan:
`yarn test-typescript`

I added relevant tests cases.

Reviewed By: robhogan

Differential Revision: D62140462

Pulled By: NickGerleman

fbshipit-source-id: 87374b0901ebc40cab48d442b61fe7a65711bc89
2024-09-03 14:50:24 -07:00
Tim Yung 2b11131247 Animated: Cleanup Types in AnimatedTransform (#46285)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46285

Cleans up the Flow types in `AnimatedTransform`.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D62054390

fbshipit-source-id: de0f0b7b35f5b1e250ea72ec563b01cde1510a23
2024-09-03 11:53:39 -07:00
Samuel Susla b875b91b91 do not ignore events dispatched during view creation (#46308)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46308

changelog: [internal]

If an event happens before view has event emitter, the event is stored in a [queue](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java#L1218) on [ViewState](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java#L1206). Once event emitter is assigned, the queue is drained.

However, if view dispatches event during view creation in preallocation, the event is dropped. This happens because when view is created, ViewState for the view is not created yet. The implementation of [createViewUnsafe](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java#L655) first creates a view (where view creation may trigger events) and only after it creates [ViewState and stores it inside of mTagToViewState](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java#L675-L680).

This diff fixes it by creating ViewState for a view before view creation.

Reviewed By: javache, rubennorte

Differential Revision: D62126909

fbshipit-source-id: bec53ea2f926a43a99dc005be257c5dc7985f373
2024-09-03 08:26:07 -07:00
Alex Hunt a1668e37e5 Remove experimental suffix from page titles (#46296)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46296

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D62095278

fbshipit-source-id: 429236c1614d689f4d64a64f062393ad524484b1
2024-09-03 04:04:28 -07:00