Summary:
solve the exception on android when `Appearance.setColorScheme` and activity recreate()
Fixes https://github.com/facebook/react-native/issues/47954
## Changelog:
[Android][Fixed] setColorScheme should be called on the UI thread
Pull Request resolved: https://github.com/facebook/react-native/pull/47955
Reviewed By: cortinico
Differential Revision: D66573373
Pulled By: javache
fbshipit-source-id: 97808e163e1c53bb94f4be7269d9cb9e212f2e95
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47962
Updates `HostAgent` to respond equivalently if either `FuseboxClient.setClientMetadata` (outgoing) or `ReactNativeApplication.enable` (incoming) are sent by the CDP frontend.
This is a partial migration, to be followed by removing the `FuseboxClient.setClientMetadata` method later.
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D66501027
fbshipit-source-id: 1ff669c24667f51d240311e75f95747efe577e2d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48006
Changelog: [internal]
This implements symbolication of error stack traces in Fantom tests. We just needed to ask Metro to generate source maps and use the `source-map` package to process the stack traces that we get back from the runtime.
Reviewed By: sammy-SC
Differential Revision: D66577818
fbshipit-source-id: 672c66c246ad8646646d5ed31cabca39eb4f7aca
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48002
Demonstrates the issue identified in https://github.com/facebook/react-native/issues/47960 and a crash we've been seeing internally around `getViewState` referencing a view that does not exist.
When reparenting unflattened nodes, Differentiator may emit an `update` with a `parentShadowView` that does not exist on the native side yet, thereby crashing Android.
Landing the test-case first (with some test cleanup), so the diff for the actual fix is clearer.
Changelog: [Internal]
Reviewed By: lenaic
Differential Revision: D66557919
fbshipit-source-id: 5428c32e5f0200a8e98568cabeedb0c61aafbe23
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47994
Changelog: [internal]
This adds a few hacks to improve errors messages in Fantom tests. Before, we were only logging the error message. After this, we log the message and the full (unsymbolicated for now) stack, including a pretty print of the exact location of the error.
For errors thrown from `expect` functions, the stack trace is modified to remove the "infra" lines from the stack.
The next step is symbolicating the errors using source maps generated by metro.
Reviewed By: javache
Differential Revision: D66555063
fbshipit-source-id: 17bd23cb30429a17e99f13f934c45e001120bbb3
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47968
Updates the Inspector Proxy to report + log when a profiling build target (experimental) is registered. This notifies the developer that debugging is available for these app(s), which will not otherwise fetch development bundles from Metro.
Changelog: [Internal]
Reviewed By: rubennorte
Differential Revision: D66501771
fbshipit-source-id: e06dee279158094ad5c70bf8e6a90e7c983de48a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47983
Changelog: [internal]
This mitigates some performance regressions caused by the migration from `ReactFabricHostComponent` to `ReactNativeElement` (enabling the DOM APIs).
Those regressions were caused by 2 main things:
1. By the use of a class hierarchy and having to call `super()`, which we transpile to a very complex code to ensure it's spec compliant.
2. By the use of private fields (`#viewConfig`) which are significantly slower than a regular field with the `_` naming convention (`_viewConfig`) processed by our custom transform.
This mitigates those problems by using the `_` convention and refactoring the class hierarchy to avoid the use of `super()` while preserving the Flow typing and most of the existing implementation.
Reviewed By: javache, andrewdacenko
Differential Revision: D66540756
fbshipit-source-id: db6aa18c12194b18e3a69e9979621d0feae6186a
Summary:
Removed `node-fetch` in favour of node builtin fetch to get rid of the deprecated `punycode` warning when using Node 22.
`react-native/community-cli-plugin` already requires Node >= 18 where it was made available by default (without `--experimental-fetch` flag).
This change is similar to the one made in https://github.com/facebook/react-native/pull/45227
## Changelog:
[GENERAL] [CHANGED] - Drop node-fetch in favor of Node's built-in fetch from undici in `react-native/community-cli-plugin`
Pull Request resolved: https://github.com/facebook/react-native/pull/47397
Test Plan: tests pass
Reviewed By: blakef
Differential Revision: D66512595
Pulled By: NickGerleman
fbshipit-source-id: c4e01baf388f9fae8cea7b4bfe25034bff28b461
Summary:
X-link: https://github.com/facebook/yoga/pull/1755
Pull Request resolved: https://github.com/facebook/react-native/pull/47975
I've been working with callsites here and its annoying if you switch these that you need to move these params around too. Let's just make them the same order
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D66519836
fbshipit-source-id: 2e98e671270a053c6e62372e2003f1ca67774ec9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47965
Changelog: [General] [Changed] - fix item disappearing with scroll in VirtualizedList
It was caused because the function `computeWindowedRenderLimits` collapsed the current window size to just 1 element. So, users start scroll current window increase from {left:0, right:5 } -> {left:0, right:6 } and after some edge cases the window collapsed to `{left:6, right:6 }` which cause to remove all elements and recreate them later. As a result users have a lot of lags and blank pages.
The diff fixes the collapsing window size to 1 element. Also fix other decreasing `left` position even if windowSize more than current amount of elements.
Reviewed By: NickGerleman
Differential Revision: D66334188
fbshipit-source-id: 2162d00d03d64ab6325c0492d87449051e68a4e9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47723
Identity of `ImageRequest` is based on `ImageSource` and a subset of `ImageProps`. If any of those change, the request must be recreated and resubmitted.
Currently, the relevant subset of ImageProps is represented by a single `blurRadius` prop. This list will grow in the future. In order to simplify adding new props to the image request, we introduce the `ImageRequestParams` type that will wrap all the relevant props.
The alternative approach to pass `ImageProps` directly to `ImageManager` is worse because it would introduce dependency cycle between `ImageManager` and the `Image` component, and also it would require to store the props in State, which is bad.
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D66172570
fbshipit-source-id: d6853bf8dcecd6e76ac90ccb2079d102a3015988
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47721
This diff splits Cxx ImageManger into Cxx and Android variants. They both are currently no-op, but the Android one will be used for image prefetching, just as `RCTImageManager.mm` for iOS.
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D65753319
fbshipit-source-id: 774ff09b6b397facee7f645706dd97ba6d1177d7
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47950
`addInArray` may reallocate `mAllChildren` so it's not correct to store this reference.
Changelog: [Internal]
Reviewed By: tdn120
Differential Revision: D66474532
fbshipit-source-id: 90ce2fcbf8ff236501ed47b2acc413e54ef8b82a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47913
CompositeBackgroundDrawable has some logic for inserting the layers that are not set through the constructor. This unit test makes sure they are being properly ordered.
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D66381515
fbshipit-source-id: 514979a4a97fa159c1d1c3c923afe969eafc21c3
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47934
This property needs to be made public for later diffs in this stack.
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D66338915
fbshipit-source-id: f4896f8404e3d7eed7255e0f923ab5eec9a1291e
Summary:
The React Native `<ScrollView>` has a peculiar `centerContent` prop. It solves a common need — keeping the image "centered" while it's not fully zoomed in (but then allowing full panning after it's sufficiently zoomed in).
This prop sort of works but it has a few wonky behaviors:
- If you start tapping immediately after pinch (and don't stop), the taps will not be recognized until a second after you stop tapping. I suspect this is because the existing `centerContent` implementation hijacks the `contentOffset` setter, but the calling UIKit code _does not know_ it's being hijacked, and so the calling UIKit code _thinks_ it needs to do a momentum animation. This (invisible) momentum animation causes the scroll view to keep eating the tap touches.
- While you're zooming in, once you cross the threshold where `contentOffset` hijacking stops adjusting values, there will be a sudden visual jump during the pinch. This is because the "real" `contentOffset` tracks the accumulated translation from the pinch gesture, and once it gets taken into account with no "correction", the new offset snaps into place.
- While not sufficiently pinched in, the vertical axis is completely rigid. It does not have the natural rubber banding.
The solution to all of these issues is described [here](https://petersteinberger.com/blog/2013/how-to-center-uiscrollview/). Instead of hijacking `contentOffset`, it is more reliable to track zooming, child view, and frame changes, and adjust `contentInsets` instead. This solves all three issues:
- UIKit isn't confused by the content offset changing from under it so it doesn't mistrigger a faux momentum animation.
- There is no sudden jump because it's the insets that are being adjusted.
- Rubber banding just works.
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[IOS] [FIXED] - Fixed centerContent losing taps and causing jitter
Pull Request resolved: https://github.com/facebook/react-native/pull/47591
Test Plan:
I'm extracting this from [a patch we're applying to Bluesky](https://github.com/bluesky-social/social-app/blob/2ef697fe3d7dec198544ed6834553f33b95790b3/patches/react-native%2B0.74.1.patch). I'll be honest — I have not tested this in isolation, and it likely requires some testing to get merged in. I do not, unfortuntately, have the capacity to do it myself so this is more of a "throw over the wall" kind of patch. Maybe it will be helpful to somebody else.
I've tested these in our real open source app (https://github.com/bluesky-social/social-app/pull/6298). You can reproduce it in any of the lightboxes in the feed or the profile.
### Before the fix
Observe the failing tap gestures, sudden jump while pinching, lack of rubber banding.
https://github.com/user-attachments/assets/c9883201-c9f0-4782-9b80-8e0a9f77c47c
### After the fix
Observe the natural iOS behavior.
https://github.com/user-attachments/assets/c025e1df-6963-40ba-9e28-d48bfa5e631d
Unfortunately I do not have the capacity to verify this fix in other scenarios outside of our app.
Reviewed By: sammy-SC
Differential Revision: D66093472
Pulled By: javache
fbshipit-source-id: 064f0415b8093ff55cb51bdebab2a46ee97f8fa9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47292
If we don't add the prop to the iterator style parser then since fabric is not parsing the prop we are not properly creating the stacking context for when a prop has a mix-blend-mode set
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D65166886
fbshipit-source-id: 7b5bce82e81bf0c566ccd4620852ae877ccbf376
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47293
We missed fabric check for the mix-blend-mode conditional on `drawChildren` adding it now
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D65167244
fbshipit-source-id: 1af5dc1979fb79c453ba0f27c0385a94dc539a55
Summary:
While trying to write some test cases for `ReactOkHttpNetworkFetcher`, I found that the cache control headers are not being sent over the network request correctly. These cache control headers are always being overwritten by the rest of the headers hence all the logic to set this custom cache control doesn't seem to be working as expected.
As per the [Request headers](https://github.com/square/okhttp/blob/2832a9e532ecbc6f1f84b3a07e8e64b75372789c/okhttp/src/main/kotlin/okhttp3/Request.kt#L256) docs, this seems to be the explanation:
> /** Removes all headers on this builder and adds [headers]. */
open fun headers(headers: Headers) = commonHeaders(headers)
With the new approach by setting the headers first, we ensure that the cache control headers don't get overwritten but they would get added on top of the passed headers.
Notice that currently it seems to be overwriting these headers even if there are not headers passed from the Image component (AKA null/empty).
See my reproduction example in the test plan.
## Changelog:
[ANDROID] [FIXED] - ReactOkHttpNetworkFetcher – cache control headers getting overwritten by the rest of the headers
Pull Request resolved: https://github.com/facebook/react-native/pull/47922
Test Plan:
By creating the following component, we log the request headers using `FLog` with the previous and the new approach. See the difference on the outputs below:
Component:
```tsx
<Image
source={{
uri: 'https://www.facebook.com/assets/fb_lite_messaging/E2EE-settings@3x.png?cacheBust=reload',
cache: 'reload',
headers: {
'some-header': 'some-header-value',
},
}}
/>
```
Setting the `headers` last (current approach):
```kt
val request =
Request.Builder()
.cacheControl(cacheControlBuilder.build())
.url(uri.toString())
.headers(headers)
.get()
.build()
FLog.w("RequestHeaders", request.headers.toString())
```
Output (notice that the Cache-Control header is not present):
```bash
RequestHeaders com.facebook.react.uiapp W some-header: some-header-value
```
<img width="561" alt="image" src="https://github.com/user-attachments/assets/797cd90a-2064-4772-99cc-5f9d39d73361">
---
New approach by setting the `headers` first:
```kt
val request =
Request.Builder()
.headers(headers)
.cacheControl(cacheControlBuilder.build())
.url(uri.toString())
.get()
.build()
FLog.w("RequestHeaders", request.headers.toString())
```
Output (Cache-Control is present now along with the passed headers):
```bash
RequestHeaders com.facebook.react.uiapp W some-header: some-header-value
Cache-Control: no-cache, no-store
```
<img width="556" alt="image" src="https://github.com/user-attachments/assets/1b9f7865-926e-496b-ad3a-36e19ae92188">
Reviewed By: rshest
Differential Revision: D66446820
Pulled By: javache
fbshipit-source-id: 2640ea4b0e678a7aa919b919b0b44bedc0da0af4
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47895
X-link: https://github.com/facebook/yoga/pull/1750
These APIs were only added so that we could do TDD as we work on intrinsic sizing functionality. As of right now they do nothing. We are aiming on publishing a new version of Yoga soon so for the time being we are going to back these out so as not to confuse anyone with this new functionality. Ideally we get to a point where we have some temporary experimental header to stage these in but this is a bit time sensitive so just backing out for now
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D66332307
fbshipit-source-id: 1d596964e0c893091c541988506e8b80fa6d1957
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47896
X-link: https://github.com/facebook/yoga/pull/1752
These APIs were only added so that we could do TDD as we work on intrinsic sizing functionality. As of right now they do nothing. We are aiming on publishing a new version of Yoga soon so for the time being we are going to back these out so as not to confuse anyone with this new functionality. Ideally we get to a point where we have some temporary experimental header to stage these in but this is a bit time sensitive so just backing out for now
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D66332309
fbshipit-source-id: 793f77dad021fa5e57b52c36ae954307636bcbf0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47336
Before mix-blend-mode would not blend with the background color due to it not being a ViewGroup. This adds the mix-blend-mode logic to ReactRootView so blending works
Changelog:
[Android][Fixed] - Enable mix-blend-mode on ReactRootView so blending works with app background
Reviewed By: NickGerleman
Differential Revision: D65156543
fbshipit-source-id: b3628b667573d0b56c74214e40d21c656fda495a
Summary:
I was just going through the README file, and I felt that the word "repo" seems a bit informal. Thus I made the correction and made it "repository".
## Changelog:
[General] [Changed] - Fixed a typo in the README file.
Pull Request resolved: https://github.com/facebook/react-native/pull/47918
Test Plan: No specific Test Plan for these changes, as it is just a typo fix in README.md
Reviewed By: fkgozali
Differential Revision: D66414686
Pulled By: arushikesarwani94
fbshipit-source-id: 578530d2dcdf046a90bf5a5bc32ba68e8f496c81
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47914
This was a bug in the original diff: D66193194.
If a fatal js error happens, we should only drop subsequent **fatal** js errors. It's fine to report soft errors.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D66392706
fbshipit-source-id: c51bae186184c54faa9bce065b81b442607e751b
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47747
Deprecate NotThreadSafeViewHierarchyUpdateDebugListener as won't be available in new arch and will be deleted
changelog: [internal] internal
Reviewed By: javache
Differential Revision: D66216730
fbshipit-source-id: 88f3346ad38b80a710d9df4ba08b63887048c8cd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47746
Remove DeprecatedInNewArchitecture annotation from ReactPropGroup since this annotation is not deprecated in new arch
changelog: [internal] internal
Reviewed By: javache
Differential Revision: D66216727
fbshipit-source-id: 252bae58557b51c9fbfb1deab4edc7c50511a005
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47745
Remove DeprecatedInNewArchitecture for ReactPropHolder annotation
ReactProp is still used in new arch, we might remove this annotation in the future but it will be independent of new arch
changelog: [internal] internal
Reviewed By: javache
Differential Revision: D66216729
fbshipit-source-id: 3f64858ab4fa60b09978b18b17200ae488e229ce
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47910
It seems there could be a race where a commit is being processed on the JS thread after the surface has been removed from the mounting manager. Since we don't actually need to retrieve the default paddings in these cases, there's no reason we need an enforced read of the SurfaceMountingManager.
## Changelog
[Internal]
Reviewed By: javache
Differential Revision: D66369969
fbshipit-source-id: 44ccdc9beafdbd0ac47457fb01c4114348c1a316
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47891
Various C++ utilities for handling callbacks and promises rely on the static LongLivedObjectCollection. Even if a host platform injects it's TurboModuleBinding with a custom LongLivedObjectCollection, there's no guarantee that the platform is not also using C++ TurboModules that use the static LongLivedObjectCollection. Clearing both collections solves issues for TurboModuleBindings with custom LongLivedObjectCollections that also have cross platform C++ TurboModules that use the static collection.
## Changelog
[Internal]
Reviewed By: javache
Differential Revision: D66324044
fbshipit-source-id: a5a973087c35fc00240e40ba757d49125473daf4
Summary:
Changelog: [Internal]
Pull Request resolved: https://github.com/facebook/react-native/pull/47907
EnableDevSupport is set to false on lifecyle events like onPause and onHostDestroy, and set to true on events like onResume and onCreate.
In apps like AMA and Twilight, there is first a loginActivity, which then calls the mainActivity. After mainActivity is created, loginActivity is destroyed. This causes enableDevSupport to always be false because onDestroy for loginActivity is triggered after onCreate for mainActivity.
Reviewed By: RSNara, alanleedev
Differential Revision: D66124018
fbshipit-source-id: e40a5b24cf73000b0bfeaa1d8e3902718b281410
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47897
Changelog: [Internal]
In some situations, we want to provide multiple `CxxReactModules` from a single lambda. Currently, this is painful -- this change makes it less so.
Reviewed By: tdn120
Differential Revision: D66337573
fbshipit-source-id: ed57ad6ca2b98d4787aca7da3714c05c3d03b649