Commit Graph

12270 Commits

Author SHA1 Message Date
Shawn Dempsey 85f1d9a518 Back out "Unify feature flags for event loop" (#47041)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47041

Original commit changeset: b879447def8a

Original Phabricator Diff: D64175216

Reviewed By: fkgozali

Differential Revision: D64439014

fbshipit-source-id: efc1bb7baa547d270322aabf6c5a4f50ace23e1b
2024-10-15 21:53:42 -07:00
Nick Gerleman 557e3447f5 Include existing attributes in newly typed text (#47018)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47018

This change makes it so that newly typed text in a TextInput will include the existing attributes present based on cursor position. E.g. if you type after an inner fragment with blue text, the next character will be blue (or, an event emitter specific to an inner fragment will also be expanded). This is a behavior change for the (admittedly rare) case of uncontrolled TextInput with initially present children AttributedText, but more often effect controlled components, before state update (we are after, less likely to need to reset AttributedString because of mismatch).

Originally included this in D64121570, but it's not needed to fix the common case since we include paragraph-level event emitter as part of default attributes, and has some of its own risk, so I decided it is better separate.

Changelog:
[iOS][Changed] - Include existing attributes in newly typed text

Reviewed By: cipolleschi

Differential Revision: D64352310

fbshipit-source-id: 90ef8c49f50186eadf777e81cf6af57e1aada207
2024-10-15 16:24:53 -07:00
Nick Gerleman 36fd5533f6 Fix cursor moving while typing quickly and autocorrection triggered in controlled single line TextInput on iOS (New Arch) (#46970)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46970

Fixes https://github.com/facebook/react-native/issues/44157

This one is a bit of a doozy...

During auto-correct in UITextField (used for single line TextInput) iOS will mutate the buffer in two parts, non-atomically. After the first part, after iOS triggers `textFieldDidChange`, selection is in the wrong position. If we set full new AttributedText at this point, we propagate the incorrect cursor position, and it is never restored.

In the common case, where we are not mutating text in the controlled component, we shouldn't need to be setting AttributedString in the first place, and we do have an equality comparison there currently. But it is defeated because attributes are not identical. There are a few sources of that:
1. NSParagraphStyle is present in backing input, but not the AttributedString we are setting.
2. Backing text has an NSShadow with no color (does not render) not in the AttributedText
3. Event emitter attributes change on each update, and new text does not inherit the attributes.

The first two are part of the backing input `typingAttributes`, even if we set a dictionary without them. To solve for them, we make attribute comparison insensitive to the attribute values in a default initialized control. There is code around here fully falling back to attribute insensitive comparison, which we would ideally fix to instead role into this "effective" attribute comparison.

The event emitter attributes being misaligned is a real problem. We fix in a couple ways.
1. We treat the attribute values as equal if the backing event emitter is the same
2. We set paragraph level event emitter as a default attribute so the first typed character receives it

After these fixes, scenario in https://github.com/facebook/react-native-website/pull/4247 no longer repros in new arch. Typing in debug build also subjectively seems faster? (we are not doing second invalidation of the control on every keypress).

Changes which do mutate content may be susceptible to the same style of issue, though on web/`react-dom` in Chrome, this seems to not try to preserve selection at all if the selection is uncontrolled, so this seems like less of an issue.

I haven't yet looked at old arch, but my guess is we have similar issues there, and could be fixed in similar ways (though, we've been trying to avoid changing it as much as possible, and 0.76+ has new arch as default, so not sure if worth fixing in old impl as well if this is very long running issue).

Changelog:
[iOS][Fixed] - Fix cursor moving in iOS controlled single line TextInput on Autocorrection (New Arch)

Reviewed By: javache, philIip

Differential Revision: D64121570

fbshipit-source-id: 2b3bd8a3002c33b68af60ffabeffe01e25c7ccfe
2024-10-15 16:24:53 -07:00
Ruslan Lesiutin d287c72804 Update debugger-frontend from 6f29504...0ecc39f (#47036)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47036

Changelog: [Internal] - Update `react-native/debugger-frontend` from 6f29504...0ecc39f

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebookexperimental/rn-chrome-devtools-frontend/compare/6f29504d63ea3de4b07545fdfa59b978e30b05a9...0ecc39f68a7dbfb76ae5801b24f0e8ad610ba785).

Reviewed By: EdmondChuiHW

Differential Revision: D64405153

fbshipit-source-id: 1fe491aa878d203bee207f5c4163aac98f4524c2
2024-10-15 13:15:07 -07:00
Ruslan Lesiutin c1a7b4a8e9 upgrade[react-devtools-*]: ^6.0.1 (#47034)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47034

allow-large-files

# Changelog: [Internal]

Upgrades React DevTools npm packages to 6.0.1 for whole xplat.

Reviewed By: EdmondChuiHW

Differential Revision: D64403912

fbshipit-source-id: 39310fcb300a2a2e48d38faacef97ef65c49bbe8
2024-10-15 13:15:07 -07:00
Joe Vilches dd1aea5ccf fix(iOS): Replace uses of CGColorRef with UIColor to avoid manual memory management v2 (#47019)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47019

NOTE: This code is largely the same as https://github.com/facebook/react-native/pull/46847, I am merely fixing some internal issues

The original diff (D63989547) was backed out because it was causing some crashes related to some internal code that had to be changed. That code did not necessarily need to be changed - we could have just left the `RCTCreateCGColorRefFromSharedColor` function and not touched the internal code - which is what I am going to do here

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D64201626

fbshipit-source-id: a8ead7a542514aee0749973e284cb7727d393c03
2024-10-15 12:59:58 -07:00
evanbacon 043e2fe14a prevent fatal crashes when launching App Clips (#47000)
Summary:
App Clips are full of bugs. One such bug is how launching an App Clip from Test Flight (and perhaps other systems) will cause the user activity to be of type `NSUserActivityTypeBrowsingWeb` but with a nullish `userActivity.webpageURL` (even though it's typed as never being nullish in this mode).

## Changelog:

[IOS] [FIXED] - Fix launching App Clips with nullish URLs.

<!-- 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/47000

Test Plan:
The following was failing cryptically and required extensive debugging to get launching.

https://github.com/user-attachments/assets/ffd26297-b20b-45a2-97cc-35a48b740cb2

Reviewed By: cipolleschi

Differential Revision: D64372170

Pulled By: lunaleaps

fbshipit-source-id: 388f05530f3bccdd9b446382931f127421bc8a27
2024-10-15 11:50:12 -07:00
Rubén Norte f9460deda7 Clean up feature flag removeNestedCallsToDispatchMountItemsOnAndroid (#47026)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47026

Changelog: [internal]

Clean up feature flag after we tested it's safe.

Reviewed By: javache

Differential Revision: D64332654

fbshipit-source-id: 33e92abb24c9350628a814ecab195f995316d2bc
2024-10-15 10:59:03 -07:00
tarunrajput 3f633473c3 Add maestro e2e test for Legacy Style Event (#46784)
Summary:
part of https://github.com/facebook/react-native/issues/46757
closes ME2E0006, ME2E0007

## 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 e2e test for Legacy Style Event

Pull Request resolved: https://github.com/facebook/react-native/pull/46784

Test Plan:
```
yarn e2e-test-ios
yarn e2e-test-android
```

Reviewed By: cortinico

Differential Revision: D64172277

Pulled By: cipolleschi

fbshipit-source-id: adf3a55b354f1a293c4620dc617a6a08e3aebd2b
2024-10-15 10:57:32 -07:00
Riccardo Cipolleschi 118c1f7035 Add support for new iOS text content type cellular EID and cellular IMEI (#46507)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46507

Support for new iOS text content type to autofill cellular EID or cellular IMEI:
- https://developer.apple.com/documentation/uikit/uitextcontenttypecellulareid?language=objc
- https://developer.apple.com/documentation/uikit/uitextcontenttypecellularimei?language=objc

## Changelog:

[General][Added] - Add JS layer for new text content type cellular EID and cellular IMEI

Reviewed By: cortinico

Differential Revision: D62737200

fbshipit-source-id: 4db9c29079e63107deeb00a3a1558aa151d80fc1
2024-10-15 10:55:03 -07:00
Rubén Norte 9e5b6e88c5 Unify feature flags for event loop (#46953)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46953

Changelog: [internal]

This unifies all the feature flags that control the new event loop on RN. Before, we'd have granular flags for different aspects of it. With this diff, we enable the event loop by default with bridgeless, and we introduce a new flag to explicitly disable it in that case if necessary.

When we're ready to clean up this opt-out, we just need to remove the `&& !ReactNativeFeatureFlags::disableEventLoopOnBridgeless()` conditions.

Reviewed By: javache

Differential Revision: D64175216

fbshipit-source-id: b879447def8ab47c6ab772812ff1031177494069
2024-10-15 09:44:01 -07:00
Rubén Norte 3ebf4f3b0e Force bridgeless feature flags in RCTAppDelegate when bridgeless is enabled (#46972)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46972

Changelog: [internal]

I'm unifying the feature flags for the new event loop (so it's enabled by default when bridgeless is enabled, unless a feature flag is explicitly set), and I realized that the feature flags for Bridgeless, Fabric and Turbo Modules aren't being set in iOS, causing my changes to be incorrect (as we're using bridgeless but the bridgeless flag is off).

This forces the right flags when using bridgeless so the configuration is consistent.

Reviewed By: rshest, cipolleschi

Differential Revision: D64234056

fbshipit-source-id: bfdbe6742ee84c23d6d2c0c56e6ca8fce1788b26
2024-10-15 09:44:01 -07:00
Riccardo Cipolleschi 7b6e8e7765 Codegen fails with Local Module (#47027)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47027

While I was writing the documentation for extracting a module in a library, I realized that Codegen ignored the local node modules.

The reason is that `require.resolve` fails to resolve a local path.

bypass-github-export-checks

## Changelog
[General][Fixed] - Make Codegen work with local modules

Reviewed By: cortinico

Differential Revision: D64242713

fbshipit-source-id: cc5167665a49df1d09eb66a0dc9d76466f087a25
2024-10-15 09:30:50 -07:00
poonamjain96 8cf27e8b6f Add test for Console.log measure in new-arch-examples (#47020)
Summary:
Part of this: https://github.com/facebook/react-native/issues/46757
Solves:
- ME2E0005

## 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 ] [ Added ] - Add console.log measure test in new-arch-example

Pull Request resolved: https://github.com/facebook/react-native/pull/47020

Test Plan:
```
yarn e2e-test-ios
yarn e2e-test-android
```

Reviewed By: cortinico

Differential Revision: D64397112

Pulled By: cipolleschi

fbshipit-source-id: c9192d66065038528751e2e366f58158b06eb864
2024-10-15 08:29:47 -07:00
zhongwuzw c1178ac208 Fixes scrollIndicatorInsets not work in old arch (#46944)
Summary:
Fixes https://github.com/facebook/react-native/issues/46918 . break change comes from https://github.com/facebook/react-native/pull/44820 and https://github.com/facebook/react-native/pull/44789 .

## Changelog:

[IOS] [FIXED] - Fixes scrollIndicatorInsets not work in old arch

Pull Request resolved: https://github.com/facebook/react-native/pull/46944

Test Plan: scrollIndicatorInsets should work in old arch.

Reviewed By: philIip

Differential Revision: D64173490

Pulled By: cipolleschi

fbshipit-source-id: f7186439146d1b811c02e584fd1d94fcbb5d88a2
2024-10-15 08:11:59 -07:00
Qichen Zhu 08bd8ac47d Fix KeyboardAvoidingView not aware of the keyboard closing after it is unmounted (#46952)
Summary:
In the new architecture, if you open the soft keyboard, unmount `KeyboardAvoidingView`, close the keyboard, and then remount `KeyboardAvoidingView`, it still assumes the keyboard is open and displays the keyboard avoiding area.

We need to check if the keyboard is still open after remounting.

Fixes https://github.com/facebook/react-native/issues/46942

## Changelog:

[GENERAL] [FIXED] - Fix KeyboardAvoidingView not aware of the keyboard closing it is unmounted

Pull Request resolved: https://github.com/facebook/react-native/pull/46952

Test Plan:
Code to reproduce in RNTester:

```JSX
import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
import {Button, KeyboardAvoidingView, Text, TextInput, View} from 'react-native';
import {Fragment, Suspense, useState} from "react";

const infiniteThenable = { then() {} };

function Suspender({ freeze, children }) {
  if (freeze) {
    throw infiniteThenable;
  }
  return <Fragment>{children}</Fragment>;
}

function Freeze({ freeze, children }) {
  return (
    <Suspense>
      <Suspender freeze={freeze}>{children}</Suspender>
    </Suspense>
  );
}

function Playground() {
  const [isFrozen, setIsFrozen] = useState(false);

  return (
    <>
      <TextInput style={{ height: 100 }} />
      <Button title="Freeze" onPress={() => setIsFrozen(true)} />
      <Button title="Unfreeze" onPress={() => setIsFrozen(false)} />

      <Freeze freeze={isFrozen}>
        <KeyboardAvoidingView behavior="padding" style={{ flex: 1 }}>
          <View style={{ backgroundColor: '#909090', flex: 1, alignItems: 'center', justifyContent: 'flex-end' }}>
            <Text>Test</Text>
            <Text></Text>
          </View>
        </KeyboardAvoidingView>
      </Freeze>
    </>
  );
}

export default ({
  title: 'Playground',
  name: 'playground',
  render: (): React.Node => <Playground />,
}: RNTesterModuleExample);
```

### Steps

1. Tap the text input to show the soft keyboard.
2. Tap Freeze.
3. Tap the Enter or Done button on the soft keyboard to hide it.
4. Tap Unfreeze.
5. Verify that there is no blank area at the bottom of the screen.

### Videos

#### iOS

Before | After
-- | --
<video src="https://github.com/user-attachments/assets/0c8d840e-14a6-47ad-a163-d34ac9cfbf40" /> | <video src="https://github.com/user-attachments/assets/1d88a70c-e029-433d-920d-da7582edb3f2" />

#### Android

Before | After
-- | --
<video src="https://github.com/user-attachments/assets/f29f6526-c5a4-4b6a-b3aa-7c4c7ff3ed30" /> | <video src="https://github.com/user-attachments/assets/c4e92356-694b-4fca-8897-7dfca8495db0" />

Reviewed By: andrewdacenko

Differential Revision: D64178982

Pulled By: cipolleschi

fbshipit-source-id: 8d71654aac599cec4e1928b14d87cff34f28174a
2024-10-15 08:03:13 -07:00
Edmond Chui 2c9176ac0f Update debugger-frontend from 87b2feb...6f29504 (#47029)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47029

Changelog: [Internal] - Update `react-native/debugger-frontend` from 87b2feb...6f29504

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebookexperimental/rn-chrome-devtools-frontend/compare/87b2feb14627b3e8713bc2637992b9a8c76bbe61...6f29504d63ea3de4b07545fdfa59b978e30b05a9).

Reviewed By: vzaidman

Differential Revision: D64393541

fbshipit-source-id: 4c87b37a192efa68a579b94bb4219099d4400714
2024-10-15 07:24:41 -07:00
Nicola Corti 11392c74d7 AGP to 8.7.1 (#47022)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47022

That's just a patch bump for AGP from 8.7.0 to 8.7.1

Changelog:
[Internal] [Changed] - AGP to 8.7.1

Reviewed By: cipolleschi

Differential Revision: D64390797

fbshipit-source-id: b48218b5737b8e7379ab4f13dfa57a97c3e30cbd
2024-10-15 06:08:09 -07:00
Nicola Corti 091025e18b Fresco to 3.4.0 (#47024)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47024

This bumps Fresco from 3.3.0 to 3.4.0
Most notable change is NDK 27 support + 16K Page support.

Changelog:
[Android] [Changed] - Fresco to 3.4.0

Reviewed By: cipolleschi

Differential Revision: D64391402

fbshipit-source-id: 4dc9b2a045d0901bd6ee41cdbd4f1db2e22eb576
2024-10-15 06:01:27 -07:00
Nicola Corti 44c5cc36ad Silence CMake warning caused by PROJECT_ROOT_DIR (#47015)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47015

CMake is complaining that this variable is set outside the build but not used.
I'm using it inside our top level .cmake file to silence this warning.
We need this variable as user projects might use it.

Changelog:
[Internal] [Changed] - Silence CMake warning caused by `PROJECT_ROOT_DIR`

Reviewed By: javache

Differential Revision: D64334462

fbshipit-source-id: 558bfc9f647e62890e3cc25628b5544880c47e4b
2024-10-15 04:27:04 -07:00
YunPeng Chong 3485e9ed87 Fix onEndReached not being called when getItemLayout is present and we scroll past render window (#46990)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46990

This is a reattempt land D63643856 to fix the scroll onendreached event not firing.

Changelog:
[General][Fixed] - Fix onEndReached not being called when getItemLayout is present and we scroll past render window

Reviewed By: NickGerleman

Differential Revision: D64222424

fbshipit-source-id: 7e22f377d2f754beb39fff2b5c097cea350daa7e
2024-10-14 15:09:25 -07:00
Rob Hogan 0902b0af75 Update Metro to 0.81.0 (#47012)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47012

Update Metro from `0.81.0-alpha.2` to `0.81.0`.

This is also intended to be the final, stable release for RN 0.76.

Changelog:
[General][Changed]: Update Metro to 0.81.0

Reviewed By: blakef

Differential Revision: D64329574

fbshipit-source-id: e12bed356b46e4ed68c75b397b7f9e2228c377be
2024-10-14 10:08:36 -07:00
Peter Abbondanzo 6e120b3b46 Add e2e test for Image resize method (#46982)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46982

E2E test setup for each of the `resizeMethod` methods for Image on Android

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D64136839

fbshipit-source-id: 876939a50243836030401c6456410f119abe01b5
2024-10-14 08:54:28 -07:00
Gabriel Donadel 4dd47eeb9e Make PackagerConnectionSettings class open again (#47005)
Summary:
When migrating `PackagerConnectionSettings` from Java to Kotlin in https://github.com/facebook/react-native/pull/45800 the new class ended up being declared as final, causing a breaking change in 0.76.

We should add the `open` directive to `PackagerConnectionSettings.kt` to restore the old behavior. That would be crucial for the `expo-dev-client` package, given that Expo needs to be able to extend this class in order to overwrite the `debugServerHost` value.

## Changelog:

[ANDROID] [FIXED] - Make PackagerConnectionSettings class open again

Pull Request resolved: https://github.com/facebook/react-native/pull/47005

Test Plan: Run RNTester on Android

Reviewed By: huntie

Differential Revision: D64323645

Pulled By: cortinico

fbshipit-source-id: 6870a3dee929ba664e4c402f321f84af7704f892
2024-10-14 04:43:52 -07:00
Fabrizio Cucci 6c19996e10 Account for diffrent frame size when using maintainVisibleContentPosition in virtualized lists (#46979)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46979

It seems that, when the items in a virtualized list don't have a fixed size (i.e. they dynamically scale with the size of the container), we need to also take into account their size when updating the scroll position as a consequense of setting `maintainVisibleContentPosition`.

Changelog:
[Android][Fixed] - Account for items dynamically scaling with the container when using `maintainVisibleContentPosition` in virtualized lists

Reviewed By: javache, NickGerleman

Differential Revision: D64238887

fbshipit-source-id: 9f05a461d178bc191137b1a350072337ba62e224
2024-10-14 04:28:31 -07:00
Rubén Norte b5271779ec Fix race condition when reporting mounting transactions for deallocated surfaces (#47008)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47008

Changelog: [internal]

This code is gated anyway so there's no harm in production.

Reviewed By: javache

Differential Revision: D64322331

fbshipit-source-id: 005eb385f7e5ccd3d33e2d8c28e45b84f1537d68
2024-10-14 04:16:04 -07:00
Samuel Susla b7fec235de small refactor of EventBeat (#47001)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47001

changelog: [internal]

EventBeat::beat is only used on Windows, let's move it there.

EventBeat::induce is only called by subclasses, doesn't need to be public.

Reviewed By: christophpurrer

Differential Revision: D64287646

fbshipit-source-id: 48edceddd273b45e8a4e63f4c1d5fda6c5adf425
2024-10-13 03:27:40 -07:00
Jeff Bahr 9ba6237bff Update google-java-format to 1.23.0 (#46860)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46860

Pulling library into our repository

Result of:
  arc artificer download com.google.googlejavaformat:google-java-format:1.23.0 --interactive

Deps
```
➜  arc artificer rquery dependencies --cross-reference com.google.googlejavaformat:google-java-format:1.23.0
com.google.googlejavaformat:google-java-format:1.23.0 
└╼ com.google.guava:guava:32.1.3-jre:compile 

```

Formatted with

```
tools/arcanist/lint/codemods/googlejavaformat_fbsource
```

Reviewed By: hick209

Differential Revision: D60787993

fbshipit-source-id: dbadc5184c0a7cccd967173e21602657013ddac7
2024-10-12 08:51:46 -07:00
Samuel Susla 3130f0d646 add timestamp to onScroll on iOS (#46978)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46978

changelog: [internal]

Add timestamp to onScroll event on Android.

Reviewed By: fabriziocucci

Differential Revision: D64068207

fbshipit-source-id: 3d4c31bbf43ef5f06af4933867380d3ef297b550
2024-10-12 04:55:12 -07:00
Samuel Susla f4855d7d37 add timestamp to onScroll on Android (#46977)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46977

changelog: [internal]

Add timestamp to onScroll event on Android.

Reviewed By: fabriziocucci

Differential Revision: D64235402

fbshipit-source-id: 606446f2a711dcb4edd94a2a54ec50c54f622904
2024-10-12 04:55:12 -07:00
David Vacca 34431272c3 Move execution of ReactNativeFeatureFlags::enableDeletionOfUnmountedViews() out of destructor (#46993)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46993

Calling ReactNativeFeatureFlags::enableDeletionOfUnmountedViews() from the destructor increases the chance of accessing ReactNativeFeatureFlags during the tear down of React Native.

We are moving this call into the contructor of the object which always happen on the js thread

changelog: [internal] internal

Reviewed By: rubennorte

Differential Revision: D64190029

fbshipit-source-id: 377b85e8ff0704db0f6603662f595b75a6705693
2024-10-12 00:39:21 -07:00
David Vacca 621622a5b1 Refactor Systrace.traceSection() to unblock CI (#46994)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46994

This diff makes a small refactor on Systrace.traceSection() to unblock CI, which was broken by D64141515

changelog: [internal] internal

Reviewed By: Abbondanzo

Differential Revision: D64276651

fbshipit-source-id: e35950f88cde3d547992bb700208a4d4d309710f
2024-10-12 00:39:21 -07:00
Benoit Girard 401991c3f0 Better instrument the startup timeline.
Summary:
Using a new JVM profiler (D64128815) to find blind spot in the early startup init markers and adding them.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D64141515

fbshipit-source-id: d2968ed5dafdd891b8cc5a6115479c0678bfdc80
2024-10-11 12:50:28 -07:00
Rubén Norte c86b5c1232 Add new dangerouslyForceOverride method to feature flags (#46963)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46963

Changelog: [internal]

This introduces a new method in `ReactNativeFeatureFlags` to force setting overrides without triggering any errors (they're returned a string instead to be handled in userland). This is partially equivalent to calling `dangerouslyReset` and `override` but completely avoids the hard crashes that could be caused by race conditions.

Reviewed By: javache, rshest

Differential Revision: D64186262

fbshipit-source-id: 854caa03810ec78217999292a4335dad373b7fcb
2024-10-11 10:05:25 -07:00
Sam Zhou 105aa129d8 Deploy 0.248.0 to fbsource
Summary: Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D64225120

fbshipit-source-id: ce00574ea5d367737191ac430017332799906ebe
2024-10-11 09:59:44 -07:00
Thomas Nardone fc199bb5f3 Convert ReactViewManager to Kotlin (#46965)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46965

Converting this class as close to 1:1 as possible.

Changelog: [Internal]

Reviewed By: NickGerleman, rshest

Differential Revision: D64124890

fbshipit-source-id: 2034ed8ecb877bb267a953b183b77daaf883a80a
2024-10-11 09:14:55 -07:00
Peter Abbondanzo 483b928224 Swallow exceptions on draw, forward to onError (#46964)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46964

Graceful degradation is better than outright crashing. When rendering images that exceed Android's memory limits, React Native applications will fatally crash. This change intervenes by swallowing the exception that Android raises and forwards it to the `onError` handler. As a result, no image will be rendered instead of fatally crashing.

Fresco already intervenes by default. It will raise a `PoolSizeViolationException` if the bitmap size exceeds memory limits set by the OS and applies a 2048 pixel maximum dimension to JPEG images, but it's still possible for these configuration limits to be removed and for images to fall just short of Fresco's memory limit. The exception is raised when we attempt to draw the bitmap, not when the bitmap is allocated in memory, so we must handle the exception here and not in Fresco.

## Changelog

[Android][Fixed] - Apps will no longer fatally crash when trying to draw large images

Reviewed By: tdn120

Differential Revision: D64144596

fbshipit-source-id: 32b69ad4ecef0564c2cad7a287a31b56688f38b8
2024-10-11 09:10:30 -07:00
Samuel Susla ca6dc67570 fix stale contentSize in ScrollView (#46981)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46981

changelog: [internal]

stateUpdate with closure syntax has to be used in order to not override contentSize stored inside of C++ state.

Reviewed By: jessebwr

Differential Revision: D64242221

fbshipit-source-id: 32d55ccc03e32922f2746293ccb6c0941ca67d92
2024-10-11 08:44:29 -07:00
Nick Lefever aacd4bba29 Disable shadow node reference updates by default (#46961)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46961

Changelog: [Internal]
Runtime Shadow Node Reference Syncing causes asserts when updating the shadow tree without passing through the JS-thread. This diff disables the feature by default to avoid the asserts encountered on RN Windows.

Reviewed By: sammy-SC

Differential Revision: D64188839

fbshipit-source-id: eb65206662d842f8150f1771c86dc8d190cbc3aa
2024-10-11 08:35:34 -07:00
Fabrizio Cucci c09f824962 Replace React.AbstractComponent with component type in ActivityIndicator (#46951)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46951

Prepare for the ref-as-prop typing change in flow.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D64175898

fbshipit-source-id: 4db76dda0c4ac604c38dc3acf5bc39448cad006e
2024-10-11 06:53:43 -07:00
Fabrizio Cucci bcb6dafedc Replace React.AbstractComponent with component type in Pressable (#46950)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46950

Prepare for the ref-as-prop typing change in flow.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D64175859

fbshipit-source-id: 56c3fe658a372b5148952850166781b733bbb37a
2024-10-11 06:53:43 -07:00
Nicola Corti 972c2c864c Bump Kotlin 1.9.x to 2.0.x (#46955)
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
2024-10-11 05:34:02 -07:00
Nicola Corti 2c4567562c RNGP - Pass PROJECT_ROOT_DIR to CMake (#46958)
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
2024-10-11 03:34:54 -07:00
Nick Gerleman b69a92e2c9 Add boxShadow support to BaseViewManager (#46936)
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
2024-10-10 18:02:50 -07:00
Nick Gerleman 6741fd94ad Add missing BaseViewManager props to BaseViewManagerDelegate (#46934)
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
2024-10-10 18:02:50 -07:00
Ramanpreet Nara 9119c32785 earlyjs: Implement decoratedExtraDataKey (#46932)
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
2024-10-10 16:03:02 -07:00
Ramanpreet Nara 9619ba5ce6 Integrate logbox into earlyjs c++ pipeline (#46935)
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
2024-10-10 16:03:02 -07:00
Ramanpreet Nara 509abff063 Extend earlyjs c++ pipeline for soft errors (#46893)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46893

Before, the c++ pipeline only supported fatal errors.

Now, it supports soft errors!

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D63927090

fbshipit-source-id: ddaad0ea9b4aa1f889b24ca388cd6b9b1c83adba
2024-10-10 16:03:02 -07:00
Ramanpreet Nara 934af0c59e Align earlyjs c++ stack trace parsing with js (#46894)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46894

This diff re-implements [js error stack trace parsing](https://github.com/facebook/react-native/blob/86cac6836502aaeb5c894bff6427e837c52c09e0/packages/react-native/Libraries/Core/Devtools/parseErrorStack.js#L41-L57) in c++.

Details:
- I migrated [stacktrace-parser](https://github.com/errwischt/stacktrace-parser/blob/ad379de5e5ac056012bbeb12923cf502aefe4710/src/stack-trace-parser.js#L7)
- I migrated [parseHermesStack.js](https://github.com/facebook/react-native/blob/86cac6836502aaeb5c894bff6427e837c52c09e0/packages/react-native/Libraries/Core/Devtools/parseHermesStack.js#L82)

I also migrated all their tests to c++:
- [stacktrace-parser tests](https://github.com/errwischt/stacktrace-parser/blob/ad379de5e5ac056012bbeb12923cf502aefe4710/test/stack-trace-parser.spec.js#L5)
- [parseHermesStack tests](https://github.com/facebook/react-native/blob/86cac6836502aaeb5c894bff6427e837c52c09e0/packages/react-native/Libraries/Core/Devtools/__tests__/parseHermesStack-test.js#L16)

Changelog: [Internal]

Reviewed By: javache, NickGerleman

Differential Revision: D63659013

fbshipit-source-id: 146acc9db7d4e8907b9fa1d42e4979133ef020f6
2024-10-10 16:03:02 -07:00
Ramanpreet Nara e4645d033a easy: Align earlyjs c++ native data structures with js (#46895)
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
2024-10-10 16:03:02 -07:00