Commit Graph

33172 Commits

Author SHA1 Message Date
Oskar Kwaśniewski 5bd751bd91 fix: running local tests (#46615)
Summary:
This PR fixes running local tests.

### Before

Tests from Pods/ are executed (including Hermes tests)

![CleanShot 2024-09-24 at 10 09 04@2x](https://github.com/user-attachments/assets/5d766321-1099-4970-bc4d-cf20ec1f5d89)

### After

![CleanShot 2024-09-24 at 10 10 24@2x](https://github.com/user-attachments/assets/356b0db3-9278-4cb3-a216-2ca78b623950)

## Changelog:

[INTERNAL] [FIXED] - Make tests run locally

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

Test Plan: 1. Run yarn run test (with and without the change). Make sure you have installed pods.

Reviewed By: huntie

Differential Revision: D63383063

Pulled By: cipolleschi

fbshipit-source-id: d7352f80c0fe4efdbb169e1adc4d5f60179f78e8
2024-09-25 05:51:49 -07:00
Hailey 99ab845a5c convert NSNull to nil before checking type in readAsDataURL (#46635)
Summary:
This issue original arose out of https://github.com/bluesky-social/social-app/issues/5100. Copying the description (with my general understanding of the problem) from the patch PR to here as well.

There's a crash that comes up in the following, pretty specific scenario:

- Have a response that has an empty body
- Do not include a `content-type` header in the response
- Set the `x-content-type-options` header to `nosniff`

RN handles the response for a request in this block of code: https://github.com/facebook/react-native/blob/303e0ed7641409acf2d852c077f6be426afd7a0c/packages/react-native/Libraries/Blob/RCTBlobManager.mm#L314-L326

Here, we see that values of `nil` - which `[response MIMEType]` will return when no `content-type` is provided in the response and the actual type cannot be determined (https://developer.apple.com/documentation/foundation/nsurlresponse/1411613-mimetype) - gets converted to `NSNull` by `RCTNullIfNil`.

When we get back over to `readAsDataURL`, we see that we grab the type from the dictionary and check if its `nil` before calling `length` on the string. https://github.com/facebook/react-native/blob/303e0ed7641409acf2d852c077f6be426afd7a0c/packages/react-native/Libraries/Blob/RCTFileReaderModule.mm#L74-L77

However, this check is dubious, because the value will never actually be `nil`. It will always either be `NSString` or `NSNull` because of the `RCTNullIfNil` call made above and `[RCTConvert NSString]` seems to just return the input if it is `NSNull`.

## Changelog:

[IOS] [FIXED] - Convert `NSNull` to `nil` before checking `type` in `readAsDataURL`

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

Test Plan:
This is a little awkward to test, but essentially this comes up in the following scenario that is described (and "tested" as being fixed by tweaking) in https://github.com/bluesky-social/social-app/issues/5100. I have personally tested by using Cloudflare rules to add/remove that particular header from an empty body response. You could also test this with a little local web server if you want.

### Before

https://github.com/user-attachments/assets/deb86c68-2251-4fef-9705-a1c93584e83e

### After

https://github.com/user-attachments/assets/9ffab11b-b2c8-4a83-afd6-0a55fed3ae9b

Reviewed By: dmytrorykun

Differential Revision: D63381947

Pulled By: cipolleschi

fbshipit-source-id: b2b4944d998133611592eed8d112faa6195587bd
2024-09-25 04:47:54 -07:00
Oskar Kwaśniewski 65575e8399 feat: get react-native package name from package.json in codegen script (#46604)
Summary:
This PR fixes the retrieval of react native package name to retrieve it from package.json.

This fixes the annoying message in codegen that poped up when installing pods:

```
[Codegen] Found react-native-macos
[Codegen] CodegenConfig Deprecated Setup for react-native-macos.
    The configuration file still contains the codegen in the libraries array.
    If possible, replace it with a single object.

BEFORE:
    {
      // ...
      "codegenConfig": {
        "libraries": [
          {
            "name": "libName1",
            "type": "all|components|modules",
            "jsSrcsRoot": "libName1/js"
          },
          {
            "name": "libName2",
            "type": "all|components|modules",
            "jsSrcsRoot": "libName2/src"
          }
        ]
      }
    }

    AFTER:
    {
      "codegenConfig": {
        "name": "libraries",
        "type": "all",
        "jsSrcsRoot": "."
      }
    }
```

## Changelog:

[GENERAL] [CHANGED] - get react-native package name from package.json in codegen script

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

Test Plan: Install pods

Reviewed By: cortinico

Differential Revision: D63335543

Pulled By: arushikesarwani94

fbshipit-source-id: 0470e54f0fc7aa962918c889855c52648d11e32d
2024-09-25 01:28:23 -07:00
Eric Rozell 68a6b69b27 Fix PointerOverOut test (#46634)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46634

The PointerEventPointerOverOut.js test case is broken due to a changed assumption about the name of the native tag property (`_nativeTag` vs. `__nativeTag`). This fixes the broken assumption.

## Changelog

[General][Fixed] Fixed issue with W3C PointerEvents tests

Reviewed By: NickGerleman

Differential Revision: D63336621

fbshipit-source-id: b54270f1c1232de6845ef73cac52f06b9a85539c
2024-09-24 19:49:34 -07:00
Pieter De Baets 0cb32d5ac9 Cleanup Fresco SystraceRequestRequestListener (#46626)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46626

Remove `!!` by reusing lookup result.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D63316175

fbshipit-source-id: 1abfb20490831f26819aef4393c9629253d33ec6
2024-09-24 13:40:47 -07:00
Riccardo Cipolleschi 303e0ed764 Fix Increment and Decrement accessibility actions (#46617)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46617

This changes fixes the Increment/Decrement accessibility actions on iOS with the New Architecture.

## Changelog
[iOS][Fixed] - Make sure that the Increment and Decrement accessibility actions works on iOS

Reviewed By: javache

Differential Revision: D63263830

fbshipit-source-id: 99dca14a002e098db2d3b0e268af32cdab6ce786
2024-09-24 09:24:24 -07:00
Pieter De Baets a9551641b4 Cleanup Modal test code (#46603)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46603

Was debugging this test for the mounting instruction changes, and found some opportunities to clean this up.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D63258342

fbshipit-source-id: f7e6be58474f112993232ce5859ccb160f050ae8
2024-09-24 05:34:01 -07:00
Nicola Corti c005609b01 Properly set REACTNATIVE_MERGED_SO for autolinked libraries. (#46606)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46606

This fixes this issue reported here:
https://github.com/react-native-community/discussions-and-proposals/discussions/816#discussioncomment-10673136

reported by both SWM and Expo.

The problem is that `REACTNATIVE_MERGED_SO` is not properly set for autolinked libraries so they can't access it
to understand if the version of ReactNative has merged so libraries or not.
This fixes it, I've tested against
https://github.com/tomekzaw/repro-reactnative-merged-so
reproducer provided by tomekzaw

Changelog:
[Android] [Fixed] - Properly set `REACTNATIVE_MERGED_SO` for autolinked libraries

Reviewed By: rubennorte

Differential Revision: D63262687

fbshipit-source-id: c505dce9036bb4cd0366b7ab99412368963273af
2024-09-24 03:35:15 -07:00
Nick Gerleman fc8224036b Fix measuring text with incorrect hyphenationFrequency
Summary:
A typo means TextLayoutManager will incorrectly measure text as if `LineBreaker.HYPHENATION_FREQUENCY_NORMAL` is set, instead of the correct default of `LineBreaker.HYPHENATION_FREQUENCY_NONE` which we use to display the `TextView`. This causes truncation if hyphenation would have caused text to be shorter than if not hyphenated. Fix the typo.

Changelog: [Android][Fixed] - Fix measuring text with incorrect hyphenationFrequency

Reviewed By: mellyeliu

Differential Revision: D63293027

fbshipit-source-id: baaf2ae2676548cf0815ae96e324af273be6f99e
2024-09-23 17:52:30 -07:00
Jorge Cabiedes Acosta 7ab0002799 Disable outline props on old architecture (#46608)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46608

tsia

Changelog: [Android][Changed] - Disabling `outline` props on Android to stay consistent with iOS

Reviewed By: NickGerleman

Differential Revision: D63143626

fbshipit-source-id: 3eafe5beeb54b1619d94fe3d886ab19d445a0b09
2024-09-23 13:46:32 -07:00
Jorge Cabiedes Acosta 8ad4b7d0cf Fix outline drawing 1px width when outlineWidth = 0 (#46586)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46586

When Paint.strokeWidth is set to 0 its not actually 0 but "hairline mode" so  the fix is just to make outline not draw at all when outlineWidth = 0 {F1879399325}

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D63136220

fbshipit-source-id: 81ef7ce0b72158c6b7c332191d332008c5a919b4
2024-09-23 11:57:39 -07:00
Dmitry Rykun 6e0e712c2a Bring back shouldSkipStateUpdatesForLoopingAnimations feature flag (#46598)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46598

Changelog: [General][Changed] - Bring back shouldSkipStateUpdatesForLoopingAnimations feature flag

Facebook
Also bring back `skip_state_updates_for_looping_animations` MC. This will allow the experiment to participate in a holdout properly.

Reviewed By: GijsWeterings

Differential Revision: D63252185

fbshipit-source-id: 89bc9321b12f07bd9b3b52c4fc1021d34594ebc0
2024-09-23 10:56:06 -07:00
Pieter De Baets b846f94b1c Refactor FabricMountingManager to enable reuse of IntBuffer methods (#46600)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46600

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D63150556

fbshipit-source-id: 039a88d6444df53767be52b9e70c20ef2ffd99be
2024-09-23 09:08:00 -07:00
Renaud Chaput 3c54e1ee45 Fix <KeyboardAvoidingView> with floating keyboard on iPad (#44859)
Summary:
On iPadOS, users can change the kind of keyboard displayed onscreen, going from normal keyboard, to split keyboard (one half on the left of the screen, one half on the right), or a floating keyboard that you can move around the screen.

When a non-normal kind of keyboard is used, `<KeyboardAvoidingView>` calculations are all wrong and, depending on the `behavior` prop, can make your screen completely hidden.

This PR attempts to detect that the keyboard is not the "normal displayed-at-bottom-of-screen" keyboard, and forces `enable={false}` if this happens.

The approach of comparing the keyboard width with the window width comes from this comment: https://github.com/facebook/react-native/issues/29473#issuecomment-696658937

A better fix might be to detect the kind of keyboard used, but this involves native code changes and I do not know iOS enough to do that. In addition, I have not found an easy way to do it using iOS APIs after a quick search.

I also chose to cache the window width as a class attribute. Maybe this is not needed as `Dimensions.get('window').width` is very fast and can be called on every keyboard event?

This fixes https://github.com/facebook/react-native/issues/44068 and https://github.com/facebook/react-native/issues/29473

## Changelog:

[IOS] [FIXED] - Fix `<KeyboardAvoidingView>` with floating keyboard on iPadOS

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

Test Plan:
Tested using RNTester and the "Keyboard Avoiding View with different behaviors" example.

Before:

https://github.com/facebook/react-native/assets/42070/111598a3-286c-464d-8db8-73afb35cd7f9

After:

https://github.com/facebook/react-native/assets/42070/0b3bc94f-8b67-4f42-8a83-e11555080268

Reviewed By: cortinico

Differential Revision: D62844854

Pulled By: cipolleschi

fbshipit-source-id: 577444be50019572955a013969d78178914b5b8d
2024-09-23 07:59:33 -07:00
Pieter De Baets a6fcad7e27 Move ShadowNodePair to Differentiator (#46590)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46590

This API should not be part of the ShadowView header, since the class is only used by Differentiator. The ShadowView header should contain public API's that the mounting layer can consume.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D63148522

fbshipit-source-id: 0545777fd311424ccd2d66de8b47b5591e8175f7
2024-09-23 07:12:09 -07:00
Pieter De Baets 300db67b27 Remove unused FabricComponents mapping (#46591)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46591

This is a duplicate of FabricNameComponentMapping, which is not exposed. Checking GitHub codesearch, this API is not referenced elsewhere.

This component should be cleaned, with the mappings moved to a generic translation layer (eg in [ViewManagerRegistry](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java#L55)) or by fixing the JS callers.

Changelog: [Android][Removed] FabricComponents is removed from public API

Reviewed By: fabriziocucci

Differential Revision: D63099721

fbshipit-source-id: 7018deadc919e21cdf3482ae454baca72937611f
2024-09-23 07:12:09 -07:00
Pieter De Baets 9eafec48f3 Unbreak RN_SHADOW_TREE_INTROSPECTION flag (#46589)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46589

This is a useful too for debugging ShadowTree mutations, but was broken due to some recent build changes.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D63099720

fbshipit-source-id: 9ae5ee062ef9a6a99b2517e4eedd286cd6259fbe
2024-09-23 04:57:17 -07:00
Rubén Norte 9235be3776 Add metadata to feature flag definitions (#46597)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46597

Changelog: [internal]

Adding explicit metadata to feature flags so they're easier to manage:
* Purpose: to indicate why the feature flags are added.
    * Release: gating features we don't want to expose in certain environments yet (e.g.: Fabric).
    * Experimentation: changes that we want to test before enabling them broadly. Should generally be short lived.
    * Operational: flags that enable certain behaviors in certain environments (e.g.: debugging logs).
* Date added: only for experimental flags, so we know how long we've been waiting to fully roll out the change (without having to go through the repository history, which could've been changed due to refactors).

Reviewed By: javache

Differential Revision: D62972237

fbshipit-source-id: ab51e989a2cddb8dc52197238b638609d30002f0
2024-09-23 04:40:37 -07:00
Pieter De Baets be7b78ec9d Use CopyOnWriteArrayList for ReactHostImpl lifecycle listeners (#46567)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46567

Switch to a simpler data structure which avoids locking and doesn't require copies when iterating. This is more consistent with other listener arrays in React Native.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D62872893

fbshipit-source-id: b0ce6a904d25057f0217f7de7ec2928c8b2d1f34
2024-09-23 04:32:13 -07:00
Pieter De Baets e27259b3db Do not hold raw RuntimeScheduler pointer in BufferedRuntimeExecutor (#46542)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46542

If `bufferedRuntimeExecutor_` is referenced beyond the lifetime of the ReactInstance, it may point to invalid memory. RuntimeScheduler already holds weak references to the actual runtime, so it's safe to retain that instead.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D62748768

fbshipit-source-id: 1cd8fcb050dd561e7d54a11d91c89eda3a5ddaaa
2024-09-23 04:32:13 -07:00
Jakub Piasecki bd323929dc Add a workaround for text being measured incorrectly when ending with an empty line (#42331)
Summary:
It looks like `StaticLayout` used for measuring multiline text on the new architecture returns wrong metrics for the last line if it's empty, however, if it contains anything, then the returned values are correct.

Similar approach with measuring `I` was already used in `ReactEditText`: https://github.com/facebook/react-native/blob/258d8e51b451b221e557dad4647cbd210fe37392/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java#L1203-L1213

## 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] - Fixed text being measured incorrectly when ending with an empty line on the new architecture

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

Test Plan:
<details>
<summary>I tested the change on this simple code on React Native 0.73.2 (with the new arch enabled)</summary>

```jsx
import React from 'react';
import {useState} from 'react';
import {SafeAreaView, TextInput} from 'react-native';

export default function App() {
  const [text, setText] = useState('ABC\nDEF\nGHI\n');

  return (
    <SafeAreaView style={{flex: 1}}>
      <TextInput
        value={text}
        onChangeText={setText}
        style={{borderWidth: 1, margin: 20, padding: 30}}
        multiline
      />
    </SafeAreaView>
  );
}
```

</details>

Before:

https://github.com/facebook/react-native/assets/21055725/0787cc86-70c6-4238-b93a-87984e527a83

After:

https://github.com/facebook/react-native/assets/21055725/2acf619f-5cb4-4869-9576-cb8cc081c15b

Reviewed By: cipolleschi

Differential Revision: D62873674

Pulled By: cortinico

fbshipit-source-id: cc2481b1924a13af7326cfc16c59b9390f0d06d8
2024-09-21 06:34:21 -07:00
Oskar Kwaśniewski 1747f57c67 feat(iOS): add colors to codegen output (#46557)
Summary:
This PR is a quality-of-life improvement, adds colors to codegen output:

![CleanShot 2024-09-18 at 12 18 00@2x](https://github.com/user-attachments/assets/13290a1c-8411-40e4-8abe-8fce4b88b6e7)

Makes it a lot easier to grasp what's going on in the actions taken by codegen.

## Changelog:

[GENERAL] [ADDED] - Add color formatting to codegen output

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

Test Plan:
1. Run codegen
2. Expect colored output

Reviewed By: christophpurrer

Differential Revision: D63031248

Pulled By: cipolleschi

fbshipit-source-id: e86bc72f16582562dc9f1e3b55dc69af4c7838f5
2024-09-20 03:33:31 -07:00
Riccardo Cipolleschi 9e2e8c1a27 Prepare scripts to simplify E2E testing (#46545)
Summary:
Add tests to simplify running Maestro e2e tests locally.
Thanks to these scripts, users can just, from the root folder:

```sh
yarn install
cd packages/rn-tester

# build android for testing
yarn e2e-build- android

# run tests on android
yarn e2e-test-android

# build iOS for testing
yarn e2e-build-ios

# run tests on iOS
yarn e2e-test-ios
```

This is a preliminary step for a future umbrella issue. We can also use these command in CI to simplify the scripts.

## Changelog:
[Internal] - add script to simplify e2e testing

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

Test Plan: Tested the command locally

Reviewed By: cortinico

Differential Revision: D62879105

Pulled By: cipolleschi

fbshipit-source-id: 6f68aebb3f8112302a458ca9e118180d3dbaf180
2024-09-20 03:29:43 -07:00
David Vacca 151008f8c2 Back out "Convert ReactViewManager, ReactClippingViewManager to Kotlin" (#46581)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46581

Original commit changeset: 09a81c91a1c9

Original Phabricator Diff: D62776270

changelog: [internal] internal

Reviewed By: bvanderhoof

Differential Revision: D63076764

fbshipit-source-id: 9cbd8ab86be356a7c35e44c86a95b80342c3da76
2024-09-19 22:56:17 -07:00
David Vacca d721d83149 Back out "Convert ReactViewGroup to Kotlin" (#46580)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46580

Original commit changeset: 780350e7e449

Original Phabricator Diff: D62642663

changelog: [internal] internal

Reviewed By: bvanderhoof

Differential Revision: D63076763

fbshipit-source-id: 01d3949c13129b71d5c96f19682bb24c51ff2552
2024-09-19 22:56:17 -07:00
Jorge Cabiedes Acosta 1288e38423 Implement outline properties on iOS (#46444)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46444

This diff adds:

`outline-width`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-width
`outline-color`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-color
`outline-style`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-style
`outline-offset`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-offset

Using `BackgroundStyleApplicator`

Changelog: [iOS] [Added] - Outline properties `outline-width`, `outline-color`, `outline-style` & `outline-offset`

Reviewed By: joevilches

Differential Revision: D62273339

fbshipit-source-id: 0ed775218e7d1dfb13bbf1760bc6ec331a388b64
2024-09-19 16:41:46 -07:00
Thomas Nardone 66c3074c65 Convert ReactViewGroup to Kotlin (#46577)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46577

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D62642663

fbshipit-source-id: 780350e7e449ffd2d6378cbed6f4381e34636a24
2024-09-19 13:20:15 -07:00
Thomas Nardone d80e1e9be3 Convert ReactViewManager, ReactClippingViewManager to Kotlin (#46578)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46578

Pre-req for converting ReactViewGroup without affecting API visibility.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D62776270

fbshipit-source-id: 09a81c91a1c95685b36f4417cb1b1a2852dd7194
2024-09-19 13:20:15 -07:00
Pieter De Baets 5f49e279f0 Fix AnimatedEvent leaking topScrollEnded handler (#46576)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46576

We automatically add this handler in `addAnimatedEventToView` but we do not remove it in `removeAnimatedEventFromView`, which causes us to leak it. This is especially bad as we attach and detach the event handler multiple times while rendering.

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D63029768

fbshipit-source-id: 9ef2bc6887fecb7ab448af4dee94463f8be27768
2024-09-19 11:56:28 -07:00
zhongwuzw 052def0da0 Fabric: Add missing source properties of Image (#46460)
Summary:
Fabric: Add missing source properties of Image

## Changelog:

[IOS] [FIXED] - Fabric: Add missing source properties of Image

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

Test Plan: Missing props should worked.

Reviewed By: javache

Differential Revision: D62847594

Pulled By: cipolleschi

fbshipit-source-id: 83d7c836a2e96c9053aa94e0e9b8e706103d026f
2024-09-19 11:00:25 -07:00
Alex Hunt a026d6d250 Update relocated JS logs message (#46558)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46558

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D62937482

fbshipit-source-id: 323d4220443e2660ff2f0cb8c019477ee245a07d
2024-09-19 10:15:05 -07:00
Pieter De Baets d8aa664adf Clear out CreateReactInstanceTaskRef early when destroying (#46544)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46544

Experiments with `completeReactInstanceCreationOnBgThreadOnAndroid` have shown a native crash in this code path, but it also existed previously.

I believe this is due to the ordering of ReactInstance teardown: we first destroy the ReactInstance, and only then destroy the reference to it in mCreateReactInstanceTaskRef. When using the immediate executor and completeReactInstanceCreationOnBgThreadOnAndroid, we read the react instance from the task, which may no longer be valid at this point. Resetting the task at the earliest point should mitigate the issue.

Changelog: [Internal]

Reviewed By: markv

Differential Revision: D62872625

fbshipit-source-id: 5aaccd53433ca806d2b93f7e3dd2bcf9bf8c09a8
2024-09-19 07:52:59 -07:00
Riccardo Cipolleschi 6d51c5cd8e Setup homebrew in ubuntu machine (#46575)
Summary:
This change setups homebrew on Ubuntu. Due to https://github.com/actions/runner-images/issues/6283, brew is not in the PATH anymore.

## Changelog:
[Internal] - Setup homebrew in ubuntu machine

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

Test Plan: Can't test before it lands. :(

Reviewed By: cortinico

Differential Revision: D63027253

Pulled By: cipolleschi

fbshipit-source-id: e0b3a3c1a2a7b0659f0c1f57c45d8d42a74734a1
2024-09-19 07:19:00 -07:00
Riccardo Cipolleschi 0d2248557b Configure E2E test to run on comments (#46572)
Summary:
This change configure the Test All job to enable the E2E tests with an input parameter.
Then it adds another workflow that is triggered on PRs when someone posts the "/test-e2e" comment.

## Changelog:
[Internal] - Let users run E2E tests on a specific PR comment

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

Test Plan: This kind of things can only be tested once the PR lands, as workflows that are triggered by comments runs only from the main branch.

Reviewed By: cortinico

Differential Revision: D63021786

Pulled By: cipolleschi

fbshipit-source-id: 95b271f6de658ca208c773429fedef2a36417752
2024-09-19 05:34:53 -07:00
Riccardo Cipolleschi c6f32828b9 Fix crash when navigating away from screens (#46559)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46559

There is an edge case when we navigate away from a screen that contains a scroll view where one of the UISCrollViewDelegates does not implement the scrollViewDidEndDecelerating method.

This happens because the Macro used assumes that the event that we are forwarding is the actual method from where the macro is called. Which is not true when it comes to `didMoveToWindow`.

This change fixes that by explicitly expanding the macro in this scenario and passing the right selector.

## Changelog:
[iOS][Fixed] - Fixed a crash when navigating away from a screen that contains a scrollView

## Facebook
This should fix T201780472

Reviewed By: philIip

Differential Revision: D62935876

fbshipit-source-id: e29aadf201c8066b5d3b7b0ada21fa8d763e9af0
2024-09-19 03:24:41 -07:00
Nicola Corti 2524c8eb72 Fix init behavior for 0.76 (#46560)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46560

The `init` command should still keep on working till 2024-12-31

This handles this scenario as currently `npx react-native@next init` is broken.

Changelog:
[Internal] [Changed] - Clarify init behavior for 0.76

Reviewed By: huntie, cipolleschi

Differential Revision: D62958747

fbshipit-source-id: ce3d974df55162720d59a7ece7fcb816e257185d
2024-09-19 03:08:10 -07:00
Samuel Susla 0fe234cb60 execute task directly instead of going through runEventLoopTick (#46540)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46540

changelog: [internal]

avoid calling `runEventLoopTick` and execute task directly. runEventLoopTick is not designed to be called on re-entries.

Reviewed By: rubennorte

Differential Revision: D62871782

fbshipit-source-id: 259514d05eebed2e09d54233729994e56f2aa1a4
2024-09-18 18:02:06 -07:00
Joe Vilches 7e38cf32eb Fix crash that happens with shadow color with 0 alpha (#46551)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46551

We crash if we pass a shadow color with 0 alpha due to some divide by 0 logic. This fixes that for inset and outset shadows and adds a test for that case.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D62899047

fbshipit-source-id: 2aff1d016dd97bed024df1c3f89bcc62e49f0306
2024-09-18 16:44:45 -07:00
David Vacca 40638b8c26 Fix logging of internals of React Native renderer (#46562)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46562

This diff if fixing the logging of internal statistics of React Native Android renderer

changelog: [internal] intenral

Reviewed By: javache

Differential Revision: D59985973

fbshipit-source-id: 5f5020a516d236ef41b0bff087b00e7d7c721bb8
2024-09-18 13:55:44 -07:00
Rubén Norte fea0aa7f83 Create feature flag to make estimation for remaining time in frame for view preallocation more precise (#46563)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46563

Changelog: [internal]

Our current implementation of view preallocation on Android runs very early in the frame (during the `animation` stage, after `input` and before `traversal`). In that implementation, we check the remaining time in the frame and we allocate half of that time for view preallocation.

This logic can make us drop frames unnecessarily, if the work that we need to do after this allocated time is longer than we expect. Because we don't know how long the `traversal` stage will be, we don't account for that time at all (or, at best, we do only use half of the remaining time).

This creates a feature flag to move view preallocation outside of the choreographer, so we can compute the remaining time considering all the work we did in the frame, and not just the work we did in the input stage.

Reviewed By: javache

Differential Revision: D62962341

fbshipit-source-id: 69aaeecc8596906e61b47af9adad23c1075a091a
2024-09-18 13:25:49 -07:00
Pieter De Baets 7f55dc0f45 Remove unused UIManager lookup in NativeAnimatedNodesManager (#46565)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46565

UIManager is initialized elsewhere in NativeAnimatedNodesManager so this is no longer required

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D62958646

fbshipit-source-id: af77ddbbc65124ed29d301340ad339d2a916f58c
2024-09-18 11:05:25 -07:00
Rubén Norte 68e55284c5 Ship correct fix for state updates after smooth scroll animation (#46564)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46564

Changelog: [internal]

I incorrectly set up an experiment to fix reported scroll position during smooth scroll animations on Android in D59233069. It was incorrect because I fixed the issue in "control", and I re-enabled the bug in "test".

That means we actually shipped the fix the moment we set up the experiment.

We can just apply the fix ungated.

Reviewed By: Abbondanzo

Differential Revision: D62965254

fbshipit-source-id: edf855619ff9ede6fd406f7f19b3c504ce89f1d6
2024-09-18 10:09:11 -07:00
Thomas Nardone 74aaf7baa1 Nullsafe react/views/view (#46490)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46490

Fix nulls to prepare this module for further Kotlin conversion

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D62641672

fbshipit-source-id: a426ae30bc0529cfd5057cae68f74f3a52cc514f
2024-09-18 09:47:13 -07:00
Rubén Norte a5dd56f7d0 Create flag to disable reentrancy in MountItemDispatcher (#46561)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46561

Changelog: [internal]

We have some logic in `MountItemDispatcher.tryDispatchMountItems` to recursively call itself for as long as there are new items to mount in the general queue. This queue is copied and processed every time `tryDispatchMountItems` is called, but it's possible that during this time new mount operations are added (either from JS or from the mount operations themselves).

This logic can cause frame drops, as we could be finish processing the current frame without processing new mount items (we could do that in the next frame, and in many cases it's just pre-rendering work and state updates that the user can't perceive anyway).

This creates a feature flag to test disabling this behavior and only process whatever mount items are queued at the start of the frame.

Reviewed By: sammy-SC

Differential Revision: D62958009

fbshipit-source-id: ca038c827715411375410215deb5d5e374f5fdb4
2024-09-18 09:10:00 -07:00
Dawid 42bad68220 fix app crashing when reloads overlap (#46416)
Summary:
Regarding the [issue](https://github.com/facebook/react-native/issues/44755) where the app sometimes crashes due to race condition when two reloads overlap in unfortunate way. This PR fixes it in some way by introducing throttling on reload command. For now I set it to 700ms as I was still able to reproduce it on 500-550ms for provided repro in the issue. The problem may still happen for bigger apps where reload may take more time to finish.

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

[GENERAL] [FIXED] - throttle reload command

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

Test Plan: I've tested on provided repro and a smaller app trying to brake it.

Reviewed By: huntie

Differential Revision: D62847076

Pulled By: cipolleschi

fbshipit-source-id: 6471f792d6b692e87e3e98a699443a88c6ef43cd
2024-09-18 07:32:59 -07:00
Riccardo Cipolleschi 7de3111f9b Add Maestro test for New Arch Example (#46541)
Summary:
This change adds automated tests for the New Architecture Examples page in RNTester.
It also updates the NativeComponentExample to make sure that iOS and Android behaves in the same way and in a reliable way.

## Changelog:
[Internal] - Adds

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

Test Plan:
* Android:

https://github.com/user-attachments/assets/65ead328-9c4f-4e0f-8b9b-992ffb584566

* iOS:

https://github.com/user-attachments/assets/412a4f68-c9c9-4ff2-a3e9-ae7194deef77

Reviewed By: cortinico

Differential Revision: D62879289

Pulled By: cipolleschi

fbshipit-source-id: 59e15f48f5995b18fd8b3ee24aca726b93e04d9f
2024-09-18 06:15:58 -07:00
Dmitry Rykun 4b035d820d Ship shouldSkipStateUpdatesForLoopingAnimations (#46556)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46556

Changelog: [General][Breaking] - Native looping animation will not send React state update every time it finishes.

Facebook
The QE shows neutral results, and has been shipped https://www.internalfb.com/intern/qe2/rn_surface_loading_performance/skip_state_updates_for_looping_animations/wrapup/config

Reviewed By: javache

Differential Revision: D62877191

fbshipit-source-id: 5b04105b3a33535c0da3bc7835098a9c4571d482
2024-09-18 05:28:07 -07:00
Oskar Kwaśniewski 2f5adc3874 fix(iOS): subscribe to orientation changes only on iOS (#46531)
Summary:
This PR adds iOS ifdefs to `RCTUIManager` to subscribe to orientation changes on this platform.

The `UIDeviceOrientationDidChangeNotification` symbol is only available there.

## Changelog:

[IOS] [FIXED] - subscribe to orientation changes in RCTUIManager only on iOS

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

Test Plan: CI Green

Reviewed By: philIip

Differential Revision: D62864013

Pulled By: cipolleschi

fbshipit-source-id: 341df9ac765735273378d017b63fcb7a4d8e98e5
2024-09-18 03:28:26 -07:00
Riccardo Cipolleschi 6d61899fc5 Fix analyze_code to use the proper PR number (#46548)
Summary:
Analyze code was still using the CIRCLECI env variable to retrieve the PR number.
This change uses the github one and also removes a duplicated flow check

## Changelog:
[Internal] - Remove duplicated flow check and use gh PR number rather than CircleCI one

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

Test Plan: Tested locally and in CI

Reviewed By: NickGerleman

Differential Revision: D62883758

Pulled By: cipolleschi

fbshipit-source-id: 0c7e97ea9caf4465972424e0b69a899ecfd07095
2024-09-18 02:57:48 -07:00
Riccardo Cipolleschi 405d982854 Add patch script to enable E2E tests in CI (#46546)
Summary:
This chang introduces a patch file that can be applied to run the E2E tests in CI.

From the root folder `react-native`, a user can just run:

```sh
git apply packages/rn-tester/scripts/enable-e2e-tests.patch
```

And then add a commit to their PR to see whether the newly added E2E tests are actually running

## Changelog:
[Internal] - add patch to simplify running E2E tests in CI

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

Test Plan: Tested locally

Reviewed By: NickGerleman

Differential Revision: D62880559

Pulled By: cipolleschi

fbshipit-source-id: 19d639b2641aaa50e4f3e0753018d426d2da81c9
2024-09-18 02:18:26 -07:00