Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51062
Document logic implemented in ComponentDescriptorRegistry when a component is not found
changelog: [internal] internal
Reviewed By: arushikesarwani94, cortinico
Differential Revision: D74036572
fbshipit-source-id: 20a5d182e0308538cdfa3f5e97957d488f010f0d
Summary:
This PR introduces a concise Kotlin DSL for constructing `ReadableMap` and `ReadableArray` in Android native modules:
- Adds `buildReadableMap { … }` and `buildReadableArray { … }` functions, modeled after Kotlin’s `buildMap`/`buildList` APIs.
- Wraps `Arguments.createMap()` / `Arguments.createArray()` in a type-safe, nested DSL to reduce boilerplate and prevent errors.
- Improves readability and maintainability when assembling nested map/array structures for React Native bridges.
Current code like:
```kotlin
val map = Arguments.createMap().apply {
putString("name", user.name)
putInt("age", user.age)
// …
}
```
can now be written as:
```kotlin
val userMap = buildReadableMap {
put("name", user.name)
put("age", user.age)
put("scores") {
user.scores.forEach { add(it) }
}
}
```
This feature proposal also written in [[Android] Support Collection DSL](https://github.com/react-native-community/discussions-and-proposals/issues/899)
## Changelog:
[Android] [Added] - Collections DSL functions for Kotlin(`buildReadableMap`, `buildReadableArray`)
Pull Request resolved: https://github.com/facebook/react-native/pull/51042
Test Plan:
### Run Unit Test
```shell
cd packages/react-native/ReactAndroid
./gradlew :ReactAndroid:unitTest
```
Ensure all tests in `src/test/java/.../ReadableMapBuilderTest.kt` and `ReadableArrayBuilderTest.kt` pass.
Reviewed By: javache
Differential Revision: D73986390
Pulled By: cortinico
fbshipit-source-id: b9f94327646bcb6e0190cdd06dfb9bb5eaa6375c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51079
This test was not using AssertJ. I've updated it then.
Changelog:
[Internal] [Changed] -
Reviewed By: javache
Differential Revision: D74065455
fbshipit-source-id: 2393340fd75aaf9599ba789237c29bb91e0192ae
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51025
(Sparsely) wires up reporting of Network events to the Web Performance subsystem.
Our plan is to report to the Web Performance APIs (lightweight timing metadata, here) for all build flavours, and report to CDP (more costly full metadata/previews) in dev/profiling builds.
**Notes**
- Introduces `PerformanceEntryReporter::unstable_reportResourceTiming` — this will become "stable" when further network events/fields are fully hydrated on Android and iOS.
Changelog: [Internal]
Reviewed By: rubennorte
Differential Revision: D73922341
fbshipit-source-id: bcfc03c3d8a9a286ae72ba00a3313602fb2adea8
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51046
This small change improves the cleanup script for ios, which is now not deleting the workspace and that it might be keeping an outdated version of the codegen for OSS.
## Changelog:
[Internal] - Improve yarn clean-ios script
Reviewed By: cortinico
Differential Revision: D73988442
fbshipit-source-id: 6de5d6ab08812ba7fdb19b0cc955a38840d82f89
Summary:
Static code analysis detected several redundant constructs across the codebase. Most of the ones fixed here are marked as warnings/weak warnings, likely code smells post-migration from Java.
Doing a small round to clean up some of them.
## Changelog:
[INTERNAL] - Kotlin: Clean up redundant constructs
Pull Request resolved: https://github.com/facebook/react-native/pull/51061
Test Plan:
```sh
yarn android
yarn test-android
```
Reviewed By: rshest
Differential Revision: D74056259
Pulled By: javache
fbshipit-source-id: 04f7ce7ce7b4f6063c8e1712840a44fd91d3b9e1
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51073
Currently the SampleLegacyModule screen is not loading in OldArch for RNTester.
That's because we gate adding a `SampleLegacyModule` to the BaseReactPackage
only if NewArch is enabled.
This shouldn't be the case as we can still build RNTester in oldarch and we
should be able to visualize the SampleLegacyModule example.
Changelog:
[Internal] [Changed] -
Reviewed By: mdvacca
Differential Revision: D74009245
fbshipit-source-id: 55eae3dc6063343f57261af2742e643a8e5c2b50
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51050
Gate network event reporting on iOS (inputting into the network reporting subsystem), now that this is load-bearing with the Performance API.
Changelog: [Internal]
Reviewed By: vzaidman
Differential Revision: D73995864
fbshipit-source-id: 65a15485cdae445eadff6c57148f3682af6de215
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50995
Refactors our previous single-struct representation for `PerformanceEntry` ([see MDN](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry)) as a `std::variant`.
This maps closely to the `PerformanceEntry` type inheritance in the web spec, and makes this type substantially cleaner to extend and work with in D73861431.
Changelog: [Internal]
Reviewed By: rubennorte, rshest
Differential Revision: D73860532
fbshipit-source-id: f3b7a7444d2456370620c1a1ba9a43f118cb9730
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51044
This change prevents RN from accessing the MainBundle every time a NativeModule is registered by caching the `legacyLogEnabled` property in a static variable.
## Changelog:
[Internal] - Prevent multiple access to mainBundle
Reviewed By: javache
Differential Revision: D73992070
fbshipit-source-id: a14aada43f367314b7f868a0b5e30b9f92d0971a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51064
This is pretty much just checked in printf debugging. Let's clean it up, before we duplicate some code which has the logs.
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D73975310
fbshipit-source-id: d2b936ad62a17aef20903fd2ca0defc23c647aa0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51040
## Resubmit
We were previously only checking for `maxNumberOfLines` of `ReactConstants.UNSET` (-1), but it may also be `0` to signify unset from other checks (wut), and different versions of Android would handle this case of `maxLines={0}` differently.
The resubmission adds an explicit check for zero here as well.
```
if (ReactNativeFeatureFlags.incorporateMaxLinesDuringAndroidLayout()) {
if (maxNumberOfLines != ReactConstants.UNSET && maxNumberOfLines != 0) {
builder.setEllipsize(ellipsizeMode).setMaxLines(maxNumberOfLines);
}
}
```
## Previous
Right now, we fully layout text, then use max lines to determine a metric to use when calculating size.
Android API 23+ which we fully target allows incorporating ellipsization and maxlines directly into the layout. This will let us directly draw the layout when using maxLines later. This may also let Android optimize line-breaking a bit, when we hit truncation.
Special care is taken not to set this when we are in `adjustsFontSizeToFit` path, so that line count will flow over, signifing overflow.
I think the main user-facing change is that `onTextLayout` events will have measures post-ellipsization.
Changelog:
[Android][Changed] - Incorporate maxLines and ellipsization into text layout
Reviewed By: lenaic, joevilches
Differential Revision: D73953691
fbshipit-source-id: 2e08faab5bb9eda90a126545571bb441ea1ece39
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51037
## Changelog:
[Android] [Changed] - Make mHybridData in CxxReactPackage protected
In some cases subclass needs to override it in constructor
Reviewed By: javache
Differential Revision: D73894471
fbshipit-source-id: 7958f9b88841a0201d39e49fba09af76927e5737
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51019
Follows D72228547 and D73770609.
This diff internalises (moves files from fbsource+GitHub to fbsource only) a number of RNTester examples which referenced `'react-native/src/private/'` subpaths.
In future, new components/APIs should be exported from index as `unstable_`, or added to `RNTesterListFbInternal` if they are exported from `src/fb_internal/`.
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D73777092
fbshipit-source-id: d9fb0833c56f2ae580b6db62ddbbbeae774a0004
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51043
The call to the mainBundle to read the `RCTLegacyWarningsEnabled` key can sometime deadlock in prod.
However, these are development logs that we don't want to run in Prod.
This change should disable the logs in prod, skipping the access to the `mainBundle`, and avoid the deadlock completely.
## Changelog:
[Internal] - Fix deadlock at startup to read `RCTLegacyWarningsEnabled`
Reviewed By: philIip, javache
Differential Revision: D73987454
fbshipit-source-id: 014410266733fdfa1e7b29d41fab5f7112b1ddb4
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50914
The URL spans generated by Linkify are not actually accessible because we do not update the delegate's virtual views.
I also had to change how AccessibilityLinks get generated, since it does not work well if it includes spans that are not `ReactClickableSpans`
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D73612119
fbshipit-source-id: 0c6028a7473e0484216300863f2d7a043fb2ea85
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50887
There is currently a bug with the recent changes to keyboard accessibility with Text and nested links. If something with nested links has a `dataDetectorType` prop then we have 2 different selections when we navigate with arrow keys since the drawing behind the 2 are separate.
Removing LinkMovementMethod is not possible since it allows for clicking the links it detects
As a result, lets just allow it to take precedence over the delegate when handling link navigation in the cases its present.
Changelog: [Android][Fixed] - Double selection with dataDetectorType and links
Reviewed By: NickGerleman
Differential Revision: D73549839
fbshipit-source-id: bbe37470e78841bb119fa68e197b327023031c7e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51029
# Changelog: [Internal]
Instead of exposing vector of samples / call frames directly, we will share pair of iterators that would allow iterating over them in a specified order.
Reviewed By: dannysu
Differential Revision: D73448002
fbshipit-source-id: 16c476453e943a71403b375b168b30da7d261cfa
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51028
# Changelog: [Internal]
There is a way to implement the trie without allocating `ProfileTreeNode` on the heap. The serialization logic (`RuntimeSamplingProfilerTraceEventSerializer.cpp`) remained mostly the same, the only new limitation is that we can only use pointer to `ProfileTreeNode` until the next push into a `children` container, when all pointers are invalidated. Not sure if we can avoid this invalidation, since we don't know the potential size of `children` vector, it has to be dynamically allocated.
Main changes are in `ProfileTreeNode`:
- Instead of receving already created instane that will be check if it should be added as a child, it will expose predicate to check if such node already exists - `getIfAlreadyExists`. If not, then caller can use `addChild` to register it and receive a pointer.
Reviewed By: huntie
Differential Revision: D73213284
fbshipit-source-id: 385be884bcc5feb61b3a8cbd0ff36402e3b20c6c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50847
# Changelog: [Internal]
We have different types of call frames, right now we defined 4 of them. Previously, they would descend from `ProfileSampleCallStackFrame`, which has `kind_` field that can be used for determining the type of the call frame.
We were using polymorphism later on React Native side to cast from base type to derived.
Instead of this, and instead of doing heap allocations for potentially tens of thousands of objects, we will use std::variant for storing frames in a single container and them distinguishing them.
This fixes memory leaks caused by new-ing objects and not clearing out when Profile is destroyed.
Reviewed By: dannysu
Differential Revision: D72803934
fbshipit-source-id: a279c6d68c7c2628f0eab585f33137222ad9e3f1
Summary:
The `Object.assign` support is [inherently unsound](https://github.com/facebook/flow/issues/3392), carries a lot of tech debt, and we want to error on them.
This diff pre-suppresses errors that will be added in the next version of Flow, to make the next release easier.
Changelog: [Internal]
Reviewed By: panagosg7
Differential Revision: D73963639
fbshipit-source-id: ebefc82c123588eb0b72ab48a24e45c42be33267
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51035
This is causing some problems with older versions of Android. Let's back out for now.
Changelog: [Internal]
Reviewed By: joevilches
Differential Revision: D73950625
fbshipit-source-id: 424dfc1216ae811e1e287774c6ac5d0c9ba5aa17
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51004
It would be very convenient if `accessibilityOrder` could reference itself. Meaning the View with the `accessibilityOrder` prop can include its own `nativeID` in the array. This makes sense API wise - we allow for referencing parents and their descendants, so long as they are treated as an element and not a container. This is pretty nice since you no longer have to wrap everything in a View who's sole purpose is `accessibilityOrder`.
Under the hood things get a bit garbled, however, since iOS only lets you have UIViews that are either accessibility elements or accessibility containers - and we need to support both at the same time for this to work. To do this, we make use of the `UIAccessibilityElement` class and just forward all of the logic to the View with the `accessibilityOrder` prop. This View will also not be an accessibility element from the point of view of iOS.
Changelog: [Internal]
Reviewed By: jorge-cab
Differential Revision: D73792934
fbshipit-source-id: b0810277c8e410319639b863b59e4e60782bffca
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50925
This crashes without this change, now it does not!
Changelog: [Internal]
Reviewed By: NickGerleman
Differential Revision: D73626930
fbshipit-source-id: 37fd99372d1781a9e895e854e8b2f75c568ef9c0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51027
Simple change to make the host of `experimental_accessibilityOrder` include the view that hosts the property in its order.
Changelog: [Internal]
Reviewed By: joevilches
Differential Revision: D73808337
fbshipit-source-id: 441329a6ca0cd4b0aba08bddb15143215d337e01
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51014
Starting from the [24th of April](https://developer.apple.com/news/upcoming-requirements/?id=02212025a), Apple only accepts app built with Xcode 16.0 or greater
This change bumps our CI to ensure that everything works with Xcode 16.
## Changelog:
[Internal] - Bump CI to Xcode 16.2
Reviewed By: javache
Differential Revision: D73924819
fbshipit-source-id: 82cdca5e12cee505de6e97513c07678776642d88
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51022
As per title, it bumps maestro to 1.40 in CI
## Changelog:
[Internal] - Bump Maestro to 1.40
Reviewed By: cortinico
Differential Revision: D73929936
fbshipit-source-id: 7dfd974a0d1227520c5a6892ff4f157633fdbd54
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51013
There's no need to use a singleton pattern here, we can just use a Kotlin object.
Changelog: [Android][Removed] Deprecated `ResourceDrawableIdHelper.instance`
Reviewed By: Abbondanzo
Differential Revision: D73923281
fbshipit-source-id: f46e125ce595fe4506b9fb5aa471109f5ba150f0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50998
I'm reverting this as this change is too disruptive for the OSS ecosystem.
It will break ALL the apps written in Kotlin and it's coming too close to the branch cut which is in less than one week.
We need to re-do this migration in a non breaking manner after the branch cut as this is highly disruptive for little benefit at this point
Changelog
[Android][Changed] - Back out "[RN][Kotlin] Migrate ReactActivity"
Original commit changeset: 936263100ca9
Original Phabricator Diff: D73507044
Reviewed By: mdvacca
Differential Revision: D73864144
fbshipit-source-id: 264921b1f1cd38301e66364de4b619807272bd27