Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46955
This is a major bump of Kotlin. It comes with no breaking changes for the Kotlin API, but there are several new warnigns that I had to fix.
Most importantly several `override` methods that are overriding Deprecated API, also need to be deprecated as well in Kotlin.
Changelog:
[Android] [Changed] - Bump Kotlin 1.9.x to 2.0.x
Reviewed By: tdn120
Differential Revision: D64179842
fbshipit-source-id: 295ab2636ce9f9bb04e9d8c7ed27d9f8a1a64338
Summary:
This change move E2E tests to larger mac machines to see if we can reduce the flakyness.
Most of the time the flakyness is due to slowness in connecting to the simulator or slowness in Metro to provide the bundle to RNTester when we run the tests in Debug.
More power should speed-up those processes.
E2E tests took < 30 min in this diff
on Main, they took > 120 min
## Changelog:
[Internal] - Move the E2E tests to bigger machines
Pull Request resolved: https://github.com/facebook/react-native/pull/46960
Test Plan: GHA
Reviewed By: blakef
Differential Revision: D64237659
Pulled By: cipolleschi
fbshipit-source-id: c2458413c8de70c07fae8f2b5f202371c6293815
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46958
This will make it easier to link against custom C++ TM which will most likely live inside ./shared or
some other paths outside of ./android.
CMake will have access to `PROJECT_ROOT_DIR` which points to ./android (the folder where the settings.gradle file exists).
Changelog:
[Internal] [Changed] - RNGP - Pass PROJECT_ROOT_DIR to CMake
Reviewed By: cipolleschi
Differential Revision: D64183641
fbshipit-source-id: 347256c04f10e92cf5a13e9c70db16aa29bcb741
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46936
Let's enable box-shadow everywhere! This should be safe, now that we assume any background mutating methods in BaseViewManager go through BackgroundStyleApplicator. `boxShadow` is also already in `BaseViewConfig` instead of configs for each native component (bc we were already planning to make this change).
Changelog:
[Android][Added] - Add boxShadow support to BaseViewManager
Reviewed By: mdvacca
Differential Revision: D64140841
fbshipit-source-id: e937a4bcaa4506fd25d0916633313083c7e49333
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46934
BaseViewManagerDelegate is a handcrafted second source of truth, used specifically for codegen.
The organization here has some problems, but this diff adds the props currently missing from it, so that these work correctly in generated view managers.
Changelog:
[Android][Fixed] - Add missing BaseViewManager props to BaseViewManagerDelegate
Reviewed By: mdvacca
Differential Revision: D64137615
fbshipit-source-id: 4ff85f2524e5472f3b768e212fd5f2d4d9a36e17
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46932
In the old error handling pipeline, when the app [assigns an object to error[ExceptionsManager.decoratedExtraDataKey]](https://fburl.com/code/9t9u8rgv)
```
const error = new Error('Some error happened');
// Annotates the error with some custom extra data.
error[ExceptionsManager.decoratedExtraDataKey] = {foo: 'bar'};
ExceptionsManager.handleException(error, true);
```
That object [gets forwarded as extraData](https://fburl.com/code/gy7v173u) to ExceptionsManager.
This diff implements that functionality within the c++ earlyjs pipeline.
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D63927091
fbshipit-source-id: ac88bf3e545714aa42531e8e1365e2eba32a7c2b
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46935
Now, whenever the earlyjs c++ pipeline handles an error, it'll invoke callbacks registered via javascript.
## The API
```
if (global.RN$registerExceptionListener != null) {
global.RN$registerExceptionListener(
(error: ExtendedExceptionData & {preventDefault: () => mixed}) => {
error.preventDefault();
// show logbox
},
);
}
```
## The Future API
We want something more aligned with the HTML spec:
```
addEventListener('error', (event) => {
event.preventDefault();
// show logbox
});
```
## Fatals vs soft errors
The earlyjs pipeline covers just main bundle execution for now.
So, it displays logbox only if there was a soft error. If there was a fatal error, it'll just continue to display redbox as usual.
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D63769385
fbshipit-source-id: 9c01e1cfe0ec80842af2e5bcfbf0adfb040dbcf3
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46895
For the js error handling pipeline, the javascript data structure looks like [this](https://www.internalfb.com/code/fbsource/[6181b57f4ba3619f58056bcec65382650d6ff59a]/xplat/js/react-native-github/packages/react-native/src/private/specs/modules/NativeExceptionsManager.js?lines=17-35):
```
export type StackFrame = {|
column: ?number,
file: ?string,
lineNumber: ?number,
methodName: string,
collapse?: boolean,
|};
export type ExceptionData = {
message: string,
originalMessage: ?string,
name: ?string,
componentStack: ?string,
stack: Array<StackFrame>,
id: number,
isFatal: boolean,
// flowlint-next-line unclear-type:off
extraData?: Object,
...
};
```
So, I made the c++ data structure look similar
```
struct ParsedError {
struct StackFrame {
std::optional<std::string> file;
std::string methodName;
std::optional<int> lineNumber;
std::optional<int> column;
};
std::string message;
std::optional<std::string> originalMessage;
std::optional<std::string> name;
std::optional<std::string> componentStack;
std::vector<StackFrame> stack;
int id;
bool isFatal;
jsi::Object extraData;
};
```
Notes:
* [parseErrorStack](https://fburl.com/code/e27q9gkc) doesn't actually generate a collapse property on the error object. So, I omitted it from the c++.
* ExceptionsManager [always provides an extraData field](https://fburl.com/code/2bvcsxac). So, I made it required.
* In C++, I just stored extraData as a jsi::Object. I wanted the freedom to store arbitrary key/value pairs. But, I also didn't want to use folly::dynamic.
Changelog: [Internal]
Reviewed By: alanleedev
Differential Revision: D63929580
fbshipit-source-id: 51d8fcc79c9383789d456cfe4527cdd3f579395f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46872
This can now be flow typed as a union because the codegen supports it.
Changelog: [Internal]
Reviewed By: yungsters
Differential Revision: D63681874
fbshipit-source-id: 97783df5ae71292dd10602dee0bea39743e62234
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46959
This method was deprecated in: b8893c7003
since React Native 0.72.
I verified that no-one is using it in OSS so I'm removing it.
This is necessary as I'll need to refactor the BridgelessDevSupportManager a bit.
Changelog:
[Android] [Breaking] - Remove Deprecated DefaultDevSupportManagerFactory.create()
Reviewed By: javache
Differential Revision: D64184635
fbshipit-source-id: a4081b2189d2e22cd9b2067f982a6ffd4f8b054e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46956
isHighlighted/isPressable/selection color are the same as the native default, there's no need to send these in our props payload needlessly.
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D64179256
fbshipit-source-id: 22e62c8d440d3bd219a79f445e49739c24fa5d52
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46898
Replaces *many* `Text` component usages with `RNTesterText`: a thin wrapper around `Text` that applies color based on the color scheme chosen by the user. It makes text legible for dark mode across 41 different example files. This changes intentionally do not touch a few larger component sites that expand beyond RNTester, like `Animated` and `NewAppScreen`
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D64053464
fbshipit-source-id: 9516fef2afe1b364eb38e85e3a2dbb5c434e44db
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46949
# Changelog:
[Internal] -
This adds an (optional) event start time field into RawEvent, so that it can be threaded by the platform-specific code to tell where is the earliest point of the event start (depending on the platform).
For example, on Android platform it can be the point of time when the original MotionEvent was received.
Reviewed By: rubennorte
Differential Revision: D64175467
fbshipit-source-id: 535c95c695713dbbed74c554bceb70fa5e511d6a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46929
Got this error on Marketplace Home when I tried on the iOS 18 simulator:
```
Cannot read property 'stack' of null
if (rejection.stack && ...
```
This indicated `rejection` was null.
Fixed by adding an extra null check there.
Changelog:
[iOS][Fixed] Fixed crash on promise rejection handler in iOS 18.
Differential Revision: D64116020
fbshipit-source-id: 4198748b47d27c6def9957ff475ee780962d3baa
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46933
Some small tweaks to either resolve or better log clipping-related crashes in ReactViewGroup
Changelog: [Internal]
Reviewed By: sammy-SC
Differential Revision: D63914809
fbshipit-source-id: cf8bfd260c6affb85b8e1ac13447ae9f01d19135
Summary:
On Android, when `ReactEditText` is attached to window, `setTextIsSelectable` moves the caret to the beginning, so we need to restore the selection.
This is similar to what we did in https://github.com/facebook/react-native/pull/17851.
Fixes https://github.com/facebook/react-native/issues/46943
## Changelog:
[ANDROID] [FIXED] - Fix TextInput caret moving to the beginning when attached to window
Pull Request resolved: https://github.com/facebook/react-native/pull/46948
Test Plan:
Code to reproduce in RNTester:
```TSX
import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
import {TextInput} from 'react-native';
import {useEffect, useRef} from 'react';
function Playground() {
const input = useRef(null);
useEffect(() => { setTimeout(() => input.current?.focus(), 1000); }, []);
return <TextInput ref={input} value='1.00' selection={{start: 4, end: 4}} />;
}
export default ({
title: 'Playground',
name: 'playground',
render: (): React.Node => <Playground />,
}: RNTesterModuleExample);
```
Before | After
-- | --
 | 
Reviewed By: cortinico
Differential Revision: D64175774
Pulled By: rshest
fbshipit-source-id: ef9fdbecca582c8075bcdfd2d9b810b04d87e3d9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46931
Prepare for deletion of this deprecated type that contain support for string ref in the next flow release.
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D64127228
fbshipit-source-id: 9d3a1c0e6303efb35a540349fdc8e42b7b70be8b
Summary:
This PR follows up with the deprecation introduced here: https://github.com/facebook/react-native/pull/46228
The idea is to have new architecture depend on one flag, namely `newArchEnabled`. It exposes additional initializers for RCTRootViewFactory.
## Changelog:
[IOS] [CHANGED] - Use `newArchEnabled` flag in RCTAppDelegate and RCTRootViewFactory
Pull Request resolved: https://github.com/facebook/react-native/pull/46652
Test Plan: CI Green
Reviewed By: javache
Differential Revision: D64173015
Pulled By: cipolleschi
fbshipit-source-id: 49474baf5415a2527e481a5d68ec94ae874185e6
Summary:
There is a numerical issue that causes vertical scroll view to be considered as the horizontal one and leads to problems described [here](https://github.com/facebook/react-native/issues/46592). The problem is no longer visible after checking if the scroll view is horizontal with float equality.
~~I am not sure if it also happens on Android, so I am leaving it as a draft for now.~~
Fixes https://github.com/facebook/react-native/issues/46592
## Changelog:
[IOS] [FIXED] - check if scroll view is horizontal with float equality.
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[IOS] [FIXED] - fixed scroll view
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
Pull Request resolved: https://github.com/facebook/react-native/pull/46836
Test Plan: Tested on the repro provided in the above issue.
Reviewed By: rshest
Differential Revision: D64114476
Pulled By: cortinico
fbshipit-source-id: a5048e1403c4bb675d32928937d6411cfb12fd51
Summary:
Update React Native on iOS to do less manual memory management, by replacing uses of `CGColorRef` with `UIColor`, and only calling `UIColor.CGColor` when needed. This results in much less manual memory management, which is probably a good thing in 2024 :D. The downside is there is a breaking change: the signature of a method in `RCTBorderDrawing` changes.
This is a followup to https://github.com/facebook/react-native/issues/46797 . After that PR merged and I tested merging React Native macOS to the `0.76-stable` branch cut commit again, I saw even more places I needed to manually call `CGColorRetain` / `CGColorRelease`. The reason is due to React Native macOS specifics (explained below) and I could update React Native macOS to not need these changes, but I thought I would at least throw up a PR to propose the changes, as it may be good to move away from using Core Graphics' C base API as much as possible.
## Longer Explanation
With https://github.com/microsoft/react-native-macos/pull/2209 , I wrote a shim of [UIGraphicsImageRenderer](https://developer.apple.com/documentation/uikit/uigraphicsimagerenderer) for macOS. The main difference is my shim calls the NSImage API [imageWithSize:flipped:drawingHandler:](https://developer.apple.com/documentation/appkit/nsimage/1519860-imagewithsize?language=objc) to shim the UIGraphicsImageRenderer API [imageWithData:](https://developer.apple.com/documentation/uikit/uiimage/1624137-imagewithdata). The difference between the two is that the macOS API copies the block, and executes it when Appkit is about to draw the image, while the iOS API executes the block right away. Because of this, I think I am hitting way more places where `CGColorRef` variables needed to be retained / released. Additionally, I hit more of them when I merge to the 0.76 branch cut commit (this is why I didn't catch it with https://github.com/facebook/react-native/issues/46797).
Given this constraint, I have a couple of options:
1. Refactor my macOS shim to use the deprecated API [[NSImage lockFocus]](https://developer.apple.com/documentation/appkit/nsimage/1519891-lockfocus)
- I am not a fan of this because `lockFocus` was deprecated for `imageWithSize:flipped:drawingHandler:`
2. Refactor my macOS shim to do what we used to do: Create a CGContext manually and write it to an image
- This is probably OK. Relies on less Appkit specifics, and potentially gives more control to RN on the rendering layer, which I recall lenaic told me is better for Fabric)
3. Refactor React Native to avoid CGColorRef altogether, and use `UIColor` (which ARC will memory manage for us) as much as possible.
- This is the approach of this PR and my preferred approach. The downside is this changes the signature of some of the methods in `RCTBorderDrawing` which is a breaking change. I've seen other PRs do this, so maybe its OK?
## Changelog:
[IOS] [BREAKING] - Replace uses of `CGColorRef` with UIColor to avoid manual memory management
Pull Request resolved: https://github.com/facebook/react-native/pull/46847
Test Plan: Launching RNTester's View example (which tests a lot of the border / outline / shadow rendering) does not crash for me on both iOS and macOS.
Reviewed By: NickGerleman
Differential Revision: D63989547
Pulled By: joevilches
fbshipit-source-id: 5e85e17567e3dd8b4b0388452398954ad2e02464
Summary:
Windows has a stricter set of rules for C++ files where we treat warning as error, the following files have fixes to correctly cast numbers and fix control path errors.
Control Path Error on React-Native-Windows repo:
```
1>react-native-windows\node_modules\react-native\ReactCommon\react\performance\timeline\PerformanceEntryReporter.h(138,1): warning C4715: 'facebook::react::PerformanceEntryReporter::getBufferRef': not all control paths return a value
1>react-native-windows\node_modules\react-native\ReactCommon\react\performance\timeline\PerformanceEntryReporter.h(154,1): warning C4715: 'facebook::react::PerformanceEntryReporter::getBuffer': not all control paths return a value
```
Apply these fixes will allow us to unfork these files in our repo :)
## Changelog:
[GENERAL] [FIXED] - Fix cast and control paths errors on windows
Pull Request resolved: https://github.com/facebook/react-native/pull/46899
Test Plan: Tested on the RNW repo, these files are already forked with the respective fix
Reviewed By: cipolleschi
Differential Revision: D64086963
Pulled By: arushikesarwani94
fbshipit-source-id: fdad72dafa1a01c426536fc1b007dd4a83588d93
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46809
BaseViewManagerInterface isn't adding much value right now. It was added in D16984121 to allow codegen generated ViewManager delegates to apply to view managers which derive from ViewMangager instead of BaseViewManager (if they did some cleverness, to make VM delegate apply to a no-op class, still implementing all of BaseViewManager's methods).
All of the cases where that was used have since been moved to `SimpleViewManager`, and `BaseViewManagerAdapter` (needed to wire this together) doesn't exist anymore, so it's not possible to take any advantage of this interface existing. We should remove it, since its existence is a source of error (e.g. it was missing setters for `accessibilityValue` or those related to pointer events), and is more generally confusing for anyone adding to `BaseViewManager` in the future.
This is a breaking change, because there are some libraries which vendor a copy of generated ViewManagerDelegate when building against legacy arch to be able to share code normally generated at build time. That means these will need to be updated to maintain compatibility with RN versions of 0.77+ with new arch disabled. This will not effect compatibility of these libraries against the default new arch, and the updated delegate is still compatible with older RN version.
```
sourceSets.main {
java {
if (!isNewArchitectureEnabled()) {
srcDirs += [
"src/paper/java",
]
}
}
}
```
1. `react-native-picker/picker`
2. `rnmapbox/maps`
3. `react-native-gesture-handler`
4. `react-native-screens`
5. `react-native-svg`
6. `react-native-safe-area-context`
7. `react-native-pdf`
Changelog:
[Android][Breaking] - Remove BaseViewManagerInterface
Reviewed By: cortinico
Differential Revision: D63819044
fbshipit-source-id: 7e4935c8e43706b168f0f599a6676e8abfa66937
Summary:
Part of this: https://github.com/facebook/react-native/issues/46757
Solves:
ME2E0019
## Changelog:
[ Internal ] [ Added ] - Added a test case for Image
<!-- 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/46831
Test Plan:
yarn e2e-test-ios
yarn e2e-test-android
Reviewed By: cortinico
Differential Revision: D63889719
Pulled By: cipolleschi
fbshipit-source-id: 674879066ec159f11894f24935fe39a86ea1ea63