Commit Graph

4341 Commits

Author SHA1 Message Date
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
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
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
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
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
David Vacca f3d0a67a73 Add logs in RN Android
Summary:
Easy diff that adds logs in RN Android

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D33350749

fbshipit-source-id: 301702ce94b684431de3c0a1bafcf318be7aecd6
2021-12-29 10:32:52 -08:00
Andrei Shikov a7104b03e7 Remember preallocated views on mounting layer
Summary:
Adds an experimental replacement for preallocation revision checks on Android mounting layer. Instead of checking revisions of props, we remember tags of preallocated/previously allocated views and use this as a filter to avoid issuing extra create and preallocate commands on copy.
This method is a bit more expensive on memory, but is more precise than relying on revisions.

Changelog: [Internal]

Reviewed By: sammy-SC, mdvacca

Differential Revision: D33038768

fbshipit-source-id: fc98c2a7912e162a3845ca80488635bffaf8cc7f
2021-12-23 18:56:51 -08:00
David Vacca 05ce2cf259 Refactor duplicated code in ReactRootView
Summary:
Quick refactor of ReactRootView where I extract 'Fabric' check into a method

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D33269025

fbshipit-source-id: 2647d5870f3b5fcc5a940a5924a39ca43b5bebac
2021-12-22 02:57:56 -08:00
Xin Chen 86001da7bd Use hit test algorithm updates for fabric only
Summary:
This diff gates the useage of overflowinset to hit test algorithm to fabric renderer only.

Changelog:
[Internal][Android] - Use overflowInset for fabric only

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D33237281

fbshipit-source-id: e5cd78ee97f62f100d42d016241d1544fb0953ad
2021-12-21 11:56:11 -08:00
Kevin Gozali fb39d45ed5 C++ - better => butter
Summary:
Renaming the `better` utilities to `butter`:
- to prevent claims that this library is superior to others - it really depends on use cases
- to indicate ease of use throughout the codebase, easily spread like butter

Changelog: [C++][Changed] Renaming C++ better util to butter, used by Fabric internals

Reviewed By: JoshuaGross

Differential Revision: D33242764

fbshipit-source-id: 26dc95d9597c61ce8e66708e44ed545e0fc5cff5
2021-12-20 22:25:14 -08:00
Xin Chen b4dab1a537 Setup mobile config and create experiment for using overflowInset in Android
Summary:
The previous diff shows how `overflowInset` could improve hit test algorithm performance. This diff adds experiment to it in order to:

1. Understand the perf improvement in production
2. Provide quick way to rollback in production -- the changes are used by FB4A as well as VR
3. The changes will pass more instructions over JNI, which may have impact on perf.

To share the MC param values in both Java and C++ side, the value is hosted by `ReactFeatureFlags` and fetched in `FbReactInstanceHolder`.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33179310

