Commit Graph

29715 Commits

Author SHA1 Message Date
Neil Dhar 255fef5263 Build shared JSI by default (#41037)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41037

Build JSI as a shared library by default. This avoids running into a
problem with duplicate JSI when building against `libhermes` as a
shared library. This is already the case for React Native on Android.

For RN's iOS builds, explicitly specify that JSI should be statically
linked.

Changelog: [Internal]

Reviewed By: dannysu

Differential Revision: D50294405

fbshipit-source-id: 5e77e6d4ab77f8e338ca5ca4154e879eb3d616d7
2023-11-14 12:34:19 -08:00
Nick Gerleman 6c4cb02e27 Allow lazy resolution of edge dimension values (#41347)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41347

X-link: https://github.com/facebook/yoga/pull/1453

This follows the previous patterns used for `Gutters` and `Dimension`, where we hide CompactValue array implementation from `yoga::Style` callers.

This allows a single read of a style to only need access to the resolved values of a single edge, vs all edges. This is cheap now because the interface is the representation, but gets expensive if `StyleValuePool` is the actual implementation.

This prevents us from needing to resolve nine dimensions, in order to read a single value like `marginLeft`. Doing this, in the new style, also lets us remove `IdxRef` from the API.

We unroll the structure dependent parts in the props parsing code, for something more verbose, but also a bit clearer.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D50998164

fbshipit-source-id: 248396f9587e29d62cde05ae7512d8194f60c809
2023-11-14 09:12:35 -08:00
Samuel Susla e51a058212 copy instanceHandle into UIManager::createNode (#41443)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41443

changelog: [internal]

instanceHandle is retained by UIManager::createNode. Let's make that obvious in the API.

Reviewed By: NickGerleman

Differential Revision: D51233821

fbshipit-source-id: b97ad80d3ac31a7830c24c8900caa723ca0e9c20
2023-11-14 07:51:57 -08:00
Samuel Susla 3e3a3dbe28 use react::hash_combine instead of folly::hash_combine (#41477)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41477

changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D51304535

fbshipit-source-id: d7de89c50e30a936b982c5dc568f3516ab140266
2023-11-14 07:24:55 -08:00
Rubén Norte 5948ab7515 Prevent intersectionRatio from being higher than 1 in IntersectionObserverEntry (#41448)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41448

This was possible before due to precision problems with `double` (we were seeing values like 1.000000002). This is an easy way to prevent that problem.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51230183

fbshipit-source-id: 757ef181fe369d525831faf8a6d907467efc544c
2023-11-14 06:11:13 -08:00
Rubén Norte 11aadb7287 Fix error when trying to unobserve detached targets in IntersectionObserver (#41454)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41454

Yet another problem caused by React being too aggressive cleaning up detached fibers. This fixes a problem in `IntersectionObserver` when trying to `unobserve` detached targets. In that case we didn't have access to its shadow node anymore, so we didn't have a way to unobserve in native. This keeps an additional mapping in JS to do the conversion even after detached.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51257960

fbshipit-source-id: 25edc9afd2108e141d178dd4939fc2de8286342b
2023-11-14 06:11:13 -08:00
Rubén Norte e8b08813ac Fix error when accessing detached targets from IntersectionObserver entries (#41449)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41449

`IntersectionObserver` was incorrectly throwing errors when reporting entries for detached targets. The problem was that we were deriving the target instance from the instance handle that we keep in native, but React removes the connection between them when the instance handle is unmounted.

This fixes the problem by keeping an internal mapping between instance handle and target internally in the intersection observer manager.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210456

fbshipit-source-id: 7c4a03c14c7f756191f395e0178eadc979cce146
2023-11-14 06:11:13 -08:00
Rubén Norte a493ea43ff Remove pending records when unobserving a target in IntersectionObserver (#41450)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41450

`IntersectionObserver` shouldn't report entries for targets that are no longer being observed by the observer. This wasn't the case before because it was possible to create an intersection observer entry, then unobserve the target and then dispatch the pending entries (including the unobserved target). This fixes that issue to align with Web browsers.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51256827

fbshipit-source-id: 28035f00bcb05a8ca53140719019032b3399436c
2023-11-14 06:11:13 -08:00
Rubén Norte fc0c084df0 Guard against unmounted components when using traversal APIs (#41451)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41451

After [this change in React](https://github.com/facebook/react/pull/27687), `ReactFabric.getPublicInstanceFromInternalInstanceHandle` can return `null` if the instance handle is a fiber that was unmounted (before that PR, it would throw an error).

This modifies the DOM traversal API to gracefully handle that case.

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D51210455

fbshipit-source-id: 05de682d840eed7f22473800efe5fb910c8f3a0d
2023-11-14 06:11:13 -08:00
rubennorte (Meta Employee) e0aa9abfaf Guard against unmounted components when accessing public instances on Fabric (#27687) (#41452)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41452

## Summary

This fixes an error in `getPublicInstanceFromInstanceHandle` where we
throw an error when trying to access the public instance from the fiber
of an unmounted component. This shouldn't throw but return `null`
instead.

## How did you test this change?

Updated unit tests.
Before:
<img width="969" alt="Screenshot 2023-11-10 at 15 26 14"
src="https://github.com/facebook/react/assets/117921/ea161616-2775-4fab-8d74-da4bef48d09a">

After:
<img width="1148" alt="Screenshot 2023-11-10 at 15 28 37"
src="https://github.com/facebook/react/assets/117921/db18b918-b6b6-4925-9cfc-3b4b2f3ab92d">

DiffTrain build for commit https://github.com/facebook/react/commit/6b3834a45b585e4340734139841ae81dc1b1a75d.

Test Plan: Sandcastle tests

Reviewed By: tyao1

Differential Revision: D51203276

Pulled By: rubennorte

fbshipit-source-id: 40c471843dea91573bff26f8595eb9554923e5d8
2023-11-14 06:11:13 -08:00
Rubén Norte 686f83e6fe Clean up legacy use of native modules to access ReactNativeConfig (#41473)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41473

This removes a legacy behavior in React Native to use the native module for MobileConfig to create `ReactNativeConfig`. It now uses the same implementation that the native module uses so we don't depend on TurboModule infra and we can instantiate `ReactNativeConfig` before that infra is ready.

Changelog: [internal]

Reviewed By: christophpurrer

Differential Revision: D51268579

fbshipit-source-id: 6b4860b064b45115e9c43997134e9aa771f330ea
2023-11-14 05:07:25 -08:00
Samuel Susla f1925c2668 fix use out-of-scope memory warning (#41441)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41441

changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D51233760

fbshipit-source-id: 5fc7ab22220e3d80729243e715e22e85e3ba7afa
2023-11-14 04:59:33 -08:00
Nick Gerleman caed1dc230 Make trunk builds "0.0.0" (#41423)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41423

X-link: https://github.com/facebook/yoga/pull/1466

Right now Yoga's main branch says it's 2.0.0, and RN's dirsync says its 1.14.0, but the code is really closer to what will be Yoga 3.0.0.

This changes trunk builds to "0.0.0" for clarity, which will be assigned a real version number the first time publishing a new Yoga branch.

This is separately a good practice to prevent the chance of accidental publishes causing damage.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D51236778

fbshipit-source-id: 06cac89bcca1c707ce5c00f9c346f627eef6b4bc
2023-11-13 22:09:35 -08:00
Riccardo Cipolleschi ef3c022ebd Remove unnecessary workflows (#41453)
Summary:
This PR removes some jobs we don't need right now

## Changelog:
[Internal] - remove unnecessary jobs

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

Test Plan: CircleCI stays green

Reviewed By: NickGerleman

Differential Revision: D51257788

Pulled By: cipolleschi

fbshipit-source-id: e348a7ef7af469ba019b2ccc33feed79a9d4febe
2023-11-13 22:07:51 -08:00
Phillip Pan d502380b91 pass down sync void config to jsi module (#41470)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41470

Changelog: [Internal]

actually pass down the config value -_-

Reviewed By: christophpurrer

Differential Revision: D51279435

fbshipit-source-id: 674d7558a30742f6bf67cacfb4025e3c7d3646f7
2023-11-13 20:58:16 -08:00
Phillip Pan 8feb84a447 put PR#41194 behind gating (#41469)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41469

Changelog: [Internal]

PR#41194 (https://github.com/facebook/react-native/pull/41194) introduces a new callsite to `RCTUnsafeExecuteOnMainQueueSync` in the module init path, which increases risk for deadlock. let's gate it

Differential Revision: D51274859

fbshipit-source-id: b2ab6d42378d2885def1fdad61e1de0f6e6285cd
2023-11-13 18:49:28 -08:00
Jane Li ad0f064852 Fix flickering (#41461)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41461

D51179007 updated the layout spec so that we wouldn't have the weird spacing. However, it introduced some weird flickering through the app.

Upon investigating in layout inspector, I found that the issue actually isn't the rn_fragment, it's the rootview being created without the proper specs. This updates the ReactNavigationFragment so that the root view gets the correct specs, similar to how it's done here: https://www.internalfb.com/code/fbsource/[80683c89da108bba70bfe60340f80c6613960119]/fbandroid/java/com/facebook/fbreact/navigation/ReactNavigationActivityDelegate.java?lines=109

[changelog] internal

Reviewed By: jessebwr

Differential Revision: D51267353

fbshipit-source-id: 6deb5f29e8a73d9cf38cb9445d69ab041b974ec8
2023-11-13 14:30:44 -08:00
David Vacca 15b0626a8e Migrate ReactInterceptingViewGroup to kotlin
Summary:
Migrate ReactInterceptingViewGroup to kotlin

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: rshest

Differential Revision: D51262573

fbshipit-source-id: fe233d7f02b4e8165300e8929707396ccab272c8
2023-11-13 14:24:02 -08:00
David Vacca 915b3c1f21 Fix lints
Summary:
Fixing lint warningns and errors found during analysis

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: rshest

Differential Revision: D51262579

fbshipit-source-id: 3644b07cd7504c012826faa98249958062366534
2023-11-13 14:24:02 -08:00
David Vacca 453ba67a78 Migrate OnInterceptTouchEventListener to kotlin
Summary:
Migrate OnInterceptTouchEventListener to kotlin

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: rshest

Differential Revision: D51262581

fbshipit-source-id: 06be429db2b871e0173c71bad26811a652a86c5c
2023-11-13 14:24:02 -08:00
Christoph Purrer 1eff870f4c react-native: JavaTurboModule > Remove unused imports (#41435)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41435

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D51243602

fbshipit-source-id: 32c45a25d3efd52652814c6c119fc91d18eb1f08
2023-11-13 14:02:07 -08:00
Gijs Weterings 453e5c0d09 Temporarily disable InspectorProxy.* tests to unblock CI (#41463)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41463

S378983 Circle CI tests have been red for 5 days. There's a test setup issue somewhere in this test suite, until motiz88 can determine where exactly, let's disable them

T169943794 filed to follow up

Changelog: Internal

Reviewed By: cipolleschi

Differential Revision: D51271630

fbshipit-source-id: 7dbc61bb4c8df0d5360ba239a1f00c4270a691f3
2023-11-13 13:24:47 -08:00
Riccardo Cipolleschi 6962b5fdd0 Move test_windows under test_JS (#41455)
Summary:
CircleCI was broken since Friday because a change broke JS tests on Windows only.
The test_windows job didn't run on those changes because they were JS changes only, therefore won't affect the build of React Native on Windows.

The `test_windows` was listed among the various `test_android` jobs, but it is not actually building React Native android on windows machines.
Instead, the test_windows jobs is actually only running JS tests on a windows machines. Therefore, it makes more sense to have this test under the test_js group.

bypass-github-export-checks

## Changelog:
[Internal] - Move the test_windows job under the testJS configuration

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

Test Plan:
CircleCI is green.
test_windows run together with the JS tests

Reviewed By: mdvacca

Differential Revision: D51258120

Pulled By: cipolleschi

fbshipit-source-id: a523c48f697b64620433ec9672f13baa308d75a8
2023-11-13 10:09:13 -08:00
Ruslan Lesiutin a226b9084d refactor[InspectorOverlay]: migrate to functional component (#41410)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41410

Changelog: [Internal]

I am planning some changes in this component. No functional changes in this diff.

Reviewed By: robhogan

Differential Revision: D50644901

fbshipit-source-id: 5464640d64bf2e50696d7e579b30985b6ceaef5a
2023-11-13 08:20:26 -08:00
Ruslan Lesiutin 066cb2bfd5 refactor[Inspector]: migrate to functional component (#41411)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41411

Changelog: [Internal]

I am planning some changes in this component. No functional changes in this diff, except for the `panelContainerStyle` change for iOS to fix top gap.

Reviewed By: robhogan

Differential Revision: D50644902

fbshipit-source-id: 3111da100261552c89d0cd4eae724500c446cdfd
2023-11-13 08:20:26 -08:00
Tommy Nguyen 3dd6a83c0e Fix build_codegen! not finding @react-native/codegen in pnpm setups (#41399)
Summary:
`build_codegen!` currently assumes that `react-native/codegen` gets installed next to `react-native`. In a pnpm setup, it's found under `/~/react-native/node_modules/react-native/codegen` instead.

However, as dmytrorykun pointed out, we don't actually need to build it outside of this repository.

## Changelog:

[GENERAL] [FIXED] - `react-native/codegen` shouldn't be built unless it's in the repo — fixes `pod install` failures in pnpm setups

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

Test Plan: We have a patched version of `react-native` working in a pnpm setup here: https://github.com/microsoft/rnx-kit/pull/2811

Reviewed By: dmytrorykun

Differential Revision: D51201643

Pulled By: cipolleschi

fbshipit-source-id: 53767ae08686a20f03b3b93abcbc7d5383083872
2023-11-13 07:58:58 -08:00
zhongwuzw 6eef3661bf Remove duplicated category NSTextStorage+FontScaling (#41437)
Summary:
We have two same categories of `NSTextStorage+FontScaling`, another one is  https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Text/Text/NSTextStorage%2BFontScaling.h. Only one category is valid, so we can delete one.

## Changelog:

[IOS] [FIXED] - Remove duplicated category NSTextStorage+FontScaling

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

Test Plan: Null.

Reviewed By: rshest

Differential Revision: D51253572

Pulled By: javache

fbshipit-source-id: 4229351bf29699076d740defec64b61ea2151063
2023-11-13 06:14:23 -08:00
Moti Zilberman 4c0d20dfbf Fix platform sensitivity in inspector-proxy tests (#41439)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41439

TSIA - should fix the [Windows test failure](https://app.circleci.com/pipelines/github/facebook/react-native/36174/workflows/055cabb6-cb41-4741-812a-59b06fc7c9b5/jobs/1200335/parallel-runs/0/steps/0-115?fbclid=IwAR38F8tE-831Rpe5J_KeFOmA5DARLWWYIAiLIgkXOLdEfMmSeaVOIGgPq5U) we saw on CircleCI.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51254843

fbshipit-source-id: d45682c460d54b3d76d3a02416b75f0c11313fd7
2023-11-13 05:12:00 -08:00
Pieter De Baets 92c5bf858e Remove unreferenced CalledOnceMovableOnlyFunction (#41440)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41440

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D51254054

fbshipit-source-id: 222191bb03959077d86e52ad5bb6833bc6e7e4cd
2023-11-13 05:02:47 -08:00
Sunbreak d7fd83ed5d Remove JSCJavaScriptExecutor/Factory (#41406)
Summary:
- `JSCJavaScriptExecutor` & `JSCJavaScriptExecutorFactory` have been deprecated according to https://github.com/facebook/react-native/issues/38594
- `JSCJavaScriptExecutor`'s native implementation is missing
- `JSCJavaScriptExecutor` should be bundle into library that contains `JSCJavaScriptExecutorHolder`, e.g. [`V8Executor`](https://github.com/Sunbreak/react-native/blob/0.69-v8/ReactAndroid/src/main/java/io/csie/kudo/reactnative/v8/executor/V8Executor.java) and [`V8ExecutorHolder`](https://github.com/Sunbreak/react-native/blob/0.69-v8/ReactAndroid/src/main/java/com/facebook/v8/executor/OnLoad.cpp)

```mermaid
classDiagram
    class JSCJavaScriptExecutor["JSCJavaScriptExecutor.java"] {
        -initHybrid()$
    }
    class JSCExecutor["JSCExecutor.java"] {
        -initHybrid()$
    }
    JSCExecutor <|.. JSCExecutorHolder: Composition
    class JSCExecutorHolder["JSCExecutorHolder.cpp"] {
        +initHybrid()$
    }
    class HermesExecutor["HermesExecutor.java"] {
        -initHybrid()$
    }
    HermesExecutor <|.. HermesExecutorHolder: Composition
    class HermesExecutorHolder["HermesExecutor.cpp"] {
        +initHybrid()$
    }
    class ProxyJavaScriptExecutor["ProxyJavaScriptExecutor.java"] {
        -initHybrid()$
    }
    ProxyJavaScriptExecutor <|.. ProxyJavaScriptExecutorHolder: Composition
    class ProxyJavaScriptExecutorHolder["ProxyJavaScriptExecutorHolder.cpp"] {
        +initHybrid()$
    }
```

Remove JSCJavaScriptExecutor/Factory

## Changelog:

[ANDROID] [REMOVED] - Remove JSCJavaScriptExecutor/Factory

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

Test Plan: None

Reviewed By: christophpurrer

Differential Revision: D51198037

Pulled By: javache

fbshipit-source-id: 73f335f76adfe644bef1ee37e8ec474625d37e0d
2023-11-13 03:18:28 -08:00
Nick Gerleman 99ebcfd3a9 "yogalayout.com" to "yogalayout.dev" (#41420)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41420

X-link: https://github.com/facebook/yoga/pull/1465

https://yogalayout.com now redirects to https://yogalayout.dev

This replaces references to "yogalayout.com" with "yogalayout.dev", the same website, with a new domain. This includes:
1. Code comments
2. Yoga website config (publish action CNAME, Docusaurus config)
3. Documentation URLs in Yoga packages

Changelog:
[General][Fixed] - "yogalayout.com" to "yogalayout.dev"

Reviewed By: christophpurrer

Differential Revision: D51229587

fbshipit-source-id: b1c336a52aab5e02565071b61430d5435381dc0a
2023-11-13 02:48:29 -08:00
David Vacca 1891d9e647 Introduce again com/facebook/react/turbomodule/core/interfaces/TurboModule.kt (#41412)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41412

The PR https://github.com/facebook/react-native/pull/39682
 moved all TurboModule classes into the folder com/facebook/react/internal/turbomodule/core/interfaces/TurboModule. The reasoning is TurboModule classes are internal implementation of RN and they shouldn't be part of the public API.

Later we realized that com.facebook.react.internal.turbomodule.core.interfaces.TurboModule interface is actually being used by OSS developers too implement the TurboReactPackage.getReactModuleInfoProvider() method:
https://reactnative.dev/docs/next/the-new-architecture/pillars-turbomodules#updating-the-calculatorpackagejava

In this diff I'm re-introducing the com.facebook.react.turbomodule.core.interfaces.TurboModule interface jus for backward compatibility.

Since the plan is to delete the TurboReactPackage.getReactModuleInfoProvider method in the next few months, the plan is:

- Iterate on the experiments to remove TurboReactPackage.getReactModuleInfoProvider method

- Once TurboReactPackage.getReactModuleInfoProvider method is ready to be deleted, there's no need to expose TurboModule interface anymore, so we will delete 'com.facebook.react.turbomodule.core.interfaces.TurboModule' and 'TurboReactPackage.getReactModuleInfoProvider' method
- com.facebook.react.internal.turbomodule.core.interfaces.TurboModule will still remain in the codebase, but this will be an internal API

changelog: [Android][Changed] Fix backward compatibility breakage

Reviewed By: fkgozali

Differential Revision: D51168413

fbshipit-source-id: 921475f4beee7c6f04912558204a1911cd74b5ca
2023-11-10 22:26:54 -08:00
Arushi Kesarwani f53bd5621c Revert D50926872: Refactor DefaultReactNativeHost to use the new way of Fabric initialization
Differential Revision:
D50926872

Original commit changeset: be2bcea7b2ce

Original Phabricator Diff: D50926872

fbshipit-source-id: 677def6c91edc505dfd312ff944fd90c6abeb645
2023-11-10 21:08:33 -08:00
Nick Gerleman a9c23fbc1e Simplify YGConfigSetPointScaleFactor (#41327)
Summary:
X-link: https://github.com/facebook/yoga/pull/1451

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

The special meaning of `0.0` is now explained in the function header, and we aren't doing any sort of insensitive compare here, so the code after should be equivalent and a bit simpler.

Reviewed By: yungsters

Differential Revision: D51014264

fbshipit-source-id: 60f4a2df039f74089d5c7fabd4b7d8ac6234ba72
2023-11-10 16:31:46 -08:00
Nick Gerleman 5910032b2d Modularize and document public API (#41317)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41317

X-link: https://github.com/facebook/yoga/pull/1449

This aims to clean up the public Yoga C API, by:
1. Documenting public YGNode, YGValue, YGConfig APIs
2. Splitting APIs for specific objects into different header files (because Yoga.h was big enough without documentation)
3. Reordering headers and definitions for consistent grouping

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D50963424

fbshipit-source-id: 45124b7370256fc63aefd6d5b7641466e9a79d3b
2023-11-10 16:31:46 -08:00
Phillip Pan 0479bebbe5 Remove vestigial reference to UIActionSheetDelegate (#41402)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41402

Changelog: [Internal]

UIActionSheet was deprecated in iOS 8.3.

The RCTActionSheetManager class listed the UIActionSheetDelegate as an adopted protocol but none of the protocol methods were implemented.

Reviewed By: sammy-SC

Differential Revision: D50732844

fbshipit-source-id: e954f1e9a03e80561b3b066557e56c7f3d3589d4
2023-11-10 12:56:58 -08:00
ehsemloh 9b33e752c7 fixed (iOS) Relayout not Working for Nested Inline (#41352)
Summary:
React Native, the text inline is made versatile by design. Being managed in an alien layout logic (i.e., text paragraph), inline views work seamlessly as if in normal **flex** layout. The capacities such as animation and relayout, however, requires extra efforts on native layer.

This PR fixed one critical issue for inline, i.e., `setState()` is not working when inline contains nested views.

Closes https://github.com/facebook/react-native/issues/41348

Demo (Fixed)

https://github.com/facebook/react-native/assets/149237137/2b42d657-4024-476b-bf0c-be25ef4f8c0c

## Problem in technical:

This issue is caused by a bug in `RCTShadowView::sizeThatFitsMinimumSize()` which accidentally unlink children (of yoga nodes) with their parent (owner). More specifically, on the critical path, it
1. first **shallow** clones the current node
```
  YGNodeRef clonedYogaNode = YGNodeClone(self.yogaNode);
```
2. then calls `YGNodeCalculateLayout()` using the cloned node
3. deallocate the cloned node `YGNodeFree()`

One unseen implication of `YGNodeFree()` is to unlink all its children (because of the **shallow** clone)

```
  for (size_t i = 0; i < childCount; i++) {
    auto child = node->getChild(i);
    child->setOwner(nullptr);
  }
```

Next, let's examine,

**How nullptr of owner can cause the broken `setState()` of nested inline views**

The orphan children has two consequences:
**a**. the changes on child node (`setState()`) cannot be propagated to the parent (`YGNodeMarkDirty` -> `node->markDirtyAndPropagate();`);
**b**. `YGNodeCalculateLayout()` (`yoga::calculateLayoutImpl`) will create new children instances when orphan is detected (see below)

```
  node->cloneChildrenIfNeeded(); // line 1599 # CalculateLayout.cpp
```

Both compounded are contributing the failed `setState()`. Respectively,
**a** causes early return of `YGNodeCalculateLayout()` because parent is recognized as not *dirty*;
**b** clones a new *dirty* node which replaces the child which is supposed to be *cleaned* within `YGNodeCalculateLayout()`. And this is the *dirty* node detected by the assertion mentioned in the issue description https://github.com/facebook/react-native/issues/41348.

## The fix:

The fix introduced in this PR is to relink the children with their parent in `RCTShadowView::sizeThatFitsMinimumSize()`

## Changelog:

[IOS] [FIXED] - `setState` is not working for nested inline views in text

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

Test Plan:
Test directly in rn-tester
TBD

Reviewed By: yungsters

Differential Revision: D51071338

Pulled By: NickGerleman

fbshipit-source-id: 1f3d8a3e1e03cb11577f903e43f2c2cce9e07b6e
2023-11-10 10:58:45 -08:00
Pieter De Baets 94da17e642 Stub nativeFabricUIManager for jest tests (#41408)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41408

When FabricRenderer is used during jests it will currently error out since `nativeFabricUIManager` is nog a configured global.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D51198314

fbshipit-source-id: 4db1450f6b36699311692c2cd467184f6abea518
2023-11-10 08:41:57 -08:00
Sunbreak c267a0679d Fix type in BlobCollector.h/cpp (#41404)
Summary:
When working on JSI module, `BlobCollector`'s `nativeInstall` is a good example. But the first type should be `jni::alias_ref<jclass>` according to https://github.com/facebookincubator/fbjni/blob/main/docs/quickref.md#basic-method-usage-java-to-c-and-c-to-java

Fix type in BlobCollector.h/cpp

## Changelog:

[ANDROID] [FIXED] - Fix type in BlobCollector.h/cpp

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

Test Plan: None

Reviewed By: cipolleschi

Differential Revision: D51198049

Pulled By: javache

fbshipit-source-id: 86f471cbe3cd683a7be605ce127b3b3c3769c037
2023-11-10 05:26:58 -08:00
Oskar Kwaśniewski 88e3913603 feat(iOS) remove deprecated [UIScreen mainScreen] references (#41388)
Summary:
The goal for this PR is to further remove references for `[UIScreen mainScreen]` and migrate them to use trait collections. This helps out of tree platforms like visionOS (where the `UIScreen` is not available).

bypass-github-export-checks

## Changelog:

[INTERNAL] [CHANGED] - use currentTraitCollection for FBSnapshotTestController.m
[IOS] [CHANGED] - use key window width to assign the correct width for RCTDevLoadingView

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

Test Plan:
– Check if tests passes
- Check if `RCTDevLoadingView` shows up correctly.

Screenshot:
![CleanShot 2023-11-09 at 13 48 48@2x](https://github.com/facebook/react-native/assets/52801365/4c91399e-f70a-4e78-8288-bc7b8377c980)

Reviewed By: javache

Differential Revision: D51156230

Pulled By: cipolleschi

fbshipit-source-id: bbe711e0281046a082fd1680b55e2d117915ad00
2023-11-10 05:03:26 -08:00
Gabriel Donadel 1a61afddf7 Expose unstable_InspectorProxy and unstable_Device from dev-middleware (#41370)
Summary:
Recently, both `metro-inspector-proxy`(https://github.com/facebook/react-native/pull/39045) and `react-native-community/cli-plugin-metro`(https://github.com/facebook/react-native/pull/38795) were moved to this repo and in the process of moving these packages, the `exports` field inside package.json was added, only exporting the `index.js` file.

The problem is that Expo CLI (and possibly other community packages) rely on functions and classes that are not exported in the `index.js` file, e.g. Importing the InspectorProxy class from `react-native/dev-middleware/dist/inspector-proxy/InspectorProxy`. Normally this wouldn't be a problem and we would just import from `dist/` but due to the `exports` field, attempting to import from any other file not specified on this field will result in a `ERR_PACKAGE_PATH_NOT_EXPORTED` error.

As a short-term fix, we should create `unstable_`-prefixed exports of individual features Expo currently depends on.

## Changelog:

[INTERNAL] [CHANGED] - Expose unstable_InspectorProxy and unstable_Device from `react-native/dev-middleware`

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

Test Plan: N / A

Reviewed By: robhogan

Differential Revision: D51163134

Pulled By: blakef

fbshipit-source-id: e67adaedc4fc64131e4c9dd8383c9877b8202283
2023-11-10 04:45:51 -08:00
Arushi Kesarwani eb3ee4d132 Refactor DefaultReactNativeHost to use the new way of Fabric initialization (#41374)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41374

Refactoring `DefaultReactNativeHost` to use the new way of Fabric initialization through `FabricUIManagerProviderImpl`

Changelog:
[Internal] internal

Reviewed By: philIip, luluwu2032

Differential Revision: D50926872

fbshipit-source-id: be2bcea7b2ce7cb1b3f903dc92fcd2c91be267da
2023-11-10 02:30:18 -08:00
Arushi Kesarwani 153a2641b4 Refactor ReactNativeHost to add UIManagerProvider (#41383)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41383

Refactor `ReactNativeHost` to add the APIs for `UIManagerProvider`.

Reviewed By: christophpurrer, philIip

Differential Revision: D51120159

fbshipit-source-id: 3d9b384e3fb2f5420c5ea28f43c4147a1425d137
2023-11-10 02:30:18 -08:00
Arushi Kesarwani ea622de4e1 Refactor react initialization to use FabricUIManagerProvider instead of JSIModule (#41313)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41313

Refactor ReactNativeHost, ReactInstanceManager & Builder of `react-native-github` to use the new way of fabric initialization using the newly added class `FabricUIManagerProviderImpl.java` instead of JSIModule and thereby also refactoring the call site in FbReactInstanceHolder.java

Changelog:
[Internal] internal

Reviewed By: philIip

Differential Revision: D50783751

fbshipit-source-id: 0a9d3412bc995834cafa8fbaec2ff17e321d9906
2023-11-10 02:30:18 -08:00
Christoph Purrer c2ac0cc72a react-native-codegen: Cxx TMs > Fixed Undefined Behavior exception when running ASAN builds (#41401)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41401

Changelog: [Internal]

When build Cxx Turbo Modules with Clang's ASAN build mode the apps are crashing at runtime due to, e.g.:
```
runtime error: downcast of address 0x00010dafd618 which does not point to an object of type 'facebook::react::NativePerformance'
0x00010dafd618: note: object is of type 'facebook::react::NativePerformanceCxxSpec<facebook::react::NativePerformance>'
 00 00 00 00  f0 08 49 06 01 00 00 00  4e 61 74 69 76 65 50 65  72 66 6f 72 6d 61 6e 63  65 43 78 78
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'facebook::react::NativePerformanceCxxSpec<facebook::react::NativePerformance>'
UndefinedBehaviorSanitizer: undefined-behavior FBReactNativeSpecJSI.h:6122:17
```

Where the corresponding generated code looks like

```
NativePerformanceCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
    : TurboModule(std::string{NativePerformanceCxxSpec::kModuleName}, jsInvoker),
      delegate_(static_cast<T*>(this), jsInvoker) {}
```

This change fixes that problem

AddressSanitizer: stack-use-after-scope shared_ptr.h:634 in std::__1::shared_ptr<facebook::react::InstanceHandle const>::shared_ptr[abi:v160006](std::__1::shared_ptr<facebook::react::InstanceHandle const> const&)
Shadow bytes around the buggy address:
  0x00016cea4a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00016cea4b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00016cea4b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00016cea4c00: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 f8 f8 f8 f8
  0x00016cea4c80: f8 f8 f2 f2 f2 f2 f8 f8 f2 f2 00 00 f2 f2 f8 f8
=>0x00016cea4d00: f2 f2 f8 f8 f2 f2 00 00 f2 f2[f8]f8 f2 f2 00 00
  0x00016cea4d80: f2 f2 f8 f8 f2 f2 f8 f8 f2 f2 f8 f8 f8 f2 f2 f2
  0x00016cea4e00: f2 f2 f8 f8 f2 f2 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
  0x00016cea4e80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f2 f2 f2 f2 f2 f2 f2
  0x00016cea4f00: f2 f2 f8 f8 f3 f3 f3 f3 00 00 00 00 00 00 00 00
  0x00016cea4f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==41992==ABORTING

```

Reviewed By: rshest

Differential Revision: D51183328

fbshipit-source-id: 5aff5b5eecb9d78f9b7438fbdda2c01625c9a4d9
2023-11-09 22:14:57 -08:00
Sam Zhou d7af27dd7d Deploy 0.221.0 to xplat (#41400)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41400

Changelog: [Internal]

Reviewed By: pieterv

Differential Revision: D51181099

fbshipit-source-id: 9489dc78e305eb44602baf0a719aaee0ba898a76
2023-11-09 16:57:15 -08:00
Tommy Nguyen c58e19e89a Correctly declare runtime dependencies (#41398)
Summary:
In pnpm setups, codegen will fail during build because it cannot find its dependencies. Some of the dependencies it relies on at runtime are currently declared under `devDependencies`. This change moves them to `dependencies`.

## Changelog:

[GENERAL] [FIXED] - Fix `react-native/codegen` not being able to resolve dependencies in pnpm setups

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

Test Plan: We are currently trying to [enable pnpm mode](https://github.com/microsoft/rnx-kit/pull/2811) in rnx-kit and hit this issue. We've patched this package locally and it works.

Reviewed By: christophpurrer

Differential Revision: D51169116

Pulled By: NickGerleman

fbshipit-source-id: 28906a0de412c660d2fc42f62deaf77240d27a58
2023-11-09 15:07:52 -08:00
Christoph Purrer 9320174df4 Cxx TurboModules > Add example to return a JS function from Cxx to JS (#41385)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41385

Changelog: Internal

Adding a Cxx TM example which adds a listener and returns a subscription to remove that listener from the TM.

You should be able to use this with React Hooks - https://legacy.reactjs.org/docs/hooks-reference.html

E.g.

```
useEffect(() => {
  const subscription =  NativeCxxModuleExample.setValueCallbackWithSubscription(
          callbackValue => // use it
        );
  return subscription;
});
```

Reviewed By: shwanton

Differential Revision: D50473063

fbshipit-source-id: 4e9b92aeccff1771eb4ffad6bdaa20ba7f18435f
2023-11-09 11:38:54 -08:00
Ruslan Lesiutin 01b4d7853d refactor: move React DevTools hook injections to DevAppContainer (#41360)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41360

Changelog: [Internal]

This is Flipper-only, React DevTools inject these internals in `connectToDevTools` call

Mostly for 2 reasons:
- For React DevTools' hook being accessed only in one place (AppContainer-dev)
- This logic is not related to Inspector itself

Reviewed By: GijsWeterings

Differential Revision: D50559547

fbshipit-source-id: 2127f3a20b71261858fdfc004a372d1d95ced164
2023-11-09 11:09:10 -08:00
Ruslan Lesiutin a1f2330ebb cleanup[Inspector]: remove unused code (#41292)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41292

Changelog: [Internal]

Seems to be unused

Reviewed By: javache

Differential Revision: D50559548

fbshipit-source-id: 4bf7c27cb75e567c43adfa5aa4c120c67ef4dd5e
2023-11-09 11:09:10 -08:00