Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53775
A refactor to align our C++ code style within `jsinpector-modern`.
We prefer `std::string` and `const std::string&` everywhere (see [C++ Core Guidelines F.15](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-conventional)), except for when we are handing potentially very large strings — in which case we must use `string_view` all the way down.
Changelog: [Internal]
Reviewed By: hoxyq
Differential Revision: D82446939
fbshipit-source-id: 4b1c43068d1339f4b4a4c7eb06b392d0b0f624e1
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53788
Fix thread safety issue due to member variable in `NetworkHandler` singleton without mutex.
Also intend to un-singleton this class in the imminent future.
Changelog: [Internal]
Reviewed By: hoxyq
Differential Revision: D82460574
fbshipit-source-id: c0c614f8f1bb5ffba22872ae5717fbd2ca01f2e9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53793
## Changelog:
[Android] [Deprecated] - Clean up batchingControlledByJS in NativeAnimated kotlin
`start/finishOperationBatch` will no longer be called on kotlin NativeAnimated since D78005971 (https://github.com/facebook/react-native/pull/52521), so `batchingControlledByJS` will remain false. Cleaning up some logic and TODO comments there
this feature was added in D23010844
Reviewed By: christophpurrer
Differential Revision: D82461457
fbshipit-source-id: a1208720b83e614c2a5f994ec1a5005189c5f197
Summary:
As per the discussion on the previous [PR thread](https://github.com/facebook/react-native/pull/52028#issuecomment-2979481948), this PR uses `SwiftUI` to implement blur filter on iOS.
## Approach:
To implement blur filter on iOS, we have two options:
1. Use `CAFilter` (private API, app can get rejected/API can break). Earlier [PR](https://github.com/facebook/react-native/pull/52028) was using that approach. Thanks to Nick for suggesting SwiftUI API.
2. Use `SwiftUI`. Wrap the view in a SwiftUI view and apply [blur](https://developer.apple.com/documentation/swiftui/view/blur(radius:opaque:)). This PR builds on top of that approach. This also enables a way to add `SwiftUI` only features like this one. Additional filters (grayscale, saturate, contrast, hueRotate) can also be added.
There are a few ways we can implement the SwiftUI approach:
1. Create a new `RCTSwiftUIComponentView` -> do style flattening in View -> check if `filter` is present and conditionally render the `RCTSwiftUIComponentView` on iOS, wrap children with a `SwiftUI` view. Tradeoff with this approach is that it adds `StyleSheet.flatten` overhead on JS side.
2. Add a `SwiftUI` container view inside of `RCTViewComponentView`. Tradeoff with this approach is that it complicates `RCTViewComponentView` a bit.
I decided to go with **2** to avoid the flattening tradeoff and try to minimize complicating `RCTViewComponentView`. it only adds the wrapper if it's required and removes if not (in this PR, blur filter style will add the wrapper, it will get removed if blur filter styling gets removed). It uses the existing container view pattern.
## Changelog:
[IOS][ADDED] - Filter blur
<!-- 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/52495
Test Plan:
Test filter blur example on iOS. SwiftUI view should be added to the hierarchy.
<img src="https://github.com/user-attachments/assets/742539f4-a96d-45f4-94ba-5eb588d0ad5a" width="300px" />
## Aside:
- This PR also adds a new swift podspec. Creating a new podspec felt the right approach as adding swift in existing ones were adding some complexity. But open for changes here. Also, need some eyes on the podspec configs. cc - chrfalch 🙏 this might also affect the SPM migration.
- Unrelated: Existing brightness filter has some inconsistency compared to android and web, it uses [self.layer.opacity](https://github.com/facebook/react-native/blob/6892dde36373bbef2d0afe535ae818b1a7164f08/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L1008) so transparent background color do not blend well unless the view has an opacity. One solution would be to calculate true background color by using brightness or else use the `SwiftUI`'s [brightness](https://developer.apple.com/documentation/swiftui/view/brightness(_:)), which would be cleaner imo (tested and it works).
Reviewed By: cipolleschi
Differential Revision: D79666764
Pulled By: joevilches
fbshipit-source-id: 05e43d75ce7b6f25b67b4eed632524a559ea1c2e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53771
# Changelog: [Internal]
Instead of opening DevTools every time we emit a background trace, we are going to check if there is an active session with Fusebox client and will send it to the first one registered.
Reviewed By: huntie
Differential Revision: D82321146
fbshipit-source-id: 46b4d090ae9a6f8b4fc98181b303ff552c561eb8
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53760
# Changelog: [Internal]
This is a different approach from the one that I've introduced initially in [1].
This saves us from the scenario, where any local session could snatch the stashed trace recording. For example, if some session was created for a Runtime binding right after we've stashed the trace and before initializing real CDP session with the Frontend.
Reviewed By: huntie
Differential Revision: D82316584
fbshipit-source-id: 806a0f6dbdb4e4e928ce33af228cae86d43772e9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53755
Changelog: [iOS][Fixed] Make `RCTSetDefaultFontHandler` compatible with the new arch, and add a more powerful version as `RCTSetDefaultFontResolver`
Reviewed By: fkgozali
Differential Revision: D82207676
fbshipit-source-id: eeeaf708491de9156ef4f1e045864e4322213902
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53777
Expose `unstable_NativeText` and `unstable_NativeView` components as root exports of the `react-native` package.
These are exposed as `unstable_` APIs which have no semver guarantee.
**Motivation**
There is significant community interest / dependance on the currently private `TextNativeComponent` and `ViewNativeComponent` deep imports, to access the faster-performing inner versions of these UI components.
Using `<Text>` and `<View>`, while recommended and stable, has led to measurable performance overhead in some apps when compared with these `<Native*>` counterparts.
Notably, these APIs are also referenced by low-level libraries such as React Strict DOM.
I am proposing this change in order to:
- Unblock libraries which safely use these.
- Meet users where they are at.
- Unblock us from enabling the Strict TypeScript API (no deep imports).
References:
- https://github.com/react-native-community/discussions-and-proposals/discussions/893#discussioncomment-13452047
- https://javascript.plainenglish.io/optimizing-text-component-rendering-in-react-native-b9d3565659d9
- https://github.com/search?type=code&q=react-native%2FLibraries%2FText%2FTextNativeComponent
**Ideal future state**
We are exposing these as unstable APIs because they should not be part of React Native's final API. The ideal end state is we improve the regular `<Text>` and `<View>` components to eliminate performance overhead and the need to access any lower level API.
Changelog:
[General][Added] - `unstable_NativeText` and `unstable_NativeView` are now exported from the `react-native` package
Reviewed By: javache
Differential Revision: D81588145
fbshipit-source-id: 2ea9b7f822286de85f49607944c6a484d1fcf242
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53761
Updates `NetworkReporter` and `PerformanceEntryReporter` to populate (minimal) `"ResourceSendRequest"` and `"ResourceFinished"` events when a CDP performance trace is active. This allows the Chrome DevTools Performance panel to display the "Network" track.
**Notes**
- The trace events that Chrome requires need extra fields which aren't present on `PerformanceResourceTiming`, hence the new + optional `devtoolsRequestId`, `requestMethod`, `resourceType` params. We only populate these in debug builds.
**Limitations**
- We emit a *complete trace event set* within `reportResourceTiming`, implementing basic initial support in the Performance panel Network track. This means 1/ either all/no events are sent for a given request (rather than incrementally), 2/ we aren't yet handling failed/cancelled requests in this pipeline.
Changelog: [Internal]
Reviewed By: hoxyq
Differential Revision: D82212362
fbshipit-source-id: 4c6d5d2510cc98ddc819a2778222b835411295c8
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53746
ScreenshotTestsManagerModule and ReactAppScreenshotTestActivity are not in use anymore, let's delete them
changelog: [internal] internal
Reviewed By: javache
Differential Revision: D82249453
fbshipit-source-id: 73b0f2ef2e9a5370057c07c3bee03f9c0793d61a
Summary:
This pull request fixes a small error in the deprecation message for `ReactContextBaseJavaModule#getCurrentActivity()`, where the reference to `getReactApplicationContext().getCurrentActivity()` contained a syntax error.
## Changelog:
[ANDROID] [FIXED] - Correct deprecation message for `ReactContextBaseJavaModule#getCurrentActivity()`
Pull Request resolved: https://github.com/facebook/react-native/pull/53751
Reviewed By: javache
Differential Revision: D82302032
Pulled By: cortinico
fbshipit-source-id: 130991ef514663223165c30fccb920ce87403148
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53752
Currently we `Objects.requireNotNull` on the `SurfaceMountingManager` inside the `getEncodedScreenSizeWithoutVerticalInsets`
function. However the `SurfaceMountingManager` could be null.
In that scenario, I'm returning 0 here (that will restore the old broken behavior, with the modal rendering on the top left corner for the first frame), instead of letting the app crash.
Changelog:
[Android] [Fixed] - Do not crash inside getEncodedScreenSizeWithoutVerticalInsets if SurfaceMountingManager is null
Reviewed By: javache
Differential Revision: D82225855
fbshipit-source-id: df84db612e77b6b981bc28afc0d293867b5d3b2e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53326
Apple changed the sizes of the UISwitchComponent and now, if you build an iOs app using the <Switch> component, the layout of the app will be broken because of wrong layout measurements.
This has been reported also by [https://github.com/facebook/react-native/issues/52823](https://github.com/facebook/react-native/issues/52823).
The `<Switch>` component was using hardcoded values for its size.
This change fixes the problem by:
- Using codegen for interface only
- Implementing a custom Sadow Node to ask the platform for the Switch measurements
- Updating the JS layout to wrap the size around the native component.
## Changelog:
[iOS][Fixed] - Fix Switch layout to work with iOS26
Reviewed By: sammy-SC
Differential Revision: D80454350
fbshipit-source-id: 1d468910276f7fde4559d2ae87cf60c8494caceb
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53741
Adds a couple of web link options to populate the "Help" menu in the RNDT desktop app. The default menu is otherwise unchanged.
Changelog: [Internal]
Reviewed By: vzaidman
Differential Revision: D82231524
fbshipit-source-id: 9a57e6067854716691dc35938d6f27735b8c8448
Summary:
While working on a somewhat non-standard library setup I ran into:
`[Codegen] TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined`
which was caused by `xcodeproj` file not found. The issue was on the project side rather than codegen, but the error message was rather unhelpful, so this improves it.
## Changelog:
[General][Changed] - improve codegen error when ios native project not found
Pull Request resolved: https://github.com/facebook/react-native/pull/53726
Test Plan:
tested locally, received the improved error message:
`[Codegen] Error: Cannot find .xcodeproj file inside /Users/some_project. This is required to determine codegen spec paths relative to native project.`
Reviewed By: cortinico
Differential Revision: D82226931
Pulled By: cipolleschi
fbshipit-source-id: dd851205655048fc35ed9f5266cefdbfb067d211
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53734
## Changelog:
[Internal] [Changed] - ensure animatedNodes collection is only accessed on render thread
now `createAnimatedNode` can be called async from js thread (since https://github.com/facebook/react-native/pull/53476), `animatedNodes_` will be written on both threads, there was no proper locking mechanism for read
we can simply add locks wherever we read/write animatedNodes_; but there's way to use fewer locking - since AnimatedNode is created async, but will not be R/W async anywhere else, we can add a new collection to temporarily hold nodes created async and flush it on render thread
Reviewed By: lenaic
Differential Revision: D82119554
fbshipit-source-id: 7f29e9e046cdf2e233c548442d70f1ff5b931cdd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53651
## Stack
We aim to remove +load methods from the codebase to reduce pre-main startup time and to unblock enabling startup optimizations
## Diff
Diff removes `+load` API from `RCT_EXPORT_MODULE` macro.
It introduces new parameter for `react_native_module_provider` function `eager`, which adds legacy RN modules to newly created socket `REACT_MODULE_EAGER_REGISTRATION_SOCKET`. This socket is invoked right before the RCTBridge is being initialized.
Impact: 137 static loaders are removed from the startup path
## RN
Changelog: [Internal]
Reviewed By: RSNara
Differential Revision: D81727845
fbshipit-source-id: 4904499f2e8587717b26579364ed48ffed934774
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53688
Support for the `removeIf` method was [added to CopyOnWriteArrayList with AOSP in API 26](https://android-review.googlesource.com/c/platform/libcore/+/304056). On devices with API 24 and 25, invocations of either `ReactScrollViewHelper#removeScrollListener` or `ReactScrollViewHelper#removeLayoutChangeListener` would cause a crash. Rather than bump the required API version and lock out apps targeting API 24/25, this adds a separate code path to bulk remove items from the array list.
Changelog: [Internal]
Differential Revision: D82039300
fbshipit-source-id: 6509dc637534b8e546f84447dbcdce1c5bca42f0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53692
With some custom typefaces, font hinting causes "jittery" artifacts upon scaling the text. We already set the subpixel text flag for views with custom or modified typefaces and this change also sets the linear text flag. Per [Android documentation](https://developer.android.com/reference/android/graphics/Paint#SUBPIXEL_TEXT_FLAG), it's recommended that both of these flags are set together to avoid this exact artifacting. This change is being gated behind a feature flag to evaluate the performance impact of disabling glyph caches for all text, and may drive the need to introduce a prop that controls this setting in the future.
Changelog: [Internal]
Reviewed By: rozele
Differential Revision: D82050029
fbshipit-source-id: 9e6e023ff723641f663935b6cd7aae07045834bc
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53718
I've just realized we ended up invoking `project.` inside the execution of `BundleHermesCTask`.
This is an anti-pattern and is breaking Gradle Configuration caching.
Instead we should be checking if hermesV1Enabled is set during the Task registration and pass over this information
to the task.
Changelog:
[Internal] [Changed] -
Reviewed By: j-piasecki
Differential Revision: D82130643
fbshipit-source-id: d2026711666867b3767824381cc5be0af3b476cc
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53725
Changelog: [GENERAL][CHANGED] - Changed the coordinates of hermes artifacts when using Hermes V1
Adds a new `version.properties` file to keep which hermes versions should be consumed from Maven once the versions of Hermes and React Native are decoupled. This diff only implements changes necessary for consuming Hermes V1, as we don't want to migrate everything quite yet (0.82).
Reviewed By: cortinico
Differential Revision: D82204203
fbshipit-source-id: d712257a73f7ba54612a55c1b312416376f28b56
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53712
Changelog: [internal]
This enables the new Web Performance APIs in the canary channel.
Reviewed By: cortinico
Differential Revision: D82117694
fbshipit-source-id: 370b8397eeec350be8434728ab9d8ce1f5926117
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53711
Changelog: [internal]
This removes some fields that contain the same time as `endTime`, which is confusing when documenting them.
Reviewed By: christophpurrer
Differential Revision: D82112473
fbshipit-source-id: 461e2b4b495ae641dcb3233874360a4f7b90dabf
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53710
Changelog: [internal]
This should be a getter according to the spec.
Reviewed By: hoxyq
Differential Revision: D82111779
fbshipit-source-id: 614bb4848907bacd80ef228aa747ae685cf2c1f7
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53619
With this change, we are making Codegen generate a Package.swift file so that we can integrate the `ReactCodegen` and the `ReactAppDependencyProvider` in apps only using SwiftPM
## Changelog
[iOS][Added] - Make codegen generate PAckage.swift file for the codegen targets
Reviewed By: cortinico
Differential Revision: D81769543
fbshipit-source-id: 1f1a1b9f41126e142931d5eda6e75109a69f828c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53618
This change makes sure that we generate the codegen files in the ReactCodegen and ReactAppDependencyProvider folder.
This is necessary as Swift PM needs the source code of packages to be grouped in folders that are children of where the Package.swift is located.
This is not a breaking change, because Cocoapods has been updated accordingly, import/include paths are not changed and the folder layout should not be accessed by anybody directly
## Changelog:
[Internal] -
Reviewed By: cortinico
Differential Revision: D81769522
fbshipit-source-id: 7c70f96a9aa503c4faaf173b94c8ee0e326094a1
Summary:
Follow-up to https://github.com/facebook/react-native/issues/53503 for a regression
When no React Native module is present this bail condition stops us from generating the artifacts podspec that's needed to complete build.
## Changelog:
[IOS] [FIXED] - Fix regression that skips artifacts code generation
Pull Request resolved: https://github.com/facebook/react-native/pull/53690
Test Plan:
- Create an app **without** any React Native modules, run `pod install`; without this fix the podspec will be missing and the build will fail
- With expo this can be reproduced using `create-expo-app --template blank-typescript@next` on `react-native@0.81.2`
- With the community CLI this can be reproduced using `npx react-native-community/cli@latest init test --skip-install --version 0.81.2` and uninstalling `react-native-safe-area-context`
Reviewed By: javache
Differential Revision: D82103491
Pulled By: cipolleschi
fbshipit-source-id: 3d9619b5a935ca920220824b3963a9a107f926ca
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53660
Changelog: [internal]
(This is internal because these APIs aren't enabled in OSS yet)
Implements `performance.timeOrigin` to allow converting timestamps from `performance.now()` to be based on the Unix epoch.
This implementation isn't fully spec-compliant to align with the current implementation of `performance.now()`, where the base of the clock is system boot time instead of app startup / navigation time.
Reviewed By: huntie
Differential Revision: D82016724
fbshipit-source-id: e3a066721cecf41e2fd963beb94a0a2f1c5d6493