fbshipit-source-id: 327100d41f7b5a668ff0d2afabcdd1fc16cb5a18
2021-12-20 18:43:47 -08:00
Xin Chen bc9168d4ca Add overflowInset to RN Android ViewGroup as separate mount instruction
Summary:
This diff adds `overflowInset` values in RN Android. These values are used to give  an enlarged boundary of a view group that also contains all its children layout. Here is [the post](https://fb.workplace.com/groups/yogalayout/permalink/2264980363573947/) that discuss more on why this is useful. I steal the pic in that post here as TLDR:

{F687030994}

In the above case, we will get overflowInset for ViewGroup A as something like `top: 0, right: -20, bottom: -20, left: 0`.

This has been added in the [Fabric core](https://fburl.com/code/f8c5tg7b) and [in IOS](https://fburl.com/code/vkh0hpt6). In Android, since we used to ignore all event coordinates outside of a ViewGroup boundary, this is not an issue. However, that caused unregistered touch area problem and got fixed in D30104853 (https://github.com/facebook/react-native/commit/e35a963bfb93bbbdd92f4dd74d14e2ad6df5e14a), which dropped the boundary check and made the hit test algorithm in [TouchTargetHelper.java](https://fburl.com/code/dj8jiz22) worse as we now need to explore all the child node under ReactRootNode.

This perf issue is getting obvious when a view loads too many items, which matches our experience with "Hover getting slow after scrolling", "Hover getting slow after going back from PDP view", and "The saved list view (in Explore) is very fast (because it has very few components)"

To fix this issue, I added the support to `overflowInset` to RN Android by
1. Sending the `overflowInset` values from Binding.cpp in RN Android as a separate mount instruction
2. Update `IntBufferBatchMountItem.java` to read the int buffer sent over JNI, and pass the `overflowInset` values to `SurfaceMountingManager.java`
3. Creating new interface `ReactOverflowViewWithInset.java` and extending the existing `ReactOverflowView.java` usages
4. Adding implementation of getter and setter for `overflowInset` in various views
5. Update `TouchTargetHelper.java` to read the values and check boundaries before exploring ViewGroup's children

Note that in #3 I didn't change `ReactOverflowView.java` interface directly. I am concerned about backward compatibility issues in case this interface is being used in OSS. I suggest we deprecate it as we are not using it anymore in our code.

Changelog:
[Internal][Android]

Reviewed By: JoshuaGross

Differential Revision: D33133977

fbshipit-source-id: 64e3e837fe7ca6e6dbdbc836ab0615182e10f28c
2021-12-20 18:43:47 -08:00
Andrei Shikov 0a3ddce928 Refactor mount out of Binding.cpp
Summary:
Binding.cpp shares many responsibilities, including surface management and mount. This change refactors mount (and mount items) into separate files, while retaining the same functionality and interface.

Changelog:
[Internal][Android] - Refactor mount into FabricMountingManager

Reviewed By: mdvacca

Differential Revision: D32977902

fbshipit-source-id: 07cdf5a19033fccaa81901e5b9a4d44192ec7853
2021-12-20 08:09:54 -08:00
Luna Wei 3204c55981 Remove usages of bump-oss-version from generated scripts
Summary: Changelog: [Internal] - Update the source of the changes in generated files, no longer bump-oss-version but set-rn-version

Reviewed By: sota000

Differential Revision: D33110408

fbshipit-source-id: 8cd5004f5d40dde82fe4d6271d5b8598cd27ca31
2021-12-17 18:37:37 -08:00
Andrei Shikov 588320831f Initialize RootView size to the display size
Summary:
Inits RootView to display size for the early surface start experiment.

Before that experiment, we always had the view measured before the surface was initialized, but here layout can sometimes happen before measure. Surface defaults use [0; Inf) for size constraints, potentially causing a crash in Yoga. This change avoids that by making a guess on default layout size with `displayMetrics`

Changelog: [Internal]

Reviewed By: feedthejim

Differential Revision: D33190397

fbshipit-source-id: 3b1b84135a4980ef2fde4024ec84a448199e00b8
2021-12-17 11:23:22 -08:00
David Vacca 08aab2b4e1 Add logging of statistics of Fabric commits
Summary:
This diff adds extra logging to track how long does it take to exeucte different stages of the fabric commit

changelog: [internal] internal

Reviewed By: philIip

Differential Revision: D33183070

fbshipit-source-id: 69e31bef69c9d9ec57dc7e00e4c36e278eb30cb6
2021-12-17 10:01:31 -08:00
Xin Chen 51fe19084f Do not register touch target for out of bounds events with clipChildren set to true
Summary:
Similar to the previous diff, we should not allow view group that has clipChildren set to true to respond events that are out of bounds.

Changelog:
[Internal][Android]

Reviewed By: ShikaSD

Differential Revision: D33102331

fbshipit-source-id: de3a5ffdd5293ada1d2c211659e79edc697b5d15
2021-12-16 17:15:57 -08:00
Xin Chen 0bd09c046a Change touch target lookup to exclude overflow hidden view group
Summary:
In D30104853 (https://github.com/facebook/react-native/commit/e35a963bfb93bbbdd92f4dd74d14e2ad6df5e14a), we added fix to the issue where touches on the child view that is outside of its parent view's boundary are not registered. The only exception to that is if the parent view has overflow style `overflow: hidden`. In that case, touches happen outside of the parent view should be ignored.

{F686521911}

That fix works, but it increases the complexity for the DFS algorithm used to find the touch target in two ways:

1. Before we only traverse views that contain the touch event point. If the touch event point is outside of the view, we won't step in and traverse that part of the tree. This is actually what caused the initial problem. The fix removed that boundary check (where `isTransformedTouchPointInView` used to do) and push it later. This increases the number of tree traversal a lot.
2. The check for `overflow: hidden` is happened after we find a potential target view, which means we've spent time to find the target view before we decide if the target view is even a candidate.

This diff aims to update for the #2 item above. Since we are checking the style of the parent view, not the target view, it's not necessary to check that after we find the target view. We could check the parent view and if it has `overflow: hidden` on it, any pointer event that are not in the boundary can be ignored already.

Changelog:
[Internal][Android]

Reviewed By: mdvacca, ShikaSD

Differential Revision: D33079157

fbshipit-source-id: c79c2b38b8affb9ea0fd25b5e880b22466ab7ed9
2021-12-16 17:15:57 -08:00
Andrei Shikov acda0fec48 Use the same lock for fields cleared on Fabric native binding uninstall
Summary:
Scheduler and JavaUIManager mutexes share the lifetime (between install-uninstall), so we can use singular shared lock to ensure that both sections are locked exclusively for install/uninstall and in shared mode for access.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33130686

fbshipit-source-id: bf283fd5410e386d2635645e17680a9f4cb7f288
2021-12-15 15:02:22 -08:00
Marshall Mann-Wood 89faf0c9a8 Added saftey for ensuring callback is called
Summary:
Adds a return value to `MessageQueueThread#runOnQueue`, it's implementors and one caller.

It is currently possible for a callback to not be called (because the HandlerThread has been shutdown). If the callback is mission-critical (frees resources, releases a lock, etc) the callee has no indication that it needs to do something.

This surfaces that information to the callee.

Changelog:
[Android][Changed] - Made `MessageQueueThread#runOnQueue` return a boolean. Made `MessageQueueThreadImpl#runOnQueue` return false when the runnable is not submitted.

Reviewed By: RSNara

Differential Revision: D33075516

fbshipit-source-id: bd214a39ae066c0e7d413f2eaaaa05bd072ead2a
2021-12-15 13:35:33 -08:00