Commit Graph

5589 Commits

Author SHA1 Message Date
Rachit Mishra 3f3394a566 fix: handle webview provider missing exception (#34456)
Summary:
The [existing fix](https://github.com/facebook/react-native/blob/fb936dfffb3ca2d9bc0969dfe36a70bdf66783e0/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java#L151) to handle missing WebView provider uses string comparison based checks to handle the exception gracefully, or otherwise simply throw the exception. This ends up crashing the app for the end user.

<img width="1319" alt="Screenshot 2022-08-19 at 4 33 31 PM" src="https://user-images.githubusercontent.com/933314/185605137-24757dad-806e-4cca-b000-7d6ce2d191e1.png">

Fatal exceptions are bad in any case and not good user experience, we can gracefully handle this by [returning](https://github.com/facebook/react-native/compare/main...rachitmishra:react-native-1:patch-2#diff-f7ca1976002c4612051e4949395e64511b6f769e347c488e9a0d15cb5331fe76R141) `null` for all cases when WebView provider is not found.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Gracefully handle crash if no WebView provider is found on the device

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

Test Plan: IMO no testing is required as we were already returning null in certain cases after handling the exception message, also `ForwardingCookieManager::getCookieManager` is already marked `Nullable` so we are safe there.

Reviewed By: lunaleaps

Differential Revision: D39809020

Pulled By: cortinico

fbshipit-source-id: 54b290ad7740859bdc84401904236c32761a4631
2022-09-26 13:30:14 -07:00
Nicola Corti bf55a3a392 Make sure ccache is considered as part of the CMake build
Summary:
I've just realized that CMake is ignoring `ccache`, even if you have it
installed. This is the necessary change needed to verify if the user
has `ccache` installed and eventually use it.

While not a necessary change for Prefab supprot, this is a nice to have
that I've discovered while working on it.

Changelog:
[Internal] [Changed] - Make sure ccache is considered as part of the CMake build

Reviewed By: cipolleschi

Differential Revision: D39815089

fbshipit-source-id: be62e5fe98954593fd907ec21c41950a967cff04
2022-09-26 08:48:04 -07:00
Paige Sun 9a253d1864 Back out "Back out "[Venice][iOS] Fix: Install Fabric UIManager before main bundle execution""
Summary:
Changelog: [Internal][Bridgeless][iOS]

# Before diff
Be in Venice > run Metro > run FBiOS > navigate to any RN surface.

 `UIManagerBinding createAndInstallIfNeeded` happens After `ReactInstance loadScript -> evaluateJavaScript`: install Fabric UIManager before main bundle execution

Reviewed By: RSNara

Differential Revision: D39760231

fbshipit-source-id: f17bf02e9b1fb0f9b0ff24c86aa6dc9349c42192
2022-09-23 17:32:49 -07:00
Rubén Norte 30fe6b341b Restore flags to disable Fabric background executor
Summary:
We want to fix the order of execution of layout, layout effects and passive effects in React Native, but the use of the Fabric background executor for layout complicates this (and other things).

This brings back a flag to disable this background thread to do layout synchronously in JavaScript, before the execution of layout effects and passive effects.

This is expected to regress performance on some screens, so we need to address the antipatterns in those screens before shipping this.

Changelog: [internal]

Reviewed By: javache

Differential Revision: D39727131

fbshipit-source-id: 4323b089234d3304ca3bfe5697668fb44ac64c12
2022-09-23 05:51:36 -07:00
Riccardo Cipolleschi b7add0aadb Always generate an EmptyNativeState (#34754)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34754

This Diff is the second step of enabling the CodeGen to parse and generate a NativeState for the components.

The feature has been largely requested by the OSS community but it could be also helpful for people in Meta.

## Changelog
[General][Added] - Always generate an empty NativeState for Fabric Components

Reviewed By: cortinico

Differential Revision: D39696435

fbshipit-source-id: e24768af78f59696c0b4db009e8065bb5c89316b
2022-09-22 06:41:44 -07:00
Samuel Susla 15dbd9121d Back out "Fix: Install Fabric UIManager before main bundle execution"
Summary:
Original commit changeset: 4491d6de1109

Original Phabricator Diff: D39493654 (https://github.com/facebook/react-native/commit/447be629091579b8656e1b10e365f3429a61bbf3)

changelog: [internal]

Reviewed By: javache

Differential Revision: D39727129

fbshipit-source-id: 412a7fc5e4bf8db26cde7d420e71cf1f314cdc93
2022-09-22 06:36:59 -07:00
Kudo Chien 3d7e1380b4 Fix port as -1 if dev server without specifying port on Android (#34705)
Summary:
when specifying dev server without port, e.g. http://www.example.com/, there are some issues.

1. redbox error
<img src="https://user-images.githubusercontent.com/46429/190540390-8ee420f2-7642-427b-9f2e-e0c6d31015f8.png" width="30%">

2. showing -1 in loading view

<img src="https://user-images.githubusercontent.com/46429/190540727-158f35ad-359f-443a-a4b0-768dd2f7e400.png" width="50%">

the root cause is coming from [`java.net.URL.getPort()` will return -1 when the url doesn't have a port](https://developer.android.com/reference/java/net/URL#getPort()). this pr replaces the parser to [`okhttp3.HttpUrl`](https://square.github.io/okhttp/4.x/okhttp/okhttp3/-http-url/#port) that it will have default port 80 for http or port 443 for https. the two call paths should only serve http/https address, not file:// address. it should be safe to change from java.net.URL to okhttp3.HttpUrl.

not fully related, in the case above, android will connect to `ws://www.example.com/:8097` for react-devtools
we should strip the trailing slash in *setUpReactDevTools.js*

## Changelog

[Android] [Fixed] - Fix port as -1 if dev server without specifying port on Android

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

Test Plan:
test on rn-tester with the following steps

1. `yarn start`
2. open another terminal and run `ngrok http 8081` and it will return a tunnel url, e.g. `71a1-114-36-194-97.jp.ngrok.io`
3. open dev setting in app and change the dev server to `71a1-114-36-194-97.jp.ngrok.io`
5. reload the app

Reviewed By: cipolleschi

Differential Revision: D39573988

Pulled By: cortinico

fbshipit-source-id: 397df90ab30533207bd87a3f069132d97c22c7fd
2022-09-22 04:20:44 -07:00
Nicola Corti 596111fabf Cleanup of ReactAndroid/build.gradle after AGP 7.3.x bump (#34747)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34747

Just a minor cleanup after the AGP bump.

Changelog:
[Internal] [Changed] - Cleanup of ReactAndroid/build.gradle after AGP 7.3.x bump

Reviewed By: cipolleschi

Differential Revision: D39687286

fbshipit-source-id: 441e449b51b25e4152cf1e7e7e22c7c9f1432d05
2022-09-21 04:28:34 -07:00
Luna Wei bcb58089c4 Create PointerEventState
Summary: Changelog: [Internal] - A refactor to pass the object PointerEventState containing relevant state / and also properties for pointerEvent objects

Reviewed By: vincentriemer

Differential Revision: D39626285

fbshipit-source-id: e2ff5313ef03d7d2d36c35ca459950ec07650df2
2022-09-20 12:01:07 -07:00
Luna Wei 4ca089f94c Simplify Coalescing Key
Summary:
Changelog: [Internal]
Stop using `TouchEventCoalescingKeyHelper` for tracking and stop making the distinction between traditional touch events (down, up, move) vs hover only events. The only events that currently coalesce are `onpointermove` events. This change uses just one counter now that we increment whenever some non-move event is fired.

Let me know if there's a simpler way to ensure counter doesn't overflow.
This change also ensures we're overriding `getCoalescingKey` which isn't used by Fabric but for old event emitter it might be (which we use for native animations). Part of that requires the `coalescingKey` to be a short so updated to that.

There was also a bug where I forgot to pass `mLastButtonState` to one of the dispatch calls. Will be wrokign on refactor so its less argument soup.

Reviewed By: javache

Differential Revision: D39530927

fbshipit-source-id: 689fa98580b206a480cc08121971cdf96bdbbfaa
2022-09-20 12:01:07 -07:00
Brett Lavalla 353b1b0f8b Simplify Accessibility Heading role for React Native (Android)
Summary:
The previous approach to set a heading in Android required us to trick the accessibility service into thinking that this element was the heading inside of a list, which used to be the only place you could use headings on Android.

This worked for the most part, but could cause problems in specific circumstances, such as if that element actually *was* part of a list. Since we were overriding its CollectionItemInfo, and presenting it as the first item in a single column list, the parent list could have confusing announcements such as announcing this item as "Item 1" even if it was not the first item in the actual list.

Since API 28, there has been an API to set any view as a heading (https://developer.android.com/reference/android/view/View#setAccessibilityHeading(boolean)).

This switches our implementation to use this new API via the AccessibilityNodeInfoCompat class for backwards compatibility to older API versions.

Changelog:
[Android][Changed] - Simplify Accessibility Heading role implementation.

Differential Revision: D39076827

fbshipit-source-id: 583dc1e9d2779a4efa5f98cabef506df2770d892
2022-09-19 20:30:22 -07:00
David Vacca d15a82dc31 Remove test BUCK configuration for cxxcomponents
Summary:
This diff removes the 'test' BUCK configuration for cxxcomponents, the goal of the diff is to fix a sandcastle issue:
https://www.internalfb.com/intern/sandcastle/log/?instance_id=36028797791859555&step_id=36028805144809956&step_index=6&name=Run%20arc%20focus-android

build-break
overriding_review_checks_triggers_an_audit_and_retroactive_review
Oncall Short Name: react_native

changelog: [internal] internal

Differential Revision: D39589523

fbshipit-source-id: 9cb6ab1e8a5929e7d288771f2f980db00a5a4adb
2022-09-16 16:56:54 -07:00
David Vacca 7003fcd6eb Delete react/fabric/components folder
Summary:
Delete react/fabric/components folder as this is not needed anymore

changelog: [internal] internal

Reviewed By: cortinico, makovkastar

Differential Revision: D39560229

fbshipit-source-id: b27ba1acd3bf46472bd022e78e171d7d22d7979d
2022-09-16 12:33:15 -07:00
David Vacca 85e9b073cb Move react/fabric/components -> react/cxxcomponents
Summary:
This diff moves Component and ComponentManager classes -> react/cxxcomponents. The purpose is to be able to use these classes from any platform, not only Android

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D39531533

fbshipit-source-id: 4732aa7bf59d82dae11441212975f0e225c6d458
2022-09-16 12:33:15 -07:00
David Vacca 5fb0ad0a48 Integrate execution of C++ ViewManagers in React Native Android renderer
Summary:
Execution of C++ ViewManagers in RN Android renderer

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D38725770

fbshipit-source-id: cd18e02940c4cb2559acdaf535e60f98b4cada13
2022-09-15 09:48:25 -07:00
David Vacca 0519dfeeaf Register C++ ViewManagers in React Native Renderer
Summary:
This diff integrates the registration of C++ component into React Native Android

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D38725769

fbshipit-source-id: 33eb9ebb93983c4038529748758eac3e43eec3e5
2022-09-15 09:48:25 -07:00
David Vacca a2d2a1df90 Introducing CPP View MutationWrapper
Summary:
CppViewMutationWrapper is a class that will be used to execute operations to mutate C++ Components in React Native Android

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D38725765

fbshipit-source-id: 3dfe11deb873750a78f6dbbaee82b62134908de4
2022-09-15 09:48:25 -07:00
David Vacca 53d2f1891e Introducing Registry for C++ Components in React Native renderer
Summary:
This diff introduces the APIs that will be used to register C++ components in React Native Renderer for Android

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D38725768

fbshipit-source-id: a7116b787f83544282230666d9d5acbfb1df4047
2022-09-15 09:48:25 -07:00
David Vacca c74f91957e Integrate C++ view managers into RN OSS build system
Summary:
Customize gradle/buck to be able to build fabric C++ components files

changelog: [internal] internal

Reviewed By: cortinico, sammy-SC

Differential Revision: D39448416

fbshipit-source-id: 3beddf27082728e2316e483c2541c7405e4c57f7
2022-09-15 09:48:25 -07:00
Nicola Corti 4ba9d0ecb1 Make the Android unitTests compile (#34690)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34690

While working on another part of the codebase I realized that
our Unit Tests are not compiling due to references to missing classes.
I'm cleaning them up + hooking the compileTest task inside the
`buildAll` task so at least they will be compiled on both CIs.

Changelog:
[Internal] [Changed] - Make the Android unitTests compile

Reviewed By: cipolleschi

Differential Revision: D39501945

fbshipit-source-id: 03d3e4872d6c738b8b85d1fef9302ac230e857d2
2022-09-15 07:00:43 -07:00
Sunbreak d0df6afe76 Remove Android.mk from internal Gradle task (#34687)
Summary:
`Android.mk`s are no longer used for internal Gradle tasks since [First Round of CMake files for React Android](https://github.com/facebook/react-native/commit/b676ca560d8af686276ac4b88e4feb9c5b7e468d) and [CMake setup for ReactAndroid](https://github.com/facebook/react-native/commit/e3830ddffd9260fe071e0c9f9df40b379d54cf26)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Fixed] - Remove Android.mk from internal Gradle task

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

Test Plan: None

Reviewed By: cipolleschi

Differential Revision: D39541322

Pulled By: cortinico

fbshipit-source-id: 421591effab2c1a82bcacff656360a2d02439a53
2022-09-15 06:32:49 -07:00
Paige Sun 447be62909 Fix: Install Fabric UIManager before main bundle execution
Summary:
Changelog: [Internal] Fix install Fabric UIManager before main bundle execution in Bridgeless

In iOS, fixed Bridgeless so that [UIManagerBinding::createAndInstallIfNeeded](https://github.com/facebook/react-native/blob/ce50c43986bae05ad62552be46f4d5bb4a46f097/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp#L24-L41) happens BEFORE the JS main bundle is evaluated.

Logic is unchanged in Android.

# Before
```
> UI [FBReactModule.mm:325] Initializing FBReactModule: start.
> UI [FBReactModule.mm:524] Initializing FBReactModule: end.
> UI [FBReactModule.mm:1839] Initializing RCTHost: start.
> UI [FBReactModule.mm:1891] Initializing RCTHost: end.
> UI[-[FBNavigationControllerObserver navigationController:willShowViewController:animated:]] <FBNewNavigationController: 0x7fd0e7859400> will show <FBReactRootViewController: 0x7fd0e7161a00; react_GemstoneHomeRoute> (animated: 1)
>   VJCPP ****** ReactInstance loadScript ->  evaluateJavaScript start      <--- loads Main Bundle
> UI[-[FBNavigationControllerObserver navigationController:didShowViewController:animated:]] <FBNewNavigationController: 0x7fd0e7859400> did show <FBReactRootViewController: 0x7fd0e7161a00; react_GemstoneHomeRoute> (animated: 1)
>   VJCPP ****** ReactInstance loadScript ->  evaluateJavaScript end
>   VJCPP ****** UIManagerBinding createAndInstallIfNeeded      <--- should happen BEFORE evaluateJavaScript

```

Reviewed By: RSNara

Differential Revision: D39493654

fbshipit-source-id: 4491d6de110966b2eb4f554ff4db8548899020e3
2022-09-14 14:51:27 -07:00
Joshua Selbo 59dc7f1b20 Remove support for is_androidx arg for robolectric tests (#34682)
Summary:
## Changelog

[Android] [Changed] - Remove internal buck rule arg for robolectric tests

Reviewed By: xiphirx

Differential Revision: D39452733

fbshipit-source-id: 2ef2ea6a30e99df11a6f0b65c61af841f396f7d7
2022-09-13 16:56:37 -07:00
Luna Wei e8a778d494 Add buttons
Summary: Changelog: [Internal] Add support for buttons/button property according to W3C PointerEvent spec

Reviewed By: vincentriemer

Differential Revision: D39460411

fbshipit-source-id: 3544a9b00e870a6028e37417ca9e4de5af62ef70
2022-09-13 16:11:35 -07:00
David Vacca 57b6bce58b Fix RN OSS CI
Summary:
Fix RN OSS CI

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D39474507

fbshipit-source-id: 7327fb0b078c21cecfc7a48166fbd944cdd725b7
2022-09-13 11:26:49 -07:00
David Vacca 4d74b4ae61 Remove ReactFeatureFlags.enableSpannableCache
Summary:
This diff removes the feature flag ReactFeatureFlags.enableSpannableCache and it's already disabled MC

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D39449840

fbshipit-source-id: 69a514b611c1179f2160a1bfd4c4199538738448
2022-09-13 09:48:57 -07:00
David Vacca 6f92a05c10 Remove ReactFeatureFlags.enableScrollEventThrottle
Summary:
Remove feature flag: ReactFeatureFlags.enableScrollEventThrottle

This feature has been disabled for a while

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D39449184

fbshipit-source-id: c5ad0d43462422d284e14302fb9d7b39aa37da70
2022-09-13 09:48:57 -07:00
Nicola Corti 59ae0487ce Further simplify the New App Template by don't requiring the dynamic library name (#34671)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34671

I'm simplifying the template further by:
- Do not expose a configurable dynamic library name. Let's use `appmodules`
and still allow the users to configure it, if needed.
- Move all the initialization logic inside the `JNI_OnLoad` method
- Cleanup the `DefaultReactNativeHost` to don't require a dynamic library
name but just a boolean.

Changelog:
[Android] [Changed] - Further simplify the New App Template by don't requiring the dynamic library name

Reviewed By: cipolleschi

Differential Revision: D39462948

fbshipit-source-id: 737733fc263162a0baf3b7a451e48b8616679d3b
2022-09-13 06:42:37 -07:00
Danilo Bürger 2d5db284b0 Support PlatformColor in borderColor on Android (#33544)
Summary:
PlatformColor should work on all *color style attributes on all platform.

Partially fixes https://github.com/facebook/react-native/issues/32942

## Changelog

[Android] [Fixed] - Support PlatformColor in borderColor

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

Test Plan: Open rn tester (USE_FABRIC=false) platform color api examples. Without the changes to ViewProps.java, it will error out.

Reviewed By: lunaleaps

Differential Revision: D39413519

Pulled By: NickGerleman

fbshipit-source-id: 58962ba2956aa3df45144108eec194aedf23886b
2022-09-12 15:07:19 -07:00
Nicola Corti e89bd4a375 Reduce the amount of C++ code in user space for RN-Tester
Summary:
This diff reduces the amount of C++ code in user space by:
- Moving all the C++ implementation of the .defaults package inside a `react_newarchdefaults` shared library
- Exposing only the entrypoint logic inside the RN-Tester's `OnLoad.cpp` file.

Changelog:
[Android] [Changed] - Reduce the amount of C++ code in user space for New Architecture

Reviewed By: cipolleschi

Differential Revision: D39381820

fbshipit-source-id: 9c4b5596b67b5a7ee58824319c80e325348ed06c
2022-09-12 12:48:43 -07:00
Luna Wei 5198d56f28 Stop sending PointerEvents when view is native gesture handling
Summary:
Changelog: [Internal] - Stop dispatching pointer events when a child view has indicated it wants to handle a native gesture.

In discussion and alignment with web standards, we've decided to not dispatch any pointer events during a native gesture.

Currently, on ACTION_HOVER_MOVE, we remove child views of the native gesture handling view and continue dispatching onPointerMove for ancestor views. This change removes this logic and won't dispatch a onPointerMove event at all.

For all other MotionEvent actions, this is already the case.

Also adding an example in RNTester that involves a scrollView (which handles gestures during scrolling)

Reviewed By: javache

Differential Revision: D39377157

fbshipit-source-id: cb0a719f67136e31b68d6f6e794fee10b256bf21
2022-09-12 12:17:21 -07:00
Samuel Susla 9929eadcb4 Remove MC for runtime scheduler
Summary:
Remove redundant feature flag.

Changelog: [internal]

Reviewed By: javache

Differential Revision: D39382607

fbshipit-source-id: fb0292258e6722160a6a1104aa1c8e35a4281a15
2022-09-12 07:57:51 -07:00
Nicola Corti 3120ae053f Update Android-prebuilt.mk to use the correct paths for turbomodule & fabricjni
Summary:
When I moved the C++ file around I only updated the Android-prebuilt.cmake
I haven't update the Android.mk equivalent. I'm doing it here.

Changelog:
[Internal] [Changed] - Update Android-prebuilt.mk to use the correct paths for turbomodule & fabricjni

Reviewed By: cipolleschi

Differential Revision: D39397567

fbshipit-source-id: f9f412ef4a9402f9528414af24eac06a0657f6f5
2022-09-12 04:29:33 -07:00
Gabriel Donadel Dall'Agnol 3e97d5fe58 feat: Add id prop to Text, TouchableWithoutFeedback and View components (#34522)
Summary:
This adds the `id` prop to `Text`, `TouchableWithoutFeedback` and `View` components as requested on https://github.com/facebook/react-native/issues/34424 mapping the existing `nativeID` prop to `id`. As this components are inherited by others this also adds the `id` prop support to `Image`, `TouchableBounce`, `TouchableHighlight`, `TouchableOpacity` and `TextInput`.
This PR also adds android tests ensuring that the `id` property is passed to the native view via the `nativeID` prop, these tests were based on the existing `nativeID` tests ([NativeIdTestCase.java](https://github.com/facebook/react-native/blob/main/ReactAndroid/src/androidTest/java/com/facebook/react/tests/NativeIdTestCase.java)).

## Changelog

[General] [Added] - Add id prop to Text, TouchableWithoutFeedback and View components

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

Test Plan: Ensure that the new `id` prop android tests pass on CircleCI

Reviewed By: lunaleaps

Differential Revision: D39089639

Pulled By: cipolleschi

fbshipit-source-id: 884fb2461720835ca5048004fa79096dac89c51c
2022-09-09 11:16:28 -07:00
Nicola Corti 5cb02ee5be Cleanup the Kotlin code in the .defaults package
Summary:
With the IDE autocompletion now working \o/ I was able to apply some suggestions
to the Kotlin code I wrote inside the .defaults package (like remove redudant qualifiers and similar).

Changelog:
[Internal] [Changed] - Cleanup the Kotlin code in the .defaults package

Reviewed By: cipolleschi

Differential Revision: D39348983

fbshipit-source-id: b443a6be179c85d2a4f4293051c4f26af93eb5f1
2022-09-09 03:12:13 -07:00
Rubén Norte b06cae3681 Extract use of renderer to its own module
Summary:
This diff creates a proxy module to interact with the React Native renderer. The goal of this proxy is to decouple usages of several functions (e.g.: `findNodeHandle`, etc.) from the actual renderer used in an app. This way, we can easily switch between renderers without having to change code depending on it.

This will be useful to remove a specific renderer from an app bundle when it's no longer used (e.g.: Paper on the Facebook App).

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D39205975

fbshipit-source-id: 05289c0c3c8cd26d81aa1d2163097c73ec40c6ad
2022-09-08 11:12:06 -07:00
Pieter De Baets a888f0c0a1 Fix broken systrace marker in getViewManagerNames
Summary:
Noticed this marker was not properly ended in the case where an early return happens. The fact that that early return is happening there is problematic too, so added a warning to follow-up on.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D39271917

fbshipit-source-id: 86dd5b1a46978629584f7cb0d615f2ad99d5a2f8
2022-09-08 06:10:50 -07:00
Pieter De Baets e7d7563195 Remove deprecated UIImplementationProvider
Summary:
UIImplementation(Provider) is not compatible with the new renderer (Fabric) and the relevant constructors have been marked deprecated for a while. While ReactInstanceManagerBuilder creates a default instance, it's not even used by CoreModulesPackage.

Changelog: [Android][Removed] Removed deprecated UIImplementationProvider

Reviewed By: NickGerleman

Differential Revision: D39271916

fbshipit-source-id: 20a3b02843ea9a2ba4bfc1352037239febbafc64
2022-09-08 05:35:00 -07:00
Kudo Chien 32d12e89f8 add debugging settings (#34489)
Summary:
For brownfield apps, it is possible to have multiple hermes runtimes serving different JS bundles. Hermes inspector currently only supports single JS bundle. The latest loaded JS bundle will overwrite previous JS bundle. This is because we always use the ["Hermes React Native" as the inspector page name](https://github.com/facebook/react-native/blob/de75a7a22eebbe6b7106377bdd697a2d779b91b0/ReactCommon/hermes/executor/HermesExecutorFactory.cpp#L157) and [the latest page name will overwrite previous one](https://github.com/facebook/react-native/blob/de75a7a22eebbe6b7106377bdd697a2d779b91b0/ReactCommon/hermes/inspector/chrome/ConnectionDemux.cpp#L77-L86).

This PR adds more customization for HermesExecutorFactory:
- `setEnableDebugger`: provide a way to disable debugging features for the hermes runtime
- `setDebuggerName`: provide a way to customize inspector page name other than the default "Hermes React Native"

## Changelog

[General] [Added] - Add more debugging settings for *HermesExecutorFactory*

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

Test Plan:
Verify the features by RNTester.

1. `setEnableDebugger`

```diff
 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
@@ -10,10 +10,12 @@ package com.facebook.react.uiapp;
 import android.app.Application;
 import androidx.annotation.NonNull;
 import com.facebook.fbreact.specs.SampleTurboModule;
+import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
 import com.facebook.react.ReactApplication;
 import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.react.TurboReactPackage;
+import com.facebook.react.bridge.JavaScriptExecutorFactory;
 import com.facebook.react.bridge.NativeModule;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.config.ReactFeatureFlags;
@@ -50,6 +52,13 @@ public class RNTesterApplication extends Application implements ReactApplication
           return BuildConfig.DEBUG;
         }

+        Override
+        protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
+          HermesExecutorFactory factory = new HermesExecutorFactory();
+          factory.setEnableDebugger(false);
+          return factory;
+        }
+
         Override
         public List<ReactPackage> getPackages() {
           return Arrays.<ReactPackage>asList(
```

after app launched, the metro inspector should return empty array.
Run `curl http://localhost:8081/json` and returns `[]`

2. `setDebuggerName`

```diff
 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
@@ -10,10 +10,12 @@ package com.facebook.react.uiapp;
 import android.app.Application;
 import androidx.annotation.NonNull;
 import com.facebook.fbreact.specs.SampleTurboModule;
+import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
 import com.facebook.react.ReactApplication;
 import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.react.TurboReactPackage;
+import com.facebook.react.bridge.JavaScriptExecutorFactory;
 import com.facebook.react.bridge.NativeModule;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.config.ReactFeatureFlags;
@@ -50,6 +52,13 @@ public class RNTesterApplication extends Application implements ReactApplication
           return BuildConfig.DEBUG;
         }

+        Override
+        protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
+          HermesExecutorFactory factory = new HermesExecutorFactory();
+          factory.setDebuggerName("Custom Hermes Debugger");
+          return factory;
+        }
+
         Override
         public List<ReactPackage> getPackages() {
           return Arrays.<ReactPackage>asList(
```

after app launched, the metro inspector should return an entry with *Custom Hermes Debugger*
Run `curl http://localhost:8081/json` and returns

```json
[
  {
    "id": "2-1",
    "description": "com.facebook.react.uiapp",
    "title": "Custom Hermes Debugger",
    "faviconUrl": "https://reactjs.org/favicon.ico",
    "devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D2 (https://github.com/facebook/react-native/commit/e5c5dcd9e26e9443f59864d9763b049e0bda98e7)%26page%3D1 (https://github.com/facebook/react-native/commit/ea93151f21003df6f65dd173dd5dcb3135b0ae94)",
    "type": "node",
    "webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=2&page=1",
    "vm": "Hermes"
  }
]
```

Reviewed By: mdvacca

Differential Revision: D38982104

Pulled By: cipolleschi

fbshipit-source-id: 78003c173db55448a751145986985b3e1d1c71bb
2022-09-07 12:52:37 -07:00
Rubén Norte 34e7d48472 Remove unused JSDevSupport module
Summary:
The `JSDevSupport` module is incompatible with Fabric. Given it's not used internally and it's undocumented in OSS, we decided to remove it altogether.

Changelog: [Internal]

Reviewed By: javache, nlutsenko

Differential Revision: D39305892

fbshipit-source-id: 82455701a0b9ba83e6f971fc774280dceb2b22e0
2022-09-07 12:20:58 -07:00
Riccardo Cipolleschi 12e5842e11 Fix/android (#34573)
Summary:
This PR should fix the issues introduced by commit c34659a5d3.
The problem is that `Collections.emptyList` creates a `List<Object>` which is not compatible with the `List<TargetView>` type.

## Changelog

[Android] [Fixed] - Make Android CI build again.

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

Test Plan: test_buck and the "test Docker android"  must be green.

Reviewed By: cipolleschi

Differential Revision: D39235674

Pulled By: cortinico

fbshipit-source-id: 574338e74aeb4635c67d91de28780fb784c9f405
2022-09-02 03:23:45 -07:00
Luna Wei c34659a5d3 PointerEvents: Store last hitPath, eventCoordinates for different pointers
Summary:
Changelog: [Internal] - Key cached values between different MotionEvents by pointerId.

Currently the implementation uses one cached list and array to store the last hitPath and event coordinates. We use these to determine if we've entered or left any views.

With more pointers, we need to be tracking these values for each pointer.

As well, clean up usage of `mLastTargetCoordinates`. This doesn't need to be a global as its an array that's updated by reference in `findTargetPathAndCoordinatesForTouch`

Reviewed By: vincentriemer

Differential Revision: D39152528

fbshipit-source-id: 28c18629bf974f41950401c7726a4757ad43ac28
2022-09-01 16:15:30 -07:00
Luna Wei b09821591c PointerEvents: Fix x/y coordinate system for PointerEvents, set some properties for "mouse" pointerType
Summary:
Changelog: [Internal] - Fix more pointer event platform tests.
* Fix the coordinate system to use DIP
* Set some properties for when pointerType="mouse"

Reviewed By: vincentriemer

Differential Revision: D39184713

fbshipit-source-id: d86f798f3e0a377ff1c159fb308329a2c9ae03ff
2022-09-01 13:11:44 -07:00
Luna Wei 64ae12e553 PointerEvents: Refactor JSPointerDispatcher to share logic for UP/DOWN for secondary pointers
Summary:
Changelog: [Internal] -  Refactor JSPointerDispatcher to group secondary actions (pointer_up, pointer_down) to use same logic and emit non-direct events

This diff re-arranges some code and re-uses some logic for different MotionEvent types.

Specifically, before our code for handling a motionEvent looked like
```
func onMotionEvent(event) {
    if (event is HOVER_MOVE) {
        handleHoverEvent(event)
    }
    if (event is ACTION_DOWN) {
       // logic for dispatching down, enter, over
    }
    if (event is ACTION_POINTER_DOWN) { // this represents any secondary pointer going down
       // logic for dispatching down
    }
    if (event is ACTION_MOVE) {
       // logic for dispatching touch move
    }
    if (event is ACTION_UP) {
       // logic for dispatching up, out, leave
    }
    if (event is ACTION_POINTER_UP) { // this represents any secondary pointer going up
       // logic for dispatching up
    }
   ....
}
```

now, we've refactored it to be like:
```
func onMotionEvent(event) {
    if (event is HOVER_MOVE) { // Still keep this as separate because it does some special things. Will refactor in follow-up diff
        handleHoverEvent(event)
    }

    switch() {
         case ACTION_DOWN or ACTION_POINTER_DOWN:
             // do same logic
         break;
         case ACTION_UP or ACTION_POINTER_UP:
             // do same logic
         break;
         case ACTION_MOVE:
             // do same logic, we will want to converge this logic with HOVER_MOVE, todo in a follow-up
         break;
         ...
    }
   ....
}
```
This refactor adds the functionality of `enter, over, out, leave` to secondary pointer events in which they weren't fired before.

Reviewed By: vincentriemer

Differential Revision: D39142820

fbshipit-source-id: 8b89db6dc22f24583f8c14dbb8392d4dc8ff6e4d
2022-09-01 13:11:44 -07:00
Luna Wei 823f6b7704 NativeGestureUtil.notifyNativeGestureEnded is called
Summary:
Changelog: [Internal] - Make sure `onChildEndedNativeGesture` is called for view managers that call `onChildStartedNativeGesture`

This affects `JSTouchDispatcher`, `JSPointerDispatcher` as they track what view is reporting native gesturing handling.

This is a bug that view managers never shared the fact that they've stopped managing a native gesture. Both `JSTouchDispatcher`, `JSPointerDispatcher` get around this by manually resetting their internal flag on ACTION_DOWN event (we will get rid of this in a later diff)

Reviewed By: javache

Differential Revision: D38850609

fbshipit-source-id: ef4afb591249bb621f42667608dc1ef20424b65c
2022-08-31 11:32:57 -07:00
Evan Charlton 361b310bcc fix: Correctly resolve classes with FindClass(..) (#34533)
Summary:
`JNIEnv`'s `FindClass(..)` function takes the classes in the standard
`foo/bar/Baz` class specification (unless they're special, like arrays).
Specifying them with `Lfoo/bar/Baz;` results in a
`ClassNotFoundException` being raised -- which is especially unhelpful
when intending to re-throw an exception.

The docs for `JNIEnv#FindClass(..)` can be found [here][jnienv].

[jnienv]:
  https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html#:~:text=The%20name%20argument,java/lang/String%22

## Changelog

[Android] [Fixed] - Correctly resolve classes with FindClass(..)

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

Test Plan:
No exact test plan. However, if an exception is thrown during the
rendering process, a fatal `ClassNotFoundException` is raised, rather
than having the error be passed up to the `ReactNativeManager`.

Fixes: facebook/yoga#1120

Reviewed By: amir-shalem

Differential Revision: D39133326

Pulled By: jacdebug

fbshipit-source-id: 86283b7d21aed49ed0e9027b2aef85f0108cdf9a
2022-08-30 18:49:10 -07:00
Rasmus Eneman 5451cd48bd fix: Crash if WebView is disabled (#34483)
Summary:
When the webview is updated by play store, all apps that has loaded webview gets killed. For background see https://issuetracker.google.com/issues/228611949?pli=1

We have a long-running app and don't want this to happen and while we are not using webview anywhere, we are using websockets that loads it for reading cookies, however we are not using cookies to authenticate the websocket and thus want to disable the webview to avoid loading it unnecessarily and then getting killed unnecessarily.

The webview has support for beeing disabled https://developer.android.com/reference/android/webkit/WebView#disableWebView() however as-is this crashes React Native. It seems to me like this case is very similar to not having web view installed and should be handled in the same way.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Avoid crash in ForwardingCookieHandler if webview is disabled

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

Test Plan: Add `WebView.disableWebView();` as the first line in `MainActivity.onCreate`.

Reviewed By: christophpurrer

Differential Revision: D38981827

Pulled By: cipolleschi

fbshipit-source-id: 335a8420568ad0c80b834ae8a3b164e55ebe26f3
2022-08-30 06:57:07 -07:00
Lulu Wu 4d642a2250 Fix isRootVisible not working with non-Venice
Summary:
## Context
```isRootViewVisible``` doesn't work as expected for non-Venice: when enter Marketplace tab, ```isRootViewVisible```  should returns true with Marketplace tab's rootViewTag, but it returns false.

## Root cause
```rootViewTag``` is added to "mVisibleRootTags" in "FbReactRootVisibilityTracker" when ```BaseFbReactFragment.onViewDidAppear()``` gets called, but ```BaseFbReactFragment.onViewDidAppear()``` is called earlier than when the ```rootViewTag``` is set.

## Fix
Move setRootViewTag to earlier when RootView is created instead of in startSurface or mounting.

Changelog:
[Android][Changed] - Move setRootViewTag to earlier when RootView is created

Reviewed By: RSNara

Differential Revision: D38586584

fbshipit-source-id: aec3ed37eb62289a19794e68b1a6b5ca213cb14a
2022-08-29 18:44:24 -07:00
David Vacca 38e1e25288 Introduce C++ component API
Summary:
This diff introduces the API that will be used to describe React Native Components written in C++

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D38725766

fbshipit-source-id: 292e28409ac6be8f9a1c2209b8c558e0e2cb96ea
2022-08-29 14:44:51 -07:00
David Vacca fdb8be72fc Avoid compiling subfolders of fabric folder
Summary:
Only compile files under Fabric folder, without including subfolders

changelog: [internal] internal

Reviewed By: lunaleaps

Differential Revision: D39108916

fbshipit-source-id: 5390b78cd529e7256f4e755b6d88999546fa705b
2022-08-29 14:44:51 -07:00