Commit Graph

33874 Commits

Author SHA1 Message Date
Alan Lee
2cd48ef351 fix Modal content being cut off when Android Activity is edge-to-edge (#47339)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47339

Fixing issue raised in https://github.com/facebook/react-native/issues/47307

This is a follow up from D62286026.
It appears there was a line that went missing while trying to refactor the code.

`fitsSystemWindows = true` is needeod for < API 30 to avoid content rendering under the system bars when Modal is shown with Activity that is edge-to-edge.

Changelog:
[Android][Fixed] Fix Regression - Modal content rendering below system bar on < API 30 when activity is edge-to-edge

Reviewed By: cortinico

Differential Revision: D65280014

fbshipit-source-id: 616ff739be55635f1295ef3bf8b997a27ef769ae
2024-11-01 01:27:40 -07:00
Alan Lee
65cdd5b82c Enable 16KB page size binaries for RN libraries + hermes (#47042)
Summary:
X-link: https://github.com/facebook/hermes/pull/1557

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

Add native build flags to support 16KB page size

- https://developer.android.com/guide/practices/page-sizes#compile-r27-higher

Changelog:
[Android][Added] add cmake arguments to support 16KB page size for native libraries

Reviewed By: cortinico

Differential Revision: D64446876

fbshipit-source-id: 5c6b7874a8837c7ebc9b3e9267ce11fb152bf535
2024-10-31 18:45:31 -07:00
Samuel Susla
66a2f1d312 Back out "delete redundant EventEmitter::dispatchEvent overload" (#47347)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47347

changelog: [internal]

Original commit changeset: cffdc3ef0424

Original Phabricator Diff: D65040505

Reviewed By: lunaleaps

Differential Revision: D65305763

fbshipit-source-id: 4c9e4b4acd9c5f9530af428402b106272a4e0054
2024-10-31 18:42:07 -07:00
Nolan O'Brien
79d55542aa Move FBHashKit to LayerZero/METAHash (#47343)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47343

Moving `FBHashKit` to *LayerZero* as `METAHash`

## Changelog

[Internal][Change] Move `FBXXHashUtils`

Reviewed By: adamjernst

Differential Revision: D65256846

fbshipit-source-id: 6e24a78925367e83e94e7c67a235cda924edd28e
2024-10-31 18:01:57 -07:00
Nolan O'Brien
f8fc90e754 Modernize in preparation for move to Layer Zero (#47342)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47342

There are things we can do to modernize `FBHashKit` to make it ready for prime time, aka Layer Zero.

  * Consolidate down to a singular `meta_hash(...)` generic macro (supports all primitives for hashing)
  * Eliminate the unnecessary C++
  * Deprecate legacy FB APIs
  * Make logic (and interfaces) explicit for 32 vs 64 bit inputs and 32 vs 64 bit outputs
  * Introduce robust unit tests
  * Have unit tests actually testable for 32-bit hashes

## Changelog

[Internal][Change] Prep to move `FBXXHashUtils`

Reviewed By: cipolleschi

Differential Revision: D65245787

fbshipit-source-id: 311404068fd9df2a77d1ae4850b8a785466e73f0
2024-10-31 18:01:57 -07:00
Parsa Nasirimehr
ec4ead59e1 fix(iOS): small test fix for RCTViewTests (#47314)
Summary:
Depracated usage of scrollInsets + an unused param.

## Changelog:

[INTERNAL] [FIXED] - Switch to verticalScrollIndicatorInsets and mark unused value as __unused in test file

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

Test Plan:
Running the specific test itself, it passes:
<img width="1092" alt="Screenshot 2024-10-30 at 18 02 08" src="https://github.com/user-attachments/assets/e3ed27c6-9f00-4777-a72c-92f0da93a79f">

Reviewed By: NickGerleman

Differential Revision: D65231365

Pulled By: philIip

fbshipit-source-id: eed795ad65bd837fb9f38175081d961245ff3932
2024-10-31 16:24:41 -07:00
Jakub Piasecki
fd273f83e0 Add RNTester examples for display: contents (#47201)
Summary:
Adds a page dedicated to `display: contents` to RNTester APIs section. Those can be used to verify that it's working correctly visually.

Needs https://github.com/facebook/react-native/pull/47194

## Changelog:

[INTERNAL] [ADDED] - Added `display: contents` examples to RNTester

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

Test Plan:
Row styles are ignored in new arch and TextInputs as leaf are hidden

https://www.internalfb.com/compare-screenshots-from-diff/D65248256

Reviewed By: javache

Differential Revision: D65248256

Pulled By: NickGerleman

fbshipit-source-id: 90410e1380e4cdb22cb4cac5c8c21e08a088ce69
2024-10-31 16:12:46 -07:00
Nicola Corti
ecd138e267 Enable warningAsErrors for hermes-engine (#47320)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47320

I've solved all the warnings on ReactAndroid/hermes-engine.
This enables warningsAsErrors for that part of the codebase so we can make sure
no further warnings get introduced.

Changelog:
[Internal] [Changed] - Enable warningAsErrors for hermes-engine

Reviewed By: NickGerleman

Differential Revision: D65243753

fbshipit-source-id: 17c22d1a7a32d2c684d7f236f7554f6e26469e99
2024-10-31 15:05:12 -07:00
Sam Zhou
b91a449e7f Cleanup problematic React.ElementRef (#47340)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47340

This diff cleans up some problematic `React.ElementRef<T>` when T is generic type.

Changelog: [Internal]

Reviewed By: alexmckenley

Differential Revision: D65280467

fbshipit-source-id: 71172b16320a10cbc7a8b46dae5d3dd0eb00ba0c
2024-10-31 13:30:17 -07:00
Pieter De Baets
6ba7cb3102 Fix potential race in FabricMountingManager (#47337)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47337

We call `onSurfaceStart` after calling `surfaceHandler.start()`. In theory it's possible for the React surface to start generating commits before we've informed the mounting manager of the surface having started, which could cause us to not accurately track views allocated for that surface so far.

Changelog: [Android][Fixed] Addressed race condition in surface start.

Reviewed By: rshest

Differential Revision: D65269674

fbshipit-source-id: 2927220bc17e61125dabcdd75f5325a0ca77e60b
2024-10-31 12:33:13 -07:00
Mateo Guzmán
e5dd7d68bf feat(image): enabling basic cache control for android (#47182)
Summary:
Fixes https://github.com/facebook/react-native/issues/12606

Previously, `Image` cache control options were not functional on Android, even though they were being passed to the native component via the `source` prop. This PR addresses that by implementing logic to manage cache behaviour on Android.

When the `reload` option is explicitly set, the image is now evicted from both memory and disk caches before a new request is made. This ensures the image is always fetched from the source, aligning the caching behaviour between Android and iOS for the `default` and `reload` options.

## Changelog:

[ANDROID][ADDED] - Enabling basic `Image` cache control for Android

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

Test Plan:
Added a new example to the `rn-tester`, where we can notice that the image on the right is reloaded if rendered or re-rendered as the cache policy is set to `reload`. The image on the left has the cache policy set to `default` and won't be re-rendered as the image is already in the cache.  See the video below:

https://github.com/user-attachments/assets/88bc1d2d-0239-4deb-bcde-fe0ce521ff4d

Also tested on both old and new architecture.

Reviewed By: NickGerleman

Differential Revision: D64915440

Pulled By: Abbondanzo

fbshipit-source-id: 32e1c55dd20bf96ab0f69ef900d821c3c2552ef7
2024-10-31 09:07:40 -07:00
Samuel Susla
a12036f7be delete redundant EventEmitter::dispatchEvent overload (#47231)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47231

changelog: [internal]

`EventEmitter::dispatchEvent` and `EventEmitter::dispatchUniqueEvent` that were accepting shared_ptr are not needed. Their functionality is covered by other methods. Let's get rid of them to keep the API of EventEmitter slim.

Reviewed By: rubennorte

Differential Revision: D65040505

fbshipit-source-id: cffdc3ef042418178c5e2e5714779dfd0b61455e
2024-10-31 08:15:21 -07:00
Pieter De Baets
3e46cb384c Downgrade fatal error in FabricMountingManager (#47329)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47329

Downgrading from fatal (introduced in D63148523). It's not yet clear why this is firing, and may point at deeper underlying issues, as the re-ordering we do in `disableMountItemReorderingAndroid` only occurs at a later point in `FabricMountingManager`.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D65267936

fbshipit-source-id: cb32b149a77c9e5a3ac6350baaeae9c7215df01b
2024-10-31 06:47:13 -07:00
HyunWoo Lee
667ba76aef Click basic button & scroll down until item 600 is visible (#46804)
Summary:
This pr is part of issue https://github.com/facebook/react-native/issues/46757 solving a task - [ME2E0008] [ME2E0009]

- Set up a test
  - Starts the app
  - Scrolls until flatlist is visilbe and clicks on flatlist
  - Click basic button
  - Scroll down until item 600 is visible

## Changelog:

[Internal] [Added] - Add e2e-test logic that click button & scroll down until specific item is visible

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

Test Plan:
### Test Locally

- iOS

```bash
yarn install
cd packages/rn-tester
yarn e2e-build-ios
```

- Android

```bash
yarn install
cd packages/rn-tester
yarn e2e-build-android
```

### Start Maestro

- iOS

```bash
 cd packages/rn-tester
 yarn e2e-test-ios
```

- Android

```
cd packages/rn-tester
yarn e2e-test-android
```

### Test in CI

To test in CI, just add a comment on your PR with the text:

```
/test-e2e
```

Reviewed By: cortinico

Differential Revision: D63829274

Pulled By: cipolleschi

fbshipit-source-id: f7b4342ed353a48123f87dcfd8d503009f65637c
2024-10-31 04:33:13 -07:00
hexboy
9a3958a619 fix(Android, iOS): Fix AnsiHighlight Style in RTL Layout (#47230)
Summary:
This pull request fixes a style bug in the AnsiHighlight component when the application is in Right-To-Left (RTL) mode. The adjustments ensure that text highlighting is visually consistent and functions properly across all layout modes.

### Before
| Android RTL | iOS RTL | Android LTR | iOS LTR |
|----------|----------|----------|----------|
|  ![Before-RTL-Android](https://github.com/user-attachments/assets/059e30e7-f6da-4a07-9c91-08d952c6a4b6) | ![Before-RTL-iOS](https://github.com/user-attachments/assets/a325c838-1510-4415-bd1f-c419ce75e7e2) | ![Before-LTR-Android](https://github.com/user-attachments/assets/26494fb1-71dd-4fae-a75c-381eead211de)  | ![Before-LTR-iOS](https://github.com/user-attachments/assets/72bba2d8-f70f-4e16-b771-4af995370d26) |

### After
| Android RTL | iOS RTL | Android LTR | iOS LTR |
|----------|----------|----------|----------|
| ![After-RTL-Android](https://github.com/user-attachments/assets/d2f674c2-7aec-454f-903a-33fcd3e93240) | ![After-RTL-iOS](https://github.com/user-attachments/assets/e3735e79-7323-48e8-8213-f0871bec0ca5) | ![After-LTR-Android](https://github.com/user-attachments/assets/18c80754-8743-4282-8f95-1e9772d51a36) | ![After-LTR-iOS](https://github.com/user-attachments/assets/068f4bd8-df4e-420b-8949-c20dff9c2bc8) |

## Changelog:
[GENERAL] [Fixed] - AnsiHighlight style in RTL layout

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

Test Plan:
To test the changes, open LogBox while the app is in RTL mode. The modifications ensure that any error messages display correctly. I have verified that the changes function properly in both LTR and RTL modes, and all existing functionality remains unaffected.

This is an example component to throw an error to show LogBox.

```tsx
import React from 'react';
import {Alert, Button, I18nManager, StyleSheet, Text, View} from 'react-native';

function SampleError() {
  return (
    <View>
      <Button
        title="Change to RTL"
        onPress={() => {
          I18nManager.allowRTL(true);
          I18nManager.forceRTL(true);
          Alert.alert('Restart app to apply changes');
        }}
      />
      <Button
        title="Change to LTR"
        onPress={() => {
          I18nManager.allowRTL(false);
          I18nManager.forceRTL(false);
          Alert.alert('Restart app to apply changes');
        }}
      />

      <Text style={styles.text}>
        isRTL: {I18nManager.isRTL ? 'true' : 'false'}
      </Text>

      <Button
        title="Show Error"
        onPress={() => {
          console.error('sample خطا');
        }}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  text: {
    fontSize: 24,
    textAlign: 'center',
    paddingVertical: 20,
  },
});

export default SampleError;
```

Reviewed By: sammy-SC

Differential Revision: D65145991

Pulled By: NickGerleman

fbshipit-source-id: cbca106813e587ed223be48b75ee5279072c2da0
2024-10-31 01:32:39 -07:00
Phillip Pan
4d90f84869 clean up unused callsites to contextContainer->at (#47322)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47322

Changelog: [Internal]

these callsites were causing crashes in new bridgeless integrations, it appears they are not used, so cleaning up. after this, we can remove all callsites that insert ReactNativeConfig to the contextContainer.

Reviewed By: javache

Differential Revision: D65191733

fbshipit-source-id: 94e694ef27249773c2a39bd77f316f8f5cc2b1fb
2024-10-31 00:56:21 -07:00
Phillip Pan
3a68f14ac2 cleanup enabled_automatic_interop_android (#47321)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47321

Changelog: [Internal]

this seems to be the last callsite where we read the ReactNativeConfig from the contextContainer. i don't think this killswitch should block cleanup of the ReactNativeConfig, so maybe we can just remove this?

Reviewed By: cortinico

Differential Revision: D65192744

fbshipit-source-id: d8b595edb6fecce05e67abc257d98805daa16a9a
2024-10-31 00:56:21 -07:00
Nolan O'Brien
b98846c2e3 Fix up designated initializers 8/x (#47316)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47316

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

In preparation of enabling `-Wobjc-designated-initializers` error

## Changelog:

[iOS][Fixed] - Fix numerous class interfaces having incorrect designated initializer patterns

Reviewed By: caodoan

Differential Revision: D65180118

fbshipit-source-id: 6f977816ede0397225ec681a5357241c28e83f6c
2024-10-30 21:08:32 -07:00
Nolan O'Brien
13b93cfdda Remove implicit "start", then clean up callsites (#47313)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47313

We're going to fix up a bunch of designated initializers.  `RCTSurfaceHostingProxyRootView` is particularly problematic because different initializers will do different things even though reading the code it looks like they should be equivalent.  Remove the encapsulated "start" to the provided "surface", and require it to be explicit at the callsite.

## Changelog:

[iOS][Changed] - `RCTSurfaceHostingProxyRootView` no longer has different behavior (whether it calls `start` on the provided *surface*) depending on which initializer is used.  Call `start` yourself on the *surface* instead.

Reviewed By: cipolleschi

Differential Revision: D65214656

fbshipit-source-id: 179d5220d4f866b4452561e1bb6e2051020c8a11
2024-10-30 21:08:32 -07:00
Sam Zhou
3a01a0c9c5 Fix signature of VirtualizedSectionList (#47318)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47318

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D65239931

fbshipit-source-id: c09eaad8d63f6c415e5d07a4d00dd0acc636c6b9
2024-10-30 18:15:03 -07:00
Panos Vekris
e3f8c63698 Deploy 0.251.1 to xplat (#47317)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47317

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D65233278

fbshipit-source-id: 35057c00f9377b6492f43bb03e5f92572799a50a
2024-10-30 14:37:10 -07:00
David Vacca
d79dc48abd Delete RCTConstants.RCTGetMemoryPressureUnloadLevel (#47297)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47297

In this diff I'm proposing to remove configuration for RCTConstants.RCTGetMemoryPressureUnloadLevel API in iOS

changelog: [iOS][Breaking] Delete experimental API RCTConstants.RCTGetMemoryPressureUnloadLevel

Reviewed By: rubennorte, philIip

Differential Revision: D65181556

fbshipit-source-id: c435bec6ed03562b53f1924add7b69ab517b190b
2024-10-30 13:32:04 -07:00
Samuel Susla
8bd1f3fbfa Back out "surface setup issues in EventBeat and Scheduler" (#47312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47312

changelog: [internal]

Original commit changeset: 5e044e1e6b02

Original Phabricator Diff: D65001802

Reviewed By: rshest

Differential Revision: D65210838

fbshipit-source-id: 90d9db256374f32d2efc366fe120bf677639e67e
2024-10-30 12:06:27 -07:00
zhongwuzw
2d9933e616 automaticallyAdjustKeyboardInsets not shifting scrollview content (#46732)
Summary:
Fixes https://github.com/facebook/react-native/issues/46595 . It seems https://github.com/facebook/react-native/issues/37766 broke the `automaticallyAdjustKeyboardInsets` when input accessory view become first responder.

## Changelog:

[IOS] [FIXED] - automaticallyAdjustKeyboardInsets not shifting scrollview content

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

Test Plan: Repro please see in #https://github.com/facebook/react-native/issues/46595 .

Reviewed By: cipolleschi

Differential Revision: D65072478

Pulled By: javache

fbshipit-source-id: 7d5d7566438d4bb0e1d50074a953b18866e324d3
2024-10-30 12:01:10 -07:00
Oskar Kwaśniewski
ec0dbb729d feat: introduce RCTArchConfiguratorProtocol (#47306)
Summary:
This PR introduces `RCTArchConfiguratorProtocol` for better separation of concerns inside of RCTAppDelegate.

It's also a prerequisite for https://github.com/facebook/react-native/issues/46298

Discussed with cipolleschi

## Changelog:

[IOS] [ADDED] - introduce RCTArchConfiguratorProtocol

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

Test Plan:
- CI Green
- Test if methods can be overriden

Reviewed By: realsoelynn

Differential Revision: D65212703

Pulled By: cipolleschi

fbshipit-source-id: 9850fec31c421f0c6230e7e23d7a208d823d828f
2024-10-30 11:24:19 -07:00
Nicola Corti
50e38cc9f1 Bump serve-static to 1.16.2 to fix CVE-2024-43800 (#47289)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47289

Bump serve-static to 1.16.2 to fix CVE-2024-43800

Changelog:
[General] [Changed] - Bump serve-static to 1.16.2 to fix CVE-2024-43800

Reviewed By: cipolleschi

Differential Revision: D65146027

fbshipit-source-id: 2876a78f195230cc4cdaa14b0076ecbecc1ee6e4
2024-10-30 09:08:55 -07:00
Samuel Susla
a85955a446 resume image download if previously cancelled (#47302)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47302

changelog: [internal]

The original cancellation logic cancelled image request when RCTImageComponentView was recycled but the image request was never resumed.

So in case the request was cancelled and later the same shadow node representing the image view was showed, the image request was never fulfilled and it stayed blank. It entered invalid state from where it would never recover. The image would go from state: Loading -> Cancelled and Cancelled is terminal state.

This diff adds a "resume" mechanism. If image goes from Loading -> Cancelled and something subscribes to the image state, the image request will be started again.
So we can go from Loading -> Cancelled -> Loading -> Completed.
This diff also moves the resume/cancel mechanism to ImageResponseObserverCoordinator. Where we can observe if anything is observing result of the image response.

Even though this case was highly unlikely, with <Activity /> component in React Native, it may occur.

Reviewed By: lyahdav

Differential Revision: D65149804

fbshipit-source-id: d59c1793785a367bb92602f6438666fa53db4ceb
2024-10-30 06:01:03 -07:00
qy
758892a7d8 bugfix(image): add ts definition of resizeMethod attribute. (#47227)
Summary:
in the `image component`, add the ts definition with the `resizeMethod` attribute value as `none`.

## Changelog:

[Android][Fixed] - the definition of ts of resizeMethod attribute is none.

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

Test Plan: <img width="579" alt="image" src="https://github.com/user-attachments/assets/e91dc47a-22c4-4d47-a4c2-6497d47cb842">

Reviewed By: javache

Differential Revision: D65058737

Pulled By: Abbondanzo

fbshipit-source-id: a077e4e4786a72ebffaf0698217809b1e7fde226
2024-10-30 05:06:18 -07:00
Rubén Norte
1108b4d97b Clean up API of PerformanceMark and PerformanceMeasure (#47241)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47241

Changelog: [internal]

The options for the internal constructor of `PerformanceMeasure` shouldn't be optional. This just cleans that up.

Reviewed By: rshest

Differential Revision: D64480048

fbshipit-source-id: d0275276b11bd329aa2e4667646c67608d562299
2024-10-30 04:58:04 -07:00
Pieter De Baets
0dcbebd285 Fix lint failure in Github CI (#47301)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47301

Lint wasn't reported on diff / seems like our internal linter config is not aligned.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D65201683

fbshipit-source-id: 879e87aafff849f9247cf1d807da092fa17d0337
2024-10-30 04:57:24 -07:00
Oskar Kwaśniewski
8850736188 feat(iOS): introduce RCTUIConfiguratorProtocol (#47139)
Summary:
This PR introduces `RCTUIConfiguratorProtocol` for better separation of concerns inside of RCTAppDelegate.

It's also a prerequisite for https://github.com/facebook/react-native/issues/46298

Discussed with cipolleschi

## Changelog:

[IOS] [ADDED] - introduce RCTUIConfiguratorProtocol

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

Test Plan:
- CI Green
- Test if methods can be overriden

Reviewed By: blakef

Differential Revision: D65063839

Pulled By: cipolleschi

fbshipit-source-id: b63766e245d57f369ab94bd8047d5de9a3447b3e
2024-10-30 04:32:17 -07:00
Alex Taylor (alta)
e797135247 Deploy 0.251.0 to www + fbsource (#47295)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47295

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D65176860

fbshipit-source-id: 2254fdac49a664f3a92ae0834c76d721132fddc4
2024-10-29 19:31:15 -07:00
Nick Gerleman
41265bac6b Reimplement Android lineHeight positioning/determination (#47271)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47271

Let's keep the recent goals of centering (instead of arbitrary prioritizing ascent), ala spec, and make some changes to allow overlapping interior line-boxes, and make the implementation a lot simpler, instead of the cruft it has been accumulating.

The new simple versions is implemented as the only `CustomLineHeightSpan`. This replaces the code used when `enableAndroidLineHeightCentering` is enabled (which is now the default).

Legacy path is renamed to `LegacyLineHeightSpan`, slated to be deleted if rollout goes well.

We cannot yet cause text to overflow the bounds of the underlying TextView until potentially large later work related to ReactTextView reimplementation.

There's a somewhat arbitrary choice here, when rounding, to whether we ceil ascent vs descent when pixels don't evenly split. This does result in a visual difference, and for sake of avoiding breakage of screenshots, I left the same choice as before.

Changelog:
[Android][Fixed] - Reimplement Android lineHeight positioning/determination

Reviewed By: javache

Differential Revision: D64716557

fbshipit-source-id: 5a947377df7cfee9dff4484c840939f527caf94b
2024-10-29 17:53:16 -07:00
Nick Gerleman
7cb9fa9737 Add lineHeight screenshot tests (#47270)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47270

Lets add some screenshot tests, along with one more example, and fixing some silly typos in test IDs.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D65094482

fbshipit-source-id: a5f3e06c4737158bf6419364d05668c3feb1bd5e
2024-10-29 17:53:16 -07:00
Joe Vilches
9f73edee2d Fix issue where text would truncate sometimes (#47294)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47294

TextView will set `setUseLineSpacingFromFallbacks` to `true` for their `StaticLayout`s while we ignore it in this case (`false` default). The docs even recommend setting it to `true`: https://developer.android.com/reference/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(boolean)

We set this in the `StaticLayout` builder below, but not up here so lets do that.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D65171352

fbshipit-source-id: aa7fd116898c6af9378d71c5c570c790e6ab415f
2024-10-29 17:49:41 -07:00
Nick Gerleman
bfca7cfe7a Fix legacy arch RTL horizontal ScrollView regression (#47282)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47282

D63318754 fixed a class of issues with RTL horizontal scrollviews by moving logic from native Android view layer to Fabric ShadowNode layer.

I realized quite a bit later this is problematic for legacy arch, since it now never runs RTL translation code, and all our RTL screenshot tests are against new arch.

It's tricky to port Fabric ShadowNode related code to Paper since its shadownodes are more coupled to Yoga nodes, and the existing solution for contextual layout direction didn't quite work, so I went with the original logic we had for this, where we use global layout direction to determine whether to offset, and disable removeClippedSubviews, and this is applied via onLayout. This is wrong in several ways, but not a regression compared to previous legacy arch behavior. The fully correct behavior will require new arch.

Changelog:
[Android][Fixed] - Fix legacy arch RTL horizontal ScrollView regression

Reviewed By: rshest

Differential Revision: D65139747

fbshipit-source-id: 5662c0744c3c402efe583e602b2272662b4d5476
2024-10-29 16:29:36 -07:00
Nick Gerleman
0df59d4f03 Fix RTL ScrollView position when content smaller than container (#47280)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47280

Noticed in the screenshots of https://github.com/facebook/react-native/pull/47230 that Android's logic of setting scroll content origin to zero, then right aligning scroll offset, won't correctly handle case where content is smaller than scrolling container. We can fix that by only resetting the origin when content overflows container, since we otherwise are not scrollable, and scroll adjustment will not translate.

Changelog:
[Android][Fixed] - Fix RTL ScrollView position when content smaller than container

Reviewed By: rshest

Differential Revision: D65136654

fbshipit-source-id: 2818ff6360cbfac64d7e57bdcbbe8c0a9b4bbb97
2024-10-29 16:29:36 -07:00
Eric Rozell
0d664100bb Avoid null reference exception when fetching ReactRootView in bridgeless (#47284)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47284

If the surface hasn't been set up yet, attempting to fetch the ReactRootView will throw a null reference exception. Since the result is already nullable, it's perhaps better to just return null when the surface has not yet been initialized.

## Changelog

[Android][Fixed] Avoid null reference exception in bridgeless ReactDelegate

Reviewed By: javache

Differential Revision: D65141137

fbshipit-source-id: 9b002b0520a7eeea61767cb8934e9bb8d049fc6a
2024-10-29 15:55:56 -07:00
Eric Rozell
e3f03269c5 Minor typo in ReactHostImpl comment (#47290)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47290

Fixes a comment typo.

## Changelog

[General][Fixed] Fixes typo in ReactHostImpl

Reviewed By: cortinico

Differential Revision: D65149529

fbshipit-source-id: b419241f861ab28b2c4a512b27f33b94e7929b81
2024-10-29 15:18:09 -07:00
Ramanpreet Nara
cc6f75bb75 earlyjs: Integrate c++ pipeline with console.error
Summary:
## Changes
If the c++ pipeline is active:

If someone calls console.error:
- The c++ pipeline will report it as a soft error

If someone reports an error:
- The c++ pipeline will log it via console.error

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D64506069

fbshipit-source-id: 293cd1774f19ee03d7eb61572b7b1f03a47a4756
2024-10-29 14:24:27 -07:00
Ramanpreet Nara
5b53c07329 earlyjs: Integrate c++ pipeline with all ios apps
Summary:
Now, all ios apps will just be integrated with the c++ error reporting pipeline, with zero configuration.

Changelog: [Internal]

Reviewed By: javache, philIip

Differential Revision: D64615457

fbshipit-source-id: db9d98115238d9a42563e39a4780234a9bc3c034
2024-10-29 14:24:27 -07:00
Ramanpreet Nara
eb3977eccf earlyjs: Introduce flag for always available js error handling
Summary:
This diff introduces ReactNativeFeatureFlags.useAlwaysAvailableJSErrorHandling.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D64791786

fbshipit-source-id: 81cf3ed1fc7057638d7d817f1fea5fc371b53646
2024-10-29 14:24:27 -07:00
Dawid
08e8f6adfd fix(Android) drawing additional empty line when 'textAlign' is set to 'justify' (#47122)
Summary:
Fixes https://github.com/facebook/react-native/issues/46908

The `justificationMode` is not set for multiline text without unicode characters with known width on both architectures. This caused the issue of drawing additional empty line at the end of `TextView` because Yoga thought that text takes 5 lines and falsely calculated it's height.

Currently, on the old architecture, the `justificationMode` is set only on text that is not boring (contains unicode characters) with unknown width. I am not sure why is that, so I am opening this as a draft for now as I am still checking if it doesn't break anything.

## 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
-->

[ANDROID] [FIXED] - fix generating empty line at the end of multiline text view when `textAlign` is set to `justify`

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

Test Plan: I've tested on both architectures on repro provided in the issue.

Reviewed By: javache

Differential Revision: D65002386

Pulled By: NickGerleman

fbshipit-source-id: 0187956c88e6eb1e637c24e82b3052cc82581a64
2024-10-29 14:22:59 -07:00
Samuel Susla
dacada7750 use move semantics in TouchEventEmitter (#47232)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47232

changelog: [internal]

TouchEventEmitter APIs take ownership of TouchEvent and PointerEvent, the use of const & qualifiers is misleading and may lead it unnecessary copy.

Reviewed By: rubennorte

Differential Revision: D65040506

fbshipit-source-id: 941e2eab6a057e31066751e26387604858f03e51
2024-10-29 13:18:50 -07:00
Phillip Pan
6fc500ee99 hook up useNativeViewConfigsInBridgelessMode feature flag (#47265)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47265

Changelog: [iOS][Breaking]

This was originally landed before as part of the effort to coalesce configurations with the feature flag infra, but got reverted due to a build issue. I'm pretty sure it was just because the legacy configuration methods were not cleaned up from the header (RCTConstants.h). I fixed that here.

Reviewed By: javache

Differential Revision: D65092536

fbshipit-source-id: 5012ba54b0314c487f2ef488c2eb30a3c4133cb5
2024-10-29 12:42:26 -07:00
Hanno J. Gödecke
0fc2e954be add example for dynamic sized text input (#46976)
Summary:
This PR adds an example showcasing a TextInput whose width gets resized dynamically based on the text content width.
This example was added for this PR, which tries to address a flickering bug with dynamic sized TextInputs:

- https://github.com/facebook/react-native/pull/46973

## 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] Added dynamic content width TextInput example

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

Test Plan:
Test in RNTester app:

https://github.com/user-attachments/assets/7571b80b-7035-47df-b840-4218ab0802b5

Reviewed By: NickGerleman

Differential Revision: D64271454

Pulled By: arushikesarwani94

fbshipit-source-id: 28fe7bd93891ffe5284340d73e9ee947654f1788
2024-10-29 12:40:09 -07:00
Abdelhafidh Belalia
e8f8ee3c0f Resume frame callback on host resume (#47264)
Summary:
When the app goes into background the frame callback is ignored by setting the `mShouldStop` flag to `true` 3111473d57/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.java (L174)
However this flag is never reset even after the app is back on foreground. This made the `AndroidEventBeat` not ticking in as much as expected causing events not being dispatched in time. In our case the `onLayout` was not being dispatched unless we tap on screen invoking a manual tick.

## Changelog:

[ANDROID] [FIXED] - Fix Frame Callback not being called after Host Resume

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

Test Plan:
1. Add log line `__android_log_print(ANDROID_LOG_DEBUG, "s77rt", "AndroidEventBeat::tick");` in `packages/react-native/ReactAndroid/src/main/jni/react/fabric/AndroidEventBeat.cpp` (tick method)
2. Open RN-Tester
3. Verify `AndroidEventBeat::tick` is logged for every frame
4. Put app into background
5. Verify no `AndroidEventBeat::tick` is logged
6. Open app again
7. Verify `AndroidEventBeat::tick` is logged for every frame

| Before | After |
|:------:|:-----:|
|     <video src="https://github.com/user-attachments/assets/9667ed49-3a56-4c30-992f-9e6426f5d08e" />   |     <video src="https://github.com/user-attachments/assets/548ae199-d9a2-497c-bba7-b89c4d684836" />  |
|     <video src="https://github.com/user-attachments/assets/e14851aa-0609-4b36-bf1e-dfd5d2ee8512" />   |     <video src="https://github.com/user-attachments/assets/db5a9fe6-dfc1-4b3c-92b0-359b4b68ac5c" />  |

Reviewed By: NickGerleman

Differential Revision: D65136338

Pulled By: javache

fbshipit-source-id: 0a101be2a7588cbbb5a55ee4d420082f85566c1b
2024-10-29 11:53:02 -07:00
Rubén Norte
e51c32d7cf Improve intersection observer errors when trying to observe nullish targets (#47291)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47291

Changelog: [internal]

Small devx improvement to distinguish problems caused by calling `IntersectionObserver.observe` with null or undefined, vs. other values not supported by the API (like legacy refs).

Differential Revision: D65150750

fbshipit-source-id: b9452ff19d35ccd0dc2d47ee2d5a0e933e0ae180
2024-10-29 11:31:30 -07:00
Alan Lee
97622a5caa RedBoxDialogSurfaceDelegate crash fix (#47249)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47249

- It is likely that Dialog is being dismissed from an invalid state causing an exception
- apply similar changes from D63712422 which is to add try/catch around and ignore the exception as we are dismissing the dialog anyway

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D65066186

fbshipit-source-id: 03ebbc3fec3adf6100e36ea38b43f410d98a5297
2024-10-29 11:19:02 -07:00
Mateo Guzmán
c19fd11ccf fix(examples): fixing XMLHttpRequest file download example (#47152)
Summary:
The `XMLHttpRequest` example with a single file download doesn't seem to be working anymore. The test case is quite old so it seems like something changed in between with the example URLs.

- Changing the URL for the example. Using another file from `filesamples.com` as it's already being used in the chunk file download example as well.
- Adding an `onerror` callback as it was loading infinitely when something went wrong.

## Changelog:

[INTERNAL] [FIXED] - fixing `XMLHttpRequest` file download example

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

Test Plan:
Using the `rn-tester`, see the before and after for comparison

<details>
<summary>Before and after videos</summary>

**Before**:

https://github.com/user-attachments/assets/01f89cd9-0f5e-4ddb-9ff2-c3e053be5413

**After**:

https://github.com/user-attachments/assets/59ef161c-d5ba-43e3-827e-e250cc663276

</details>

Reviewed By: cipolleschi

Differential Revision: D65126952

Pulled By: NickGerleman

fbshipit-source-id: 7a4b2187570fd85d4444bfe63ae7bc77b09af261
2024-10-29 11:18:34 -07:00