Commit Graph

5280 Commits

Author SHA1 Message Date
David Vacca bfd72ecab1 Revert D31628461
Summary:
Revert of D31628461 (https://github.com/facebook/react-native/commit/e494e4beb6a124008fd116178cbc38335bd87809), this diff broke Text selections in Android. Also I'm unable to reproduce original bug fixed by D31628461 (https://github.com/facebook/react-native/commit/e494e4beb6a124008fd116178cbc38335bd87809)

changelog: [Android][Fixed] Fixed text selection, broken in 0.68

Reviewed By: ShikaSD

Differential Revision: D34700739

fbshipit-source-id: 85cde0032632dc77eb77f91b63c5d3c29b1bbbaf
2022-03-07 16:17:46 -08:00
Genki Kondo 87cdb607e4 Support animating text color with native driver
Summary:
Typically, ReactTextView#setText is called via ReactTextViewManager#updateExtraData, but natively animated color changes bypass render and layout pass via direct call to SurfaceMountingManager#updateProps from UIManager#synchronouslyUpdateViewOnUIThread.

Thus, for animated color changes to get applied, we need to handle the color prop in ReactTextAnchorViewManager.

In addition, native driver updates are not synchronized with Fabric's mounting; if the native driver update happens before mount, the update is done in updateState.

Changelog:
[Android][Added] - Support animating text color with native driver

Reviewed By: mdvacca

Differential Revision: D34630294

fbshipit-source-id: c0f1e19c801c0e909e84387d623a6556ce6f2d67
2022-03-07 15:10:24 -08:00
skychx ae3d4f7008 Android: Fix crash caused by Image.queryCache parsing null (#32101)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32101

Reviewed By: cortinico

Differential Revision: D34687038

Pulled By: ShikaSD

fbshipit-source-id: 1b39a34a689a043425891416ff141ef622eacd24
2022-03-07 11:01:25 -08:00
Nicola Corti a0511a1daa Attempt to fix CircleCI by bumping CMake to 3.18.1 (#33382)
Summary:
I accidentally broke CircleCI. This PR attempts to fix it by setting the requested CMake version to `3.18.1`.

We might have to bump the Docker image to fix this instead.

## Changelog

[Internal] - Attempt to fix CircleCI by bumping CMake to 3.18.1

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

Test Plan: Will rely on Green CircleCI

Reviewed By: motiz88

Differential Revision: D34679269

Pulled By: cortinico

fbshipit-source-id: 2addb0914d900c5e712e905cf14a54d6028cf417
2022-03-07 01:26:23 -08:00
Nicola Corti 29aed0812c Revert Add support for C++17 in OSS for ReactAndroid
Summary:
changelog: internal

This broke the build of `ReactAndroid`. The error reported is the following:

https://github.com/react-native-community/docker-android/runs/5432343549?check_suite_focus=true

Created from CodeHub with https://fburl.com/edit-in-codehub

Reviewed By: ShikaSD

Differential Revision: D34667826

fbshipit-source-id: fa84f03eca4cc7873088ebf2de473547dffea224
2022-03-05 12:41:37 -08:00
Nikita Lutsenko 1f87729697 rn | cxx | Move the definitions of TurboModule virtual methods to declaration, to allow for use in context with RTTI.
Summary:
Not having this disallows including turbo module and extending in places where RTTI is enabled.
There is no additional includes or implementation changes - it merely allows for things to nicely link with other libraries.

Changelog: [General][Fixed] - Allow including TurboModule.h in mixed rtti/no-rtti environment, even if TurboModule.h/cpp is compiled without RTTI.

Reviewed By: appden

Differential Revision: D34637168

fbshipit-source-id: 2e5d9e546bdc5652f06436fec3b12f1aa9daab05
2022-03-04 19:04:36 -08:00
Xin Chen 87ad1e8570 Intercept touch event for simulated joystick scrolling to avoid nested scroll view issues
Summary:
The issue to be fixed here is an edge case when in nested scroll view, for example vertical scroll wraps horizontal scroll, when user scrolls horizontally then move the joystick downwards, the horizontal scroll would bounce back. This is shown in the demo:

https://pxl.cl/209f8

The root cause of the issue is due to two workflows fight to set the scroll position and confusing the scroll change dispatcher to calculate fling velocity direction, which caused a wrong fling behavior. Check this log and description to get more details:

{F706620839}

To fix the issue, in this diff we overridden the `onInterceptTouchEvent` method in panel app scroll views, and make it return true when the previous scroll is still running. This effectively skips the drag slop in the default scroll view behavior, as we know the touch event should've been handled by the scroll view if it's still scrolling.

This way, the vertical scroll part on the vertical scroll view will not be dispatched to the horizontal scroll at all. This allows the nested scroll view to work separately.

Changelog:
[Android][Internal] - Share the post intercept touch event logic in scroll views

Reviewed By: javache

Differential Revision: D34627329

fbshipit-source-id: d500ec3bfbe349a45ef5c1360b5c8807c168f682
2022-03-04 15:50:00 -08:00
Xin Chen 0368081858 Cancel the post touch fling when new touch is registered
Summary:
This diff aims to fix an issue I found while working on T113264056. It's to address the [comment](https://www.internalfb.com/diff/D3207608 (https://github.com/facebook/react-native/commit/a3146e41a259175f0c79e3c213523a0fb21613d7)?dst_version_fbid=507451319451602&transaction_fbid=1615731455398227) in an old diff D3207608 (https://github.com/facebook/react-native/commit/a3146e41a259175f0c79e3c213523a0fb21613d7). That issue begins to surface after I made the change in the next diff, which is discussed in detail in the task description (T113385381).

The fix here is to cancel the post touch processing when a new touch down is received. This should've cancel any previous post touch processing as the new touch should take full control of scrolling.

Changelog:
[Android][Fixed] - Cancel post touch process when new touch is received

Reviewed By: javache

Differential Revision: D34627330

fbshipit-source-id: 1fb8cfc1a4d94349b5290915a0a9f190186f2af3
2022-03-04 15:50:00 -08:00
Lulu Wu ab45138394 Report js exceptions via Lacrima
Summary:
Why Lacrima?
- Throw a JavascriptException in native won't get the js error reported to backend, we need to use reporter APIs
- Lacrima is a new error reporting framework to report crashes and app deaths in android applications at Facebook, and it has APIs for reporting js exceptions.
- ```FbErrorReporterImpl.java``` uses ```Acra``` API to report, and ```Lacrima``` is a rewrite of ```Acra``` https://fb.workplace.com/groups/323014308578038/
- We've been receiving js errors reported via Lacrima https://fburl.com/logview/y1vhc8u8

In this diff all js errors are treated as soft errors during reporting because they don't usually crash the app, crashes will be reported with a different category.

Changelog:
[Android][Chagned] - Change static string to public

Reviewed By: fkgozali

Differential Revision: D34095100

fbshipit-source-id: 73d89647134a197baf5d228d620732781b6bd723
2022-03-04 15:42:52 -08:00
Nicola Corti 350f8c5ed0 Setup publishing for the ReactAndroid/hermes-engine to the top level /android folder.
Summary:
This sets up the publishing of the `hermes-engine` to end up in the Maven Local repository
we have set up inside the ./android folder of the NPM package of `react-native`.
Artifacts from there will be picked up similarly to what it's happening for React Android

Changelog:
[Internal] [Changed] - Setup publishing for the `ReactAndroid/hermes-engine` to the top level `/android` folder.

Reviewed By: hramos

Differential Revision: D34213638

fbshipit-source-id: adbc0d1559ee815f9d7a711c9c77489ec92b76ff
2022-03-04 07:27:13 -08:00
Nicola Corti a211089b9b Setup an android library project inside ReactAndroid/hermes-engine
Summary:
This commits sets up an Android library by applying the plugin
and configuring all the necessary flags.

Flags have been adapted from:
https://github.com/facebook/hermes/blob/main/android/hermes/build.gradle
Removing the unnecesary ones and adapting the build to conform
to the React Native build system.

Changelog:
[Internal] [Changed] - Setup an android library project inside `ReactAndroid/hermes-engine`

Reviewed By: hramos

Differential Revision: D34213534

fbshipit-source-id: c2e7b810bf4c4b1831a764a6f76cb73722da2125
2022-03-04 07:27:13 -08:00
Nicola Corti d96cd6d285 Create a Gradle task to setup the Hermes Ninja build
Summary:
As the title says, we need to invoke:
```
./utils/build/configure.py ./ninja_build
cmake --build ./ninja_build --target hermesc
```
In order to build the Hermes compiler, otherwise the CMake build
will fail with a missing Cmake file.

Changelog:
[Internal] [Changed] - Create a Gradle task to setup the Hermes Ninja build

Reviewed By: hramos

Differential Revision: D34213468

fbshipit-source-id: 83f70bdb068f99ce17a44207b4282fde2d7420ca
2022-03-04 07:27:13 -08:00
Nicola Corti 191fc0f7cc Setup a Gradle build inside ReactAndroid/hermes-engine to download Hermes sources
Summary:
This Diff sets up a small Gradle build inside `ReactAndroid/hermes-engine`
The idea is to kickoff a small project where we can download Hermes sources and start a compilation of
the Hermes sources from there.

Specifically the used paths are:

- `/sdk/hermes` for the unzipping
- `/sdk/download/hermes.tar.gz` for the tarball location
- `/sdk/hermes/.hermesversion` for the hermes version.

allow-large-files

Changelog:
[Internal] [Changed] - Setup a Gradle build inside `hermes-engine` to download Hermes sources

Reviewed By: hramos

Differential Revision: D34210236

fbshipit-source-id: 97034f5608dfb3fcd1d74e9851944f7a60e52ea1
2022-03-04 07:27:13 -08:00
Samuel Susla a159416333 Use std::optional instead of butter::optional
Summary: changelog: Use std::optional instead of butter::optional

Reviewed By: fkgozali

Differential Revision: D33352680

fbshipit-source-id: 45a53fec181a6ffb6218909bc23348f7c9f21ec4
2022-03-04 07:25:59 -08:00
Samuel Susla c2e4ae39b8 Add support for C++17 in OSS
Summary: changelog: Add support for C++17

Reviewed By: cortinico

Differential Revision: D34612257

fbshipit-source-id: 88a0307a750f2e0793a639b7a2b670a4571332fe
2022-03-04 07:25:59 -08:00
David Vacca 97f3eb2d3b Ship large text measure cache in Fabric Android
Summary:
Ship large text measure cache in Fabric Android

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D34602873

fbshipit-source-id: bd0a77b8b2f85301a78d528e7810938b78c7f7b8
2022-03-03 09:41:23 -08:00
Samuel Susla 8669277b3b Use std::unordered_set::find instead of std::unordered_set::contains
Summary:
changelog: [internal]

I'm looking into JS exceptions in React 18 on Android and I've noticed we use [std::unordered_set::contains]((https://en.cppreference.com/w/cpp/container/unordered_set/contains) that is only supported in C++20. I don't think this causes the exceptions but I would like to eliminate this option.

Reviewed By: javache

Differential Revision: D34547741

fbshipit-source-id: 6cffcff3366e7579a2c0e19bc01ffcb355b9ddb6
2022-03-03 09:22:32 -08:00
Samuel Susla 664f9b11ba Add option to delay deletion of viewState
Summary:
changelog: [internal]

ViewState is sometimes deleted but not created again because of race condition in C++ pre-allocation and how it checks for revision to determine if createView mount item should be dispatched.

In this diff, we add an option to delay deletion of ViewState until the next commit.

Reviewed By: ShikaSD

Differential Revision: D34553174

fbshipit-source-id: e5213f1d39137fb56fc745321a7c1b28d417ea27
2022-03-03 06:02:02 -08:00
Samuel Susla f7e4037c65 Clean up constructor in FabricMountingManager
Summary:
changelog: [internal]

Make all feature flags `const` and initialise them as ivars. Also makes the class final and removes virtualised destructor since it is not needed.

Reviewed By: ShikaSD

Differential Revision: D34549013

fbshipit-source-id: 2b326bc5b6c1dd6d89c2fb9c671bda6da669fa76
2022-03-03 04:35:53 -08:00
Andrei Shikov fc9dec9a35 Download kotlin compiler JARs for Buck instead of checking them in (#33209)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33209

Downloads Kotlin compiler JARs with Buck before starting docker build. This solution is slower than checking in JARs directly, but it allows to keep lighter size of the repo for people who want a complete checkout.

Changelog: [Internal] - Update CI build to download Kotlin jars for buck

Reviewed By: cortinico

Differential Revision: D34582932

fbshipit-source-id: 290398579ce2a4d57c7af318c66526689db6073c
2022-03-02 13:04:49 -08:00
Pieter De Baets f743bed657 Enable paintFilterBitmap when rendering images with rounded corners
Summary:
Per Android docs (https://developer.android.com/reference/android/graphics/Paint#FILTER_BITMAP_FLAG):

> This should generally be on when drawing bitmaps, unless performance-bound (rendering to software canvas) or preferring pixelation artifacts to blurriness when scaling significantly.

Changelog:
[Android][Fixed] - Improve rendering of images when resampled and corner radius applied

Reviewed By: genkikondo

Differential Revision: D34551184

fbshipit-source-id: 649da53af816be829e5b7f8e2a100f07a8b412b7
2022-03-02 02:55:55 -08:00
Andrei Shikov 131844f40e Add feature flag to disable pre-allocation on clone
Summary:
Disables preallocation for cloned nodes, switching to create during commit for those cases instead.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D34555621

fbshipit-source-id: 21fc834cea318ca299aa37a9aab28a2f2a9675b5
2022-03-01 18:10:49 -08:00
David Vacca ec27141b93 remove duplicate code in FabricUIManager
Summary:
remove duplicate code in FabricUIManager

The removed line is already called few lines above

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D34553849

fbshipit-source-id: 2e0102a77e7464c9803fb1175385fdafbb88f1fa
2022-03-01 14:56:44 -08:00
David Vacca 34d3373bb0 Ship enableNestedTextOnPressEventFix
Summary:
Ship the NestedTextOnPressEventFix feature flag

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D34554304

fbshipit-source-id: 3350c56d0cc4f2593645bcb6650034be336bd902
2022-03-01 12:07:36 -08:00
Andrei Shikov 964e816752 Update usages of default ReactNativeConfig (#33196)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33196

Fixes compilation of Android template and renames the field according to Java guidelines.

Changelog: [Android][Changed] - Rename field with default values for ReactConfig to DEFAULT_CONFIG

Reviewed By: cortinico

Differential Revision: D34523356

fbshipit-source-id: 46ed703e7ca8ab5e05879dd93e8e4d2d816c2d03
2022-02-28 14:45:09 -08:00
David Vacca a7a2d2307c Quick update in the Fabric statistics loggiing
Summary:
Quick update in the Fabric statistics loggiing

changelog: [internal] internal

Reviewed By: ShikaSD

Differential Revision: D34315716

fbshipit-source-id: c0e2e1611b0b6a947ffef6e0cc444b15e812d01b
2022-02-27 22:23:48 -08:00
David Vacca 858ccfc9c8 Refactor to reuse EmptyReactNativeConfig from ReactNativeConfig
Summary:
Quick refactor to reuse EmptyReactNativeConfig from ReactNativeConfig

changelog: [internal] internal

Reviewed By: genkikondo

Differential Revision: D34283060

fbshipit-source-id: 32400d5ed6defd9f82953dc49ae365598db71bbc
2022-02-27 22:23:48 -08:00
David Vacca 5c9c901d0c Introduce DefaultValuesReactNativeConfig constant
Summary:
Introduce DefaultValuesReactNativeConfig constant that represents a ReactNativeConfig that always return default values

I also use this constant in all the apps using fbaric that don't have a custom Mobile Config

changelog: [internal] internal

Reviewed By: RSNara

Differential Revision: D34160478

fbshipit-source-id: 5730054fd4cc87e1fe5dc8247cc237194bf48981
2022-02-27 22:23:48 -08:00
Pieter De Baets 42719e3bb7 Implement ReadableNative*::mapException without dynamic_cast
Summary:
Changing fbjni's mapException interface to use `std::exception_ptr`, this enables us to use `std::rethrow_exception` and `catch` statements to check for specific exception types, rather than using dynamic_casts and having an explicit dependency on RTTI.

While generally, we should always be enabling RTTI and exception support simultaneously, we have a number of targets where we don't, or where avoiding RTTI provides significant binary size gains.

Changelog: [Internal]

Reviewed By: mhorowitz

Differential Revision: D34379950

fbshipit-source-id: 446d105f9fb50ada3526f242f98e163215abd0ab
2022-02-25 09:41:19 -08:00
Pieter De Baets dc50308994 Remove default usages of enable_exceptions/rtti
Summary: Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D34379947

fbshipit-source-id: abff08ec99cff60d16ff82b7c0422d72caffd59b
2022-02-25 07:46:11 -08:00
Andrei Shikov 8b226f9f6a Add kotlin_home and related JARs for OSS Buck Kotlin build (#33168)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33168

Buck Kotlin setup requires jars to be available locally before the build, so we are checking them in.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D34419817

fbshipit-source-id: 5e75f0f3818fb76b640349c003bd258bc12aa53d
2022-02-24 03:10:05 -08:00
Andrei Shikov 1953f6f02e Exclude raw props from view shadow nodes
Summary:
With the `MapBuffer`-based props calculated from C++ props, there's no need to keep `rawProps` around for Android views.

This change makes sure that the `rawProps` field is only initialized under the feature flag that is responsible for enabling `MapBuffer` for prop diffing, potentially decreasing memory footprint and speeding up node initialization as JS props don't have to be converted to `folly::dynamic` anymore.

For layout animations, props rely on C++ values, so there's no need to update `rawProps` values either.

Changelog: [Internal][Android] - Do not init `rawProps` when mapbuffer serialization is used for ViewProps.

Reviewed By: mdvacca

Differential Revision: D33793044

fbshipit-source-id: 35873b10d3ca8b152b25344ef2c27aff9641846f
2022-02-22 17:23:05 -08:00
Andrei Shikov cbcdaae2b5 Use mapbuffer for ReactViewGroup
Summary:
Provides an alternative way of diffing props on Android side. Instead of passing dynamic JSON values from JS, the new approach diff C++ props and serializes difference into a `MapBuffer`. Current implementation does this only for `RCTView` component to test performance, correctness and memory impact (as MapBuffers are supposed to be more compact and performant).

This way of passing props allows for additional alignment between platforms, as C++ props are now source of truth for the view state, similar to iOS. At the same time, changing serialization method requires reimplementing `ViewManager` codegen (done manually for now) to account for `MapBuffer`s.

Changelog: [Added][Android] - Added an experimental prop serialization path based on MapBuffer

Reviewed By: mdvacca

Differential Revision: D33735245

fbshipit-source-id: 1515b5fe92f6557ae55abe215ce48277c83974a6
2022-02-22 12:23:49 -08:00
Andrei Shikov b1a779392d Enable Kotlin build in OSS (#33160)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33160

Enables Kotlin build in RNAndroid, while adjusting the package structure to help with path/package inconsistency.

Moves `react/uimanager/interfaces` files into `react/uimanager` to make sure package name matches with file location and updates Buck configuration to still include it as a separate target.

Changelog: [Android][Changed] - Moved `com/react/facebook/uimanager/interfaces` files into `com/react/facebook/uimanager` to enable Kotlin build

Reviewed By: cortinico

Differential Revision: D34381179

fbshipit-source-id: 252588d9c7f62b8019bdfcce66197628d63e63a1
2022-02-22 10:22:52 -08:00
Andrei Shikov 733f228506 Diff C++ props for Android consumption
Summary:
Creates a mapbuffer from two ViewProp objects. This MapBuffer is used later instead of bag of props from JS to set the properties with platform ViewManager.

Changelog: [Internal] - Added MapBuffer diffing for ViewProps

Reviewed By: mdvacca

Differential Revision: D33735246

fbshipit-source-id: 10ad46251ea71aa844586624c888f5223fa44e57
2022-02-22 08:23:40 -08:00
Andrei Shikov 6b5c3db9c2 Execute animated operations that were peeked and not polled
Summary:
Changes `peek`->`poll` on Animated node queues to a single `poll`, accounting for race conditions. In case the queue batch is split at some point, previously polled operation is kept as a "carry-over" inside the queue abstraction.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D34377737

fbshipit-source-id: 78e5ca60c4777576fbf009c3d3ffa53629221910
2022-02-21 20:23:01 -08:00
Gabriel Donadel Dall'Agnol 200488e87c build: Bump AGP to 7.1.1 and fix bundle inclusion in release mode (#33057)
Summary:
Upgrade Android Gradle to 7.1.0 on template and fix a bug where the bundle was not getting included when building the app in release mode

Closes https://github.com/facebook/react-native/issues/33002
Closes https://github.com/facebook/react-native/issues/33018
Closes https://github.com/facebook/react-native/issues/33046
Potentially fixes https://github.com/facebook/react-native/issues/33029

## Changelog

[Android] [Changed] - Bump AGP to 7.1.0 and fix bundle inclusion in release mode

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

Test Plan:
1. Run `./scripts/test-manual-e2e.sh`
2. Select `A new RN app using the template` and `Android`
3. Test app on the emulator
4. Open Android studio build the app using release variant
4. Check the release apk using Android studio "Analyze APK" tool and ensure the bundle is included

![image](https://user-images.githubusercontent.com/11707729/152700410-3bcb80b0-35b6-4bdc-bf57-98a42a29e5a6.png)

Reviewed By: ShikaSD

Differential Revision: D34076884

Pulled By: cortinico

fbshipit-source-id: da4392af37e08e22dbcafba38476fd712141474a
2022-02-21 06:23:31 -08:00
Andrei Shikov d7f748a944 Drain animation operation queue before execution
Summary:
The concurrent queue seems to leak values on some Android 12 devices when interleaving instruction polling and execution. To help with that, we can drain the queue before executing operations, reducing the window when `add` and `poll` happen concurrently.

Changelog: [Internal] - Drain the Animated queue before execution

Reviewed By: JoshuaGross

Differential Revision: D34370056

fbshipit-source-id: 781631dbf1a10e3f1ba9564db985403bd77a2c06
2022-02-20 14:23:31 -08:00
Joshua Gross 7a3e6ae48f Add logging to detect inconsistencies with peeked/polled animation operations
Summary:
Just trying something out.

Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D34369919

fbshipit-source-id: 236f886fcc000a444bad494fd738688425159f21
2022-02-20 12:23:41 -08:00
Pieter De Baets fc35a65a7e moveToResumedLifecycleState must be called from UI thread
Summary:
I was seeing a SoftException in our apps due to this method being called as part of ReactInstanceManager's init. It seems inconsistent that we would call this from a background thread when all other `onHost*` methods are marked as confined to the UI thread.

Changelog: [Internal]

Reviewed By: ryancat

Differential Revision: D34340210

fbshipit-source-id: 0104eda66b2ca6bb315e64e806e9a30409d0d45c
2022-02-18 11:23:42 -08:00
Nicola Corti 8bc324fd34 Gradle: Deprecate reactRoot in favor of root and reactNativeDir (#33142)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33142

The `reactRoot` property was confusing as we were using it for both the root of the project
and the react-native NPM Package root. I'm deprecating it and splitting it in two.

I've added several warning in the codebase to tell the people how to migrate away from it.
Moreover this is specifying default values that are more user-friendly. Users won't have to
configure anything unless they are in a monorepo.

Changelog:
[Android] [Changed] - Gradle: Deprecate `reactRoot` in favor of `root` and `reactNativeDir`

Reviewed By: ShikaSD

Differential Revision: D34277050

fbshipit-source-id: fc7f45017452b086726516a9586cacd9a661c287
2022-02-18 04:32:40 -08:00
Alfonso Curbelo c1db41f060 Fixed - Text with adjustsFontSizeToFit changes the text layout infinitely (#33135)
Summary:
Fixes the infinite loop explained in the issue https://github.com/facebook/react-native/issues/33129 by reverting commit  59021521e7. PR https://github.com/facebook/react-native/pull/31538.

`onCollectExtraUpdates` is part of the node update cycle. By marking the node as updated `markUpdated()` in `onCollectExtraUpdates` we are restarting the update infinitely.

Unfortunately, reverting this PR also reintroduces the original issue https://github.com/facebook/react-native/issues/30717 which IMO is minor compared to the infinite loop.

## 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] - Text with adjustsFontSizeToFit changes the text layout infinitely

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

Test Plan:
I added a console.log to the Text `onTextLayout` in [packages/rn-tester/js/examples/Text/TextAdjustsDynamicLayoutExample.js ](https://github.com/facebook/react-native/blob/main/packages/rn-tester/js/examples/Text/TextAdjustsDynamicLayoutExample.js) to see if the infinite loop is gone.

![image](https://user-images.githubusercontent.com/3791120/154523914-e6aa7cf5-7a1c-488f-a392-898f4c85a833.png)

![Screen Shot 2022-02-17 at 11 20 31 AM](https://user-images.githubusercontent.com/3791120/154524274-880c3bed-d2c6-456b-8947-42e75793c424.jpg)

```

Reviewed By: ShikaSD

Differential Revision: D34310218

Pulled By: lunaleaps

fbshipit-source-id: 0d40f49d15c562ec25983145897bd95dc182f897
2022-02-17 13:46:23 -08:00
David Vacca 78e03b6fb7 Refactor of Fb4aReactFabricPerfLogger
Summary:
This diff refactors Fb4aReactFabricPerfLogger in order consume fabric commit statistics outside of fabric

changelog: [internal] internal

Reviewed By: sshic

Differential Revision: D34056540

fbshipit-source-id: 8f3b8003e1601ca36c9ba57be874a40bad455235
2022-02-16 00:23:59 -08:00
David Vacca 8dddff5547 Refactor logging of Fabric commit statistics
Summary:
This is a refactor of the logging of Fabric commit statistics to simplify the way we track performance points.

we'll later refactor and iterate on the API to integrate fabric perf point into developer tools

changelog: [internal] internal

Reviewed By: ShikaSD

Differential Revision: D34006700

fbshipit-source-id: 93a01accd90dfacc8b44edd158033b442a843284
2022-02-16 00:23:59 -08:00
David Vacca 6ab5bb6869 Rename ReactNativeConfig.getInt64 -> ReactNativeConfig.getLong
Summary:
In this I'm renaming ReactNativeConfig.getInt64 -> ReactNativeConfig.getLong

changelog: [internal] internal

Reviewed By: javache, philIip

Differential Revision: D33901536

fbshipit-source-id: 688aff9a849299eb8ad904b75b03d7fb5f0d8172
2022-02-15 15:21:38 -08:00
Pieter De Baets 45af635b1e Fix some nits/typos in MapBuffer
Summary:
Was trying out some behaviour when using the MapBuffer experiment and fixed some small issues.

Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D34108859

fbshipit-source-id: 550ca0847419006ec17472cc4b70d38fc8d05396
2022-02-15 14:06:42 -08:00
Genki Kondo 9f6f97151c Fix ReactHorizontalScrollView contentOffset
Summary:
Brings the same fix https://www.internalfb.com/diff/D34015853 (https://github.com/facebook/react-native/commit/be260b9f479a3b55ee43d2959d2c49fd3c1eb4ac) for ReactScrollView to ReactHorizontalScrollView

When setting ScrollView's contentOffset, if the ScrollView hasn't been laid out yet when ReactHorizontalScrollViewManager.setContentOffset is called, then scroll position is never set properly. This is because the actual scroll offset (0, 0) was being passed into setPendingContentOffsets, instead of the desired scroll offset. Thus, when ReactHorizontalScrollView.onLayout gets called, ReactHorizontalScrollView.scrollTo gets called with (0, 0).

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

Reviewed By: bvanderhoof

Differential Revision: D34246489

fbshipit-source-id: d923f7c9f136f7275d64bd658ffd5c2cc049d392
2022-02-15 13:09:29 -08:00
Pieter De Baets 90b98efa73 Resume LockFreeEventDispatcher from onHostResume
Summary:
Found that after backgrounding `mShouldStop` would always remain true, which prevents events from being dispatched / scheduled.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D34247567

fbshipit-source-id: 63876986dc0cee5e2a73cb4f8a35d90379d9f8ea
2022-02-15 13:05:38 -08:00
fabriziobertoglio1987 7b2d8178b1 Text Component does not announce disabled and disables click functionality when disabled (#33076)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/30937 fixes https://github.com/facebook/react-native/issues/30947 fixes https://github.com/facebook/react-native/issues/30840 ([Test Case 7.1][7.1], [Test Case 7.3][7.3], [Test Case 7.5][7.5]) .
The issue is caused by:

1) The missing javascript logic on the `accessibilityState` in the Text component https://github.com/fabriziobertoglio1987/react-native/commit/6ab7ab34e56411a7e87f396feb2f7ece1c4f98dd (as previously implemented in [Button][20]).
2) The missing setter for prop `accessible` in `ReactTextAnchorViewManager` https://github.com/fabriziobertoglio1987/react-native/commit/17095c6615107695f44af262846da446868b4cd8 (More information in previous PR https://github.com/facebook/react-native/pull/31252)

Related PR https://github.com/facebook/react-native/pull/33070 PR https://github.com/callstack/react-native-slider/pull/354

[20]: https://github.com/facebook/react-native/pull/31001/files#diff-4f225d043edf4cf5b8288285b6a957e2187fc0242f240bde396e41c4c25e4124R281-R289

## Changelog

[Android] [Fixed] - Text Component does not announce disabled and disables click functionality when disabled

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

Test Plan:
[1]. Text has `disabled` and `accessibilityState={{disabled: false}}` ([link][1])
[2]. Text has `disabled` ([link][2])
[3]. Text has `accessibilityState={{disabled: true}}` ([link][3])
[4]. Text has `accessibilityState={{disabled:false}}` ([link][4])
[5]. Text has `disabled={false}`  and `accessibilityState={{disabled:true}}` ([link][5])
[6]. Text has `accessibilityState={{disabled:true}}` and method `setAccessible` in `ReactTextAnchorViewManager` (tested on commit [b4cd8][10]) ([link][6])
7. Test Cases on the main branch
[7.1]. Text has `disabled` and `accessibilityState={{disabled: false}}` ([link][7.1])
[7.3] Text has `accessibilityState={{disabled: true}}` ([link][7.3])
[7.5] Text has `disabled={false}`  and `accessibilityState={{disabled:true}}` ([link][7.5])
[7.6] Text has `onPress callback` and `accessibilityState={{disabled: true}}` ([link][7.6])
[7.7] Text has `accessibilityState={{disabled:true}}` and no method `setAccessible` in `ReactTextAnchorViewManager` (tested on commit [c4f98dd][11]) ([link][7.7])

[1]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465424
[2]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465631
[3]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465706
[4]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465755
[5]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465813
[6]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1038473783
[7.1]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465874
[7.3]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033465961
[7.5]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033466018
[7.6]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1033321965
[7.7]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/1#issuecomment-1038471984

[10]: https://github.com/facebook/react-native/pull/33076/commits/17095c6615107695f44af262846da446868b4cd8
[11]: https://github.com/facebook/react-native/pull/33076/commits/6ab7ab34e56411a7e87f396feb2f7ece1c4f98dd

Reviewed By: blavalla

Differential Revision: D34211793

Pulled By: ShikaSD

fbshipit-source-id: e153fb48c194f5884e30beb9172e66aca7ce1a41
2022-02-15 11:23:11 -08:00
Kunal Farmah 8c573d9336 Added fail-safe check to catch MissingWebViewPackage Exception. (#33088)
Summary:
The check implemented in PR https://github.com/facebook/react-native/issues/29089 is flawed as the exception class name and message depends on the OS version as well as the OEM. In OxygenOS running android 11, it comes out as RuntimeException and the check fails and hence the crash occurs again. But on observing closely, its clear that the exception message is consistent across OEMs with similar strings appearing in them that have been included in the if check.
Hence there is a simple fix to this issue, by checking the message instead of the exception class.

Here is the snippet:

```
private Nullable CookieManager getCookieManager() {
    if (mCookieManager == null) {
      possiblyWorkaroundSyncManager(mContext);
      try {
        mCookieManager = CookieManager.getInstance();
      } catch (IllegalArgumentException ex) {
        // https://bugs.chromium.org/p/chromium/issues/detail?id=559720
        return null;
      } catch (Exception exception) {
        String message = exception.getMessage();
        // We cannot catch MissingWebViewPackageException as it is in a private / system API
        // class. This validates the exception's message to ensure we are only handling this
        // specific exception.
        // The exception class doesn't always contain the correct name as it depends on the OEM
        // and OS version. It is better to check the message for clues regarding the exception
        // as that is somewhat consistent across OEMs.
        // For instance, the Exception thrown on OxygenOS 11 is a RuntimeException but the message contains the required strings.
        // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/webkit/WebViewFactory.java#348
       if (exception.getClass().getCanonicalName().contains("MissingWebViewPackageException") ||
            (message!=null && (message.contains("WebView provider") ||
               message.contains("No WebView installed")))){
            return null;
        } else {
          throw exception;
        }
      }
    }

    return mCookieManager;
  }
```

## Changelog

[General] [Added] - A fail proof check to catch any crash involving webview:
if (exception.getClass().getCanonicalName().contains("MissingWebViewPackageException") || (message!=null && (message.contains("WebView provider") || message.contains("No WebView installed"))))
[General] [Removed] - Flawed check to catch WebViewProvider crash:
if (message != null && exception.getClass().getCanonicalName().contains("MissingWebViewPackageException"))

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

Test Plan:
This code has been tested rigorously on OnePlus Nord CE 5G (Oxygen OS 11.0) and Realme X (Realme UI 2.0) both running on Android 11 and reproducing the crash on a hybrid (Native android + ReactNative) app that showed this crash in production being dependent on WebViews. I have implemented an entire patched fork of 0.67.2 to fix this issue in our app.

How to test:

Launch any app that has a webview.
Go to settings->apps->Android System Webview -> disable.
Resume/Restart the app.

In this fix:
Open a webview and notice that the app will not crash.

In current version:
App crashes on startup as the exception escapes the catch block.
Even if it survives startup (did on Realme X), it will crash once you try to open a webview.

Reviewed By: rh389

Differential Revision: D34240097

Pulled By: cortinico

fbshipit-source-id: 0f1f9a3b078c0ad3074c7841392892cb70b427eb
2022-02-15 04:50:51 -08:00