Commit Graph

5046 Commits

Author SHA1 Message Date
Xin Chen 97ce240a27 Update RedBoxDialog to separate content view and dialog
Summary:
This diff separates the content view creation logic from existing `RedBoxDialog` logic. After the change, `RedBoxDialog` is no longer a subclass of `Dialog`, but behaves like a dialog with forwarding pattern to delegate dialog API to internal member. This will keep the APIs consistent with dependent components.

The motivation of the change is to make the content view reusable. This is important in VR surface where we don't have activities and necessary implementations for Dialog to show.

Changelog:
[Android][Internal]

Reviewed By: javache

Differential Revision: D34016503

fbshipit-source-id: 261594bda9f6fb2d83764a1e5ec2e9e60d8d39a3
2022-02-07 15:31:15 -08:00
Xin Chen 99890bfacf Move RedBoxHandler interface to the proper interfaces directory
Summary:
We put the `:interfaces` target on the dependencies list for `:devsupport` target in the [BUCK file](https://fburl.com/code/lrr1c0pn). In the following diffs I will need to put the interface [`/devsupport/RedBoxHandler`](https://fburl.com/code/v53euvps) on to [`/devsupport/interfaces/DevSupportManager`](https://fburl.com/code/k8gwxa0f). This violates the dependency rule.

Since `RedBoxHandler` is an interface, I moved it to the interfaces list in this diff to unblock.

Changelog:
[Android][Internal]

Reviewed By: yungsters

Differential Revision: D33987834

fbshipit-source-id: 77a1ee14bd10c6bbaac2ee465ae7050e99ed0399
2022-02-07 13:43:49 -08:00
Samuel Susla 731429ebcf Enable RuntimeScheduler::callExpiredTasks on Android
Summary:
changelog: [internal]

In order to call `RuntimeScheduler::callExpiredTasks`, we need to pass it to `Scheduler` through context container.

Reviewed By: javache

Differential Revision: D34042293

fbshipit-source-id: 62d18507fb107c5be2ac9d003f63735aab6a09ac
2022-02-07 10:06:08 -08:00
Genki Kondo be260b9f47 Fix ScrollView contentOffset
Summary:
When setting ScrollView's contentOffset, if the ScrollView hasn't been laid out yet when ReactScrollViewManager.setContentOffset is called, then scroll position is never set properly. This is because the actual scroll offset (0, 0) was being passed into setPendingContentOffsets, instead of the desired scroll offset. Thus,
when ReactScrollView.onLayout gets called, ReactScrollView.scrollTo gets called with (0, 0).

Also updates out of date comments,

Changelog:
[Android][Fixed] - Fix ScrollView contentOffset

Reviewed By: ryancat

Differential Revision: D34015853

fbshipit-source-id: 84141a663fdb0ace2be7cef61f14944cb08125d1
2022-02-04 16:28:54 -08:00
David Vacca 7cc7e66564 Update javadoc of ReactRoot.getState()
Summary:
Update javadoc of ReactRoot.getState() since the task was fixed and the API remained the same

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D33981298

fbshipit-source-id: 0136a640b884a787b0a20162781735630c1fa1c7
2022-02-04 10:34:52 -08:00
Samuel Susla 4cbcb7a13a Abandon mc react_fabric.enable_event_emitter_wrapper_raw_pointer
Summary:
changelog: [internal]

Remove gating.

Reviewed By: philIip

Differential Revision: D33944220

fbshipit-source-id: bba076a2166f8d676119d5c069a3894e3d547285
2022-02-03 04:50:04 -08:00
Genki Kondo 08faa130dd Delete ReactFeatureFlags.enableRoundedCornerPostprocessing
Summary:
Rounded corner postprocessing has been disabled for 2 months now, and [metrics neutral](https://www.internalfb.com/intern/qe2/react_fabric_marketplace_home_android_universe/react_fabric_disable_rounded_corner_postprocess_android/setup/config). Removing the flag and associated codepaths.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33953645

fbshipit-source-id: b0e5a6068114d74292f17450a22816f19cae6f15
2022-02-02 15:55:54 -08:00
John Porto 1bf84a63d8 Make automatic SampleProfiling registration optional.
Summary:
This change makes automatic sample profiling registration opt in. This is in preparation for an upcoming change where hermes
will enforce that the sampling profiler must be destroyed on
the same thread it was created.

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D33826992

fbshipit-source-id: 89843b5fc5b936f674a8d0a470e92af0cd8f6125
2022-02-02 10:52:56 -08:00
Andrei Shikov 65df2f30a5 Support view allocation counters with Venice
Summary:
Venice uses `SurfaceHandler` abstraction which start/stops surfaces independently from `Binding.cpp`, so previous `onSurfaceStart/Stop` callback would not be triggered.

On Android, each surface is used exactly once at the time of writing, so we can use `register/unregister` callbacks to create/clear remembered views for the surface.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D33845685

fbshipit-source-id: 8de4204c7498176fdbe8d44fbc5f2e4079212a1c
2022-02-02 09:17:56 -08:00
Genki Kondo cb42049e0a Support platform color with AnimatedColor on Android
Summary:
Adds support for platform colors in AnimatedColor.
Passes the processed native color object to the native ColorAnimatedNode via the native config; ColorAnimatedNode then uses ColorPropConverter.getColor to resolve the resource path.

Note: setting a platform color via setValue on an existing AnimatedColor is not supported yet

Changelog:
[Android][Added] - Support platform color with AnimatedColor

Reviewed By: yungsters

Differential Revision: D33922266

fbshipit-source-id: 04d39a5ce0872b31d06ffbd4639d2f2213cf3314
2022-02-01 16:12:30 -08:00
Felipe Perez 3552ff0562 Back out "Delete RuntimeScheduler yielding mobile config"
Summary:
D33740360 (https://github.com/facebook/react-native/commit/16ed62a850dd81bd9cc7f77ab3e77f42ed64b177) broke Explore VR on React Native. The app would go into a loop on boot and not finish mounting. This is probably a product code issue, but it's not a trivial issue to solve. Unlanding to unblock the RN migration.

Changelog:

[internal] internal

Reviewed By: mdvacca

Differential Revision: D33918026

fbshipit-source-id: cc77c70ece9994d82c91f7ae8783e959629e9cfb
2022-02-01 15:17:14 -08:00
Pieter De Baets 79975d146e Fix display metric used for scrollview snapping
Summary:
Similarly to D29864944 (https://github.com/facebook/react-native/commit/6d4fff2e5ccaffb6b0255a139f2ae8e009278948) we want to use `getWindowDisplayMetrics` instead of `getScreenDisplayMetrics`.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33916223

fbshipit-source-id: cae07b1f0c1498745f28d0b9f860edcc55bde5ed
2022-02-01 10:58:25 -08:00
Keshav Kolur 554b35daf4 Revert D33852709: Replace fb_xplat_platform_specific_rule calls where rule = fb_java_library with direct call to fb_java_library_android
Differential Revision:
D33852709 (https://github.com/facebook/react-native/commit/dc507be4d9a9d3edce4b2a0b2b7a0cbbcd0cffd0)

Original commit changeset: 1ff3a1225e68

Original Phabricator Diff: D33852709 (https://github.com/facebook/react-native/commit/dc507be4d9a9d3edce4b2a0b2b7a0cbbcd0cffd0)

fbshipit-source-id: 10db2d1bda1ea69b9a0226041493af06b78c16c4
2022-01-31 14:15:36 -08:00
Keshav Kolur dc507be4d9 Replace fb_xplat_platform_specific_rule calls where rule = fb_java_library with direct call to fb_java_library_android
Summary: Replace fb_xplat_platform_specific_rule calls where rule = fb_java_library with direct call to fb_java_library_android

Reviewed By: alexmalyshev

Differential Revision: D33852709

fbshipit-source-id: 1ff3a1225e681d0924ec04e955b0039724182b1c
2022-01-31 13:41:23 -08:00
Kuba Holuj 50c8e973f0 Update StatusBar for Android 11+ (#32975)
Summary:
Android 11 (API 30) introduced a new interface for changing the appearance of the status bars with [`WindowInsetsController#setSystemBarsAppearance`](https://developer.android.com/reference/kotlin/android/view/WindowInsetsController#setsystembarsappearance) and deprecated using the `WindowManager#systemUiVisibility` properties.

Apparently, once you call `setSystemBarsAppearance` Android will no longer respect `systemUiVisibility` and if anyone, such as the Android 12 Splash Screen library, happens to call it, it will break status bars.

This PR augments the RN StatusBarModule to use the new interface on Android 11+.

Also updated the rn-tester app, see video.

https://user-images.githubusercontent.com/1124321/151321561-8202e237-cf7d-45ce-b957-18b5bafd17c4.mov

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Changed] - Use new StatusBar API on Android 11 (API 30)+

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

Reviewed By: cortinico

Differential Revision: D33814853

Pulled By: ShikaSD

fbshipit-source-id: c0f2651015dddb4871a3e3b26642f76a46da2a76
2022-01-31 11:32:51 -08:00
Elias Nahum 6239e2f5ce Android: Fix crash when WindowInsets is null on ReactRootView (#32989)
Summary:
Fixes a potential crash was introduced by https://github.com/facebook/react-native/issues/30919 that aimed to get the keyboard height on devices with a Notch. The problem is that it considers that any ReactRootView will have an insets available.

When using [react-native-navigation](https://github.com/wix/react-native-navigation) and assigning a Navigation button to the TopBar as a component, the component gets registered as a RootView but won't have any insets attach to the view.

[getRootWindowInsets()](https://developer.android.com/reference/android/view/View#getRootWindowInsets()) in fact return a `WindowInset` only available if the view is attached, so when executing `checkForKeyboardEvents` method from ReactRootView, is trying to access the `DisplayCutout` of a null object, leading to a crash.

## Changelog

[Android] [Fixed] - Fix potential crash if ReactRootView does not have insets attached.

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

Test Plan:
Without the code change: Notice how the second screen being push contains a React Component on the top right of the navigation bar, and when component is unmounted (going back) the app crashes.

https://user-images.githubusercontent.com/6757047/151558235-39b9a8b5-be73-4c31-8053-02ce188637b8.mp4

crash log
```
2022-01-28 10:27:52.902 15600-15600/com.mattermost.rnbeta E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mattermost.rnbeta, PID: 15600
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.DisplayCutout android.view.WindowInsets.getDisplayCutout()' on a null object reference
        at com.facebook.react.ReactRootView$CustomGlobalLayoutListener.checkForKeyboardEvents(ReactRootView.java:778)
        at com.facebook.react.ReactRootView$CustomGlobalLayoutListener.onGlobalLayout(ReactRootView.java:769)
        at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:1061)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3214)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2143)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8665)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1037)
        at android.view.Choreographer.doCallbacks(Choreographer.java:845)
        at android.view.Choreographer.doFrame(Choreographer.java:780)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7839)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
```

After applying the patch which is only a null check validation and does not change any previous behavior

https://user-images.githubusercontent.com/6757047/151558429-9ff1a608-abb6-4168-8db9-df0c3c71d79e.mp4

Reviewed By: cortinico

Differential Revision: D33844955

Pulled By: ShikaSD

fbshipit-source-id: ed5579ad3afeed009c61cc1851eee45c70087cf5
2022-01-31 07:58:28 -08:00
Genki Kondo 3f49e6763e Support color animation with native driver for Android
Summary:
Adds support for Animated.Color with native driver for Android. Reads the native config for the rbga channel AnimatedNodes, and on update(), converts the values into an integer (0xaarrggbb)

Followup changes will include support for iOS and platform colors.

Changelog:
[Android][Added] - Support running animations with AnimatedColor with native driver

Reviewed By: javache

Differential Revision: D33833600

fbshipit-source-id: 2bf05c9715b603cf014ace09e9308b2bfd67f30a
2022-01-29 13:51:41 -08:00
Paige Sun 79ae50f3e9 Remove Static View Configs from bridge mode
Summary:
Changelog: [Internal]

Remove all the MCs that enable SVCs in Fabric, because we'll only test SVCs in Bridgeless mode to simplify rollout. There were complications with enabling SVCs in Fabric at a previous rollout.

Reviewed By: RSNara

Differential Revision: D33861243

fbshipit-source-id: fdbfedce77f8bd1bab2a807237017787ae8bf7c1
2022-01-28 23:39:38 -08:00
Paige Sun b4b5c59645 Add ComponentNameResolverManager to make UIManager.hasViewManagerConfig() work on Venice
Summary: Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D33860658

fbshipit-source-id: 41079b13acef531877c82dc0b2063dbe2b42edcf
2022-01-28 18:46:04 -08:00
Pieter De Baets b3c69e85d7 Use AssetManager buffer instead of copying bundle
Summary:
The current JSLoader implementation (on Android) will copy the buffer into a JSBigBufferString during startup. This duplicates work Android is already doing (it allocates creates a copy of the bundle in memory while decompressing the asset from the APK) or worse, if the APK is mmap'ed this will unnecessarily create dirty memory.

The risk with this approach is that the bundle loaded from disk is no longer \0 terminated, but that's also the case for the bundles we load with `JSBigFileString` and is not an issue as  far as I can tell.

Changelog: [Internal]

Reviewed By: mhorowitz

Differential Revision: D33792735

fbshipit-source-id: 61fc089a223f3602d3575340d79a8de2ec92d8a0
2022-01-28 02:55:42 -08:00
David Vacca 34dcbfb8d9 Ship ReactFeatureFlags.enableScrollViewSnapToAlignmentProp
Summary:
This diff ships ReactFeatureFlags.enableScrollViewSnapToAlignmentProp, QE showed neutral metrics in fb4a

changelog: [internal] internal

Reviewed By: philIip

Differential Revision: D33781627

fbshipit-source-id: d4e52d8bdf1acb4904e92f13b7d721582d140ba3
2022-01-27 17:03:26 -08:00
David Vacca 11b7443afb Delete ReactFeatureFlags.enableReactContextCleanupFix
Summary:
This diff deletes the flag ReactFeatureFlags.enableReactContextCleanupFix, the flag was disabled for many months, I just disable it.

changelog: [internal] internal

Reviewed By: genkikondo, makovkastar

Differential Revision: D33781628

fbshipit-source-id: 4b5e22adf9d30da5b85bbbde8bdc98d98f5e8891
2022-01-27 17:03:26 -08:00
David Vacca 9abcea7e11 Delete enableFabricInLogBox flag
Summary:
This diff deletes the ReactFeatureFlag enableFabricInLogBox, from now on Logbox will be rendered in Fabric when Fabric is enabled

changelog: [internal] internal

Reviewed By: genkikondo

Differential Revision: D33781626

fbshipit-source-id: 3187a22fec80125afd27860995637564640dab8d
2022-01-27 17:03:25 -08:00
Xin Chen 67355f6c74 Update PointerEvents static method to reduce duplication
Summary:
This diff updated `PointerEvents` enum to reduce duplication for null checks on pointer events string.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D33717223

fbshipit-source-id: ff542a05240393416d85651ca08cd55136eb79a4
2022-01-27 11:17:55 -08:00
owjsub d6db5c5464 Android: upgrading OkHttp from 4.9.1 to 4.9.2 to fix CVE-2021-0341 (#32968)
Summary:
Security vulnerability CVE-2021-0341 is present in okhttp 4.9.1. Upgrading to 4.9.2 will resolve the issue.

http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2021-0341

## Changelog

[Android] [Security] - Upgraded okhttp to 4.9.2 to fix CVE-2021-0341

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

Test Plan: Upgrading okhttp 4.9.1 to 4.9.2 should be backwards compatible per https://github.com/square/okhttp/blob/master/CHANGELOG.md#version-492. Should be safe to merge if CircleCI tests pass.

Reviewed By: ShikaSD

Differential Revision: D33788131

Pulled By: cortinico

fbshipit-source-id: e9593a42a8e40a903ee6f529d94c82adcf5d0977
2022-01-27 07:23:03 -08:00
Xin Chen 45244ebce2 Fix TouchTargetHelper to correctly use the overflowInset information
Summary:
The overflowInset uses negative values to indicate extending from parent view. This diff fixes the math so that it's correctly check if the point is within overflowInset.

Changelog
[Android][Fixed] - Fix math for detecting if children views are in parent's overflowInset area.

Reviewed By: genkikondo

Differential Revision: D33750129

fbshipit-source-id: 1a5a33a227280c687b158b4a81a56017b6f4f3e0
2022-01-26 19:23:13 -08:00
Samuel Susla 16ed62a850 Delete RuntimeScheduler yielding mobile config
Summary:
changelog: [internal]

Yielding in RuntimeScheduler is shipped. This diff removes the gating around it.

Reviewed By: sshic

Differential Revision: D33740360

fbshipit-source-id: 267372e81e66dda96e451435954a7c3546cc6fbe
2022-01-26 09:23:08 -08:00
David Vacca 93677cecde Ship eager initialization of mapbuffer
Summary:
Ship eager initialization of mapbuffer

changelog: [internal] internal

Reviewed By: ShikaSD

Differential Revision: D33754255

fbshipit-source-id: 1b8359b8c9fbc4fc7a155cb73e9147fd5b1f5963
2022-01-25 17:23:30 -08:00
David Vacca 9df02fff6b Eager initialize Fabric in RN VR apps
Summary:
Enable eager intialization of FabricUIManager during intiialization of React Native.
This feature highly improved TTRC in Markeptlace Home

changelog: [internal] internal

Reviewed By: genkikondo

Differential Revision: D33585099

fbshipit-source-id: 0ffbc720bcb1edd1b04180189a52c82e9e2fa800
2022-01-25 17:23:29 -08:00
Xin Chen 48f6967ae8 Add pointerEvents prop to RN Android scroll views
Summary:
Per discussion in the previous diff D33672110, it's ok to add the `pointerEvents` prop to scrollview. This will help prevent scrolling on the ScrollView if pointerEvents is set to `box-none`, or `none`.

Corresponding doc changes are in https://github.com/facebook/react-native-website/pull/2936

Changelog:
[Android][Added] - Add new API in ScrollView and HorizontalScrollView to process pointerEvents prop.

Reviewed By: javache

Differential Revision: D33699223

fbshipit-source-id: 1cae5113e9e7d988fc4c4765c41d817a321804c4
2022-01-21 13:40:09 -08:00
Ramanpreet Nara 0343e697fd Fix NVC for RCTTextInlineImage
Summary:
This diff fixes the Static/Native ViewConfigs for RCTTextInlineImage.

Changelog: [Internal]

Reviewed By: p-sun, sshic

Differential Revision: D33674127

fbshipit-source-id: 8cf5ffeaca635b4afd30c437dc0f87ea1fdc15a8
2022-01-20 13:52:03 -08:00
Ramanpreet Nara 26d05d8dd7 Fix SVC for RCTModalHostView
Summary:
Making the native ViewConfig for RCTModalHostView match its static ViewConfig.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D33303419

fbshipit-source-id: 6fac237d670ee221ad867f79e54d5a3576c156da
2022-01-20 13:52:03 -08:00
Andrei Shikov adb2167640 Serialize and assert type information in mapbuffer
Summary:
Serializes type information along with key/value in MapBuffer, asserting the data type on Java side during read. At the moment, accessing value with incorrect will result in a crash.

Other changes:
Adds a `getType` method to verify types before accessing them.
Removes `null` as a type, as just not inserting value and checking for its existence with `hasKey` is more optimal.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33656841

fbshipit-source-id: 23a78daa0d84704aab141088b5dfe881e9609472
2022-01-20 12:57:22 -08:00
CodemodService FBSourceClangFormatLinterBot ceb01db25f Daily arc lint --take CLANGFORMAT
Reviewed By: zertosh

Differential Revision: D33677079

fbshipit-source-id: 997b73bebdcf83e09138bddc4bce257d0740e874
2022-01-20 04:09:51 -08:00
Janic Duplessis 3a07dcf81e Allow passing ReadableNativeMap/Array to push/put methods (#32910)
Summary:
This allow adding ReadableNativeArray/Map to a WritableNativeArray/Map. There is no reason why this can't be allowed, the types were actually updated in https://github.com/facebook/react-native/commit/1a2937151b8d36e8741ef9d4fbe7d2ebf65cb775#diff-d1dc45892b3ba242aed9a1bf7219d2838fae8c7a654c402ba70bc4b100149624, but the assertion remains.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Internal] [Added] - Allow passing ReadableNativeMap/Array to push/put methods

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

Test Plan: Tested that RN tester builds and run correctly on android.

Reviewed By: christophpurrer

Differential Revision: D33646510

Pulled By: yungsters

fbshipit-source-id: 878f1994b73ed1cf830966ab296b9c0325630da1
2022-01-19 11:17:00 -08:00
Sam Kline c8d823b9bd Reset ReactInstanceManager state on failure to allow retries (#32901)
Summary:
This fixes https://github.com/facebook/react-native/issues/32898 by reseting ReactInstanceManager state when `createReactContext` throws. By resetting the state, we allow future attempts at creating the React context.

## Changelog

[Android] [Fixed] - Fixed empty screen after retrying a BundleDownloader failure in dev mode

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

Test Plan: Go through the steps to reproduce listed in https://github.com/facebook/react-native/issues/32898 and see that the React Native application starts.

Reviewed By: cortinico

Differential Revision: D33634178

Pulled By: ShikaSD

fbshipit-source-id: e54d12d5f33c9c7c0ca213113871b88c2f1dc261
2022-01-19 05:06:18 -08:00
Andrei Shikov b173bf3c0e Minor MapBuffer renames for consistency
Summary:
Rename `_header` to `header_` to align with the C++ naming scheme we use.
Rename `readKey` to `readUnsignedShort` as purpose of the method have changed.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D33637127

fbshipit-source-id: a82f4d6c1b753b21e0567fbe919af98e4c78105d
2022-01-18 18:00:07 -08:00
Joshua Gross 2151d11527 Fix T110060790
Summary:
In the case of T110060790, there is a JavaScript crash that causes RN teardown to race with a ScrollView event being emitted, which ends up being reported as the "real" cause of the crash.

This is not correct, and it's better to just ignore this case. If there's no EventDispatcher, it means something has gone wrong (usually teardown) before, RN is in an inconsistent state, and we should
not crash here or report here.

Changelog: [Android][Fixed] Fix crash from ScrollView that occurs while reporting an error from JS

Reviewed By: mdvacca

Differential Revision: D33644692

fbshipit-source-id: 41c3defde795b804239cc8401c8aff71d017d59d
2022-01-18 16:15:37 -08:00
Pieter De Baets 08e76772fe Avoid repeated value read in SubtractionAnimatedNode
Summary:
Minor optimization, but spotted this while reviewing the implementation for D33622997

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33622996

fbshipit-source-id: 8712753803fc46e6a046d50f77454a813e4a641a
2022-01-18 13:53:43 -08:00
Pieter De Baets b2105711a0 Support Animated.event extracting values from array
Summary:
`onPointerMove` events get dispatched with an `offset: [x, y]` attribute (API is not yet available in OSS, so subject to change), but `EventAnimationDriver` in RN Android is not able to extract values with such keys (even though the equivalent JS implementation does allow it).

(TODO: verify iOS behaviour)

Changelog:
[General][Added] - Animated.event can be used to extract values with numeric keys from native events

Reviewed By: mdvacca

Differential Revision: D32531117

fbshipit-source-id: 918a5443c5d8f5f8200d86bb67f84e8bc175c1d3
2022-01-18 13:53:43 -08:00
Andrei Shikov a054379a54 Remove short conversions in MapBuffer
Summary:
MapBuffer uses unsigned short in C++, but Java doesn't really have a type that represents that. That means that MapBuffer would be limited to max 32768 values instead of 65536, which doesn't make much sense as a limitation.
Considering weird (and usually not performant) handling of short values in Java in general, this change replaces them with ints, converting keys from short when needed with `key & 0xFFFF`.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D33595308

fbshipit-source-id: a7adde8a207bb4aa1d81d367ab5d7b41ace2e291
2022-01-17 11:13:15 -08:00
Andrei Shikov ead669524e Check if the allocated views set for exists for surface on mount
Summary:
Adds a check to verify that we are not trying to insert a new view id into a non-existent set.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D33621031

fbshipit-source-id: 8468af69bea250a70d656789ea819c39b55a9de6
2022-01-17 06:32:37 -08:00
Ramanpreet Nara 28f5abc717 Fix NVC for RCTSlider
Summary:
## Android Failures
```
LOG  SVC RCTSlider Invalid
 LOG  {
  "missing": {
    "directEventTypes": {
      "topSlidingComplete": {
        "registrationName": "onSlidingComplete"
      }
    }
  },
  "unexpected": {
    "bubblingEventTypes": {
      "paperValueChange": {
        "phasedRegistrationNames": {
          "captured": "onValueChangeCapture",
          "bubbled": "onValueChange"
        }
      },
      "topValueChange": {
        "phasedRegistrationNames": {
          "captured": "onValueChangeCapture",
          "bubbled": "onValueChange"
        }
      }
    },
    "directEventTypes": {
      "paperSlidingComplete": {
        "registrationName": "onSlidingComplete"
      }
    },
    "validAttributes": {
      "disabled": true,
      "maximumTrackImage": {
        "process": "[Function resolveAssetSource]"
      },
      "minimumTrackImage": {
        "process": "[Function resolveAssetSource]"
      },
      "thumbImage": {
        "process": "[Function resolveAssetSource]"
      },
      "trackImage": {
        "process": "[Function resolveAssetSource]"
      }
    }
  },
  "unequal": {}
}
```

## iOS Failures
```
 LOG  SVC RCTSlider Invalid
 LOG  {
  "missing": {},
  "unexpected": {
    "bubblingEventTypes": {
      "paperValueChange": {
        "phasedRegistrationNames": {
          "captured": "onValueChangeCapture",
          "bubbled": "onValueChange"
        }
      }
    },
    "directEventTypes": {
      "paperSlidingComplete": {
        "registrationName": "onSlidingComplete"
      }
    },
    "validAttributes": {
      "enabled": true
    }
  },
  "unequal": []
}
```

Reviewed By: yungsters

Differential Revision: D33409401

fbshipit-source-id: 519b6e35246e6671dbea1f374435d92937d96c1d
2022-01-14 16:31:50 -08:00
Andrei Shikov f33892081a Cleanup ReadableMapBuffer
Summary:
Cleans up `ReadableMapBuffer` APIs and migrates to use `std::vector` instead of raw pointer array.

Also uses `fbjni` utility to allocate the bytes instead of making manual JNI calls.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D33513027

fbshipit-source-id: afe7d320d12830503de4c9994117d849f0b25245
2022-01-12 08:13:32 -08:00
grgr-dkrk 36037fa81b feat: add accessibilityLabelledBy props (#32470)
Summary:
related: https://github.com/facebook/react-native/issues/30846, https://github.com/facebook/react-native/issues/26739

Added `accessibilityLabelledBy` props to find the nativeID of the associated label, it mainly for` <TextInput> `.

The reason for implementing it as `labelledBy` instead of `labelFor` is as follows.
- It was difficult to find a component with `labelFor` because the `<Text>` component does not add the `labelFor` received from her Props to the View's tag.
- The use case looks like the HTML `aria-labelledby`, which is intuitive for web developers. It also seems easy to convert to a web platform.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Added] - add `accessibilityLabelledBy` props

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

Test Plan:
I checked it with RNTester using an Android11.

https://user-images.githubusercontent.com/40130327/138666856-891d9f4d-52cf-4181-a81f-13b033037db4.mp4

Reviewed By: lunaleaps, kacieb

Differential Revision: D31897112

Pulled By: ShikaSD

fbshipit-source-id: 66361735679560c01834b3a4483adf264098b3e3
2022-01-11 06:51:39 -08:00
Ramanpreet Nara ae6a84e70d Fix NVC for AndroidProgressBar
Summary: Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33341772

fbshipit-source-id: eddd344135e6deed60c21eb838a244753e2204b5
2022-01-11 00:24:41 -08:00
Ramanpreet Nara 848e34e753 Fix SVC/NVC for AndroidDrawerLayout
Summary:
## Failures
```
 LOG  SVC AndroidDrawerLayout Invalid
 LOG  {
  "missing": {},
  "unexpected": {
    "directEventTypes": {
      "topDrawerOpened": {
        "registrationName": "onDrawerOpen"
      },
      "topDrawerClosed": {
        "registrationName": "onDrawerClose"
      }
    },
    "validAttributes": {
      "keyboardDismissMode": true,
      "drawerBackgroundColor": {
        "process": "[Function processColor]"
      },
      "statusBarBackgroundColor": {
        "process": "[Function processColor]"
      }
    }
  },
  "unequal": []
}
```

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D33409393

fbshipit-source-id: 9fa5b6cd5c8fc9bc01d825eb8fb7965c5cb691d2
2022-01-11 00:24:41 -08:00
Lulu Wu 705236e363 Remove unused import of JMessageQueueThread.h
Summary:
As title.

Changelog:
[Android][Changed] - Remove unused import of JMessageQueueThread.h

Reviewed By: philIip

Differential Revision: D33477760

fbshipit-source-id: a62bd9bb34f5a08446a59fbd7fd1b0cd27dd6606
2022-01-07 15:54:18 -08:00
Mengke Ding a03bd2f13e A quick fix for inital fb4a_debug launch crashes due to fetching string com.facebook.react.R.string.catalyst_sample_profiler_enable
Summary: Changelog: [Android][Internal] - a quick fix for inital fb4a_debug launch crashes due to fetching string `com.facebook.react.R.string.catalyst_sample_profiler_enable`

Reviewed By: paveldudka

Differential Revision: D33410712

fbshipit-source-id: f63e4b7e9aba3e79d4aa11983d68fee7341972bb
2022-01-05 16:37:59 -08:00
Ramanpreet Nara 4b9e4fa1ef Codemod: Make Android native ViewConfigs inherit parents' bubbling/direct events
Summary:
# Problem
1. Static ViewConfigs on **both platforms** contain their parent component's inherited bubbling/direct events (and props).
2. On Android, native ViewConfigs for child components **do not** inherit bubbling/direct events from their parent. (They do inherit the props, however).

# Cause

How child components inherit props from their parent component on Android:
1. A ViewManager's native props are calculated by [calling ViewManager.getNativeProps()](https://www.internalfb.com/code/fbsource/[5769b6d6ca123b2bed31dc2bc6bc8e4701581891]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java?lines=139)
2. Which [calls into ViewManagerPropertyUpdater.getNativeProps()](https://www.internalfb.com/code/fbsource/[11f0031c5e83d4d8903112d7d720b58981d3613f]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java?lines=278-280)
3. Which [calls into a code-generated $$PropsSetter object](https://www.internalfb.com/code/fbsource/[11f0031c5e83d4d8903112d7d720b58981d3613f]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerPropertyUpdater.java?lines=73-74%2C112)
4. The ReactProp annotation processor [code-generates a $$PropsSetter object](https://www.internalfb.com/code/fbsource/[cbc8ca6036219069ad52fb6aec66488b7a06a879]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java?lines=265) by [visiting the ViewManager’s *entire class hierarchy* in search of ReactProp annotations](https://www.internalfb.com/code/fbsource/[cbc8ca6036219069ad52fb6aec66488b7a06a879]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java?lines=203-230).

Why child components don't inherit direct/bubbling events from their parents:
1. When we get the bubbling/direct events for a component on Android, we just call into the child ViewManager, which didn't forward its parent's props (until this diff):

https://www.internalfb.com/code/fbsource/[5769b6d6ca123b2bed31dc2bc6bc8e4701581891]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java?lines=113%2C122

# Fix

Codemod all components to manually forward the bubbling/direct events from their parents.

Why Not:
- Leads to a lot of boilerplate code.
- Feels like a bandaid solution.
- Doesn’t scale to open source. There’s more process when authoring new components.
- Are thre more idiomatic alternative solutions? (See alternatives considered).

Why:
- It’s a bandaid solution, yes. And it doesn’t scale well to other components, true. But, we’re only bloating deprecated APIs. Long term, we’re going to kill off getExportedCustomBubblingEventTypeConstants() and getExportedCustomDirectEventTypeConstants().
- Our goal is to just unblock Static ViewConfigs. This is the simplest/safest/least intrusive way to accomplish our goal.

# FAQ
**If child components don't contain their parents bubbling/direct events, how can they can respond to their parent's bubbling/direct events?**
- Bubbling/direct events are stored in a [global map](https://www.internalfb.com/code/fbsource/[2de1e1d59f6e0316868a6c4d9bca5fe673210106]/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js?lines=20-34). Once *one* component registers a bubbling/direct event, all components [can respond to that event](https://www.internalfb.com/code/fbsource/[2de1e1d59f6e0316868a6c4d9bca5fe673210106]/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.js?lines=2439-2440).

**How does this component prop/event inheriting work on iOS?**
1. On iOS, ViewConfigs have a baseViewConfig property.
2. All components at least have baseViewConfig = RCTViewManager.
3. To create the native ViewConfig for the component, JavaScript runs this loop:

https://www.internalfb.com/code/fbsource/[058bc6c4976d4cebb442dd2675a2a0570a214403]/xplat/js/react-native-github/Libraries/ReactNative/getNativeComponentAttributes.js?lines=42-61

# Alternative Solutions
***Solution 1:** Make Android components leverage baseViewConfig, like iOS.*

Why Not:
- baseViewConfig leads to unnecessary round trips from JS → Native (see [this TODO](https://www.internalfb.com/code/fbsource/[a88c9751494f1ee863a76238b532fca2b134032d]/xplat/js/react-native-github/Libraries/ReactNative/getNativeComponentAttributes.js?lines=34-35) that tells us we should avoid this on iOS).

***Solution 2:** In [UIManagerModuleConstantsHelper](https://www.internalfb.com/code/fbsource/[6717cba1e0db71777cf11dcf7b861b171bfd0c84]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java?lines=105-145), which generates the native ViewConfig for Android components, use Java reflection APIs to visit the class hierarchy of all ViewManagers when collecting bubbling/direct events.*

Complications:
- **Challenging to Implement**: Have to rely on advanced Java reflection APIs. You can’t just do getSuperclass().getDeclaredMethod(...).invoke(object) to invoke an overridden method.
- **Challenging to Ship**: Would lead to a penalties when creating native view configs: either performance, or memory. This negatively impacts VR and legacy React Native android.

***Solution 3:** Create a deprecated ReactProp-like annotation (e.g: ReactEvent) but for declaring bubbling/direct events in Java ViewManagers for zero runtime cost event declaration.*

Details:
- Legacy React Native infra will be code-modded to newer ReactEvent annotation infra.
- The ReactEvent annotation processor will navigate the ViewManager’s class hierarchy at build-time to generate a class that returns the ViewManager’s bubbling/direct events.
- UIManagerModuleConstantsHelper will call into this class to get the bubbling/direct events.
- **Aside:** The component codegen can also generate these annotations. This way, all you need to do is hook up your ViewManagers to codegen to guarantee that your native component exports the right bubbling/direct events to JavaScript.

Why Not:
- This is a lot of throwaway work for just making the SVC === NVC check pass, which we're only doing to unblock the SVC migration.

Why is this throwaway work?
- Java ViewManagers don’t do anything special in native with the Bubbling/Direct events. They declare the Bubbling/Direct events for JavaScript consumption. If JavaScript is the source of truth, then there’s no value in sending these Bubbling/Direct events to Java ViewManagers.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D33303418

fbshipit-source-id: 8d99fe80f83244443406bcfdc6cfea43b26f9c75
2022-01-04 16:04:16 -08:00