Summary:
D57285584 was reverted because we have service code with a faulty measure function, and adding logging to Yoga when invalid measurements were received was enough to spike error rate to elevated levels and block release.
This is a reland of the below change, with a couple modifications:
1. We log warnings instead of errors, which from what I heard, shouldn't block release, but should still make signal
2. We only zero the dimension which was NaN, to preserve exact behavior
## Original
We've started seeing assertion failures in Yoga where a `NaN` value makes its way to an `availableHeight` constraint when measuring Litho tree.
Because it's only happening on Litho, I have some suspicion this might be originating from a Litho-specific measure function. This adds sanitization in Yoga to measure function results, where we will log an error, and set size to zero, if either dimension ends up being negative of `NaN`.
This doesn't really help track down where the error was happening, but Yoga doesn't have great context to show this to begin with. If we see this is issue, next steps would be Litho internal intrumentation to find culprit.
Changelog: [Internal]
Reviewed By: sbuggay
Differential Revision: D57473295
fbshipit-source-id: 979f1b9a51f5550a8d3ca534276ec191a3cb7b9e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44600
I didn't pay close enough attention during merge between V1 and V2 of D57248205, and what I ultimately checked in is not correct. Fix the logic here.
Changelog: [Internal]
Reviewed By: yungsters
Differential Revision: D57488372
fbshipit-source-id: c9db597a6ae4ca5ae81e6ccd9913a14be268dd57
Summary:
This PR adds percentage support in translate properties for new arch iOS. Isolating this PR for easier reviews.
The approach taken here introduces usage of `ValueUnit` struct for transform operations so it can support `%` in translates and delay the generation of actual transform matrix until view dimensions are known. I have tried to keep the changes minimal and reuse existing APIs, open to changes if there's an alternative approach.
## Changelog:
[IOS] [ADDED] - Percentage support in translate in new arch.
<!-- 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/43192
Test Plan:
- Checkout TransformExample.js -> Translate percentage example.
- Added a simple test in `processTransform-test.js`. The regex is not perfect (values like 20px%, 20%px will pass, can be improved, let me know!)
Related PRs - https://github.com/facebook/react-native/pull/43193, https://github.com/facebook/react-native/pull/43191
Reviewed By: javache
Differential Revision: D56802425
Pulled By: NickGerleman
fbshipit-source-id: 978cbbdde004afe1e68ffee9a3c7eb7d16336b46
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44538
Android originated without RTL support. When RTL support was added, Applications needed to set `android:supportsRtl="true"` in their manifest, to allow Android to do RTL specific layout and drawing. This became the default for new projects created by Android Studio at some point.
React Native was not setting this in template, which means apps created from it do not do any of Android's RTL layout, text alignment, or drawing (e.g. in D3652980 8 years ago, a native drawer component came from the wrong side of the screen). RN would still layout the app using Yoga in RTL if in RTL locale though.
This change sets `android:supportsRtl` in template matching default new Android projects, and to avoid mismatched states in the future, will only tell I18NManager that RTL is allowed if `android:supportsRtl` is also set. This is breaking, since existing apps may not get Yoga RTL support unless telling Android that the application should support RTL layout.
Changelog:
[Android][Breaking] - Set and require `android:supportsRtl="true"` for RTL layout
Reviewed By: joevilches
Differential Revision: D57248205
fbshipit-source-id: 3f60c9f855db26f8d34a2e05d460f95961f5ffeb
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44561
D57089275 introduced a layer to parse component values out of the token stream. I modeled this similar to the tokenizer, as a flat iterator of component values. Because function components can nest a variable number of child component values, this now looks like storing a fully resolved tree of tokens on the heap during parsing.
This diff changes the model, so that `CSSSyntaxParser::consumeComponentValue()` no longer returns a resolved CSS function value. Instead, users of the parser are expected to provide "visitors" which continue parsing, matched based on component value type pattern matched. Visitors can perform parsing specific to their context, and propagate values up the stack, based on their evaluation of the component value.
Removing the heap allocated list of tokens here also lets this core CSS parsing stack keep constexpr, so I added that back, though we need to keep expression trees for math expressions in uncommon cases, so the layer up probaly won't keep constexpr.
Changelog: [Internal]
Reviewed By: joevilches
Differential Revision: D57206706
fbshipit-source-id: 25db84d376ef18f6291e60ed953e29c4000a7a26
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44546
# Changelog:
[Internal] -
This is the first chunk of moving all of the interfaces to Kotlin inside `react.bridge`, covering the small-ish (functional/SAM and such) interfaces.
Reviewed By: javache
Differential Revision: D57253634
fbshipit-source-id: aa26d26b9681ac7c6059c249b985ff5121ad1e9d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44583
This native module is only available in the new architecture, stub the methods elsewhere.
Changelog: [Internal]
Reviewed By: christophpurrer
Differential Revision: D57382785
fbshipit-source-id: f6c988bcfd12633697b45a1f862b2cd4fb5d00d4
Summary:
Currently RCTPerfMonitor won't show up in scene based app, we should first try to extract the window from the connected scenes, and fallback to the window in `UIApplicationDelegate`.
## 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] - Fix RCTPerfMonitor not showing up in scene based app
Pull Request resolved: https://github.com/facebook/react-native/pull/43476
Test Plan:
- Tested RCTPerfMonitor in app not using scenes;
- Tested RCTPerfMonitor in app using scenes in iOS 13 & 14;
- Tested RCTPerfMonitor in app using scenes in iOS 15+.
Reviewed By: rshest
Differential Revision: D57381551
Pulled By: javache
fbshipit-source-id: fd6cce20c9a4ed41d7aae84751fc0c83391d0865
Summary:
I used the `createRootViewWithBridge` in a Project and got the hint to migrate to the `customiseView` Method. I searched for the Method, but found it under a different name: `customizeRootView`.
So i thought it would be helpful to use the correct Method name inside the hint message.
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[IOS] [FIXED] - fixed Method name in hint from customiseView to customizeRootView
Pull Request resolved: https://github.com/facebook/react-native/pull/44585
Test Plan:
* Use `createRootViewWithBridge`
* Should get a hint to migrate to `customizeRootView` method
Reviewed By: fabriziocucci
Differential Revision: D57431185
Pulled By: javache
fbshipit-source-id: 14f8c33771551ea3fb66d2c8f3fce4b4e3ef962a
Summary:
The current implementation does not support System font variants. Currently the isCondensed variable is always returning false. This pr adds an extra check to support the 'SystemCondensed' font variant on iOS.
## 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][ADDED] - Update font to handle system condensed variant
Pull Request resolved: https://github.com/facebook/react-native/pull/43188
Test Plan:
```
<Text style={{ fontSize: 28, fontFamily: 'System' }}>System</Text>
<Text style={{ fontSize: 28, fontFamily: 'SystemCondensed' }}>SystemCondensed</Text>
<Text style={{ fontSize: 28, fontFamily: 'AmericanTypewriter-Condensed' }}>AmericanTypewriter-Condensed</Text>
<Text style={{ fontSize: 28, fontFamily: 'HelveticaNeue' }}>HelveticaNeue</Text>
<Text style={{ fontSize: 28, fontFamily: 'HelveticaNeue-CondensedBold' }}>HelveticaNeue-CondensedBold</Text>
```

