Граф коммитов

5132 Коммитов

Автор SHA1 Сообщение Дата
Andres Riveros Moya 7a770526c6 Remove DatePickerAndroid from react-native-github
Summary:
Changelog:
[JavaScript][Removed] - Remove DatePickerAndroid from React Native

Reviewed By: lunaleaps, yungsters

Differential Revision: D30281952

fbshipit-source-id: 5cd0ad2ad741afeef3e6f8a39635c6baf4b79b38
2021-08-25 13:38:25 -07:00
Joshua Gross 8c4912a42f Fabric should be enabled or disabled app-wide without entrypoint-specific options
Summary:
Add new ReactFeatureFlag to enable or disable Fabric appwide.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D30504714

fbshipit-source-id: f615d4c888a89f5401b0ff8f8305fdfbdf75fba3
2021-08-25 13:09:36 -07:00
fabriziobertoglio1987 ee3e71f536 onKeyPress event not fired with numeric keys (#29046)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/19507 fixes https://github.com/facebook/react-native/issues/30475 onKeyPress event not fired for numeric keyboard
The TextInput onKeyPress event is not fired when pressing numeric keys on Android.

The method sendKeyEvent will dispatchKeyEvent only for:
- ENTER_KEY_VALUE
- KEYCODE_DEL (delete key)

The solution proposed is trigger dispatchKeyEvent for KeyEvents with event.getUnicodeChar() value included between 47 and 58 (numeric keys 0-9)

## 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] [Fixed] - onKeyPress event not fired with numeric keys

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

Test Plan:
**<details><summary>CLICK TO OPEN TESTS RESULTS</summary>**
<p>

| **BEFORE** | **AFTER** |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/83673015-7ce2a000-a5d7-11ea-9c1d-32a5f5605687.gif" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/83673017-7f44fa00-a5d7-11ea-8d93-edf1f61f7023.gif"  width="300" height="" /> |

</p>
</details>

Reviewed By: hramos, cortinico

Differential Revision: D30427789

Pulled By: sshic

fbshipit-source-id: b4e17ab94daa59fe28de5a5141b0fdd49bab72e3
2021-08-25 04:56:45 -07:00
Joshua Gross 4841e1bae0 Add first-class support to ReactInstanceManager for Activity-less usage
Summary:
I'm not sure if we'll ever need to do more than this (probably!) but I want to have a specific option for Activity-less usage, so
that our logic in ReactInstanceManager and elsewhere is more clear. I want to be able to confidently assert that the Activity is present
and correct, or never present, depending on if this `requireActivity` flag is set; instead of adding else statements that imply "well, the Activity should be here, hope everything is okay" which feels hacky.

Doesn't change much for now, but it's an additional constraint in the RN Android codebase that we need to explicitly embed in code so that
we can point to it, and so that the logic is more clear.

Changelog: [Internal]

Reviewed By: javache, motiz88

Differential Revision: D30504616

fbshipit-source-id: d2abdb7c4765a16113c9517406cdbb8cf42822ff
2021-08-25 02:21:18 -07:00
Valentin Shergin 59021521e7 Fixed dynamic behavior of <Text adjustsFontSizeToFit={true}> on Android (#31538)
Summary:
This PR fixes https://github.com/facebook/react-native/issues/30717, a bug in `<Text adjustsFontSizeToFit={true}>` implementation that prevents it from adjusting text size dynamically on Android.

The way `adjustsFontSizeToFit` was implemented in https://github.com/facebook/react-native/issues/26389 (and the design of ReactTextShadowNode) implies that Yoga will call `onMeasure` on every size change of a `<Text>` component, which is actually not the case (Yoga can cache the results of the measures, call the function multiple times or do not call at all inferring the size from the size constraints). The implementation of `adjustsFontSizeToFit` computes the adjusted string inside the measure function and then eventually passes that to the view layer where it's being rendered.

The proper fix of this issue requires the full redesign of the measure and rendering pipelines and separating them, and that... would be too invasive. And, I believe, this issue is already fixed in Fabric where this part is already designed this way.

Instead, this diff implements a small workaround: if `adjustsFontSizeToFit` is enabled, we manually dirty the Yoga node and mark the shadow node updated to force remeasuring.

## Changelog

[Android] [Fixed] - Fixed dynamic behavior of <Text adjustsFontSizeToFit={true}> on Android

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

Test Plan: https://user-images.githubusercontent.com/22032/118508162-8c79cc80-b6f4-11eb-853f-a1a09f82935f.mov

Reviewed By: mdvacca

Differential Revision: D28631465

Pulled By: yungsters

fbshipit-source-id: 7db1d22e2a5a464c7bf941d1d3df8e3fe8df66a2
2021-08-24 17:58:12 -07:00
Chatura Atapattu 2c2b831716 Apply new buildifier fixes
Summary: Changelog: [Internal]

Reviewed By: zertosh

Differential Revision: D30407205

fbshipit-source-id: 022a02829d59a900764b228afb9856ed1ba2cf8c
2021-08-19 20:01:02 -07:00
Chatura Atapattu 8258f5e271 Remove BUILD FILE SYNTAX from build files
Summary: Changelog: [Internal]

Reviewed By: zertosh

Differential Revision: D30410441

fbshipit-source-id: 62deebb502121f23270bfa18286b155ad161af2d
2021-08-19 15:25:19 -07:00
Nicholas Tinsley abc1ace6ec - Fix broken Circle CI due to missing BUCK rule for androidx:tests (#32052)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32052

Changelog: Update the OSS React Native dependencies to match the internal dependency structure.

Reviewed By: cortinico

Differential Revision: D30397818

fbshipit-source-id: a70e26d764729f6ead9eb6a4d689e32d25243571
2021-08-19 14:21:08 -07:00
Arushi Kesarwani cb0782c87e Adding activity check to enable Dev mode
Summary:
It is assumed that there will always be an activity associated on enabling the dev support which is not the case. Hence adding that null check.

Changelog:
[Android][Fixed] - Added null check for activity in onHostResume()

Reviewed By: javache

Differential Revision: D30411311

fbshipit-source-id: 8936be2df7f16c355693163347d5e1d94c5ce2e1
2021-08-19 10:47:26 -07:00
Sota Ogo b29a78732d Emit soft error for warning
Summary:
This diff adds a default behavior for the unified logger on Android.

Added the call site in the CXXNativeModule.

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D30377767

fbshipit-source-id: 000014828f2f245dc9492e3617218895d9a33536
2021-08-18 23:38:01 -07:00
Joshua Gross 10cd2730af Ship "Disable 'virtual view' preallocation" experiment in code
Summary:
The impact of this has proven impressive, and safe. Ship in code and remove feature-flag.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D30269561

fbshipit-source-id: 9bb72567cfd881928d14d9bee43cf32b390664fb
2021-08-18 21:19:37 -07:00
Albert Sun 29249e19bd Call super.onActivityResult in ReactActivity
Summary:
This change allows native activities and fragments to also handle onActivityResult callbacks, in addition to sending the result to React Native.

Changelog:
[Android][Changed] - Call super.onActivityResult in ReactActivity's onActivityResult()

Reviewed By: JoshuaGross

Differential Revision: D30232449

fbshipit-source-id: cb080d6f2eff57dcf839660ee715cb4068ffcdd5
2021-08-18 17:11:11 -07:00
Andrei Shikov 22f81b203f Clean up Fabric startSurface API used in Venice
Summary:
Update FabricUIManager methods for `SurfaceHandler` to start usual rendering or prerendering based on presence of the view instead of using two methods with same logic.

Changelog: [Internal]

Reviewed By: sshic

Differential Revision: D30346502

fbshipit-source-id: 297f2b4a16dc7af7c36379252bd73e6dc953ff59
2021-08-18 12:44:41 -07:00
Jonathan Andrew c18a492858 Fix Dimensions not updating on Android (#31973)
Summary:
When retrieving the device dimensions through the JS `Dimensions` utility, the result of `Dimensions.get` can be incorrect on Android.

### Related issues

- https://github.com/facebook/react-native/issues/29105
- https://github.com/facebook/react-native/issues/29451
- https://github.com/facebook/react-native/issues/29323

The issue is caused by the Android `DeviceInfoModule` that provides initial screen dimensions and then subsequently updates those by emitting `didUpdateDimensions` events. The assumption in that implementation is that the initial display metrics will not have changed prior to the first check for updated metrics. However that is not the case as the device may be rotated (as shown in the attached video).

The solution in this PR is to keep track of the initial dimensions for comparison at the first check for updated metrics.

## Changelog

[Android] [Fixed] - Fix Dimensions not updating

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

Test Plan:
### Steps to reproduce
1. Install the RNTester app on Android from the `main` branch.
2. Set the device auto-rotation to ON
3. Start the RNTester app
4. While the app is loading, rotate the device
5. Navigate to the `Dimensions` screen
6. Either
 a. Observe the screen width and height are reversed, or
 b. Quit the app and return to step 3.

### Verifying the fix

#### Manually
Using the above steps, the issue should no longer be reproducible.

#### Automatically
See unit tests in `ReactAndroid/src/test/java/com/facebook/react/modules/deviceinfo/DeviceInfoModuleTest.java`

### Video

https://user-images.githubusercontent.com/4940864/128485453-2ae04724-4ac5-4267-a59a-140cc3af626b.mp4

Reviewed By: JoshuaGross

Differential Revision: D30319919

Pulled By: lunaleaps

fbshipit-source-id: 52a2faeafc522b1c2a196ca40357027eafa1a84b
2021-08-17 18:10:31 -07:00
hank121314 842bcb902e `Android/ColorProps`: ColorProps with value null should be defaultColor instead of transparent (#29830)
Summary:
This pr:
- Fixes: https://github.com/facebook/react-native/issues/30183
- Fixes: https://github.com/facebook/react-native/issues/30056
- Fixes: https://github.com/facebook/react-native/issues/29950
- Fixes: https://github.com/facebook/react-native/issues/29717
- Fixes: https://github.com/facebook/react-native/issues/29495
- Fixes: https://github.com/facebook/react-native/issues/29412
- Fixes: https://github.com/facebook/react-native/issues/29378

Because most of ReactProps(name = ViewProps.COLOR) accept @ Nullable Integer.
For example:
abb6433f50/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java (L472-L479)

After update to react-native 0.63.2 to make PlatformColor work, there is a new ColorPropSetter.
abb6433f50/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagersPropertyCache.java (L194-L215)

But ColorPropSetter won't return an nullable value with getValueOrDefault, it will always return it's defaultValue which is 0.
And 0 is equal to TRANSPARENT, will cause <Text /> disappear.
## Changelog

[Android] [Fixed] - ColorProps with value null should be defaultColor instead of transparent

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

Test Plan:
Please initiated a new project and replaced the app with the following code:
```
import * as React from 'react';
import {Text, View, TouchableOpacity, PlatformColor} from 'react-native';

export default function App() {
  const [active, setActive] = React.useState(false);

  return (
    <View>
      <Text style={active ? {color: 'green'} : null}>Example</Text>
      <Text
        style={
          active ? {color: PlatformColor('android:color/holo_purple')} : null
        }>
        Example2
      </Text>
      <TouchableOpacity onPress={() => setActive(!active)}>
        <Text>Toggle Active</Text>
      </TouchableOpacity>
    </View>
  );
}
```

Thanks you so much for your code review!

Reviewed By: JoshuaGross

Differential Revision: D30209262

Pulled By: lunaleaps

fbshipit-source-id: bc223f84a92f742266cb7b40eb26722551940d76
2021-08-17 18:01:14 -07:00
Nicholas Tinsley f971ea9023 replace testing-support-lib with androidx buck targets in RN
Summary: Changelog: [Internal] - codemod testing library Buck redirect to actual dependency

Reviewed By: jiawei-lyu

Differential Revision: D30379180

fbshipit-source-id: eb9a22569230d07732bd0aa63dddfcfff7c3800f
2021-08-17 17:17:04 -07:00
Dark Knight 48567e5277 Revert D20590739
Summary:
This diff is reverting D20590739 (3e5998e651)
D20590739 (3e5998e651) is making the following tests to fail and this revert diff is either the revert of the blame diff or the revert of the stack of diffs that need to be reverted to revert the blame diff
Tests affected:
- https://www.internalfb.com/intern/test/281475012591721/
Multisect link:
https://www.internalfb.com/intern/testinfra/multisect/476214

## Changelog

`[Android] [Fixed] - Revert: Fix dashed/dotted border-drawing when border-radius is 0`

Reviewed By: charlesbdudley

Differential Revision: D30361262

fbshipit-source-id: 21dd507deb5817dda1063a267a38749c77e7ae1a
2021-08-17 10:22:18 -07:00
Hein Rutjes 3e5998e651 Fix dashed/dotted border drawing when border-radius is 0 (#28359)
Summary:
This PR fixes the border-style that is not respected when drawing a border with 0 border-radius on Android. This would cause the faster `drawRectangularBackgroundWithBorders` path to be used, but that uses rectangular drawing and doesn't support dashed/dotted stroke patterns.
This PR changes the behavior to use the generic `drawRoundedBackgroundWithBorders` code-path which does support dashed/dotted border-styles.

## Changelog

`[Android] [Fixed] - Fix dashed/dotted border-drawing when border-radius is 0`

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

Test Plan:
**Faulty situation:**

![Screenshot_1584721992](https://user-images.githubusercontent.com/6184593/77184987-e838cd80-6ad0-11ea-9585-058eafbd361a.png)

**After the fix:**

![Screenshot_1584721410](https://user-images.githubusercontent.com/6184593/77184801-9d1eba80-6ad0-11ea-92a7-7212f40ace73.png)

Reviewed By: lunaleaps

Differential Revision: D20590739

Pulled By: charlesbdudley

fbshipit-source-id: 18657ea21e54f763e22c623bf979b3500c1bdcbd
2021-08-16 15:35:37 -07:00
fabriziobertoglio1987 5819538a08 Fix selectionColor doesn't style Android TextInput selection handles (#31007)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/30283 selectionColor does not change the handles color.

The method setCursorColor changes the cursor color of field `mCursorDrawable` using a reflection for Android Devices lower then API 28. This fix adds a reflection to change color of the left, center and right handles of a selection (mTextSelectHandleLeftRes, mTextSelectHandleRes and mTextSelectHandleRightRes).

## 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] [Fixed] - Fix selectionColor doesn't style Android TextInput selection handles

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

Test Plan:
This changes fix the Java API for which I can not write Java tests as explained in commit 709a441ecf
The java TextInputTest was excluded from the test suite in commit 709a441ecf as they need the Yoga libraries to run

**<details><summary>CLICK TO OPEN TESTS RESULTS - API 22</summary>**
<p>

left/right handles do not change color with the cursor

| **BEFORE** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/108241887-98351180-714c-11eb-9c7b-7c693ea0bb06.png" width="250" height="" /> |

center Handle color does not change color

| **BEFORE** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/108241904-9ec38900-714c-11eb-9fc3-dbd26f83b979.png" width="250" height="" /> |

The left and right handle change color with the cursor color

| **AFTER** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/108241796-805d8d80-714c-11eb-9d90-6871ddaea86f.png" width="250" height="" /> |

The center handle color is correctly updated

| **AFTER** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/108241571-45f3f080-714c-11eb-8475-86e6dea64d73.png" width="250" height="" /> |

`setCursorColor` changes correctly the cursor color

| **AFTER** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/108241484-2d83d600-714c-11eb-8a0c-80a847f28537.png" width="250" height="" /> |

Default Colors do not have issues

| **AFTER** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/108241346-04634580-714c-11eb-933e-0dce504498a8.png" width="250" height="" /> |

| **AFTER** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/108241347-04fbdc00-714c-11eb-902a-fc057cf94986.png" width="250" height="" /> |

</p>
</details>

Reviewed By: ShikaSD

Differential Revision: D28682935

Pulled By: sota000

fbshipit-source-id: ff037c93f36bbf20c915373b995bbfd8e8ca92d0
2021-08-16 12:04:13 -07:00
Samuel Susla 22bc8c23b7 Clean up AsyncEventBeatV2 experiment
Summary:
changelog: [internal]

This experiment is abandoned. It regressed engagement metrics.

Reviewed By: JoshuaGross

Differential Revision: D30303383

fbshipit-source-id: 1d86eb5c7c257d4b369632007d0bda23e80c88ab
2021-08-16 04:35:02 -07:00
Amy Nichol c0ce346203 Nullable ReconnectingWebSocket params
Summary: Changelog: [Internal] - Annotated the MessageCallback and ConnectionCallback params of the ReconnectingWebSocket with Nullable

Reviewed By: makovkastar

Differential Revision: D30298832

fbshipit-source-id: 4e0a6ea339d1d8b25fb7bb24dfbada93d5cebc96
2021-08-16 02:08:50 -07:00
Levi Buzolic f51773ecde Allow Modal to handle hardware escape key in the same way the back button is handled (#31564)
Summary:
On Android, when a hardware keyboard is connected pressing the escape key will partially dismiss an active `<Modal>` without calling the `onRequestClose` callback. The modal will disappear, but I beleive the underlying activity may still be present, blocking interaction with the main app below and leaving things in a partially broken state.

This code change allows the escape key to be handled in the same way as the hardware back button, calling the `onRequestClose` and allowing the developer to decide the behaviour.

This issue isn't present on iOS, so no change is required there.

## 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] [Fixed] - Fix Modal being dismissed incorrectly when pressing escape on a hardware keyboard

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

Test Plan: I've tested this manually locally, but unsure if it's possible to test in an automated way as the emulator didn't respond to a hardware escape key in the same way as a physical device.

Reviewed By: ShikaSD

Differential Revision: D28953718

Pulled By: lunaleaps

fbshipit-source-id: 5547bc5d894da0d3d9daf4515b1af9c2407815db
2021-08-13 19:27:33 -07:00
Ramanpreet Nara f536f82e12 Warn whenever CxxNativeModules are used
Summary:
After this diff, when ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse is enabled, the legacy NativeModule infra will log soft exceptions whenever legacy NativeModules are accessed/used.

Changelog: [Internal]

Reviewed By: p-sun

Differential Revision: D30272695

fbshipit-source-id: 7111402c1d8b883a600dcb4559e9ff1d56447070
2021-08-13 13:53:44 -07:00
Ramanpreet Nara b7fd68e611 Introduce JReactSoftExceptionLogger to log SoftExceptions from C++
Summary:
When the TurboModule system is enabled, C++ NativeModules shouldn't be used in production. We'll use this JReactSoftExceptionLogger to log soft exceptions from C++ NativeModules this scenario.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D30272694

fbshipit-source-id: 8dadcfe51bcbc353d438d1a403e74da5e2cb9546
2021-08-13 13:53:44 -07:00
Ramanpreet Nara f93d95e079 Log SoftExceptions when the legacy NativeModule system is used
Summary:
When ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse is true, we will log a SoftException, whenever:
1. A Java/Cxx NativeModule is created by the legacy system.
2. Any method on the Java NativeModule is executed, including getConstants().

NOTE: Logs to CXXModule use incoming.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D30252953

fbshipit-source-id: 570929624d0114bb298c593ba909e5cdbd54bd6c
2021-08-13 13:53:44 -07:00
Ramanpreet Nara 2b427f8692 Add a flag to warn whenever the legacy NativeModule system is used
Summary:
When true, this flag will cause React Native to start logging soft exceptions, whenever the legacy NativeModule system is used. This flag is independent of useTurboModules. In practice, it's only enabled when TurboModules is enabled.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D30250363

fbshipit-source-id: f610567c5b99a4fbf8252c3962908668f483d028
2021-08-13 13:53:44 -07:00
fabriziobertoglio1987 3560753559 Fix TextInput Cursor jumping to the right when the placeholder null (#28995)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/28794 fixes https://github.com/facebook/react-native/issues/27658
Flow type ?Stringish allows to set the placeholder value to null. The null value causes the cursor to jump to the right in a TextInput. The fix replaces the placeholder null value with an empty string which avoid calling setHint(null) as causes the placeholder to jump to the right.

## 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] [Fixed] - avoid calling setHint with a null parameter causing cursor to jump to the right

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

Test Plan:
**<details><summary>CLICK TO OPEN TESTS RESULTS (28 May 2020 20a9473aaa330ad9b6e7a0b42ebd9c4ed41ce60b)</summary>**
<p>

More videos and information included in issue https://github.com/facebook/react-native/issues/28794
The below test cases are from the [following repository](https://github.com/fabriziobertoglio1987/AwesomeProject)

| **BEFORE** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/83123470-3e2f8000-a0d5-11ea-8718-11e6a0575a0c.gif" />|

| **AFTER** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/83123554-599a8b00-a0d5-11ea-9701-6557f0d76044.gif" />|

Extensive testing on `RNTester` did not identify any regression.

| **AFTER** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/83123586-628b5c80-a0d5-11ea-92eb-449d499dcc7d.gif" />|

</p>
</details>

**<details><summary>CLICK TO OPEN TESTS RESULTS (15 February 2021 20a9473aaa)</summary>**
<p>

| **BEFORE** |
|:-------------------------:|
| <video src="https://user-images.githubusercontent.com/24992535/107960803-5d44a980-6fa5-11eb-90e2-f0d665e35291.mp4" />|

| **AFTER** |
|:-------------------------:|
| <video src="https://user-images.githubusercontent.com/24992535/107960602-1f478580-6fa5-11eb-8f39-b985fafa6a6c.mp4" />|

</p>
</details>

Reviewed By: charlesbdudley

Differential Revision: D30095877

Pulled By: lunaleaps

fbshipit-source-id: 38a3e788443a22d48a4335063cd4315638bd8e97
2021-08-11 22:53:16 -07:00
Luna Wei 18132c1597 Remove autoCompleteType as a native component prop
Summary: Changelog: [Android][Internal] - Cleanup `autoCompleteType` prop from Android native component.

Reviewed By: charlesbdudley

Differential Revision: D30057497

fbshipit-source-id: c80dd5682b314112ae70551bf8135372bb1ddc8b
2021-08-11 17:53:37 -07:00
Ramanpreet Nara cbec66ef92 Rename ReactSoftException to ReactSoftExceptionLogger
Summary:
ReactSoftException makes it seem like the class is an Exception, when it's actually a logger. This rename I think is more appropriate.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D30251735

fbshipit-source-id: 550bd543388e698774ec31753200bd3f722d8c17
2021-08-11 13:29:42 -07:00
Ramanpreet Nara 56dcc6ea55 Un-deprecate ReactSoftException
Summary:
After creating and using this utility, we learned that (1) it's really useful, and (2) its interface is good enough. So, let's un-deprecate this utility.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D30251651

fbshipit-source-id: d1ecf81484f865587a5552d5ddf0e68da86397d9
2021-08-11 13:29:42 -07:00
Nicola Corti ffb183174b Cleanup warnings in the NDK build
Summary:
This diff is cleaning up some configurations in the `Android.mk` files
of the native build. Specifically I simplified some of the rules and removed
a duplicate file specification.

Changelog:
Internal - Cleanup warnings in the NDK build

Reviewed By: ShikaSD

Differential Revision: D30220715

fbshipit-source-id: a100953fe977879a6d28cb0a2ef4b3358fb7c774
2021-08-10 09:44:14 -07:00
Janic Duplessis 91cac20289 Create slider accessibility delegate in createViewInstance (#31942)
Summary:
Recent change in https://github.com/facebook/react-native/pull/31865 made it so if `ReactSliderManager` is created on the react context creation thread it will crash with the following error. This happens because `ReactAccessibilityDelegate` tries to create a handler on a thread without a looper.

This seems to happen because react-native-reanimated tries to get the UIManager module during its initialization which will cause view managers to be created and explains why the crash probably does not happens in RNTester or using only RN bundled modules.

```
08-03 14:44:56.318 21206 21360 E AndroidRuntime: FATAL EXCEPTION: create_react_context
08-03 14:44:56.318 21206 21360 E AndroidRuntime: Process: com.th3rdwave, PID: 21206
08-03 14:44:56.318 21206 21360 E AndroidRuntime: java.lang.ExceptionInInitializerError
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.shell.MainReactPackage.createViewManagers(MainReactPackage.java:166)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:882)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:137)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.CoreModulesPackage.getModule(CoreModulesPackage.java:102)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:159)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:147)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:191)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:156)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:153)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:486)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:462)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.bridge.ReactContext.getNativeModule(ReactContext.java:176)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.swmansion.reanimated.NodesManager.<init>(NodesManager.java:153)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.swmansion.reanimated.ReanimatedModule.getNodesManager(ReanimatedModule.java:101)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.swmansion.reanimated.ReanimatedJSIModulePackage.getJSIModules(ReanimatedJSIModulePackage.java:17)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.th3rdwave.MainApplication$1$1.getJSIModules(MainApplication.java:135)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1329)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:136)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1058)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:923)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: Caused by: java.lang.RuntimeException: Can't create handler inside thread Thread[create_react_context,5,main] that has not called Looper.prepare()
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at android.os.Handler.<init>(Handler.java:227)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at android.os.Handler.<init>(Handler.java:129)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.uimanager.ReactAccessibilityDelegate$1.<init>(ReactAccessibilityDelegate.java:185)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.uimanager.ReactAccessibilityDelegate.<init>(ReactAccessibilityDelegate.java:184)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.views.slider.ReactSliderManager$ReactSliderAccessibilityDelegate.<init>(ReactSliderManager.java:281)
08-03 14:44:56.318 21206 21360 E AndroidRuntime: 	at com.facebook.react.views.slider.ReactSliderManager.<clinit>(ReactSliderManager.java:301)
```

To fix it I changed the delegate creation to be done in `createViewInstance` which will be called on main thread. This is also more in line with how other accessibility delegates are created for other view managers. Since Slider is probably not used a lot, creating more delegate instance won't be an issue.

Another alternative could be to initialize a Looper on the thread that creates the react context, but it seems more involved and probably not needed.

## Changelog

[Android] [Fixed] - Create slider accessibility delegate in createViewInstance

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

Test Plan: Reproduced the crash in an app and made sure this patch fixes it.

Reviewed By: JoshuaGross

Differential Revision: D30167451

Pulled By: p-sun

fbshipit-source-id: 5327130064db52ac0086e1ae5541a1b3e3954f15
2021-08-06 18:43:03 -07:00
Harry Yu e35a963bfb Fix to make taps on views outside parent bounds work on Android (#29039)
Summary:
By default, Views in React Native have `overflow: visible`. When a child view is outside of the parent view's boundaries, it's visible on Android, but not tappable. This behaviour is incorrect, and doesn't match iOS behaviour.

- Taps on Views outside the bounds of a parent with `overflow: visible` (or unset) should register
- Taps on Views outside the bounds of a parent with `overflow: hidden` should continue to not register

Related issues:

- fixes https://github.com/facebook/react-native/issues/21455
- fixes https://github.com/facebook/react-native/issues/27061
- fixes https://github.com/facebook/react-native/issues/27232

### Fix

- Made `findTouchTargetView` not check that the touch was in the bounds of the immediate children, but instead
  - Check that the touch is in its own bounds when returning itself
  - Check that the touch for a child is in its own bounds only when `overflow: hidden` is set
- Modified related code to adjust to this change
- Added RNTesterApp test

## 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] [Fixed] - Allow taps on views outside the bounds of a parent with `overflow: hidden`

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

Test Plan:
This can be tested with 2 examples added to the bottom of the PointerEvents page of the RNTesterApp:

| Before | After |
| --- | --- |
| ![Before](https://user-images.githubusercontent.com/2937410/83610933-19079b00-a535-11ea-8add-22daae0191e1.gif) | ![After](https://user-images.githubusercontent.com/2937410/83610583-8830bf80-a534-11ea-97e2-71e180a70343.gif) |

Reviewed By: ShikaSD

Differential Revision: D30104853

Pulled By: JoshuaGross

fbshipit-source-id: 644a109706258bfe829096354dfe477599e2db23
2021-08-06 12:33:08 -07:00
David Vacca cf717ffc19 Add TODOs to unify component names between JS - Android - iOS - C++
Summary:
EZ diff that adds a few TODOs to unify component names between JS - Android - iOS - C++
see task: T97384889

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D30139942

fbshipit-source-id: 91f51d04e7e7ecba7f059f94a121be43d820647d
2021-08-05 18:35:52 -07:00
Sunny Luo 72f7962d4a Update JSLoader.cpp (#29270)
Summary:
Since react-native-cli is deprecated, the correct command should be `npx react-native start`

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

Reviewed By: sammy-SC

Differential Revision: D30017028

Pulled By: sota000

fbshipit-source-id: cfcf9e1d150f51750a4e86133bd3167506ee7348
2021-08-05 10:39:55 -07:00
Moti Zilberman b385484502 Fix OSS Buck parsing errors (#31957)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/31957

Changelog: [Internal]

Some fixes for the GitHub shims for FB-internal Buck macros. Should fix the Buck-related breakages in the `test_android` and `test_docker` CI jobs.

Also adds license headers to some recently-added files that didn't have them.

Reviewed By: mdvacca

Differential Revision: D30114177

fbshipit-source-id: 88a24fa7130bd98dd60568566bde51fcfc89df60
2021-08-05 02:23:28 -07:00
Moti Zilberman 1ed1ac7caf Move integration test Buck targets to GitHub
Summary: Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D30032467

fbshipit-source-id: 56e293c821f02e78fe13f5e7f22bcb2b2050019a
2021-08-04 13:03:21 -07:00
David Vacca 81167e0e80 Add documentation for FabricUIManager.getInspectorDataForInstance
Summary:
Add documentation for FabricUIManager.getInspectorDataForInstance

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D30095818

fbshipit-source-id: dfe8590598099e7581460ca45bc0e779690463a6
2021-08-04 11:39:17 -07:00
David Vacca 43a91d03eb Extend getInspectorDataForInstance to return props
Summary:
This diff extends the FabricUIManager.getInspectorDataForInstance to return the props of the React Native component associated to the view passed as a parameter.

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D30095406

fbshipit-source-id: 50fdba6636a1f5042dbc113e341c3cb2534a1b04
2021-08-04 11:39:17 -07:00
Pieter De Baets de255528e0 Allow resolving view from FabricUIManager
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D30043188

fbshipit-source-id: d8675754b29fb58a28a06777f602098da6dbc27f
2021-08-03 10:55:47 -07:00
Moti Zilberman d4ee734f32 Merge BUCK file at Libraries/ into root
Summary:
Merges the Facebook-internal Buck target definitions in `Libraries/` into the BUCK file at the root of the repo (which is currently not synced to GitHub at all). This does not affect how React Native is built in open source.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D27967499

fbshipit-source-id: 39c51a544b3868242598072d24cb6cfb5a6e2d8c
2021-08-03 05:42:03 -07:00
Joshua Gross 402eec8de7 Protect against crashes when over-releasing a TouchEvent
Summary:
It seems that, possibly due to optimizations and refactoring elsewhere in the event system, some TouchEvents are being over-disposed.

This doesn't really pose a problem besides performance; and could even indicate that an Event was in a pool but never properly initialized. In these
cases it seems perfectly reasonable to silently continue, and to log a soft exception. This WILL still crash in debug mode, so we can gather more information
if we find a good repro; otherwise we will continue to get production data from this soft exception if it's an issue and we can investigate further.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D30061178

fbshipit-source-id: 05d1f60afc382ce0a202ac8f3de34770cf9a760d
2021-08-02 20:47:42 -07:00
Vegas Murphy 0fa8253d56 setup fragment based tab bar navigation
Summary: `Changelog: [Android] [Changed] - Make ReactFragment variables protected instead of private, create getter for ReactDelegate`

Reviewed By: keoskate

Differential Revision: D29981436

fbshipit-source-id: 3e5df811cd07edccf37f72c9f917f9ea0882be0b
2021-08-02 15:23:06 -07:00
Ramanpreet Nara 034c6dfe34 Stop sharing LongLivedObjectCollection with the bridge
Summary:
This is the Android analogue to D30019833.

Changelog: [Internal]

Reviewed By: p-sun

Differential Revision: D30029295

fbshipit-source-id: 13df0dfb915697eeedcc527dcdb6c246e89afb0c
2021-08-02 11:22:22 -07:00
Ramanpreet Nara 1e4dd5e877 Clean up RAIICallbackManager experiment
Summary:
This experiment was shipped in D27436402 (3d1afbbda3).

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D30023039

fbshipit-source-id: 5f7335f2ddaf6f4e2d876a917aaff2cf3d906b5c
2021-08-02 11:22:22 -07:00
Samuel Susla 3ed3d34987 Correct error message in getViewState method
Summary:
Changelog: [internal]

Here, getting `viewState` has failed, not its view property.

Reviewed By: mdvacca

Differential Revision: D30042652

fbshipit-source-id: 42831b577f17db1f64860e68be33870f5be27207
2021-08-02 09:36:33 -07:00
fabriziobertoglio1987 cb0e1d603a Allows to set individual (left,top,right,bottom) dotted/dashed borders (#29099)
Summary:
This issue:

fixes https://github.com/facebook/react-native/issues/24224 fixes https://github.com/facebook/react-native/issues/28695 fixes https://github.com/facebook/react-native/issues/23651 fixes https://github.com/facebook/react-native/issues/23475  fixes https://github.com/facebook/react-native/issues/22256 fixes https://github.com/facebook/react-native/issues/22226 fixes https://github.com/facebook/react-native/issues/19234 fixes  https://github.com/facebook/react-native/issues/18285  fixes https://github.com/facebook/react-native/issues/17344 fixes https://github.com/facebook/react-native/issues/17343 fixes https://github.com/facebook/react-native/issues/17251 fixes https://github.com/facebook/react-native/issues/12817 fixes https://github.com/facebook/react-native/issues/12403 fixes https://github.com/facebook/react-native/issues/11042 fixes https://github.com/facebook/react-native/issues/9343 fixes https://github.com/facebook/react-native/issues/8236 fixes https://github.com/facebook/react-native/issues/8105 fixes https://github.com/facebook/react-native/issues/7838 fixes https://github.com/facebook/react-native/issues/6721 fixes https://github.com/facebook/react-native/issues/5411 fixes https://github.com/facebook/react-native/issues/3159 fixes https://github.com/facebook/react-native/issues/2335 fixes https://github.com/facebook/react-native/issues/840 fixes https://github.com/facebook/react-native/issues/27133 fixes https://github.com/facebook/react-native/issues/28695

Allows to set individual (left,top,right,bottom) dotted/dashed borders.

If a single border is specified and the borderStyle is dotted or dashed, each border will be drawn with moveTo and lineTo taking in consideration of the border style and thickness.

## 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] [Fixed] - Quickfix individual border style dotted or dashed rendering as solid

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

Test Plan:
**<details><summary>CLICK TO OPEN TESTS RESULTS</summary>**
<p>

| **AFTER** | **AFTER** |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/84158300-05e05800-aa6c-11ea-96a3-40007b2ca611.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/84158309-07aa1b80-aa6c-11ea-973b-51e8e68b5808.png"  width="300" height="" /> |

| **AFTER** | **AFTER** |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/84158320-0d9ffc80-aa6c-11ea-9d7f-dfba49fbfe41.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/84158334-11cc1a00-aa6c-11ea-8422-cd5b9384f391.png"  width="300" height="" /> |

| **AFTER** | **AFTER** |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/84158556-4c35b700-aa6c-11ea-9a4d-eea791b3813a.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/84158574-51930180-aa6c-11ea-8e84-526cfb168f49.png"  width="300" height="" /> |

| **AFTER** | **AFTER** |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/84158586-55268880-aa6c-11ea-9540-51d79a8e4cb0.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/84158601-5952a600-aa6c-11ea-82e7-85d54b858f1a.png"  width="300" height="" /> |

| **AFTER** | **AFTER** |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/84158638-62dc0e00-aa6c-11ea-8765-ecba0d9d126f.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/84158652-67a0c200-aa6c-11ea-8336-e6eb8aa52e96.png"  width="300" height="" /> |

| **AFTER** | **AFTER** |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/84158690-738c8400-aa6c-11ea-9cf1-edec72d27cb7.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/84158912-b6e6f280-aa6c-11ea-94a7-0ee0db685f38.png"  width="300" height="" /> |

</p>
</details>

Reviewed By: mdvacca

Differential Revision: D28688914

Pulled By: RSNara

fbshipit-source-id: 34781d63265dcf55e30f11c014e6b4a35d67dcbd
2021-08-02 04:06:07 -07:00
David Vacca cdce14f670 Implement PlatformColor in Fabric Android
Summary:
This diff implements PlatformColor in Fabric Android

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D29841461

fbshipit-source-id: 63a523626b021c634bc399e749b639b55730391a
2021-07-30 22:16:08 -07:00
jeswinsimon 8066bc9ff6 Updated TextInput autoCompleteType prop to autoComplete 1/2 (#26010)
Summary:
Fix for bug https://github.com/facebook/react-native/issues/26003 Rename TextInput prop "autoCompleteType" to "autoComplete".

## Changelog

[Android] [Changed] - Updated `autoCompleteType` prop of `TextInput` to `autoComplete`

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

Test Plan:
Test Pass

PR for [Doc Update](https://github.com/facebook/react-native-website/pull/1184)

Reviewed By: mdvacca

Differential Revision: D29980220

Pulled By: lunaleaps

fbshipit-source-id: 3c9e7d3250b5f95b0dbd523fdb0d917a039cd6a9
2021-07-30 03:16:35 -07:00
Joshua Gross 175b1ea636 Pass PropsParserContext to prop parsing layer
Summary: Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D29921232

fbshipit-source-id: ba045f545b564aedf1b287045a0e75428de30a0f
2021-07-28 20:18:20 -07:00
Joshua Gross 09b9422516 Pass context through to all prop parser (core changes)
Summary:
Unfortunately, parsing some props requires stateful context - namely, PlatformColor on Android. We explored several different options but they all seemed inferior to the approach of using ContextContainer, and most would require using global state.

By introducing this change everywhere as early as possible, we can avoid later pain. It is likely that some prop, on some platform, will require this mechanism. We'll be ready for it!

Because we can pass a constref of the ContextContainer through to all props and because the context and context data is never retained by prop parsers, perf and memory hit should be ~0.

This diff contains core changes only. Leaf changes to all props structs and conversions files will be in next diff(s).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D29838789

fbshipit-source-id: f5090e7f02eb6e8fbe0ef4dd201e7d12104a3e3c
2021-07-28 20:18:20 -07:00
Amy Nichol 3081db28a7 Refactor DevServerHelper to separate checking if packager running
Summary:
Changelog: [Internal]
Separate the functionality of the  isPackagerRunning() function into a new class PackagerStatusCheck with the intention of being able to use this without needing a DevServerHelper

Reviewed By: makovkastar, ShikaSD

Differential Revision: D29933318

fbshipit-source-id: d708bb987b08634015d6ee6b6c8989faba416c5a
2021-07-28 11:12:37 -07:00
David Vacca 6d4fff2e5c Fix android view dimensions
Summary:
This diff fixes the Android View dimensions in VR

PixelUtil.toSPFromPixel and PixelUtil.getDisplayMetricDensity() are both using getScreenDisplayMetrics() to perform conversion of dimensions. This is not correct because we should take into consideration the density of the Context / Activity instead of the Screen. This problem didn't raise before in Fabric Android because it seems that android OS on phones usually share the scale between the screen and the Activity?

These two methods are only used in Fabric and they were introduced by D9583972 (5c0da011cb) and D9173758 (8b5e3fc16b)

As part of this diff I'm also deleting the method toSPFromPixel in favor of toDIPFromPixel because I noticed the usages of these methods are meant to use toDIPFromPixel()

changelog: [Internal] internal

Reviewed By: JoshuaGross

Differential Revision: D29864944

fbshipit-source-id: a0a093c120bde21a6cf9e1043a83c31e870d4368
2021-07-28 09:09:23 -07:00
Jesse Katsumata 1c21a112a8 docs: Fix dead links in README for rn-tester (#31901)
Summary:
Part of https://github.com/facebook/react-native/issues/31788

~Updated link in README that was pointing to master branch to main branch~

Realized that link in rn-tester README and ReactAndroid README leads to a dead link, so I've fixed the links

## 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] [FIXED] - Fix dead links in README

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

Test Plan: - [ ] Updated link directs you to appropriate page

Reviewed By: PeteTheHeat

Differential Revision: D29933044

Pulled By: GijsWeterings

fbshipit-source-id: c1f301626acbb2995d74f78d8bc19214c70e9319
2021-07-27 11:01:47 -07:00
Lulu Wu a480346ee0 Make initializeMessageQueueThreads() thread safe
Summary:
**Context:**
Issue:
```java.lang.IllegalStateException: Message queue threads already initialized
	at com.facebook.react.bridge.ReactContext.initializeMessageQueueThreads(ReactContext.java:100)
```

Possible root cause:
1, ReactContext.initializeMessageQueueThreads() can be called from different threads, so it's not thread safe
2, ReactContext.initializeMessageQueueThreads() is called again without detroying the threads.

**Fix:**
Make initializeMessageQueueThreads() thread safe. If this won't fix T93983690, I'll continue investigating with possible root cause 2.

Changelog:
[Android][Changed] - Make initializeMessageQueueThreads() thread safe

Reviewed By: GijsWeterings

Differential Revision: D29877386

fbshipit-source-id: 11b32c7184e9e8d6f882474fd607538df12276b7
2021-07-26 03:33:19 -07:00
Lulu Wu 7929551623 Make mHybridData thread safe for EventEmitterWrapper
Summary:
In T94154173, when calling ```EventEmitterWrapper->invoke()```, hybrid function ```invokeEvent``` is null, even if we checked that ```mHybridData``` is valid before calling ```invokeEvent```.

**Theory:**

```invoke()``` is called from ```mqt_js``` thread, ```desotry()``` is called from ```main``` thread, which cause multi-thread access of```mHybridData```.

So if ```desotry()``` is called after ```isValid()``` check and before calling ```invokeEvent()```, ```invokeEvent``` could be destroyed and is null.

I can reproduce with above theory:

{F633411001}

**Fix:**

Make functions synchronized so ```mHybridData``` can be thread safe.

Changelog:
[Android][Fixed] - Make mHybridData thread safe

Reviewed By: RSNara

Differential Revision: D29792453

fbshipit-source-id: 8b4c754d53ece933be7b2cf99c6cd026b39e24ad
2021-07-26 02:03:41 -07:00
David Vacca 43cdd84a22 Expose new API FabricUIManager.getInspectorDataForInstance
Summary:
This diff exposes a new API in FabricUIManager called getInspectorDataForInstance. The goal of this method is to return React metadata for a Native view.

This data will be used from partner teams to build tools that uses React metadata in RN

Data returned from React: P429701924

changelog: [internal] internal

allow-large-files

Reviewed By: JoshuaGross

Differential Revision: D29747864

fbshipit-source-id: 8cb55573be08cb530f7e3c83eed8b4fcf43e7781
2021-07-24 09:12:44 -07:00
Andrei Shikov de44184e01 EditText: maintain cursor position when text changes
Summary:
Similar to D29786190 (b0e39b2ed9) on iOS, keeps cursor position constant to the end of the text whenever text changes without selection updates.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D29879663

fbshipit-source-id: da1b50a99ae3b9ef796423146ba49e4172e286df
2021-07-23 14:29:11 -07:00
Hubert Gendron efb359f318 Fix testID support for TextInput, Slider and ScrollView component (#31865)
Summary:
With the advent of https://github.com/facebook/react-native/issues/29610, we are now able to use the `testID` view prop on Android in black-box testing framework through the  view's `resource-id`.

But after testing it, I noticed that on the `TextInput`, `Slider` and `ScrollView` components, the `testID` prop was not exposed as  the `resource-id` properly. The main issue was that those component was using the `AccessibilityDelegateCompat` instead of the `ReactAccessibilityDelegate`.

## Changelog

[Android] [Fixed] - Fix `testID` prop for `TextInput`, `Slider` and `ScrollView` components

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

Test Plan: ![test-screenshot](https://user-images.githubusercontent.com/69216913/125802180-c0791a8c-a740-4657-a44f-42b1885eee39.png)

Reviewed By: mdvacca

Differential Revision: D29765333

Pulled By: yungsters

fbshipit-source-id: 2b8e362257e3e5fdcd20330280c588dabb44f28a
2021-07-23 13:04:47 -07:00
Tomáš Havlas bb33c1050b Add INFO, and MENU key event support to Android TV (#31884)
Summary:
Add INFO, and MENU key event support to Android TV

## Changelog

[Android] [Added] - Add INFO, and MENU key event support to Android TV

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

Test Plan: We develop application that utilizes aforementioned events, we've made a build against react-native fork with these changes and it was working as expected. These changes just add 2 more button mappings, so I don't think it requires some extensive testing.

Reviewed By: mdvacca

Differential Revision: D29821996

Pulled By: yungsters

fbshipit-source-id: 5f97c29c9c29d6e3bafed352b8b65f0cb02f3f1d
2021-07-23 00:49:12 -07:00
Sandeep Raghunandhan cc13060d70 Downgrade warning of view illegally being added to parent to Soft Exception
Summary: - This is crashing too much in debug, which is good signal but making it harder to test, and test unrelated features.

Reviewed By: JoshuaGross

Differential Revision: D29857626

fbshipit-source-id: c52cfb6131747ae420b27de0591620fe79f47359
2021-07-22 20:35:19 -07:00
Tim Yung 7884fc519b RN: 5s Delay in `ReactAppInstrumentationTestCase`
Summary:
Tests like `CatalystSubviewsClippingTestCase` are intermittently failing due to registered callable modules not yet being registered.

Increasing the timeout to wait for the bundle execution to mitigate these intermittent failures.

Changelog:
[Internal]

Reviewed By: mdvacca

Differential Revision: D29835227

fbshipit-source-id: c9fe03202ad4028d3785216d50c6c173a56c6d84
2021-07-21 17:11:30 -07:00
Yuqing Duan 998cadd523 integrate RCTImpressionTrackingView into Fabric on Android
Summary:
This diff integrates RCTImpressionTrackingView into Fabric on Android

Following
https://www.internalfb.com/intern/wiki/React_Native/Migration_of_RN_Renderer_(Fabric)/
and
https://fb.quip.com/T8AtArEVcb0Z

Changelog: [Internal]

Reviewed By: bearzx

Differential Revision: D29804625

fbshipit-source-id: 16e89d629390093ace51d3b25725c37a49a08a39
2021-07-21 16:23:27 -07:00
Jason Safaiyeh d9e0ea77f0 Migrate to androidx.autofill.HintConstants & Support all constant types (#28008)
Summary:
Fix for https://github.com/facebook/react-native/issues/27952.

Noticed more than just `AUTOFILL_HINT_NEW_PASSWORD` were missing, this PR will support every `AUTOFILL_HINT_*` type.

## Changelog

[Android] [Added] - Added all autofill types to TextEdit

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

Reviewed By: sturmen

Differential Revision: D29766235

Pulled By: mdvacca

fbshipit-source-id: d5171aef8092d37716fddcb6f3443637a4af8481
2021-07-21 15:14:41 -07:00
Joshua Gross 24d91268b6 Add systrace sections to core
Summary:
I'm hunting down the source of a perf regression on a screen and think that having these systrace sections could be handy for this and future investigations.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D29802969

fbshipit-source-id: f4030261da8888ddeb32ae41b9cf2b25af6a5583
2021-07-20 19:28:06 -07:00
Adrián Cuesta 1465c8f387 Add support to URI keyboard type in Android (#31781)
Summary:
Android react-native `TextInput` component does nothing if prop `keyboardType` is `url` value. This PR solves that problem.

## Changelog

[Android] [Added] - Add support to URI keyboard type in Android

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

Test Plan:
Before change:

{F630980679}

After Change:

{F630986399}

Reviewed By: lunaleaps

Differential Revision: D29517822

Pulled By: sshic

fbshipit-source-id: 1bda29584a3799570f34e772b5589b59ac80c524
2021-07-16 05:13:07 -07:00
CodemodService FBSourceGoogleJavaFormatLinterBot 2970de9400 Daily `arc lint --take GOOGLEJAVAFORMAT`
Reviewed By: zertosh

Differential Revision: D29729648

fbshipit-source-id: aae1163fce96129d4953e9faa839b85147117a8e
2021-07-16 04:41:51 -07:00
Joshua Gross 9a78121ed3 Non-Fabric UIModuleManager should not flush View updates if there are no non-Fabric views
Summary:
In Fabric, we currently incur the cost of (frequently!) flushing non-Fabric UI updates, even if there are no non-Fabric views.

For now it is still possible to run both renderers at the same time, so we still largely continue to use the non-Fabric path, but only use UIImplementation if there is actually a RootView being managed outside of Fabric.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D29724538

fbshipit-source-id: 0f1148870c04ca9aaed0edfd6b5c55a3756a2bd7
2021-07-15 17:42:13 -07:00
Joshua Gross 4f38cb30b8 ][Fabric] Simplify init, always create new EventEmitter for Fabric
Summary:
Always create a new EventEmitter specifically for Fabric when initializing the Fabric JSI module.

Previously, we were (sometimes!) reusing the EventEmitter being used for the old renderer and they were shared. There doesn't seem to be a compelling reason to continue doing this, and Fabric has optimized EventEmitters that we can use instead.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D29724537

fbshipit-source-id: 1b2c7a7d656e3fb86ddf98a6cf0f2e67dcbf8aef
2021-07-15 17:42:13 -07:00
Tim Yung 92c13f0d1d RN: Replace `master` with `main` in Documentation
Summary:
Updates documentation in React Native to reference `main` (or `HEAD` for URLs) instead of `master`.

Part of https://github.com/facebook/react-native/issues/31788.

Changelog:
[General][Changed] - Update documentation reference from `master` to `main` or `HEAD`.

Reviewed By: JoshuaGross

Differential Revision: D29717128

fbshipit-source-id: 0b0babd8407c6fd3d0e5431f6eaf976059731d6f
2021-07-15 15:22:57 -07:00
Joshua Gross ff9c8cdac9 Downgrade warning about non-clippable views being clipped to no-crash exception
Summary:
This is crashing too much in debug, which is good signal but making it harder to test, and test unrelated features.

We have some good data about this internally and validated that it's useful; we can follow up on the logged soft exceptions without actually crashing now.

Changelog: [Internal]

Differential Revision: D29698447

fbshipit-source-id: 61387c18f17f76e5de60baa1fd3c94028229c0f6
2021-07-14 11:21:04 -07:00
Tomek Zawadzki f00e348ca7 Fix support for blobs larger than 64 KB on Android (#31789)
Summary:
Fixes https://github.com/facebook/react-native/issues/31774.

This pull request resolves a problem related to accessing blobs greater than 64 KB on Android. When an object URL for such blob is passed as source of `<Image />` component, the image does not load.

This issue was related to the fact that pipe buffer has a limited capacity of 65536 bytes (https://man7.org/linux/man-pages/man7/pipe.7.html, section "Pipe capacity"). If there is more bytes to be written than free space in the buffer left, the write operation blocks and waits until the content is read from the pipe.

The current implementation of `BlobProvider.openFile` first creates a pipe, then writes the blob data to the pipe and finally returns the read side descriptor of the pipe. For blobs larger than 64 KB, the write operation will block forever, because there are no readers to empty the buffer.

41ecccefcf/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobProvider.java (L86-L95)

This pull request moves the write operation to a separate thread. The read side descriptor is returned immediately so that both writer and reader can work simultaneously. Reading from the pipe empties the buffer and allows the next chunks to be written.

## 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] [Fixed] - Fix support for blobs larger than 64 KB

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

Test Plan:
A new example has been added to RN Tester app to verify if the new implementation properly loads the image of size 455 KB from a blob via object URL passed as image source.

<img src="https://user-images.githubusercontent.com/20516055/123859163-9eba6d80-d924-11eb-8a09-2b1f353bb968.png" alt="Screenshot_1624996413" width="300" />

Reviewed By: ShikaSD

Differential Revision: D29674273

Pulled By: yungsters

fbshipit-source-id: e0ac3ec0a23690b05ab843061803f95f7666c0db
2021-07-14 11:11:31 -07:00
Tim Yung b5c94e316c RN: Upgrade `infer-annotation` to 0.18.0 (#31856)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/31856

Upgrades `infer-annotation` to 0.18.0 so that we can use `Nullsafe` in Android Java.

I found this when looking at the "Bazel" steps on this page: https://search.maven.org/artifact/com.facebook.infer.annotation/infer-annotation/0.18.0/jar

Changelog:
[Android][Changed] - Upgraded `infer-annotation` to 0.18.0.

Reviewed By: mdvacca, ShikaSD

Differential Revision: D29685321

fbshipit-source-id: a017ad29355c4790bffa8bcd349336e51261f83e
2021-07-13 15:08:32 -07:00
Tim Yung 9d2fedc6e2 RN: Unify Typeface Logic (Android)
Summary:
Refactors how `Typeface` style and weight are applied in React Native on Android.

- Unifies all style and weight normalization logic into a new `TypefaceStyle` class.
  - Fixes font weight support for the Fabric renderer.
  - De-duplicates code with `TextAttributeProps`.
  - Simplified normalization logic.
- Fixes a rare crash due to `Typeface.sDefaultTypeface` (Android SDK) being `null`.
- Adds a new example to test font weights in `TextInput`.
- Adds missing `Nullsafe` and `Nullable` annotations.
- Clean up a bunch of obsolete inline comments.

Changelog:
[Android][Fixed] - Fixed a rare crash due to `Typeface.sDefaultTypeface` (Android SDK) being `null`.
[Android][Fixed] - Fixed font weight support for the Fabric renderer.
[Android][Added] - Added a new example to test font weights in `TextInput`.

Reviewed By: JoshuaGross

Differential Revision: D29631134

fbshipit-source-id: 3f227d84253104fa828a5561b77ba7a9cbc030c4
2021-07-12 22:17:12 -07:00
Tomáš Havlas 3e2bb331fc Add MEDIA_STOP, MEDIA_NEXT, and MEDIA_PREVIOUS event support to Android TV (#31837)
Summary:
Add MEDIA_STOP, MEDIA_NEXT, and MEDIA_PREVIOUS event support to Android TV (TVEventHandler)

## Changelog

[Android] [Added] - Add MEDIA_STOP, MEDIA_NEXT, and MEDIA_PREVIOUS event support to Android TV

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

Test Plan: We develop application that utilizes aforementioned events, we've made a build against react-native fork with these changes and it was working as expected. These changes just add 3 more button mappings, so I don't think it requires some extensive testing.

Reviewed By: TheSavior

Differential Revision: D29668706

Pulled By: yungsters

fbshipit-source-id: e4bd8dcf7de6b094ffdbbca12d875b85e468d49a
2021-07-12 21:29:56 -07:00
Janic Duplessis d6ed1ff58b Allow configuring ndk build architectures (#31232)
Summary:
Building from source in debug takes a very long time because native builds need to run for all supported architectures. It is possible to check which architecture the devices for which we are about to launch the app on are and build only for those. For most cases we can reduce the number of architectures we build for to 1 instead of 4, resulting in a large speedup of the build.

This is inspired by iOS which has a "Build for active architecture only" option. Since android doesn't really support this natively we can implement it here and also in react-native by reading the build properties that we pass and alter the abi we build for.

With fabric / codegen coming up I suspect that we might want to default to building c++ soon. This should ease the transition as builds won't be orders of magnitude slower.

See https://github.com/react-native-community/cli/pull/1388 for more context and how we use this new config to automatically detect running emulator architectures.

## Changelog

[Android] [Added] - Allow configuring ndk build architectures

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

Test Plan:
Tested by setting reactNativeDebugArchitectures with different values in gradle.properties.  Checked the build logs to see which architectures are being built. Also made sure release builds are not affected by this value.

Clean build

reactNativeDebugArchitectures not set
824.41s

reactNativeDebugArchitectures=x86
299.77s

Reviewed By: mdvacca

Differential Revision: D29613939

Pulled By: ShikaSD

fbshipit-source-id: d20a23d1d9bbf33f5afaaf3475f208a2e48c0e1a
2021-07-12 09:53:30 -07:00
Andrei Shikov 8dfc3bcda1 Return early from textview layout pass if text layout is null
Summary:
Could not repro myself, but logview shows steady low number of crashes coming from this mid. Current fix returns early if the layout is not defined, relying on the following layout passes to position view correctly.

Changelog: [Android][Fixed] Exit early from layout in textview if text layout is null

Reviewed By: JoshuaGross

Differential Revision: D29636040

fbshipit-source-id: 876ce80222cbc5ff09450224f6808f9f6433c62a
2021-07-12 06:07:17 -07:00
Anas Khurshid 25a16123a6 Added Support for Entrance/exit from collection by Flatlist (#31630)
Summary:
Issue https://github.com/facebook/react-native/issues/30964 .When using a screen reader, flatlist does not announce entrance/ exit from the flat list.

## Changelog

[Android] [Changed] - Added support for accessibility role of "list" for flatlist and sectioned list

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

Test Plan: I have added accessibility role prop in flatlist and sectioned list in rntester app, that will announce entrance/ exit from flatlist and sectioned list.

Reviewed By: kacieb

Differential Revision: D29599351

Pulled By: blavalla

fbshipit-source-id: e16ec69a694780d12f15f88a1e6bb5d7d77ac15f
2021-07-09 19:25:36 -07:00
Andrei Shikov 0b40fea60c Fix NDK path propagation
Summary:
Latest Android Gradle plugin doesn't respond to ANDROID_NDK env variable, so I propagated it explicitly and included with recommended `ndkPath` clause.

Changelog: [Internal]

allow-large-files

Reviewed By: fkgozali

Differential Revision: D29593132

fbshipit-source-id: 0785fe92385037d2d4cf290c2462b299800b6928
2021-07-08 13:23:48 -07:00
Agastya Darma 6caec9d91f Android: upgrading to OkHttp from 4.9.0 to 4.9.1 to fix java.lang.NullPointerException: bio == null crash (#31822)
Summary:
Douring our routine crash report check we are occasionally seeing reports of exceptions like this in the wild from our crash stack:

```
java.lang.NullPointerException: bio == null
       at com.android.org.conscrypt.NativeCrypto.SSL_pending_written_bytes_in_BIO(NativeCrypto.java)
       at com.android.org.conscrypt.NativeSsl$BioWrapper.getPendingWrittenBytes(NativeSsl.java:660)
       at com.android.org.conscrypt.ConscryptEngine.pendingOutboundEncryptedBytes(ConscryptEngine.java:566)
       at com.android.org.conscrypt.ConscryptEngineSocket.drainOutgoingQueue(ConscryptEngineSocket.java:584)
       at com.android.org.conscrypt.ConscryptEngineSocket.close(ConscryptEngineSocket.java:480)
       at okhttp3.internal.Util.closeQuietly(Util.kt:501)
       at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFile:245)
       at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFile:106)
       at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFile:74)
       at okhttp3.internal.connection.RealCall.initExchange$okhttp(ExchangeFile:255)
       at okhttp3.internal.connection.ConnectInterceptor.intercept(ExchangeFile:32)
       ...
  ```

![Screen Shot 2021-07-07 at 1 38 23 PM](https://user-images.githubusercontent.com/8868908/124711795-b5fee980-df28-11eb-98c4-9668661340b6.png)

This appears to only be happening on devices running Android 10 and 11. This happens because there is concurrency issue in Conscrypt where two threads race to close an SSLEngine-based SSLSocket and access to the underlying BIO is unsynchronized.

 **The OkHttp team already released a fix for this issue on version 4.9.1** this PR aims to update our OkHttp package to version 4.9.1.

 Related discussion:
 [https://issuetracker.google.com/issues/177450597](https://issuetracker.google.com/issues/177450597)
 [https://publicobject.com/2021/01/30/bio-null/](https://publicobject.com/2021/01/30/bio-null/)

cc dulmandakh fkgozali

## Changelog
[Android] [Changed] - Bumping OkHttp from 4.9.0 to 4.9.1.

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

Test Plan: Manual & Automated from CI

Reviewed By: fkgozali

Differential Revision: D29590198

Pulled By: ShikaSD

fbshipit-source-id: 4228bfd3472114253e13acb436dc1dd9287a148d
2021-07-08 13:23:48 -07:00
Joshua Gross 94a2b2c86d Resolve T94204073 by swallowing errors
Summary:
At risk of hiding errors, given the low volume, I think it's safe to cause this to crash in debug and continue gracefully in release-mode.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D29618047

fbshipit-source-id: 19b19d8f6e27703227de4947ed01f7f2177f463b
2021-07-08 12:23:57 -07:00
David Vacca fb386fccdd Fix NullPointerException caused by race condition in ReactInstanceManager.getViewManagerNames method
Summary:
This diff fixes a NullPointerException that is caused when the method ReactInstanceManager.getViewManagerNames is called at the same time ReactInstanceManager is being destroyed.

Following the stacktrace I noticed that this crash can only happen when RN was destroyed by another thread while this method was being executed

This diff fixes the NullPointerException, but it doesn't fix the root cause race condition that cuases this bug

changelog: [Android][Fixed] Fix NullPointerException caused by race condition in ReactInstanceManager.getViewManagerNames method

Reviewed By: JoshuaGross

Differential Revision: D29616401

fbshipit-source-id: 6ae8ecdd765d2fe3529fef3237f08b182d8ed243
2021-07-08 12:10:55 -07:00
Joshua Gross 8ed4068381 Don't pass on receiveEvent after CatalystInstance destruction
Summary:
It is possible for receiveEvent to be called concurrently with/after destruction of FabricUIManager. Drop events if we are able to detect that case.

Changelog: [Internal]

Reviewed By: sshic

Differential Revision: D29596271

fbshipit-source-id: 1fa50d9c3cff0bf578316d905966e1bdfffe94d1
2021-07-08 11:36:50 -07:00
Joshua Gross 4ad4426daf Ship "state update scroll race" to ScrollView and HorizontalScrollView
Summary:
As a followup to T91209139, ship "state update scroll race" in code. This also ships it for HorizontalScrollView since it's been validated for vertical scroll views.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D29595601

fbshipit-source-id: 64b6a23e2dab2c13123e132d9d899fb769d03172
2021-07-07 16:23:10 -07:00
Joshua Gross 421df26266 Mitigate T94864568 by dropping TouchEvents that do not have a MotionEvent
Summary:
I suspect that T94864568 is caused by TouchEvents being dispatched after they've been recycled. This needs further analysis, but to stop the bleeding, we can drop events at the point they'd be dispatched before the crash, and log a soft error.

Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D29594749

fbshipit-source-id: f50df8df2125b83126616ceaf4e529127d154c7c
2021-07-07 15:23:14 -07:00
Joshua Gross 3b569b8aff Ensure that TouchEvent is initialized with a valid MotionEvent
Summary:
It is unlikely but possible that the crash T94864568 is caused by a TouchEvent being initialized with a null MotionEvent. Regardless, we should guard against this case.

Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D29594750

fbshipit-source-id: 3a409b716a9f1eec8017002ae7e23273677e53ba
2021-07-07 13:36:34 -07:00
Kudo Chien ebe939b18a Upgrade folly to fix NDK 21 build issue (#31802)
Summary:
Upgrade folly for the https://github.com/facebook/folly/pull/1593 fix for NDK 21 failure

## 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] - Upgrade folly to 2021.06.28.00

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

Test Plan:
`./gradlew :ReactAndroid:installArchives`
`./gradlew packages:rn-tester:android:app:installJscRelease`
`./gradlew packages:rn-tester:android:app:installHermesRelease`

Reviewed By: RSNara

Differential Revision: D29547027

Pulled By: ShikaSD

fbshipit-source-id: a10c7c65f459091bd0e7cca750a9b9e067189b73
2021-07-06 10:35:25 -07:00
Joshua Gross 34903ba418 Add mechanism to enforce certain Views always being visible in the View hierarchy
Summary:
See comments in ReactClippingProhibitedView for details and motivation behind this new feature.

You may have a View class inherit from the ReactClippingProhibitedView interface in order to enable this feature for instances of that View type.

This can be added to Views that should /never/ be clipped from the View hierarchy - namely, TTRC components or other telemetry components that always need to be rendered in order for some feature to function.

Changelog: [Added] Opt-in mechanism to allow native Android Views to be marked as "not clippable", soft exceptions will be logged if these Views are clipped from the View hierarchy

Reviewed By: sshic

Differential Revision: D29472439

fbshipit-source-id: b3be53df836b452aed5dc40514ff585ce0ad812b
2021-06-30 10:39:55 -07:00
Pieter De Baets e6b9508f12 Fix crash when PlatformColor is used as backgroundColor
Summary:
@public

When PlatformColor is used with backgroundColor, this line would throw, as the object type is not convertible to int.

Changelog:
[Android][Fixed] - Fix Crash in ViewProps.isLayoutOnly

Reviewed By: JoshuaGross

Differential Revision: D29430151

fbshipit-source-id: a1fe801925430dad3a17871bdebb79d942775280
2021-06-30 01:19:53 -07:00
Joshua Gross 41ecccefcf Immediately destroy EventEmitterWrapper on update instead of waiting for GC
Summary:
Immediately destroy EventEmitterWrapper on update instead of waiting for Java GC. This can resolve JSI::~Pointer deallocation crashes by clearing out EventEmitter and therefore EventTarget sooner, before RN teardown.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D29415386

fbshipit-source-id: 05517bfd9e2cc2bd1b8c58d4f84c84f6f547268a
2021-06-26 12:21:16 -07:00
David Alves b673e352fb Use weak hash map for react scroll view helper
Summary:
This prevents us from leaking things via this static field.

Changelog: [Android][Changed] Native ScrollView listeners list maintains weak references to listeners to avoid memory leaks

Reviewed By: JoshuaGross

Differential Revision: D29317937

fbshipit-source-id: 4daeb8b5533cccaebcb03acf3d595dfa58de7883
2021-06-25 13:24:01 -07:00
Joshua Gross f33e6f08b2 Delete unused struct
Summary:
This struct is no longer used.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D29312925

fbshipit-source-id: b766014ecb7b6c5dc96d54a94d465e104e292f5f
2021-06-22 15:42:01 -07:00
Samuel Susla 090f828bdd Remove redundant dependency of runtimescheduler
Summary:
Changelog: [internal]

This dependency is redundant and is causing CircleCI to fail: https://app.circleci.com/pipelines/github/facebook/react-native/9495/workflows/c6002413-bd5f-431f-b23d-c1ee820cbebf/jobs/206781

Reviewed By: ShikaSD

Differential Revision: D29292209

fbshipit-source-id: a974e48300c96669ec041cb145ce57fe5c2a7fe2
2021-06-22 06:18:16 -07:00
Luna Wei 77366cd869 Remove Picker from OSS
Summary: Changelog: [General][Removed] - Remove Picker code from Android

Reviewed By: ShikaSD

Differential Revision: D29123164

fbshipit-source-id: 4471ea5f52885735ead07a656452ed5ef2bff65b
2021-06-21 23:00:42 -07:00
Samuel Susla 130b0f69ee Move RuntimeScheduler initialisation to the start of the runtime
Summary:
Changelog: [internal]

Reland of D29131766 (18165367b0) which had to reverted because it caused binary size regression in instagram.

Size check for `automation_instagram_stablesize_release` and `automation_igtv_release`
{F626711916}

Reviewed By: JoshuaGross

Differential Revision: D29263302

fbshipit-source-id: cc8f5609ebaed9ddf666f7c57cdbf3dbf77a8f78
2021-06-21 16:15:11 -07:00
Joshua Gross 006f5afe12 Guard against unsafe EventEmitter setup and teardown
Summary:
Because of T92179998, T93607943, and T93394807, we are still seeking resolution to tricky crashes wrt the use of EventEmitters.

I believe the recent spike is because of two recent changes: we pass in EventEmitters earlier, during PreAllocation; and we clean them up earlier, during stopSurface, to avoid jsi::~Pointer crashes.

Additionally, the gating previously added around the PreAllocation path was incorrect and led to more nullptrs being passed around as EventEmitters.

To mitigate these issues:

1) I am adding/fixing gating to preallocation and early cleanup paths
2) I am making EventEmitterWrapper more resilient by ensuring EventEmitter is non-null before invoking it.
3) I am making sure that in more cases, we pass a non-null EventEmitter pointer to Java.
4) I am backing out the synchronization in EventEmitterWrapper (java side) as that did not resolve the issue and is a pessimisation

There are older, unchanged paths that could still be passing in nullptr as the EventEmitter (Update and Create). As those have not changed recently, I'm not going to fix those cases and instead, we can now rely on the caller to ensure that the EventEmitter is non-null before calling.

Changelog: [internal]

Differential Revision: D29252806

fbshipit-source-id: 5c68d95fa2465afe45e0083a0685c8c1abf31619
2021-06-19 22:57:12 -07:00
Joshua Gross 499ac1f14b Resolve race condition in usage/teardown of EventEmitterWrapper
Summary:
In stopSurface we destroy these EventEmitters which is not a threadsafe operation. Wrap usage and destruction of these wrappers to prevent crashes.

This crash is caused by D29020768 (25e8fbe8ff) which was landed to fix T92179998, which was in turn caused by D28938637 (ac6d1982f4).

Changelog: [internal]

Reviewed By: sammy-SC, mdvacca

Differential Revision: D29239828

fbshipit-source-id: 6be5acf4a24b82c75c13fe9f1d16a87cce5b7e00
2021-06-18 14:22:43 -07:00
Joshua Gross 225ff72d2d Temporary mitigation for T93398735 crash: swallow PreAllocate crashes
Summary:
Because of the "disable preallocation of virtual views" experiment, for some reason, some views are being preallocated multiple times instead of not being preallocated at all.

This isn't really a problem for CreateView, and Preallocate is actually more strict here than it needs to be. I'm going to downgrade this to a soft error and will continue to analyze more. This is more of a perf issue than a correctness issue, so this should be fine.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D29206416

fbshipit-source-id: 9490a1a705c2b39def3a3e56086634439543515e
2021-06-17 17:28:32 -07:00
Andrei Shikov 6be4f2b2c8 Fix Android build sequencing
Summary:
The native libraries are compiled outside of the usual Android build flow using separate CLI task. Because of that, shared native libraries may not exist when AAR is bundled, resulting in weird sequencing issues.

This change updates gradle dependency graph, executing RN native build before Android part (as it is done in RNTester already).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D29209249

fbshipit-source-id: 36386c78996b1cd9b1731735e36e571199e9e81b
2021-06-17 15:11:06 -07:00
Samuel Susla 475de7982e Call invokeUnique if event can be coalesce
Summary:
Changelog: [internal]

We should be calling invokeUnique if event can be coalesced, not the other way around.

Reviewed By: JoshuaGross

Differential Revision: D29194528

fbshipit-source-id: 36e4ae71254420ef47deea436cad20eec09712fc
2021-06-17 11:50:03 -07:00
Samuel Susla a9f1e23d38 Check if instance is valid before calling C++
Summary:
Changelog: [internal]

Why does the crash happen?
We call method on invalid address. We crash on `std::weak_ptr::lock` because that's the first accessed ivar.
In D29020768 (25e8fbe8ff), eventEmitter may be destroyed before an event is dispatched. Calling destroy on hybrid object destroys only C++ part.

Reviewed By: JoshuaGross

Differential Revision: D29194906

fbshipit-source-id: ae8d9d90aa8d98d69d29884e80d6b930b1e66870
2021-06-17 10:01:22 -07:00
Samuel Susla 30ce8618b9 Remove using namespace from header file
Summary:
Changelog: [internal]

It is recommended to not use `using namespace` in the header file. It changes namespace for anything that imports the header file.
Also keeping imports in header file to minimum is recommended to lower build times.

Reviewed By: JoshuaGross

Differential Revision: D29131371

fbshipit-source-id: ad1868f6200c00023a62a00859d9a05140a12849
2021-06-17 06:29:39 -07:00
Dulmandakh aa43aab77c Bump NDK to 21.4.7075529 (#31731)
Summary:
This PR bumps NDK_VERSION to 21.4.7075529, and patches FileUtil.cpp from folly based on patch from https://github.com/facebook/folly/pull/1593. We can remove the patch once PR lands in Folly and bump Folly version in RN.

FYI, NDK 20 is deprecated and 21 is LTS release.

## Changelog

[Android] [Changed] - Bump NDK to 21.4.7075529

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

Reviewed By: mdvacca

Differential Revision: D29166690

Pulled By: ShikaSD

fbshipit-source-id: 0792691404f718aaf5af1369f66f0cba046b4e20
2021-06-17 04:21:50 -07:00
Luna Wei 625d9e5090 Remove PickerAndroidTestModule
Summary: Changelog: [Internal] - Delete PickerAndroidTestModule in prep for deprecating Picker from OSS

Reviewed By: kacieb

Differential Revision: D29082826

fbshipit-source-id: eb7219f1a1e77205eeb8532ac3e17f8956f23c03
2021-06-16 12:29:17 -07:00
Samuel Susla 279fb3eedc Back out "Move RuntimeScheduler initialisation to the start of the runtime"
Summary:
Changelog: [internal]

Original commit changeset: cbc650f6fbce

Fix app size regression.

Reviewed By: julian-krzeminski

Differential Revision: D29162397

fbshipit-source-id: 54b344c2da631aaa704fd640cdb2a71239ea754f
2021-06-16 08:40:29 -07:00
Ramanpreet Nara e91fb05db7 DevMenu: Change "Toggle Inspector" to Show/Hide Element Inspector
Summary:
Rationale:
- This makes the element inspector button consistent with the Fast Refresh, Perf Monitor and other buttons in the DevMenu
- This makes the button more informative

Changelog: [Android][Changed] Rename the "Toggle Inspector" DevMenu item to "Hide/Show Element Inspector"

Reviewed By: JoshuaGross

Differential Revision: D29146871

fbshipit-source-id: 8e8c19217ea2ff2f1d176521aa22200058e7e643
2021-06-15 18:21:13 -07:00
Samuel Susla 18165367b0 Move RuntimeScheduler initialisation to the start of the runtime
Summary:
Changelog: [internal]

RuntimeScheduler needs to be created and registered in the runtime before any JS is allowed to run. This diff moves the registration right after the runtime is initialised.

This diff removes funnelling of Fabric events through RuntimeScheduler. This will be added in subsequent diff to keep the complexity low.

Reviewed By: JoshuaGross

Differential Revision: D29131766

fbshipit-source-id: cbc650f6fbce95e4b9c2c9695e8e0aba5beac635
2021-06-15 17:35:32 -07:00
Samuel Susla 741b4d4421 Remove RuntimeScheduler from SchedulerToolbox
Summary:
Changelog: [internal]

Remove `RuntimeScheduler` from `SchedulerToolbox` and all of its uses.
`RuntimeScheduler` needs to be allocated before `Scheduler` and therefore its presence in the toolbox is redundant.

Reviewed By: JoshuaGross

Differential Revision: D29134769

fbshipit-source-id: fa00c5dcc4b565d6941e6d742c6aefade37b31c4
2021-06-15 17:35:32 -07:00
Ramanpreet Nara cf2238eb66 Add title to DevMenu
Summary:
Before the DevMenu would just open up as a DialogBox. After this change, the DialogBox will have a title. This should help distinguish between the Bridgeless DevMenu and the Bridge DevMenu.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29071185

fbshipit-source-id: 72533f10b73b36cd890fe152c6de901c867159f2
2021-06-15 12:15:39 -07:00
Ramanpreet Nara 6676d01033 Give each DevSupportManagerBase subclass a unique bundle filename and split bundle directory
Summary:
With bridgeless mode enabled, there can be two instances of DevSupportManager. Previously, both of them wrote to the same files on disk. After this change, each instance will write the bundle to different files on disk.

Changelog: [Internal]

Reviewed By: sshic

Differential Revision: D29068794

fbshipit-source-id: 67270be17d084cc89ab618ea54f729f9b595b5f7
2021-06-15 12:15:39 -07:00
Ramanpreet Nara 5f2fae0c2d Move Chrome debugging menu item to BridgeDevSupportManager
Summary:
Google Chrome debugging is only supported by the bridge. So, it makes sense to move it to BridgeDevSupportManager.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29031514

fbshipit-source-id: 4d6b6bb3bc298be5fe4d9f96c0d019676fe256db
2021-06-15 12:15:39 -07:00
David Vacca 2f943d9d63 Fix NullPointerException during tear down of RN Android
Summary:
This diff prevents a NullPointerException caused by a race condition in the tear down of React Native.

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D29135942

fbshipit-source-id: 76d5a1f16c2ca63a146b56c761f5f9595dcfe2a5
2021-06-15 10:22:39 -07:00
Andrei Shikov a7adaf3062 Retry mounting items that were scheduled on view attach
Summary:
The mount items executed before the view attach can fail with the RetryableMountingLayerException, which we should either retry or skip the item. This change updates logic for such items to catch these exceptions.

Instead of passing `MountingManager` to execute the items, this change now passes a reference to the `MountItemDispatcher` (abstracted through interface to resolve cycle between the manager and dispatcher). The dispatcher executes the queue directly and schedules retry together with the next batch.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29068063

fbshipit-source-id: 04030b21db188d5617c3448322d25ba77d5fbb9f
2021-06-15 05:45:57 -07:00
Joshua Gross 883f4651bc Remove unused field
Summary:
This field doesn't serve a purpose anymore.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D29118454

fbshipit-source-id: b755a761eb7e9854d48c99dfedaf2e871f29d7f7
2021-06-14 19:44:09 -07:00
Joshua Gross e67007c928 Gate early EventEmitter update during PreAllocation behind feature flag
Summary:
This feature is still causing some number of crashes, though prod impact is not yet determined. For safety I'm adding a feature flag so we can disable this if necessary.

Changelog: [internal]

Reviewed By: kacieb

Differential Revision: D29117957

fbshipit-source-id: 3b19bac9dd00735f51f5c9cba606378b2a62975e
2021-06-14 19:31:32 -07:00
Dulmandakh 8fa8934011 bump fresco to 2.5.0 (#31699)
Summary:
This PR bumps Fresco to 2.5.0, which is first version on MavenCentral since jCenter announcement.

## Changelog

[Android] [Changed] - Bump Fresco to 2.5.0

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

Test Plan: CI is green

Reviewed By: TheSavior

Differential Revision: D29031847

Pulled By: passy

fbshipit-source-id: 486ffbf5461d07d736c0ebe17c0c7726937db344
2021-06-11 03:15:20 -07:00
Ramanpreet Nara 67a486e577 Move Sampling profiler from DevSupportManagerBase to BridgeDevSupportManager
Summary:
## Rationale
The sampling profiler not supported with bridgeless mode. Why: [the sampling profiler uses the JavaScriptExecutorFactory](https://www.internalfb.com/code/fbsource/[927e2dc640a45e7e408f621cb06f6b1056ce357a]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java?lines=654-655), which is explicitly not implemented in bridgeless mode: [AsyncDevSupportManager.java](https://www.internalfb.com/code/fbsource/[927e2dc640a45e7e408f621cb06f6b1056ce357a]/fbandroid/java/com/facebook/venice/AsyncDevSupportManagerImpl.java?lines=108).

So, this diff moves the sampling profiler into BridgeDevSupportManager.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29006837

fbshipit-source-id: 2bb2889253b33d7b5b00d3e935e8d624f1c3612e
2021-06-10 16:47:20 -07:00
Ramanpreet Nara 61dda3242d Refactor: Delete ExceptionLogger interface in DevSupportManagerBase
Summary:
## Rationale
- ExceptionLogger [is a private interface](https://www.internalfb.com/code/fbsource/[0fa3b362177087a2b5c4544c9d65a01f7f09b0e7]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java?lines=256-258) is [only implemented by JSExceptionLogger](https://www.internalfb.com/code/search?q=repo%3Afbsource%20regex%3Aon%20implements%20ExceptionLogger&tab=all)
- You can only have one ExceptionLogger, which is [a JSExceptionLogger created in DevLoadingViewBase](https://www.internalfb.com/code/fbsource/[0fa3b362177087a2b5c4544c9d65a01f7f09b0e7]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java?lines=227).

So, we could remove this generalized ExceptionLogger interface and just use replace it with an instance method on DevSupportManagerBase. This makes DevSupportManagerBase easier to reason about.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29007764

fbshipit-source-id: 357f0e2e07f381f43b4b5e0c5f1415f87af7fd88
2021-06-10 16:47:20 -07:00
Ramanpreet Nara 1d14df217e Refactor: Stop having DevSupportManager conform to PackagerCommandListener
Summary:
## Rationale
The public methods of PackagerCommandListener should not be a part of the public API of DevSupportManagerBase. It's cleaner to just create a new PackagerCommandListener object inline, when we need it. This way, there're are less methods to think about when reasoning about the public API of DevSupportManagerBase.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29006835

fbshipit-source-id: 0eea86c22e7d676c94d29b240a1f39955d8216ab
2021-06-10 16:47:20 -07:00
Ramanpreet Nara 675e480fb9 Refactor: Make DevSupportManager not conform to DevInternalSettings.Listener
Summary:
## Rationale
This reduces the surface area of DevSupportManager's public API.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29006836

fbshipit-source-id: 579364f6c556b8588f3b6bac79df3deb244a92e5
2021-06-10 16:47:20 -07:00
Ramanpreet Nara 39d9122445 Delete unnecessary DevSupportManager constructor
Summary:
## Rationale
This DevSupportManagerBase constructor isn't used anywhere, aside from VeniceDevSupportManager. Even in VeniceDevSupportManager, we should use the more specific constructor, because it informs readers of the class what specifically is being nullified in the base class. So, this diff gets rid of the smaller arity constructor.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29004542

fbshipit-source-id: 74e20db93cf1871a364bf228dc089cd7d124297f
2021-06-10 16:47:19 -07:00
Ramanpreet Nara 7c6eb1fecb Move handleReloadJS() from DevSupportManagerBase to BridgeDevSupportManager
Summary:
## Rationale
DevSupportManagerBase.handleReloadJS() implements reloads for the bridge. Therefore, it's best to move this method to BridgeDevSupportManager.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29004541

fbshipit-source-id: f77244e9c44cd442e7e0ab2845f78d699b143e66
2021-06-10 16:47:19 -07:00
Ramanpreet Nara 2c88459e24 Refactor: Introduce methods to show/hide DevLoadingView in DevSupportManagerBase
Summary:
## Rationale

Throughout DevSupportManagerBase, we show/hide the DevLoadingView and simultaneously write to the `mDevLoadingViewVisible` boolean. This diff pulls all those boolean writes into methods, so that subclasses of DevSupportManagerBase can show/hide the DevLoadingView without accessing the boolean directly.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29004062

fbshipit-source-id: d54d79701e31f9ac8d1d1d44019199718fe1c8c0
2021-06-10 16:47:19 -07:00
Ramanpreet Nara 30340890dc Move loadSplitBundleFromServer from DevSupportManagerBase to BridgeDevSupportManager
Summary:
## Rationale
DevSupportManagerBase.loadSplitBundleFromServer() uses the bridge. So, it's best to move it to DevSupportManagerBase.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D29004064

fbshipit-source-id: 9acfb769d57a44ee4871e1997ff0950c3d66b757
2021-06-10 16:47:19 -07:00
Ramanpreet Nara 3feaecd473 Rename DevSupportManagerImpl to BridgeDevSupportManager
Summary:
## Rationale
See the description of D28978217.

Changelog: [Internal]

Reviewed By: sshic

Differential Revision: D28978218

fbshipit-source-id: 29b9269b3d0e25171abaf6b74cacd0439f5c8ab5
2021-06-10 16:47:19 -07:00
Joshua Gross f2e0b2f45f Fix crash in PreAllocation optimization
Summary:
PreAllocation currently always happens at revision 0 (after ShadowNode creation), and all CREATE mutations are triggered for ShadowNodes at revision 1 or higher (since CREATE mutations are generated by the differ, it means that all ShadowNodes have revision 1 or higher when CompleteRoot is called). This means that between PreAllocation and CREATE, we /always/ expect at least one clone.

It is possible for a node to be "non-view-forming" at revision 0, causing view preallocation to be skipped, and "view-forming" at revision 1 (causing the CREATE mutation to be thrown away, since all CREATE mutations of revision 0 or 1 are thrown away). This causes a crash. It is extremely marginal, but there are repros in the wild.

Thus, I'm introducing one new UIManager and Scheduler delegate method that allows the mounting layer to be notified of clones. If a clone from rev 0->1 results in a node going from non-view-forming to view-forming, we can preallocate then, as well.

This resolves this crash, and allows us to keep experimenting safely with this View PreAllocation optimization. I believe all edge-cases are accounted for.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D29043426

fbshipit-source-id: dff11d3140ded1cbb02a5518a3aeb52dc812cc50
2021-06-10 15:50:14 -07:00
Joshua Gross 25e8fbe8ff Ensure that EventEmitterWrapper is cleaned up as soon as a View is deleted
Summary:
In T92179998, there is a crash when an EventEmitterWrapper is deallocated after the JS VM is torn down, and the EventEmitterWrapper tries to free its JSI::Pointer reference (double-free).

To make sure this happens less/not at all, free EventEmitterWrappers on ViewState when a view is deleted, instead of waiting for all of RN to be torn down.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D29020768

fbshipit-source-id: 9d72a23bc9966992ef56c1e3ee523405d4333194
2021-06-09 23:48:04 -07:00
Maxime Bertheau ba387b91d3 Fix `setSnapToOffsets` crashing on Android if `snapToOffsets` is null (#31681)
Summary:
Fixes https://github.com/facebook/react-native/issues/30502.
This PR fixes a crash caused by a `NullPointerException` when updating the `snapToOffsets` property.
I noticed this crash on production, you'll find the stack trace below.

Cause: `snapToOffsets` is annotated `Nullable` but there are no nullability check before calling `snapToOffsets.size()`.

## Changelog

[Android] [Fixed] - Fixed a crash when updating `snapToOffsets` to a null value

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

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

Test Plan:
Passing `snapToOffsets={undefined}` to a `FlatList` used to crash on Android. Not anymore.

## Stacktrace

```
com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'snapToOffsets' of a view managed by: RCTScrollView
        at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:102)
        at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.java:136)
        at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:56)
        at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:49)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties(NativeViewHierarchyManager.java:143)
        at com.facebook.react.uimanager.UIViewOperationQueue$UpdatePropertiesOperation.execute(UIViewOperationQueue.java:93)
        at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:908)
        at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1019)
        at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:47)
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1079)
        at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1008)
        at android.view.Choreographer.doCallbacks(Choreographer.java:809)
        at android.view.Choreographer.doFrame(Choreographer.java:740)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8512)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:87)
        at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.java:136)
        at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:56)
        at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:49)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties(NativeViewHierarchyManager.java:143)
        at com.facebook.react.uimanager.UIViewOperationQueue$UpdatePropertiesOperation.execute(UIViewOperationQueue.java:93)
        at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:908)
        at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1019)
        at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:47)
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1079)
        at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1008)
        at android.view.Choreographer.doCallbacks(Choreographer.java:809)
        at android.view.Choreographer.doFrame(Choreographer.java:740)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8512)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'int com.facebook.react.bridge.ReadableArray.size()' on a null object reference
        at com.facebook.react.views.scroll.ReactScrollViewManager.setSnapToOffsets(ReactScrollViewManager.java:107)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp(ViewManagersPropertyCache.java:87)
        at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty(ViewManagerPropertyUpdater.java:136)
        at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:56)
        at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:49)
        at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties(NativeViewHierarchyManager.java:143)
        at com.facebook.react.uimanager.UIViewOperationQueue$UpdatePropertiesOperation.execute(UIViewOperationQueue.java:93)
        at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:908)
        at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1019)
        at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:47)
        at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1079)
        at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
        at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
        at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1008)
        at android.view.Choreographer.doCallbacks(Choreographer.java:809)
        at android.view.Choreographer.doFrame(Choreographer.java:740)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8512)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
```

Reviewed By: ShikaSD

Differential Revision: D28965864

Pulled By: JoshuaGross

fbshipit-source-id: f08f1df371c1892935e1290806cc67d34394203b
2021-06-09 11:30:16 -07:00
Joshua Gross ac6d1982f4 Re-land: Pass in EventEmitter during View CREATE and Preallocation
Summary:
This is a re-land of D28810022 (7e9c741146), which was reverted due to T92179998. The fix is in D28938530. This issue could also be resolved by preventing more view preallocations (D28811419 (8ca18f0b60)).

 ---

EventEmitter is not transmitted from C++ to Java until an UPDATE operation is enqueued.

Practically this usually happens "right away", but in the case of an Image component, especially, the EventEmitter could be missing while events are being fired from the native side (for example, loading events).

The fix is just to pass EventEmitter in sooner, in both Create and Preallocate. There should be no ill effect since EventEmitter is nullable anyway.

One potential side-effect: since Views can be PreAllocated and potentially never deallocated until StopSurface is called, this could result in more EventEmitter objects being leaked and retained from Java. I believe the fix is to remove PreAllocated Views more aggressively.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D28938637

fbshipit-source-id: c9e290a24ed15c28881e3eead4a5f580f66b288f
2021-06-07 12:16:12 -07:00
Joshua Gross 792acff149 Clean up EventEmitterWrapper on surface deallocation
Summary:
clean up EventEmitterWrapper on surface deallocation. Will resolve T92179998.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D28938530

fbshipit-source-id: f718945f52a652a4b79a7a376f052035e4f41edb
2021-06-07 12:16:12 -07:00
Joshua Gross e15f171080 Back out "Pass in EventEmitter during View CREATE and Preallocation"
Summary:
Original commit changeset: ae4c8b4eefe6

Reverting temporarily to resolve T92179998.

Changelog: [Internal]

Reviewed By: fkgozali, sammy-SC

Differential Revision: D28938467

fbshipit-source-id: a855c8f08f4826e0bb4b918f2dd3269f200787f5
2021-06-07 12:16:12 -07:00
fabriziobertoglio1987 3827ca6171 Fix font weight numeric values (#29117)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/25696 fixes https://github.com/facebook/react-native/issues/28854 fixes https://github.com/facebook/react-native/issues/26193
Since Android API 28 it is possible to specify fontWeight with numerical values ranging from 100 to 900

This pr uses the new Typeface.create() method available on Android API 28+ to set font weight value ranging from 100 to 900, while still keeping existing functionalities (custom fonts, bold/italic and other styles).
https://developer.android.com/reference/android/graphics/Typeface#create(android.graphics.Typeface,%20int,%20boolean)

## Changelog

[Android] [Fixed] - Fix font weight numeric values

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

Test Plan:
Works in all scenarios.

**<details><summary>CLICK TO OPEN TESTS RESULTS</summary>**
<p>

| **BEFORE** | **AFTER** |
|:-------------------------:|:-------------------------:|
|  <img src="https://user-images.githubusercontent.com/24992535/84420949-1daa0e80-ac1b-11ea-9a2e-eaac03dc4533.png"  width="300" height="" />| <img src="https://user-images.githubusercontent.com/24992535/84490766-edf31900-aca3-11ea-90d8-7c52d2e2be59.png" width="300" height="" /> |

| **AFTER** | **AFTER** |
|:-------------------------:|:-------------------------:|
|  <img src="https://user-images.githubusercontent.com/24992535/84490768-ee8baf80-aca3-11ea-8d3e-937d87b3c56a.png"  width="300" height="" />| <img src="https://user-images.githubusercontent.com/24992535/84490769-ef244600-aca3-11ea-9dec-5eb70358834b.png" width="300" height="" /> |

| **AFTER** |
|:-------------------------:|
|  <img src="https://user-images.githubusercontent.com/24992535/84490772-f0557300-aca3-11ea-851a-5befc900192c.png"  width="300" height="" />|

</p>
</details>

Reviewed By: lunaleaps

Differential Revision: D28917328

Pulled By: yungsters

fbshipit-source-id: 8b84e855b3a8b87960cb79b9237d452b26974c36
2021-06-05 00:47:40 -07:00
Joshua Gross 3ba815228e Ship `setJSResponder` in code
Summary:
setJSResponder/clearJSResponder have been in use in prod for a while and are stable. Ship them in code.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D28889894

fbshipit-source-id: 1c42526cd890d528062eeb50761fc49cc6109d76
2021-06-04 11:56:13 -07:00
Kacie Bawiec 399285f91c Localize "search", "button", and "togglebutton" accessibility roles by using the platform roles
Summary:
Several accessibilityRole strings are hardcoded to only English on Android. Swap them to just use the platform constants. This way, TalkBack will handle translations.

This change swaps roles "search", "button", and "togglebutton" roles to use the platform description.

Changelog:
[Android][Changed] Localize "search", "button", and "togglebutton" accessibility roles by using the platform roles

Reviewed By: lunaleaps

Differential Revision: D28077246

fbshipit-source-id: 5b88a6fd7e78b3426506f253b823ecca0608c4bc
2021-06-03 14:44:01 -07:00
Dulmandakh fc6fc637bb use maven-publish plugin (#31611)
Summary:
Gradle has been showing below warning for a while, and this PR fixes the warning using maven-publish plugin, thus taking us one step closer to Gradle 7.x.

> The maven plugin has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the maven-publish plugin instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.9/userguide/upgrading_version_5.html#legacy_publication_system_is_deprecated_and_replaced_with_the_publish_plugins

Configured maven-publish plugin according to https://developer.android.com/studio/build/maven-publish-plugin, also added **installArchives** task for backwards compatibility.

## Changelog

[Internal] [Changed] - use maven-publish plugin to build and publish Android artifact

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

Test Plan: ./gradlew :ReactAndroid:installArchives will create **android** directory for local maven repository with **react-native** package.

Reviewed By: yungsters

Differential Revision: D28802435

Pulled By: ShikaSD

fbshipit-source-id: 7bc7650a700e1a61213c5ec238bcb24fdca954db
2021-06-03 14:29:07 -07:00
Amir Shalem a3a7fc2c94 Don't allocate large arrays on stack when copying native pointers, use heap based array
Summary:
Don't allocate large arrays on stack when copying native pointers, use heap based array.

Today the code copies the native pointers on the stack, since it may be too big, lets make sure to use heap based allocating using std::vector.

This array is afterwards converted into a reversed map from index to pointer, so it is heap based anyhow.

Changelog: [Internal] Don't allocate large arrays on stack when copying native pointers, use heap based array

Reviewed By: Andrey-Mishanin

Differential Revision: D28747213

fbshipit-source-id: da69b4b2d0960fdade9f07f44654b30d6dacc43a
2021-06-03 07:04:18 -07:00
Ramanpreet Nara 281daf1222 Ship bridge RuntimeExecutor JSIExecutor flushing
Summary:
The RuntimeExecutor that Fabric gets from the bridge doesn't call JSIExecutor::flush(). In the legacy NativeModule system, we're supposed to flush the queue of NativeModule calls after every call into JavaScript. The lack of this flushing means that we execute NativeModule calls less frequently with Fabric enabled, and TurboModules disabled. It also means that [the microtask checkpoints we placed inside JSIExecutor::flush()](https://www.internalfb.com/code/fbsource/[62f69606ae81530f7d6f0cba8466ac604934c901]/xplat/js/react-native-github/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp?lines=427%2C445) won't be executed as frequently, with Fabric enabled.

Changelog: [Android][Fixed] - Flush NativeModule calls with Fabric on Android, on every Native -> JS call.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D28620982

fbshipit-source-id: ae4d1c16c62b6d4a5089e63104ad97f4ed44c440
2021-06-02 16:54:33 -07:00
Joshua Gross 8ca18f0b60 Don't PreAllocate virtual views
Summary:
Virtual views that are flattened and don't "FormsView" on-screen should not be preallocated.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28811419

fbshipit-source-id: 949dcbf4cf3791355c58af785603b35fa50f3f02
2021-06-02 12:49:49 -07:00
Joshua Gross fc2153cc43 Remove mounting-layer hack
Summary:
This hack should not be necessary. It should be fixed at Differ or LayoutAnimations level if there are existing issues there.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28810021

fbshipit-source-id: 98b8d2ae9991ad527a3b3e90943d75063b2a4496
2021-06-02 12:49:49 -07:00
Dulmandakh 70da640946 remove jcenter (#31609)
Summary:
jcenter is read-only now, and newer versions of dependencies will be published to either MavenCentral or Jitpack. This PR removes jcenter to avoid future issues, then uses MavenCentral and Jitpack as replacement. Current flipper depends on Stetho version that is not available on MavenCentral, so had to exclude and bump the version.

Both Gradle and Buck successfully download all the dependencies.

## Changelog

[Android] [Changed] - Remove jcenter

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

Test Plan: rn-tester builds and runs as expected.

Reviewed By: mdvacca

Differential Revision: D28802444

Pulled By: ShikaSD

fbshipit-source-id: 043ef079d0cda77a1f8dd732678452ed712741a4
2021-06-02 09:57:28 -07:00
David Vacca 286fac5ad0 Delete eager initialization of Fabric classes
Summary:
I run an experiment and I verified that eager initialization of fabric classes is neutral and it's showing a regression in "marketplace:interface:metrics"
See: https://www.internalfb.com/intern/qe2/react_fabric_marketplace_home_android_universe/react_fabric_marketplace_home_eager_init_v1/analysis?control=test_no_eager_init&test=test_eager_init_classes

This diff removed the optimization and it cleans up the code

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28815647

fbshipit-source-id: 2c9fe3875b1797d9a7def61e5ab97c2df2a462dd
2021-06-01 18:27:04 -07:00
Joshua Gross 7e9c741146 Pass in EventEmitter during View CREATE and Preallocation
Summary:
EventEmitter is not transmitted from C++ to Java until an UPDATE operation is enqueued. Practically this usually happens "right away", but in the case of an Image component, especially, the EventEmitter could be missing while events are being fired from the native side (for example, loading events).

The fix is just to pass EventEmitter in sooner, in both Create and Preallocate. There should be no ill effect since EventEmitter is nullable anyway.

One potential side-effect: since Views can be PreAllocated and potentially never deallocated until StopSurface is called, this could result in more EventEmitter objects being leaked and retained from Java. I believe the fix is to remove PreAllocated Views more aggressively.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28810022

fbshipit-source-id: ae4c8b4eefe619d9a99fa5f90f612d6dd4880da5
2021-06-01 15:15:47 -07:00
Dulmandakh 547b4c92e4 Gradle 6.9, Android Gradle Plugin 4.2.1 (#31593)
Summary:
Bump Gradle to 6.9 which supports Apple Silicon, also Android Gradle Plugin 4.2.1 which defaults to Java 1.8 so no additional config required.

## Changelog

[Android] [Changed] - Bump Gradle to 6.9, Android Gradle Plugin to 4.2.1

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

Test Plan: rn-tester builds and runs as expected

Reviewed By: mdvacca

Differential Revision: D28711942

Pulled By: ShikaSD

fbshipit-source-id: 2a4616cd0f17db7616ab29dea1652717f2cd0f6d
2021-06-01 11:29:51 -07:00
Andrei Shikov d1ab03235c Remove feature flag for layout transition tag cleanup
Summary:
Removes stale feature flag that was in production for a couple of months. Fix helped to decrease number of crashes significantly, so we can remove it.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28757995

fbshipit-source-id: 375da09c11f265e8bbe03cd99de1b83f168420ce
2021-05-27 14:43:53 -07:00
Andrei Shikov fff0107e5a Fix robolectric tests for touch events
Summary:
Touch event logic has been recently modified to contain surfaceId only in the new renderer. This change aligns OSS tests that have been failing for them.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28749961

fbshipit-source-id: 483ab3ac97bbdc4f1fbdb2a8c699ef060cca9f77
2021-05-27 10:14:32 -07:00
Andrei Shikov 712bc6769b Log when item execution is delayed during mounting
Summary:
Adds logs to indicate that MountItem was queued instead of executed.
Also moves logging of preMount items to dispatcher for consistent logging with other items.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28690203

fbshipit-source-id: 14d24f0bebb97a810127f5187b4d46f66b6c836f
2021-05-27 04:44:30 -07:00
David Vacca 4efd603b26 Update customDirectEvent types for ReactVitoImageManager
Summary:
This diff updates the customDirectEvent types for ReactVitoImageManager

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28682669

fbshipit-source-id: 3341a7d6dbd5ec90f274f0770c6e883bd82f0a2d
2021-05-25 11:31:47 -07:00
Joshua Gross 5a9b6fc49b Simplify LockFreeEventDispatcherImpl further
Summary:
TL;DR: simplify and delete a bunch of stuff that shouldn't be necessary in Fabric.

I discovered that this event dispatcher (and the older one this is based on) is triple-queueing: we queue events into "staging", and then post "dispatch events" to only run /on the JS thread/. Even in Fabric. Then, each of these events is emitted into C++ where they are queued /again/! This refactor eliminates one more level of queueing - instead of scheduling dispatch for the JS thread, we just emit them directly to C++ when they're received in Java.

Unfortunately, the EventDispatcher is also used to drive AsyncEventBeat in C++:

1. EventBeatManager.onBatchEventDispatched: https://fburl.com/diffusion/qf6dyhsw
   In the C++ impl, it indirectly will drive the AsyncEventBeat/AsyncEventBeatV2.
2. onBatchEventDispatched is ONLY called from EventDispatcherImpl: https://fburl.com/codesearch/mxk8ifyj
3. Which is queued and only runs on the JS thread: https://fburl.com/codesearch/czvbst4u

This means the AsyncEventBeat is only ticked when the JS thread is free, and ticks will be skipped when the JS thread is occupied for long periods.

Now, in this refactor, when this class is used it will drive AsyncEventBeat on every UI tick. This is also potentially not correct. On iOS (Fabric), AsyncEventBeat is driven when the UI thread is "about to sleep".

For now I'm not going to worry about that detail - it is significant, but Fabric+Android is currently /not doing the right thing/ and it's not clear that we want to maintain iOS behavior. This is something we need to discuss further and figure out.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28654033

fbshipit-source-id: b3cb9b706343c8dd3c4cf84f24388908c57e2138
2021-05-24 20:14:46 -07:00
Joshua Gross 900fed576b Events: Remove default `getCoalescingKey` impls
Summary:
Event.java's default implementation of `getCoalescingKey` returns 0. Most overrides of getCoalescingKey just return 0. Delete them.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28650792

fbshipit-source-id: 374591fb4ba2305df934de412790b3397ca2fa1c
2021-05-24 13:41:19 -07:00
Joshua Gross 0510821170 Replace EventDispatcherImpl with LockFreeEventDispatcherImpl
Summary:
EventDispatcherImpl uses synchronized blocks all over to make it thread-safe. I'm concerned about the perf implications of this and creating contention between JS and UI threads.

This is locked behind a feature flag.

Enabled only for Fabric in StaticViewConfig mode, and a feature flag, for now.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28591331

fbshipit-source-id: ea8f93a2e1343ce37fa78690dcb62fe03594120f
2021-05-21 17:22:41 -07:00
Joshua Selbo 0aa1aa6cc2 Convert remaining targets to wrapper
Summary: Changelog: [Internal]

Differential Revision: D28479823

fbshipit-source-id: 997c6ac137d85d22ee5052d69dae006a1a0a7aac
2021-05-21 12:47:26 -07:00
Joshua Gross cd4bebb6c6 Make sure that touch events have a SurfaceId only in Fabric
Summary:
Could fix some infrequent crashes in non-Fabric.

Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D28605773

fbshipit-source-id: 57555e013657e61cfb02b25d9fd14c9c15774e0e
2021-05-21 11:32:02 -07:00
Andres Suarez ffab8e3f46 Apply clang-format
Reviewed By: igorsugak

Differential Revision: D28477074

fbshipit-source-id: f15dfc45b9fb30c661ebe2899cd882676d0fdf2a
2021-05-20 21:24:25 -07:00
Joshua Gross b161241db2 Proposed fix for ScrollView race condition between C++ state update and onScroll
Summary:
FlatList relies heavily on onScroll events + the measure API. In Fabric, usage of `measure` relies on C++ having an accurate view of the current scroll position of the ScrollView.

We already have a mechanism for updating the scroll position in C++ using UpdateState. But, it is only used currently at the /beginning/ and /end/ of scrolling, and UpdateState is not called /during/ scrolling at all.

This means that we will see a series of events like this while scrolling:

```
Scrolling begins
UPDATE C++ STATE: scrollLeft = 0, scrollTop = 0
JS event: onScroll x=0, y=0
JS event: onScroll x=0, y=100
JS event: onScroll x=0, y=200
...
JS event: onScroll x=0, y=1000
UPDATE C++ STATE: scrollLeft = 0, scrollTop = 1000
```

Notably, not many C++ state updates are queued; and the last one is queued AFTER the JS event is sent. The last JS event and UpdateState will race, which means that sometimes the C++ update will /lose/ and C++ will have an inaccurate view of the world when FlatList receives the onScroll event and calls `measure`.

My proposed solution, gated behind a feature flag, is to delay /some/ onScroll events until the C++ UpdateState has made its way back to Java, and send UpdateStates more frequently. The balance here is that UpdateState is a relatively expensive operation, so we probably still want to call it /less/ than we call onScroll. This means that `measure` will still return some incorrect results but will return correct results more frequently. Win?

Changelog: [Internal[

Reviewed By: mdvacca

Differential Revision: D28558380

fbshipit-source-id: 11c7cd714fae67ee5a94c4413be988481413ec03
2021-05-20 12:53:39 -07:00
Joshua Gross d670381fac Reduce FabricUIManager soft errors further
Summary:
Reduce soft error volume; see comments.

Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D28551214

fbshipit-source-id: 7e6aa1ee7cad812650bd6219d0cbe568c3cdd3de
2021-05-20 09:49:11 -07:00
Shoaib Meenai 6b713f519f Avoid using std::unique_ptr with incomplete type
Summary:
It's not supported, and building with libc++ using its unstable ABI
exposes the issue. Include the header to get the complete type.

Changelog: [Internal]

Reviewed By: lanza, sammy-SC

Differential Revision: D28405500

fbshipit-source-id: 65e039a465d8d736eaecb89e82895889fd2379ca
2021-05-18 15:27:09 -07:00
David Vacca 0b371304aa Create ReactFeatureFlag to initialize MapBufferSo file during Fabric initialization
Summary:
This diff creates a ReactFeatureFlag to initialize MapBufferSo file during Fabric initialization.

This is necessary to be able to compare properly Mapbuffer vs ReadableNativeMap (because ReadableNativeMap c++ files is already included in the bridge so file)

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D28436044

fbshipit-source-id: 338e1bb72b5313dc29a309e1b0e979e7c8bd1c18
2021-05-14 12:55:24 -07:00
Samuel Susla 831e2d41ab Funnel All Fabric calls to RuntimeExecutor to RuntimeScheduler
Summary:
Changelog: [internal]

This diff moves all calls to RuntimeExecutor to RuntimeScheduler. The calls are still immediately dispatched. Timing of events will not change.

The goal of this diff is to prepare infrastructure for Concurrent Mode.

Reviewed By: JoshuaGross

Differential Revision: D27938536

fbshipit-source-id: 750b0e21e0ecbd7aa5a14885ebc70aae82203bd4
2021-05-13 08:03:29 -07:00
Joshua Gross 3c7809ed0d Call `onDropViewInstance` on all Views when stopSurface is called
Summary:
Call `onDropViewInstance` on all Views when stopSurface is called.

We used to do this but stopped doing it ~6 months ago. This did not cause any prod issues but is not correct.

This allows product code to do cleanup upon view deletion.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28388929

fbshipit-source-id: a8f06d4b1b12a11a907667e0a837c653db035941
2021-05-12 14:05:56 -07:00
Joshua Gross 52b45a44b4 Event should infer UIManagerType by presence of SurfaceId
Summary:
See comments inline for motivation. It's not safe to use viewtag of an Event to infer whether or not the view is in a Fabric or non-Fabric RootView.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28365566

fbshipit-source-id: 187ddcc5d5a43a31a71232fdb2f1f5b334bec8c2
2021-05-12 09:14:14 -07:00
David Vacca aafdf9fee1 Refactor access of ReactFeatureFlags from C++
Summary:
This diff is a follow up of D28360679 (e3367354cc), here we refactor the access of ReactFeatureFlags from C++ to use methods instead of fields

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28362066

fbshipit-source-id: caed5e7fddeb6c0d9846fb037152befa8f1ed5c2
2021-05-11 14:10:47 -07:00
David Vacca 22ddab2025 Ensure ReactFeatureFlag fields are not deleted by Redex
Summary:
Since we are now using ReactFeatureFlag from C++, we need to ensure redex doesn't strip its fields.

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28360678

fbshipit-source-id: 74604e2d008a056c161d8b6ab8f5b30807087d9e
2021-05-11 12:57:38 -07:00
David Vacca e3367354cc Use ReactFeatureFlags to enable mapBuffer in C++
Summary:
This diff refactors the way we are populating the 'MapBufferSerializationEnabled' context cointainer key to use ReactFeatureFlags instead of MobileConfig.

This is necessary to make sure we always use a consistent value between C++ and Java. e.g. to prevent SEV like S230730 set different values in java and c++ code

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28360679

fbshipit-source-id: baef9d53f84de25c5671483dcd995674bfa61984
2021-05-11 12:57:38 -07:00
Andrei Shikov 66173e1d04 Update folly to 2021.04.26.00 in OSS build
Summary:
Updates Gradle script to include new version of folly (synced to iOS update)
Adds fmt and libevent as well as some boost ASM sources to enable compilation of folly futures.

Changelog:
[Android] Updated folly to 2021.04.26

Reviewed By: fkgozali

Differential Revision: D28124377

fbshipit-source-id: d44c5a1ded5ee7ad514a9df14ea2ba326d4aa0e3
2021-05-11 06:03:43 -07:00
David Vacca 13169f0987 Delete ReactFeatureFlags.useViewManagerDelegatesForCommands
Summary:
This diff deletes ReactFeatureFlags.useViewManagerDelegatesForCommands, this has been enabled in prod for 9+ months

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28265338

fbshipit-source-id: 2f07cb83d6ef9191f9ebea52e230490ef98d6e2d
2021-05-10 15:57:43 -07:00
Joshua Gross 0ef5beee85 Support ScrollAway in ReactScrollView
Summary:
Support ScrollAway in ReactScrollView for Fabric/non-Fabric.

Changelog: [Android][Added] Support for ScrollAway native nav bars added to ReactScrollView

Reviewed By: mdvacca

Differential Revision: D28308855

fbshipit-source-id: 9a922159ef50fb7c8e9c484a4b97ca57ab248496
2021-05-10 12:16:10 -07:00
David Vacca bf8037cad0 Remove ReactFeatureFlags.useViewManagerDelegates
Summary:
This diff deleted the ReactFeatureFlags.useViewManagerDelegates, this has been enabled for 9+ months

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28265339

fbshipit-source-id: f5c97e77ca4fc72d2e2b8f891e800e362177d67a
2021-05-07 20:40:38 -07:00
David Vacca 570c6f1f29 Quick refactor of string tags used in UIManagerHelper
Summary:
this is a quick refactor of the string tags used in UIManagerHelper

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28243264

fbshipit-source-id: c32c9908d40e6184d7e940b14c9782799db3f891
2021-05-06 12:13:40 -07:00
David Vacca b0e8c1eac0 Refactor UIManagerHelper.getUIManager to return null when there's no UIManager registered
Summary:
This diff refactors the UIManagerHelper.getUIManager method to return null when there's no UIManager registered for the uiManagerType received as a parameter.

This is necessary to workaround: https://github.com/facebook/react-native/issues/31245

changelog: [changed] UIManagerHelper.getUIManager now returns null when there's no UIManager registered for the uiManagerType received as a parameter

Reviewed By: fkgozali

Differential Revision: D28242592

fbshipit-source-id: c3a4979bcf6e547d0f0060737e41bbf19860a984
2021-05-06 12:13:40 -07:00
David Vacca 7fe6bc1150 Create MC to verify impact of eager initialization of fabric classes
Summary:
This diff creates a MC to verify impact of eager initialization of fabric classes, the purpose is to remove this code, but before doing that I would like to verify what's the impact.

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D28223943

fbshipit-source-id: 6f7c4701fb730fe1c0629ec13ead592ff619373f
2021-05-05 13:06:56 -07:00
David Vacca c6b8625664 Eager load all fabric classes before initializing Fabric
Summary:
Eager load all fabric classes before initializing Fabric

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D28207855

fbshipit-source-id: 205f8220fd75178aa0f33cbf734ea74859a4f973
2021-05-05 09:12:41 -07:00
David Vacca 3555bf20a8 Update javadoc in fabric to remove reference to UIManagerModule
Summary:
Update javadoc in fabric to remove reference to UIManagerModule

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D28207024

fbshipit-source-id: 1658c01b10c2433565d6df1a6ed989d83a3c4a8d
2021-05-05 09:12:41 -07:00
David Vacca d583cb8def Dispatch switch events using the proper UIModule
Summary:
This diff ensures that the dispatch of switch events is performed using the proper UIModule

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28204930

fbshipit-source-id: 625b536ab3106efa7dbf583589dfe268b880a6a0
2021-05-05 09:12:41 -07:00
sangeethaKP 7db89f90ee #31386 Fix Readme link to Testing (#31387)
Summary:
Fix Readme link to Testing section

Fix Readme link to Testing section

## 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] [Fixed] - Fixed link to Testing in React Native Android ReadMe file

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

Test Plan: Change has been made to a Readme documentation, no changes in code

Reviewed By: TheSavior

Differential Revision: D28192184

Pulled By: PeteTheHeat

fbshipit-source-id: 6d4503f68398accacead116b43981e03e4c1430a
2021-05-04 15:50:02 -07:00
fabriziobertoglio1987 333b46c4b0 Fix Image does not announce "disabled" (#31252)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/30935 screenreader does not announce Image disabled accessibilityState.

As stated in AOSP View.java, the framework will handle routine focus movement, views indicate their willingness to take focus through the `isFocusable` method https://bit.ly/3dCnyHb

```
* <p>The framework will handle routine focus movement in response to user input. This includes
* changing the focus as views are removed or hidden, or as new views become available. Views
* indicate their willingness to take focus through the {link #isFocusable} method. To change
* whether a view can take focus, call {link #setFocusable(boolean)}.
```

The property is updated through its shadow node `ReactImageManager` method `setAccessible` https://bit.ly/3dDuK5L

```java
 * <p>Instances of this class receive property updates from JS via @{link UIManagerModule}.
 * Subclasses may use {link #updateShadowNode} to persist some of the updated fields in the node
 * instance that corresponds to a particular view type.
```

## 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] [Fixed] - adding setAccessible to ReactImageManager to allow screenreader announce Image accessibilityState of "disabled"

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

Test Plan:
**<details><summary>CLICK TO OPEN TESTS RESULTS</summary>**
<p>

Enable audio to hear the screenreader

TEST SCENARIO
- The user moves the screenreader focus to an image and the screenreader reads the Image accessibilityLabel "plain network image"

RESULT
- The screenreader announces the accessibilityState disabled after reading the Image accessibilityLabel "plain network image"

```javascript
<Image
  accessible={true}
  accessibilityLabel="plain network image"
  accessibilityState={{disabled: true}}
  source={fullImage}
  style={styles.base}
/>
```

<video src="https://user-images.githubusercontent.com/24992535/112670432-2f366d00-8e61-11eb-843f-4b56f4a06a91.mp4" width="700" />

</p>
</details>

Reviewed By: kacieb

Differential Revision: D28194597

Pulled By: lunaleaps

fbshipit-source-id: 5f89ce5c714405506261885ac6fea2c15c2e1f23
2021-05-04 14:29:58 -07:00
Kacie Bawiec da899c0cc4 Add support for Toggle Button accessibilityRole
Summary:
Changelog:
[General][Added] Add support for "togglebutton" accessibilityRole

# Context
The role for ToggleButton, which is needed on Android to implement toggle buttons correctly, is not currently supported.

# What does this diff do?
Adds support for accessibilityRole `"togglebutton"`.

On Android, this maps to class `"Android.widget.ToggleButton"`.

iOS does not have an equivalent trait for togglebutton, so I set it to be the same as setting `accessibilityRole="button"` for iOS.

# Caveats - checked vs selected
It seems to me like this role currently requires that you set `accessibilityState={{checked: true/false}}`. The behavior is strange when setting `selected` state, I think because on Android ToggleButtons are meant to use `checked` to indicate toggled on/off.

This is tricky because typically on iOS if you have a toggle button, you would use `selected` instead of `checked`, so RN users are likely to mess this up.

Possible solutions:
1. document that you should use `checked` state on Android for toggle buttons (and maybe throw a warning if someone passes in `selected`).
2. have RN ignore it if someone passes in accessibilityState `selected`, if this role is used.
3. Have RN convert passed in `selected` state to `checked` on the Android side.

Reviewed By: nadiia

Differential Revision: D27976046

fbshipit-source-id: 4ce202449cf2371f4bf83c4db2d53120369ee7b0
2021-05-03 11:50:02 -07:00
Paige Sun 0932a0d775 iOS: 2/5 Remove use of bridge from Modal by dismissing with visible prop
Summary: Changelog: [Fabric][iOS][Fix] Remove use of bridge from Modal by dismissing Modal with visible prop

Reviewed By: sammy-SC

Differential Revision: D28074326

fbshipit-source-id: 0278bfb031db802b59429c553ac62d83838f4cc9
2021-05-02 15:42:49 -07:00
David Vacca a56c15894a Enable Fabric in logbox
Summary:
This diff enables  Fabric in logbox in the facebook app

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28031255

fbshipit-source-id: 8abc301651ad09e4e48c88961bc7f3b91e6c4ae3
2021-04-27 19:45:08 -07:00
David Vacca 3d0cf8dcf8 Fix IllegalArgumentException when creating layout with negative width
Summary:
This diff fixes an IllegalArgumentException that's thrown when creating layout with negative width.

This is not a new bug, but it started firing recently (probably caused by a change in text being measured)

stacktrace:
```
stack_trace:	java.lang.IllegalArgumentException: Layout: -2 < 0
	at android.text.Layout.<init>(Layout.java:265)
	at android.text.Layout.<init>(Layout.java:241)
	at android.text.BoringLayout.<init>(BoringLayout.java:179)
	at android.text.BoringLayout.make(BoringLayout.java:61)
	at com.facebook.react.views.text.TextLayoutManager.createLayout(TextLayoutManager.java:290)
	at com.facebook.react.views.text.TextLayoutManager.measureText(TextLayoutManager.java:384) [inlined]
	at com.facebook.react.views.text.ReactTextViewManager.measure(ReactTextViewManager.java:172) [inlined]
	at com.facebook.react.fabric.mounting.MountingManager.measure(MountingManager.java:349) [inlined]
	at com.facebook.react.fabric.FabricUIManager.measure(FabricUIManager.java:461)
	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)

```

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28015820

fbshipit-source-id: 129cd2a4c492d95d57fcdf3883b967a0b5df639a
2021-04-27 19:45:08 -07:00
David Vacca 3178e80c88 Cleanup unused variables
Summary:
EZ cleanup of unused variables in TextLayoutManager
changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D28015819

fbshipit-source-id: 8e380926ebff9256e89e6cd654fa96eeb938d797
2021-04-27 19:45:08 -07:00
Andrei Shikov 0aa7e5b5d4 Back out "Assign batch number to only batched animated instructions"
Summary:
This change broke some animations on non-Fabric surfaces due to inconsistent batching of animation operations.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D28013968

fbshipit-source-id: 2f65c799dbe00168f1e756ef0af60206df5a8fcc
2021-04-27 04:00:16 -07:00
Andrei Shikov ef0db95300 Back out "Adjust animation batch numbers to be consistent when controlled by native"
Summary:
This change caused crashes in animations on some surfaces.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D28013969

fbshipit-source-id: 95845c69d6e67d59582ea14ad08cbf42fd3e2f8f
2021-04-27 04:00:16 -07:00
Nadiia D 46ffe84453 Make RootTag an opaque type
Summary:
Changelog:
[General][Changed] Make the RootTag an opaque type

Reviewed By: yungsters

Differential Revision: D27992320

fbshipit-source-id: 2901f0e59f573106295b986fe04db227134235da
2021-04-26 22:57:55 -07:00
Samuel Susla 9cd98fa3ee Prevent redundant dispatches onto RuntimeExecutor queue in AsynchronousEventBeat::induce
Summary:
Changelog: [internal]

Prevent redundant calls to RuntimeExecutor by making sure no two calls to the executor are scheduled at the same time.

Reviewed By: mdvacca

Differential Revision: D27989412

fbshipit-source-id: 8f9b1591f7c9c2265fd4b05bf3dc5505ffc2568b
2021-04-25 16:15:25 -07:00
Ramanpreet Nara d48c2be46f Wire up RuntimeExecutorFlushing to MobileConfig
Summary:
With D27975839, RuntimeExecutor will be able to start flushing the queued up NativeModule calls in every call from C++ -> JavaScript. We're going to test this feature to measure its impact. In this diff, I wire up the the MobileConfig to ReactFeatureFlags.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D27978112

fbshipit-source-id: 47e1e74398c62755bb0fdc6b54b7fd3aa47eb877
2021-04-23 18:16:03 -07:00
Ramanpreet Nara c0ec82e61e Add flushing to RuntimeExecutor
Summary:
## Motivation
With the bridge, every call into JS flushes the queue of NativeModule calls. Fabric bypasses this mechanism, because it uses a RuntimeExecutor that schedules work directly on the JavaScript thread. This diff makes Fabric's RuntimeExecutor also flush the queue of NativeModule calls.

This likely won't fix anything in Fabric, because we don't execute any async NativeModule calls on Fb4a. However, this is necessary for the drainMicrotask work we're doing in D27729702 (7310847758), because (1) we need to drain the Hermes microtask queue on every call from C++ -> JavaScript (2) we drain the microtask queue [inside JSIExecutor::flush()](de477a0df6/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp (L427),L445).

Changelog: [Android][Fixed] - Flush JSIExecutor in Fabric's RuntimeExecutor

Reviewed By: JoshuaGross

Differential Revision: D27975839

fbshipit-source-id: 27f031fb36593253da116a033e30998475eb1473
2021-04-23 18:16:03 -07:00
Ramanpreet Nara 090196f330 ReactContext: Fail fast when NativeModules thread is null
Summary:
By the time that we call [ReactContext.assertOnNativeModulesQueueThread()](https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java?commit=747a25280435d276fb975ccfe36fd5e60254c4e4&lines=355%2C359), ReactContext.mNativeModulesMessageQueueThread must be non-null. This implies that two things must have happened:
1. We initialized the ReactContext
2. After initialization, ReactContext.mNativeModulesMessageQueueThread must be non-null.

According to T85807990, ReactContext.mNativeModulesMessageQueueThread is null. Since ReactContext doesn't ever write to ReactContext.mNativeModulesMessageQueueThread aside from during initialization, it must mean that we either didn't initialize properly, or we initialized, but set the NativeModules thread to null. This diff throws IllegalStateExceptions inside ReactContext initialization, which should help narrow down the crash in T85807990.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D27729355

fbshipit-source-id: e39030b7db8862ae76fb644efaafb382a79b8ad0
2021-04-23 15:12:46 -07:00
Andrei Shikov bda032af6e Adjust animation batch numbers to be consistent when controlled by native
Summary:
D27682424 (ea1ff374de) updated how animated node batches are executed in Fabric. On Paper, these batches were controlled by native module in some places (batch was executed ~every 2 frames), but some animations were switching animation batching control to JS globally there as well.

This change updates two things:
- If batching is controlled by native, it makes sure batches are calculated correctly.
- At the same time, this change switches control for animation node batching to JS, aligning it with Fabric.

Changelog: [Internal]

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D27939659

fbshipit-source-id: d6251bce2a303a4a007dc10297edc0175cc4b348
2021-04-23 15:07:35 -07:00
Peter Laraia 42b6e6682c Fix crash - check if backgroundColor is null before trying to fetch it in ViewProps isLayoutOnly
Summary:
Noticed while working in MobileHome with android device, when interacting with the Tasks change progress/priority components (MobileHomeTasksDetailsSelectorToken), which provides `borderRadius` style and `backgroundColor: ifSelected ? value : null`, and when `backgroundColor` is `null`, the line changed in this diff crashes (throwing the `NoSuchKeyException` at `ReadableNativeMap:110` [because of isNull check on `ReadableNativeMap:107`])

Changelog:
[Android][Fixed] - Fixed crash when using style borderRadius: any with backgroundColor: null

Reviewed By: JoshuaGross

Differential Revision: D27932828

fbshipit-source-id: 801b04c856ee9dc5a36bbf3e6e3d81de9b1e81a1
2021-04-22 10:41:38 -07:00
David Vacca b67dc01d1d Replace int -> int32_t
Summary:
This diff replaces all usages of int by int32_t. This is to ensure we always use a fixed size for int that matches what's expected on Java.

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27915608

fbshipit-source-id: 634c45796dda1d4434c3ad6ff3e199931c22940b
2021-04-22 09:50:23 -07:00
Andrei Shikov 6fda118116 Show surfaceId when logging IntBufferBatchMountItem
Summary:
Adds surface id for string logs of the IntBufferBatchMountItem to help debug updates with multiple surfaces.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D27884232

fbshipit-source-id: c5ec65585830f7aa5b902603bcd1e91b61cfe4c1
2021-04-21 10:32:18 -07:00
David Vacca b614afc613 Refactor MapBufferBuilder to use int to store size of Mapbuffer data
Summary:
Refactor MapBufferBuilder to use int to store size of Mapbuffer data

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D27904646

fbshipit-source-id: 6b8b96fdd30184b6d35c1d612743eae653854d6d
2021-04-21 10:27:57 -07:00
David Vacca 668d71aa0b Refactor dataSize to use int instead of short
Summary:
DynamicData can contain a big amount of data, refactoring type to use int instead of short

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27904643

fbshipit-source-id: 157064b280e27a9c7c4a4f55af310392b178feda
2021-04-21 10:27:57 -07:00
David Vacca e92be1c14b Add extra asserts and early deallocation in ReadableMapBuffer::importByteBufferAllocateDirect
Summary:
Add extra asserts and early deallocation in ReadableMapBuffer::importByteBufferAllocateDirect

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27904645

fbshipit-source-id: 075a007c4ec5e005b839add054bd68c233b65801
2021-04-21 10:27:57 -07:00
David Vacca 64844d900a Refactor names of ReadableMapBuffer class variables
Summary:
Refactor names of ReadableMapBuffer class variables

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27867056

fbshipit-source-id: de96429cbd1142e14fa74f7f953d560ba5918954
2021-04-21 10:27:57 -07:00
David Vacca 69a48ec9d4 Fix importByteBufferAllocateDirect method
Summary:
This diff fixes the importByteBufferAllocateDirect method.
This was tested enabling importByteBufferAllocateDirect in ReadableMapBuffer.java

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27867055

fbshipit-source-id: 9ef5e93ff6c7903782598dde1c499daa82cd467b
2021-04-20 12:13:48 -07:00
David Vacca 19d881d838 integrate asserts in ReadableMapBuffer
Summary:
This diff integrates asserts in ReadableMapBuffer

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D27864305

fbshipit-source-id: 0e7802a33cbf5ccfb4b845fffd14f8517bed70ec
2021-04-20 12:13:48 -07:00
Lulu Wu 49af5e7385 Create and show DatePickerDialogFragment in UI thread
Summary:
Fix 'An Unexpected error occurred' in Messenger Kids caused by DatePickerDialog.

Changelog:
[Android][Fixed] - Create and show DatePickerDialogFragment in UI thread

Differential Revision: D27882121

fbshipit-source-id: 2490a8178e5986222105bfbc16e7c0de471baa02
2021-04-20 09:27:02 -07:00
CodemodService FBSourceBuckFormatLinterBot 73b9f78e33 Daily `arc lint --take BUCKFORMAT`
Reviewed By: zertosh

Differential Revision: D27761011

fbshipit-source-id: 6231e04819b758d0daa1c78b412742be9b23cf3f
2021-04-14 04:05:56 -07:00
Kudo Chien e57de5f32f Fix CI "Build Tests: Android Instrumentation Tests" errors (#31352)
Summary:
To fix [the CI error](https://app.circleci.com/pipelines/github/facebook/react-native/8708/workflows/d584348e-941f-4653-96c2-46375894dfaa/jobs/196410)
  There are two errors:
  `error: undefined reference to '__android_log_write'` which solved by adding `-llog` linker flag.

  `ld: error: cannot find -lc++` which workaround by static linking.
  For the root cause, I am thinking that is after [NDK r19](https://developer.android.com/ndk/guides/other_build_systems),
  the `-target` should specificy api level.
  However, buck does not add this accordingly, e.g. `-target armv7-none-linux-androideabi`
  Given wrong target will make NDK to have `cannot find -lc++` error.
  The workaround is to use static linking.
  Since it was an oss_cxx_library, the change should not have impact to Facebook internal testing.

## Changelog

[Internal] [Fixed] - Fix CI "Build Tests: Android Instrumentation Tests" errors

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

Test Plan: Make CI green

Reviewed By: JoshuaGross

Differential Revision: D27757838

Pulled By: fkgozali

fbshipit-source-id: 8f9c80a89c6240938218abacb8a82e3e2e71adbc
2021-04-13 21:25:31 -07:00