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

4947 Коммитов

Автор SHA1 Сообщение Дата
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