Reviewed By: fabriziocucci
Differential Revision: D57329036
Pulled By: javache
fbshipit-source-id: b0fffde1a568cb498f907e0a007df4da3e11d586
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44554
Noticed than when reload is triggered by Metro (`handleReloadJS`), the application would often get stuck and not respond to further reload commands. Often an IOException would get printed as well, due to concurrent bundle loads happening.
Changelog: [Android][Fixed] Improved resiliency of reloads when bundle loading fails
Reviewed By: RSNara
Differential Revision: D57112152
fbshipit-source-id: b0bf8c8311264504684a137c0910e2eeb008b0c7
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44574
`emitDeviceEvent` is frequently used for perf-critical operations such as sending network responses from native to JS. We don't need to go through JavaScriptModule Proxy (which is missing caching in bridgeless) and instead can immediately invoke the callable JS module.
Changelog: [Internal]
Reviewed By: RSNara
Differential Revision: D57329165
fbshipit-source-id: 6506a7afb522b672a1f3dc7d348c9b80e6734225
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44577
There are no references to `AnimationsDebugModule` and it is also no longer public, so it is dead code. This cleans it up.
Changelog:
[Android][Removed] - Removed `NativeAnimationsDebugModule` (already not Public API)
Differential Revision: D57351893
fbshipit-source-id: 5a78a3b8e93a87ccb0cd5cdf8d2308d6c53d0ffa
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44558
Right now this is only exposed to RNTester on iOS, but the prop exists on both platforms.
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D57281892
fbshipit-source-id: 9effc2b9c6421f8c74a2f4b933ab0fa0f15e7d70
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44540
Noticed when running `arc nn`
> Advice xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java:39
> [Class has 0 issues and can be marked Nullsafe] Congrats! `IntBufferBatchMountItem` is free of nullability issues. Mark it `Nullsafe(Nullsafe.Mode.LOCAL)` to prevent regressions.
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D57249958
fbshipit-source-id: d38559a3fafae0ad778c19dd85c5da610a650d7c
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44557
We've started seeing assertion failures in Yoga where a `NaN` value makes its way to an `availableHeight` constraint when measuring Litho tree.
Because it's only happening on Litho, I have some suspicion this might be originating from a Litho-specific measure function. This adds sanitization in Yoga to measure function results, where we will log an error, and set size to zero, if either dimension ends up being negative of `NaN`.
This doesn't really help track down where the error was happening, but Yoga doesn't have great context to show this to begin with. If we see this is issue, next steps would be Litho internal intrumentation to find culprit.
Changelog: [Internal]
Reviewed By: joevilches
Differential Revision: D57285584
fbshipit-source-id: 935fcdd28c05bbac0d73e1c7654ae11a74898537
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44562
D56963463 deleted some tests for code it also deleted. This broke the Android GTest OSS build, which is a centralized list of these test files. Remove from there as well.
Changelog: [Internal]
Reviewed By: joevilches, realsoelynn
Differential Revision: D57299969
fbshipit-source-id: 1bf0b718ca5fcee03272dd0142f80ea2f8257902
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44464
Adds `app` to allow building and serving your React Native app in a similar structure to the boostrap and build tasks. This is the more comprehensive followup to D57067040.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D57067039
fbshipit-source-id: fdbe891657d826535cb779a4d1b71cfd13921684
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44462
Users using the new `react-native/scripts/cocoapods/autolinking.rb` script will expect all of the helper methods previously exposed throug `react_native_pods.rb`.
This was an oversight.
Changelog: [iOS][Fixed] exposes react_native_pods methods through autolinking.rb
Reviewed By: cipolleschi
Differential Revision: D57066094
fbshipit-source-id: d65dc79430101c9c43cbd90d1456630e338a22bb
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44463
Helper methods to help the cli grab system state, devices and run react-native/core-cli-utils tasks using Listr.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D57067037
fbshipit-source-id: 28cb4239f3a93558b88417f366a2146f696cc411
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44466
Contains a *light* wrapper to help launch Metro and build bundles or wait for localhost requests against Metro's dev-server.
Changelog: [Internal]
Reviewed By: cipolleschi
Differential Revision: D57067040
fbshipit-source-id: 8ab7ecb5d9b98d1abddd5d4f04c7eb25129cd0a1
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44512
We only ever go through MapBuffer now, so we can remove the code related to storing text fragments in folly::dynamic.
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D56963463
fbshipit-source-id: 98bce8aa4ccad134ce18bf35028e1b7b5082c3ca
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44529
The percentage formula was incorrect. We actually want to consider the shorter side as 100%. If we set a radius > minimum side there are no changes reflected. This is correct on iOS.
D56943825's summary also highlights the reasoning.
Changelog:
[Android][Fixed] Border-Radius percentages are now correctly resolved.
Reviewed By: NickGerleman
Differential Revision: D57214561
fbshipit-source-id: 45125b80289506a6dd51d24451e2b0222cd227c0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44542
React Native no longer has a `Navigator` component, so let's clean up this reference in a comment in the `StatusBar` component definition.
Changelog:
[General][Changed] - Obsolete comments referencing Navigator
Reviewed By: GijsWeterings
Differential Revision: D57251899
fbshipit-source-id: bf2923bcaf22daf525381efbc3577c3610afaec4
Summary:
Changelog: [Internal]
Pull Request resolved: https://github.com/facebook/react-native/pull/44524
After D56845572, I've started seeing the following redbox when running apps in bridgless mode:
{F1633641432}
Note sure this is the correct/complete fix but, after this, the error seems to go away.
Reviewed By: RSNara
Differential Revision: D57207925
fbshipit-source-id: c02b9b268c135aabaaa1dc8329abc80ca5c8a500
Summary:
Though the `ReactHost.destroy()` is not being used from OSS code, we use it at Expo for expo-dev-client to change loading apps from different dev servers. Without cleanup the `mAttachedSurfaces`, it will have dangling or duplicated attached surfaces that cause duplicated react trees.
<img src="https://github.com/facebook/react-native/assets/46429/f84d274e-aaad-4352-9e3c-6262571a5625">
This PR tries to cleanup the `mAttachedSurfaces` from destroying.
## Changelog:
[ANDROID] [FIXED] - Fixed dangling `mAttachedSurfaces` after `ReactHost.destroy()`
Pull Request resolved: https://github.com/facebook/react-native/pull/44393
Test Plan: have to manually call `ReactHost.destroy()` and recreate the MainActivity without killing the process. then reload the app will startSurface for the same attached surfaces.
Reviewed By: RSNara
Differential Revision: D56901863
Pulled By: javache
fbshipit-source-id: c7f822501d971810ac6aa7262b15da69ec41355e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44470
CSS component values, as defined in the syntax spec, are either "preserved tokens", CSS functions, or simple blocks. This is distinct from the higher-level "component value type" specified in the [values and units](https://www.w3.org/TR/css-values-3/#component-types) spec.
I was previously short-circuiting a bit, from preserved tokens, to a higher level data structure. This separates them out, adding a layer exposing the preserved token as `CSSSyntaxParser::Token`, and now a `CSSSyntaxParser::Function`, which can represent a named function and its nested component values.
This does not yet wire functions beyond CSSParser returned component values.
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D57089275
fbshipit-source-id: 97eeb1a7b3363c79d99f9419ba6e022c4c3c31d0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44521
changelog: [internal]
mapbuffer leaks into every component even though it is only used by 2: Paragraph and TextInput. Let's isolate it only to those two.
To do that, I added a new template prop: usesMapBufferForStateData. It is false by default and only Paragraph and TextInput set it to true.
Reviewed By: christophpurrer
Differential Revision: D56636011
fbshipit-source-id: 4a99e6e68caaf40111b6b7b205854a71f33c5864