Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39464
We currently have 854 warnings emitted due to nested namespaces being a C++ 17 extension lol.
This sets the standard explicitly to C++ 20 in the specs emitting the warnings (mostly RCT-Text).
It is undesirable that we add hundreds of warnings to the CocoaPods build without signal. Our Buck build and OSS Android build both treat warnings as errors. But... that is for another day.
Changelog: [Intenrnal]
Reviewed By: cortinico
Differential Revision: D49303081
fbshipit-source-id: 1233e9d51426fb8dbd8ca39a771e2fef3d0df856
Summary:
This is a reopened version of https://github.com/facebook/react-native/issues/35224 by isidoro98 which was closed without explanation, updated to resolve new merge conflicts and now includes an example in the RN-Tester app. Aside from that it is unchanged. Here is isidoro98's description from their original PR:
This PR builds on top of https://github.com/facebook/react-native/issues/31402, which introduced the `automaticallyAdjustsScrollIndicatorInsets` functionality. It aims to fix one of RN's longstanding pain point regarding the keyboard.
The changes provide a better way of handling the `ScrollView` offset when a keyboard opens. Currently, when a keyboard opens we apply an **offset** to the `Scrollview` that matches the size of the keyboard. This approach is great if we are using an `InputAccessoryView` but if we have multiple `TextInputs` in a `ScrollView`; offsetting the content by the size of the keyboard doesn't yield the best user experience.
## Changelog:
[iOS] [Changed] - Scroll `ScrollView` text fields into view with `automaticallyAdjustsScrollIndicatorInsets`
Pull Request resolved: https://github.com/facebook/react-native/pull/37766
Test Plan:
The videos below compare the current and proposed behaviors for the following code:
```js
<ScrollView
automaticallyAdjustKeyboardInsets
keyboardDismissMode="interactive">
{[...Array(10).keys()].map(item => (
<CustomTextInput placeholder={item.toString()} key={item} />
))}
</ScrollView>
```
| Current behaviour | Proposal |
|-|-|
|  |  |
As can be seen in the video, the **current behavior** applies an offset to the `ScrollView` content regardless of where the `TextInput` sits on the screen.
The proposal checks if the `TextInput` will be covered by the keyboard, and only then applies an offset. The offset applied is not the full size of the keyboard but instead only the required amount so that the `TextInput` is a **specific** distance above the top of the keyboard (customizable using the new `bottomKeyboardOffset` prop). This achieves a less "jumpy" experience for the user.
The proposal doesn't change the behavior of the `ScrollView` offset when an `InputAccessory` view is used, since it checks if the `TextField` that triggered the keyboard is a **descendant** of the `ScrollView` or not.
## Why not use other existing solutions?
RN ecosystem offers other alternatives for dealing with a keyboard inside a ScrollView, such as a `KeyboardAvoidingView` or using third party libraries like `react-native-keyboard-aware-scroll-view`. But as shown in the recordings below, these solutions don't provide the smoothness or behavior that can be achieved with `automaticallyAdjustsScrollIndicatorInsets`.
| KeyboardAvoidingView | rn-keyboard-aware-scroll-view |
|-|-|
|  |  |
As shown in the videos, the `TextInput` is hidden by the keyboard for a split second before becoming visible.
Code for the videos above:
```js
// KeyboardAvoidingView
<KeyboardAvoidingView
style={{flex: 1, flexDirection: 'column', justifyContent: 'center'}}
behavior="padding"
enabled>
<ScrollView>
{[...Array(10).keys()].map(item => (
<CustomTextInput placeholder={item.toString()} key={item} />
))}
</ScrollView>
</KeyboardAvoidingView>
```
```js
// rn-keyboard-aware-scroll-view
<KeyboardAwareScrollView>
{[...Array(10).keys()].map(item => (
<CustomTextInput placeholder={item.toString()} key={item} />
))}
</KeyboardAwareScrollView>
```
Reviewed By: sammy-SC
Differential Revision: D49269426
Pulled By: javache
fbshipit-source-id: 6ec2e7b45f6854dd34b9dbb06ab77053b6419733
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39454
1. Build with C++ 20 everywhere.
2. Update folly in OSS build to avoid a warning, and let us opt out of heavy bits required for supporting coroutines (we are still more than a year behind).
3. Update the folly podspec for the new version of folly
4. Update the many, many, copy/pasted header search paths for folly dependencies to be able to resolve fmt, now exposed to folly headers
4. Replaces a deprecated atomic usage with equivalent.
5. Fixes a deprecated implicit capturing `this` by value in lambda (same behavior, added a TODO because it seems sus)
Changelog: [Internal]
Reviewed By: sammy-SC
Differential Revision: D49271685
fbshipit-source-id: 16610f7bcd1032d5796cc11f1cfa92a33d8c2593
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39462
In this diff I'm introdcuing the new UnstableAPI called LazyTurboModuleManagerDelegate.
The goal of this class is to provide a Lazy registration of TurboModules without relying on ReactModule annotations neither the TurboReactPackage#getReactModuleInfoProvider method.
This is not the final implementation, it's just a prototype that will be used to experiment and learn about perf implications.
This class will be used in the next diffs of the stack
changelog: [intenral] internal
Reviewed By: cortinico
Differential Revision: D49172555
fbshipit-source-id: 1609c523e6e72f2aa42ca7cc35e9170104a101db
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39461
In this diff I'm creating an empty constructor on ReactPackageTurboModuleManagerDelegate. This will be used in the next diffs of the stack.
I'm also resorting methods for better read of the class
changelog: [intenral] internal
Reviewed By: arushikesarwani94
Differential Revision: D49172554
fbshipit-source-id: 54073c86c87aa145b12e783d8d8f75cd1f5b228c
Summary:
X-link: https://github.com/facebook/yoga/pull/1384
Pull Request resolved: https://github.com/facebook/react-native/pull/39446
This adds logic to the enum generator to generate C++ style scoped enums.
This gives us a few nicities over C enums, even if both must exist:
1. We can add types and keep unsgined enums directly in bitfields
2. Style/readability
3. Avoiding implicit int conversion
Reviewed By: rozele
Differential Revision: D49267996
fbshipit-source-id: 1c41164c377b317c1fef97811c46cbc00b5a837e
Summary:
X-link: https://github.com/facebook/yoga/pull/1380
Pull Request resolved: https://github.com/facebook/react-native/pull/39433
Back when rolling out flex gap, we encountered a bug where gap was added to the end of the main axis when a size was not specified.
During flex line justification/sizing, we calculate the amount of space that should be in between children. We erroneously add this, even after the last child element.
For `justify-content`, this space between children is derived from free space along the axis. The only time we have free space is if we had a dimension/dimension constraint already set on the parent. In this case, the extra space added to the end of the flex line is usually never noticed, because we bound `maxLineMainDim` to container dimension constraints at the end of layout, and the error doesn't effect how any children are positioned or sized.
There was at least one screenshot test where this issue showed up though, and I was able to add a slightly different repro where we may have free space without a definite dimension by enforcing a min dimension and not stretching.
{F1091401183}
The new reference is correct, and looking back at diffs, is what this seemed to originally look like when added three years ago. Seems like there may have been a potential regression, but I didn't spot anything suspicious when I looked around the code history.
`betweenMainDim` may still be set for `gap` even if we don't have a sized parent, which makes the extra space propagated to `maxLineMainDim` effect parent size.
Because we were in a code freeze, I opted to have us go with a solution just effecting flex gap, instead of the right one, in case there were any side effects. This cleans up the code to use the right calculation everywhere, and fixes a separate bug, where `endOfLineIndex` and `startOfLineIndex` may not be the last/first in the line if they are out of the layout flow (absolutely positioned, or display: none_
See the original conversation on https://github.com/facebook/yoga/pull/1188
Reviewed By: javache
Differential Revision: D49260049
fbshipit-source-id: 218552c5ff938668b9f257df7a1493e13ded4d0d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39458
## Changelog
[Android][Deprecated] - hasConstants in ReactModuleInfo is marked as deprecated
getting rid of `mHasConstants` ivar here and marking the getter as deprecated
Reviewed By: cortinico
Differential Revision: D49262577
fbshipit-source-id: 5394281bdc4a315ffc0d1debfaef1808dc6f4299
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39457
## Changelog
[Android][General] - hasConstants in ReactModuleInfo does nothing now
we can get rid of this. currently, the default value of hasConstants true, and the only library setting this value to false is `WebSocketModule`. this value is only read in bridge mode - it is an optimization that will not initialize the constants dictionary for native modules in bridge.
however, we have plenty of native modules that don't provide constants that have not set this flag, so this is only turned on for `WebSocketModule`, which is probably not moving anything significant.
i would recommend we get rid of this to simplify the ReactModuleInfo deprecation plan.
Reviewed By: cortinico
Differential Revision: D49210251
fbshipit-source-id: c82c997e01cd8012b2c1a5c3c36061f81799eb04
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39431
Changelog: [Android][Breaking] - Do not enable `excludeYogaFromRawProps` feature flag, if you need to pass layout props to Java view managers when using new architecture
[Internal]
Reviewed By: NickGerleman
Differential Revision: D49114771
fbshipit-source-id: 171dfceef61d9851094465be8ff4eb9a87a3ab8f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39342
Annotate HybridData with DoNotStrip
The stack of diffs aims to introduce new features and deprecate old ones in the React Native Android architecture. The main goal is to make the architecture more stable and easier to use for developers. The changes include marking ReactPackage as NullSafe, introducing the new getModule method, introducing the WillBeDeprecatedInNewArchitecture annotation, deprecating createNativeModules and marking getModule as UnstableReactNativeAPI, and fixing a lint warning in MainReactPackage.
# This diff
This diff is adding the annotation `DoNotStrip` to the `HybridData` field in the `NativeMethodCallInvokerHolderImpl` and `CallInvokerHolderImpl` classes. This is to prevent the Android ProGuard optimizer from stripping the `HybridData` field, which is necessary for the proper functioning of the TurboModule system in React Native. Additionally, the `BUCK` file for the `core` module is updated to include the `androidx:annotation` and `com.facebook.proguard.annotations:annotations` dependencies.
changelog: [intenral] internal# Context
Reviewed By: cortinico
Differential Revision: D49077065
fbshipit-source-id: cb36c0a11bdb8f5f0f4eaa7db1f0c9dcb3be2341
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39339
Deprecating createNativeModules method from ReactPackage interface recommending using getModule instead in the new architecture of React Native
changelog: [Android][Changed] Deprecating createNativeModules method from ReactPackage interface recommending using getModule instead in the new architecture of React Native
Reviewed By: cortinico
Differential Revision: D48992719
fbshipit-source-id: b20de9274ed4bd35a239c672b52bfac529a79bc2
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39351
In this diff I'm introducing the new WillBeDeprecatedInNewArchitecture annotation, the goal of this annotation is to describe that a class or method will be deprecated when the new architecture of react native is fully rolled out in
OSS.
changelog: [Android] Introduce WillBeDeprecatedInNewArchitecture annotation
Reviewed By: cortinico
Differential Revision: D49068234
fbshipit-source-id: 4c5ce25b3fbcc2d7545f2000d931be893a661332
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39336
We are introducing the new getModule method into the ReactPackage interface following the "Registration of Native Modules" design
This method defaults to true with the goal to avoid compatibility breakage
changelog: [Android][Changed] Introducing getModule method into ReactPackage interface, defaulting to null. This method will be used in the Stable API of React Native
Reviewed By: cortinico
Differential Revision: D48992720
fbshipit-source-id: 4ecc93bc84daa8903a4d9a1cf6ced60adb78f153
Summary:
X-link: https://github.com/facebook/metro/pull/1078
Pull Request resolved: https://github.com/facebook/react-native/pull/39159
Source is not required for `getPreset` of `react-native/babel-preset`. There is a codition that adds `react-native/babel-plugin-codegen` to the preset only if source is passing certain regex. This condition fails if source is null, but that's wrong because the plugin may still be requred for this transformation even though source is not provided.
This diff changes the condition so the regexp tests source only if it is not null, and `react-native/babel-plugin-codegen` automatically added to the preset otherwise.
Changelog: [Internal]
Reviewed By: robhogan
Differential Revision: D48684443
fbshipit-source-id: 7cea69c91c0175ac0374d72e91f58e20fe75fd53
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39407
changelog: [internal]
CoreFeatures::enableMapBuffer is not used and always set to false, let's delete it.
Reviewed By: christophpurrer
Differential Revision: D49144919
fbshipit-source-id: 7d6a2a96ade13f7cedc2d12f7672c9df9d247e0d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39418
Changelog: [Internal]
Adds the `enableOpenDebuggerRedirect` experiment flag. The flag enables the handling of GET requests in the `/open-debugger` endpoint, in addition to POST requests. GET requests respond by redirecting to the debugger frontend, instead of opening it using the `BrowserLauncher` interface.
This can be useful when integrating `dev-middleware` in highly customised environments (e.g. VS Code remoting) where things like automatic port forwarding interact poorly with the `BrowserLauncher` abstraction.
WARNING: As this is gated by an experiment flag, the functionality may change or go away unannounced. In separate work, we will look into a stable solution for this use case.
Reviewed By: huntie
Differential Revision: D49144733
fbshipit-source-id: 5af6c8b2ddaa7b6e7d14c792e49fe3d0849c7a25
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39423
D49158227 made the CDP WebSocket URLs returned from `/json` proxy-safe by using the Host header (etc) from the HTTP request. This did *not* fully fix the related `/open-debugger` endpoint, because the original headers were being lost in the internal `fetch('/json')` call.
Here, we eliminate that `fetch` call, and instead give the `/open-debugger` handler direct access to the method on `InspectorProxy` that backs the `/json` endpoint. This allows us to pass in an appropriate base URL derived from the headers seen by `/open-debugger`.
Changelog: [Internal]
Reviewed By: huntie
Differential Revision: D49229545
fbshipit-source-id: 9036ab295721e0d1fd3cdb608d0a7cc07b8f2eeb
Summary:
Right now we're fetching latests versions of drivers which isn't the best, we should always download the same versions.
## 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
-->
[INTERNAL] - Add versions when installing Appium drivers.
Pull Request resolved: https://github.com/facebook/react-native/pull/39275
Test Plan: CI Green - (side note: if jobs `test_e2e_ios` and `test_e2e_android` are green it doesn't mean that they passed.)
Reviewed By: cipolleschi
Differential Revision: D49248778
Pulled By: NickGerleman
fbshipit-source-id: 5b114b7dc1172993afc4b02e9d3380afa9f03c40
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39367
Updates React Native to use the new CDP handler provided by the Hermes engine instead of the legacy one (`Connection.cpp`) built into React Native. The new Hermes CDP handler has a simpler & safer design, new features (e.g. `console.log` buffering) and is under active development by the Hermes team.
NOTE: Both the legacy and modern handlers are Hermes-specific. In future work, React Native will *wrap* the modern Hermes handler in an engine-agnostic CDP layer implementing additional functionality and managing the lifecycle of debugging sessions more correctly. This diff is the first step of this larger migration.
Changelog: [General][Changed] Use new Hermes CDP handler implementation for debugging
Reviewed By: cipolleschi
Differential Revision: D48783980
fbshipit-source-id: 4d2ca3fa04e96e92a38d82c90737cb660ba56655
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39426
When opening the react-native repo in Android Studio the first time, users is missing 3rd party native dependencies,
which gets downloaded during the first build.
Here I'm hooking the Gradle sync step to the `preBuild` task that takes care of preparing the repo so that the whole build can succeeds (i.e. downloading and unzipping native deps, running codegen, preparing hermes/hermesc, etc.).
Changelog:
[Internal] [Changed] - Make sure first Gradle Sync is downloading 3rd party deps
Reviewed By: cipolleschi
Differential Revision: D49231058
fbshipit-source-id: 11a3d436550581f8a67a582f9fd325ad39486ddc
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39429
Using `require` after `const registerFn = require('babel/register')` but before `registerFn(config)` causes Babel to transform required code with the default configuration (ie, using a nearby `babel.config.js`, if available).
This was causing the Babel plugins loaded by `metro-babel-register` to be (unnecessarily) transformed according to `babel.config.js`, which actually fails if the plugins/presets referenced in `babel.config.js` themselves require transformation.
This ensures no code is loaded in between registering Babel as a side effect of requiring Babel register, and replacing that hook with something explicitly configured.
## React Native
Changelog: [Internal]
## Metro
```
* **[Fix]:** `metro-babel-register` prevent arbitrary transformation of Babel plugins during registration setup
```
Reviewed By: dmytrorykun
Differential Revision: D49238671
fbshipit-source-id: 52a55b1b5dbd127171558c056f16ab04e8fa8232
Summary:
This mirrors the clang-format config used by fbsource to Yoga.
They are pretty similar, except for an annoying habit where Yoga's previous forced small functions in headers to be a a single line, so you would get a combination of multiline and single line functions next to each other which are hard to read. That is what motivated this change.
It also enforces header ordering (yay). I don't think we have any side-effect causing headers, so this should be safe.
Reviewed By: yungsters
Differential Revision: D49248994
fbshipit-source-id: 66998395e7c0158ff9d9fb1bee44e8401bdd8f21
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39404
X-link: https://github.com/facebook/yoga/pull/1378
We thread a config through the root node, to every function, that we don't actually use (with the exception of `canUseCachedMeasurement` in the previous diff which was passing root `pointScaleFactor`).
Since the model is currently per-node config, this only creates redundancy/confusion.
I do think we might want to make some more global/layout-pass scoped configuration in the future, but likely not with this sort of drilling.
Reviewed By: yungsters
Differential Revision: D49180385
fbshipit-source-id: 91248042df7d3cea1fc316b47b8137fcb790b521
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39417
## Changelog
[Android][Breaking] - Deleting warnOnLegacyNativeModuleSystemUse
this has not fired in over a year, we should clean it up. there's an argument we want to keep this for consumers that are in the middle of upgrading, but personally i think that this needs to be built into the interop layer - currently we can only configure this in Fb specific infra.
Reviewed By: cortinico
Differential Revision: D49209540
fbshipit-source-id: 0e2bb293999ad356e564a0acf069211a7a205f21
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39415
Add a simple constructor for `JSError` which does not accept a
`jsi::Runtime` and cannot call back into JSI. This guarantees that the
constructor cannot recursively invoke itself, leading to stack
overflows.
Changelog: [Internal]
Reviewed By: avp
Differential Revision: D48796703
fbshipit-source-id: 1c134e8a59ff54be64a5da901e548436d512c21d
Summary:
X-link: https://github.com/facebook/yoga/pull/1379
Pull Request resolved: https://github.com/facebook/react-native/pull/39403
Right now we have a `pointScaleFactor` per-node, but only ever read the one off the root node. In most cases where config is global, these will be the same, but it is possible for these to differ.
This... doesn't make much sense from an API perspective, and there are edge cases where we may want to allow laying out a subtree with a different DPI then the rest of the tree (though I think there might be other solutions to that).
We should rethink some of what is currently on config being allowed per-node (do we really need each node to be able to have a separate logger?), but this makes the model consistent in the meantime.
This change is breaking to any users relying on setting `pointScaleFactor` on the config of the root node, but not other nodes.
Reviewed By: yungsters
Differential Revision: D49181131
fbshipit-source-id: f1363ca242094f04b995fd50c1e56834d5003425
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39289
"tickleJS" is a function in RN Hermes Debugger, we need to implement it for Bridgeless for feature correctness and keep parity with Bridge.
Changelog:
[Internal] - Implement "tickleJS" for Hermes in Bridgeless mode
### Summary of discussion:
**Goal of this diff**:
Implement tickleJS for Hermes debugger with Bridgeless, here is Bridge's implementation
https://www.internalfb.com/code/fbsource/[7058fb4dae4f]/xplat/ReactNative/react/jsi/HermesExecutorFactory.cpp?lines=45-57
**The key problem to solve:**
As you can see from Bridge's implementation, we need to dispatch the js call of "__tickleJs" to dedicated JS thread queue for thread safety, and it did cause a crash for me locally without dispatching to JS thread queue (see P818439922).
For Bridgeless passing the JS message queue directly works, but then we would naturally want ask if RuntimeExecutor/RuntimeScheduler is a better choice because: 1, It should also work 2, It's the common way to run js code in native with Bridgeless 3, Can avoid potential race condition caused by dispatching to JS message queue directly 4, We're planning to expose RuntimeExecutor/RuntimeScheduler or a similar abstraction anyway. So the argument here is which solution should we take?
**Why we decide to move forward with the JS msq solution?**
- Time constraint: we need to ship this before 0.73
- After discussion there hasn't been any major concern over dispatching to JS msq directly so far
- How to expose RuntimeExecutor/RuntimeScheduler is a bigger topic which need further research, we don't want to hold this diff for it
For detailed discussion see the post https://fb.workplace.com/groups/react.technologies.discussions/permalink/3615044702060575/
Reviewed By: javache
Differential Revision: D48952581
fbshipit-source-id: 3dfb05d35c422f3fd6a420e265e4efe8fa13f057
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39413
`yarn android` on main is currently broken due to the CLI attempting to search for the manifest inside the src/androidTest folder.
This fixes it by specifying the exact path of the Android Manifest.
The fix to the CLI is also pending to prevent the CLI from searching inside test folders.
Fix for the CLI is here:
- https://github.com/react-native-community/cli/pull/2075
Changelog:
[Internal] [Changed] - Unblock `yarn android` on main
Reviewed By: huntie
Differential Revision: D49190626
fbshipit-source-id: 99309f17cb08a33be2a565f5faa29130862686ea
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39422
Those scripts were used when Buck OSS was invoking codegen. As we don't do Buck OSS anymore, we can remove them.
Changelog:
[Internal] [Changed] - Remove Codegen buck-oss scripts as they're unused
Reviewed By: huntie
Differential Revision: D49229846
fbshipit-source-id: fad0526e609bab159c56a62b85c91690e4cdbbce
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39380
Changelog:
[Internal][Added] - Created a new event dispatching pipeline that immediately moves events over to the C++ queue, along with the onFrame that triggers the event beat ticking mechanism.
Reviewed By: sammy-SC
Differential Revision: D49012996
fbshipit-source-id: 0bc9067e5b019f308ec1f45ca8bd83fd195b37ce
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39420
changelog: [internal]
The intent of the code is to retain shared_ptr<Scheduler> but by using a reference, it didn't do that. Leading to a race condition.
bypass-github-export-checks
Reviewed By: rubennorte
Differential Revision: D49227147
fbshipit-source-id: 1a548f7174eacb95c14c89f72b51ccd263c5ab01