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

5132 Коммитов

Автор SHA1 Сообщение Дата
Xin Chen 7b77cc637e Change Vertical ScrollView to take Context instead of ReactContext
Summary:
The `ReactScrollView.java` constructor is using `ReactContext` instead of `Context`, which is inconsistent to the horizontal scroll view. This is the result from D3863966 (2cf2fdbc04) when an OSS issue needs to be addressed. That issue and all call sites to use the `ReactContext` are deprecated now.

Revert this back to use `Context` to be less restrictive.

Changelog:
[Android][Fixed] - Revert `ReactScrollView` to use `Context` instead of `ReactContext` in the constructor to be less restrictive.

Reviewed By: javache

Differential Revision: D31819799

fbshipit-source-id: 3f00d64850aebd2e20615033b2e1f1c721fed37e
2021-10-21 13:26:12 -07:00
Pieter De Baets 8de8d475d4 Add surfaceId helper to Event baseclass
Summary:
Colocate the surface ID generate with the code that consumes it. This allows us to re-use this method in other event emitter locations.

Changelog: [Android][Changed] Add helper to get surfaceId for event dispatching

Reviewed By: philIip

Differential Revision: D31651881

fbshipit-source-id: 109e189f90261d3ba0077ffa519c3d12a9111439
2021-10-21 03:43:49 -07:00
Pieter De Baets 03e513de41 Add emitting view to onChildStartedNativeGesture callback
Summary:
Changelog:
[Android][Changed] RootView's onChildStartedNativeGesture now takes the child view as its first argument

Reviewed By: philIip

Differential Revision: D31399515

fbshipit-source-id: b9438f6118e604a04799ef67d0b46303a06d6434
2021-10-21 03:43:49 -07:00
CodemodService FBSourceGoogleJavaFormatLinterBot e007c8a9de Daily `arc lint --take GOOGLEJAVAFORMAT`
Reviewed By: zertosh

Differential Revision: D31824304

fbshipit-source-id: 146d9ca721773af1200ca01876387bcb44f95a40
2021-10-21 03:34:48 -07:00
Tuomas Jaakola d839b24b06 Load jsc or hermes lib in static method (#30749)
Summary:
Many have reported about the misguiding error `Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so` even though they don't use Hermes (for example issues https://github.com/facebook/react-native/issues/26075 #25923).

**The current code does not handle errors correctly when loading JSC or Hermes in `ReactInstanceManagerBuilder`**.

**ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java:**
```java
try {
  return new HermesExecutorFactory();
} catch (UnsatisfiedLinkError hermesE) {
  // We never get here because "new HermesExecutorFactory()" does not throw an exception!
  hermesE.printStackTrace();
  throw jscE;
}
```

In Java, when an exception is thrown in static block, it will be RuntimeException and it can't be caught. For example the exception from `SoLoader.loadLibrary` can't be caught and it will crash the app.

**ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java:**
```java
static {
  // Exception from this code block will be RuntimeException and it can't be caught!
  SoLoader.loadLibrary("hermes");
  try {
    SoLoader.loadLibrary("hermes-executor-debug");
    mode_ = "Debug";
  } catch (UnsatisfiedLinkError e) {
    SoLoader.loadLibrary("hermes-executor-release");
    mode_ = "Release";
  }
}
```

This PR fixes the code so that the original exception from failed JSC loading is not swallowed. It does not fix the original issue why JSC loading is failing with some devices, but it can be really helpful to know what the real error is. For example Firebase Crashlytics shows wrong stack trace with current code.

I'm sure that this fix could have been written better. It feels wrong to import `JSCExecutor` and `HermesExecutor` in `ReactInstanceManagerBuilder.java`. However, the main point of this PR is to give the idea what is wrong with the current code.

## 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 error handling when loading JSC or Hermes

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

Test Plan:
* from this PR, modify  `ReactAndroid/src/main/java/com/facebook/react/jscexecutor/JSCExecutor.java` so that JSC loading will fail:
```java
// original
SoLoader.loadLibrary("jscexecutor");
// changed
SoLoader.loadLibrary("jscexecutor-does-not-exist");
```
* Run `rn-tester` app
* Check from Logcat that the app crashed with correct exception and stacktrace. It should **not** be `java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so`

Tested with Hermes

```
    SoLoader.loadLibrary("hermes-executor-test");
```
Got this one in logcat
```
09-24 20:12:39.552  6412  6455 E AndroidRuntime: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes-executor-test.so
```

Reviewed By: cortinico

Differential Revision: D30346032

Pulled By: sota000

fbshipit-source-id: 09b032a9e471af233b7ac90b571c311952ab6342
2021-10-20 17:53:26 -07:00
Nicola Corti 30df66c648 Use explicit codegen path in ReactAndroid
Summary:
This Diff is adapting the codegen configuration for ReactAndroid
to specify a path for the codegen package. I've used the `findNodeModulePath`
so this will work for both:
* The top level OSS project as `node_modules` will be at the top level
* The scenario where ReactAndroid will be included and built from source (as `node_modules` is in the `..` folder).

Changelog:
[Internal] [Changed] - Use explicit codegen path in ReactAndroid

Reviewed By: mdvacca

Differential Revision: D31730920

fbshipit-source-id: 6637da5d0098114f4379bcaeb8a40e976c46f194
2021-10-20 09:34:06 -07:00
Andrei Shikov d9689b90a4 Fix memory corruption issue in SurfaceHandler
Summary:
SurfaceHandlerBinding uses string from JVM memory when initializing, which is released before it is used. If JVM manages to collect this memory before instance init, it can lead to use-after-free.

Changelog:
[Internal] - fix memory corruption in cxx binding of surface handler

Reviewed By: mdvacca

Differential Revision: D31794515

fbshipit-source-id: 3944ebd065f42a516f036096d07c0126a43c912f
2021-10-20 08:28:23 -07:00
Nicola Corti e5ad0b403e useJavaGenerator output should override the react-native-codegen one
Summary:
Turns out that the Java generator is (as expected) outputting only Java code.
Therefore the C++ and the Markdown files are still generated by `react-native-codegen`.
I'm updating the logic to make sure the Java generator is not mutually exclusive and
overrides the output of `react-native-codegen`

Changelog:
[Internal] [Changed] - useJavaGenerator output should override the react-native-codegen one

Reviewed By: sshic

Differential Revision: D31754428

fbshipit-source-id: 3e6dae8212fbfebd28247ec17e88243871265808
2021-10-20 06:11:20 -07:00
Nicola Corti afc96ab126 Safely access the project NDK properties
Summary:
This diff is making sure that we're not failing the build
if either `ANDROID_NDK_PATH` or `ANDROID_NDK_VERSION` are missing.
Currently if any of the two is missing, a Gradle sync will fail.

This is problematic for the New Arch Rollout playbook as users will
import the `:ReactAndroid` project to build from source, and those
properties are instead defined at the `react-native` top level project.

Changelog:
[Internal] [Changed] - Safely access the project NDK properties

Reviewed By: sshic

Differential Revision: D31731291

fbshipit-source-id: ce4b762998ed545b3ec7ddcc07abbe4452602190
2021-10-20 06:07:15 -07:00
Joshua Gross d291a7efdd Allow disabling RTTI/exceptions for android builds; disable by default on Android
Summary:
For fbandroid builds only, disable RTTI and exceptions by default.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D31632757

fbshipit-source-id: cfe0e43486df19fcaacc2b5b818b9d00ec2d427f
2021-10-19 17:17:30 -07:00
David Vacca e494e4beb6 Fix onPress event for nested Text in RN Android
Summary:
This bug is caused by RNAndroid dispatching an incorrect sequence of events to JS when the user taps on a Text.

Taking into consideration the example P462662009, when the user taps of the "Inner" text, RN Android is dispatching three events:
topTouchStart, topTouchStart and topTouchEnd.

The information stored on the first two JS events is correct, but the problem is that it is duplicated. This sequence of events makes Pressability to dispatch the event to the incorrect target.

This was originally introduced in D3035589 (39fdce259d) (2016)

In this diff I'm changing the way RN Android bubbles events when the user taps on a ReactTextView. From now on, events won't be bubbled anymore, and they will be handled by the ReactRootView.onInterceptTouchEvent: https://fburl.com/code/rbt8$

Additionally, I'm creating a FeatureFlag in case this change has a unknown side effect that's only detected in production.
I will create a MC for FB4A in the next diffs of the stack

changelog: [Fixed][Android] Fix onPress event for nested Text in RN Android

Reviewed By: javache

Differential Revision: D31628461

fbshipit-source-id: 177397d4369191a3c97e2f86e801757b27ee5121
2021-10-19 15:49:36 -07:00
Lulu Wu ce74aa4ed3 Add ReactInstanceEventListener for Venice and expose in FbReactInstanceHolder
Summary:
Add ```ReactInstanceEventListener``` for Venice and migrate Bridge-only callsites from
- FbReactInstanceHolder.getReactInstanceManager().addReactInstanceEventListener()
- FbReactInstanceHolder.getReactInstanceManager().removeReactInstanceEventListener()

To:
- FbReactInstanceHolder.addReactInstanceEventListener()
- FbReactInstanceHolder.removeReactInstanceEventListener()

Changelog:
[Android][Changed] - Add ReactInstanceEventListenerV2 for migration

Reviewed By: RSNara

Differential Revision: D31501785

fbshipit-source-id: e1cd03f07e28fbb995ea0a1bb76400089a461879
2021-10-19 04:11:17 -07:00
Nicola Corti bc93fefe13 Refactor Extract Headers and JNI from AARs to an internal task (#32426)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32426

This diff refactors the extractHeader and extractJni tasks to a single Gradle task in the `.internal` package.
The reason for this change is that those two tasks were always running, therefore invalidating the
whole native build cache.

Changelog:
[Internal] [Changed] - Refactor Extract Headers and JNI from AARs to an internal task

Reviewed By: mdvacca, ShikaSD

Differential Revision: D31682942

fbshipit-source-id: 191cc77902e82c0425949cee743d240ded790137
2021-10-18 04:34:43 -07:00
Nicola Corti 75b2e5cc97 Export prepareJSC to an internal task (#32427)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32427

This diff refactors the `prepareJSC` task to a separate Gradle task in the `.internal` package.

The reason for this change is that `prepareJSC` was just a plain `Task` and not a `Copy` task.
It was defining a top level `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the JSC headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareJSC to an internal task

Reviewed By: ShikaSD

Differential Revision: D31682293

fbshipit-source-id: 3d4cd9d9ce2fcd45e61f3c8c6685b69a622a1912
2021-10-18 04:34:43 -07:00
Nicola Corti 52b0cc0355 Export prepareBoost to an internal task (#32424)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32424

This diff refactors the `prepareBoost` task to a separate Gradle task in the `.internal` package.
The reason for this change is that `prepareBoost` was defining a `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the Boost headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareBoost to an internal task

Reviewed By: ShikaSD

Differential Revision: D31662120

fbshipit-source-id: 87ba82c634da832ee54c3d13561df45d3fd71381
2021-10-18 04:34:43 -07:00
Nicola Corti bb981b2055 Export prepareLibevent to an internal task (#32425)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32425

This diff refactors the `prepareLibevent` task to a separate Gradle task in the `.internal` package.
The reason for this change is that `prepareLibevent` was defining a `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the Libevent headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareLibevent to an internal task

Reviewed By: ShikaSD

Differential Revision: D31661988

fbshipit-source-id: e55c2179a187fa156f701c25bae3b48a796e2660
2021-10-18 04:34:43 -07:00
Nicola Corti c3e7ea0b5b Export prepareGlog to an internal task (#32421)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32421

This diff refactors the `prepareGlog` task to a separate Gradle task in the `.internal` package.
The reason for this change is that `prepareGlog` was defining a `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the Glog headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareGlog to an internal task

Reviewed By: ShikaSD

Differential Revision: D31661668

fbshipit-source-id: efcd5505a67d6c9f02fcab7a5c3255a160215661
2021-10-18 04:34:43 -07:00
Pieter De Baets dfe42d6b75 Fix incorrect hitState when non-React views are hit
Summary: Changelog: [Android][Changed] Improved logic of findTargetPathAndCoordinatesForTouch

Reviewed By: Guad

Differential Revision: D31688645

fbshipit-source-id: b9ba91e135b6359e49998a314bf6c91a67fae5ed
2021-10-18 02:31:02 -07:00
Rob Hogan 61755aced1 Merge textDecoration(LineStyle|LinePattern) into textDecorationStyle
Summary:
The [first implementation of `TextAttributes` in Fabric](62576bcb78) included two separate props instead of `textDecorationStyle`: `textDecorationLineStyle` (single, double, ...) and `textDecorationLinePattern` (dot, dash, dotdash, ...). These two props were implemented in C++ and iOS but never supported in JS.

Pre-Fabric (and CSS) on the other hand use a single prop `textDecorationStyle: 'solid' | 'double' | 'dotted' | 'dashed'`.

This diff implements this same API in Fabric, and removes the unused `textDecorationLineStyle` and `textDecorationLinePattern` props.

Changelog:
[iOS][Fixed] - Implement `textDecorationStyle` on iOS and remove unused `textDecorationLineStyle` and `textDecorationLinePattern` from Fabric.

Reviewed By: dmitryrykun

Differential Revision: D31617598

fbshipit-source-id: f5173e7ecdd31aafa0e5f0e50137eefa0505e007
2021-10-18 02:16:03 -07:00
Lulu Wu f1b5fe1d3e Prevent NPE on ThemedReactContext
Summary:
When pre-prerendering a surface without rendering it, "SurfaceMountingManager.getContext()" will return null since no ThemedReactContext is passed into it:
https://www.internalfb.com/code/fbsource/[0f4812c8039d975b3651dfa756d60a882bf8e193]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java?lines=298-317

Changelog:
[Android][Fixed] - Prevent NPE on ThemedReactContext

Reviewed By: ShikaSD

Differential Revision: D31691022

fbshipit-source-id: 4cca6c4550a77075f8fd754dbf21fe5bf5da77e6
2021-10-17 02:55:19 -07:00
CodemodService FBSourceGoogleJavaFormatLinterBot ed8e5e5151 Daily `arc lint --take GOOGLEJAVAFORMAT`
Reviewed By: zertosh

Differential Revision: D31681073

fbshipit-source-id: 1283e00c2ba1ecfa824b3c182ac35ae11cbe9bc2
2021-10-15 10:53:00 -07:00
Pieter De Baets ec31b38ef1 Fix bug with hittesting when skipping views due to overflow
Summary:
Noticed we were sometimes receiving incorrect paths through the view hierarchy. This was largely harmless, as the hover events generated from this would still be correct. We just sometimes send more onExit/onEnter events than necessary.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D31434300

fbshipit-source-id: 3888270eaa16edf48f5d894a1e6daeca1ecfed1e
2021-10-15 04:35:05 -07:00
Joshua Gross 6525f9b082 Stop using RTTI features in Fabric core and components
Summary:
These dynamic_casts aren't really giving us much (they have never fired once in dev! and don't run in prod anyway). They also prevent us from disabling RTTI. So, let's get rid of them.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D31634895

fbshipit-source-id: 4a9b259837127feb324f64fa3e9e23eb1cc481a6
2021-10-14 19:23:09 -07:00
Andrei Shikov f7a33e3501 Use `Arguments.createArray` instead of `WritableNativeArray`
Summary:
Using `WriteableNativeArray` directly in common code is breaking unit tests on CircleCI.

Changelog:
[Android][Internal] - Use mock of native array for sending touches

Reviewed By: mdvacca

Differential Revision: D31665842

fbshipit-source-id: 886418ff6a3f07046e8e17d4743060d80c26b288
2021-10-14 16:17:08 -07:00
Joshua Gross b60e229d7f Remove compiler_flags from BUCK modules
Summary:
Nearly all of these are identical and these compiler_flags are now centralized in rn_defs.bzl. This should have NO CHANGE on build configuration, the flags have just moved for now.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D31631766

fbshipit-source-id: be40ebeb70ae52b7ded07ca08c4a29f10a0ed925
2021-10-14 15:34:29 -07:00
Pieter De Baets ad0d4534a7 Remove jsMessageQueueThread from Fabric binding
Summary:
This seems like a remnant of an old refactor. This is passed in, we wrap it with a JMessageQueueThread and then never use it again.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D31506280

fbshipit-source-id: aca01439dcddbe2b44ce80342fa8664f827919c9
2021-10-14 05:29:02 -07:00
Andrei Shikov a2feaeb5f1 Refactor touch event dispatch
Summary:
Updates touch events in Fabric to be dispatched through the same pipeline as the rest of events, instead of relying on custom dispatch behavior.

Previous method of handling touches was reusing Paper behavior which required:
1. Transform event into a Paper-compatible form of WritableArray and dispatch it to `RCTEventEmitter.receiveTouches`.
2. Intercept `receiveTouches` for Fabric and redirect it to `FabricEventEmitter`
3. Perform transformations copied from Paper JS renderer in Java, transform it to the final form and dispatch this event as usual after.

The new behavior uses emitter's `receiveEvent` method directly to dispatch events. Additionally, it should decrease allocations done when transforming events during step 3 above, as `WritableNativeMap`-based operations performed many re-allocations when reading/re-creating arrays.

Changelog:
[Android][Changed] - Added an experimental touch dispatch path

Reviewed By: JoshuaGross

Differential Revision: D31280052

fbshipit-source-id: 829c2646ac6b0ebff0f0106159e76d84324ac732
2021-10-14 05:19:17 -07:00
Andrei Shikov 53fd0f4026 Retrieve touch dispatch information from event directly
Summary:
Simplifies logic of touch dispatch by retrieving surface id and other require info from the event directly.

Changelog: [Android][Internal] - Simplify logic of dispatching touches

Reviewed By: cortinico

Differential Revision: D31583314

fbshipit-source-id: c6b6e131a759c2ebe0cf4441c3aeb1a8b9f5781e
2021-10-14 05:19:17 -07:00
Joel Arvidsson d1a33cd139 Fix Android border positioning regression (#32398)
Summary:
https://github.com/facebook/react-native/issues/29099 introduced a regression where non-rounded borders on Android would render partly outside of the bounds of the view as I reported in https://github.com/facebook/react-native/issues/32393. This PR addresses that by rendering the borders completely inside the view like it works on iOS, previous version of RN and for rounded corners.

## 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 Android border positioning regression

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

Test Plan:
Rendering the following code (as reported in the issue) in the RN Tester app:

```jsx
<View
  style={{
    aspectRatio: 1,
    backgroundColor: 'green',
    borderWidth: 8,
    borderColor: 'black',
    borderStyle: 'dashed',
  }}
/>
```

|Before|After|
|--|--|
|![before](https://user-images.githubusercontent.com/378279/137178113-dd2fea7e-48c8-450b-be3a-92706ef93194.png)|![after](https://user-images.githubusercontent.com/378279/137178140-b5ce7b3d-d455-48a9-a57f-0f3194a65c9a.png)|

Reviewed By: yungsters

Differential Revision: D31623647

Pulled By: lunaleaps

fbshipit-source-id: c38d172ae4a9dc48f800c63258223a59e2f621ed
2021-10-13 17:00:33 -07:00
Andrei Shikov 8ba4a2f127 Define event category in Event class
Summary:
Propagate event category definition to every event that is using `dispatchModernV2` (gated in production), providing opportunity to override categories of some events if needed. No events are meaningfully affected by this change, as coalesced events (e.g. scroll) are always dispatched as continuous and touch events are handled separately.

Changelog:
[Internal] Expose event category in Event class

Reviewed By: cortinico

Differential Revision: D31276249

fbshipit-source-id: f9a756b3a5cf5897e17209f3d0aed6a1c16cbd2e
2021-10-13 08:23:03 -07:00
Lulu Wu 24ac66984c Add more logs
Summary:
Added more logs to understand what's the root cause for https://fburl.com/logview/kgknonri

```java.lang.IllegalStateException: Message queue threads already initialized
	at X.5y2.A0I(:64)
	at com.facebook.venice.ReactInstance.<init>(:112)
	at X.PrB.EgB(:33)
	at X.2pN.run(:4)
	at X.2pA.execute(:32)
	at X.2p6.A00(:30)
	at X.2p6.A08(:2)
	at X.PrC.EgB(:26)
	at X.Pr7.run(:4)
	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:919)
```

Changelog:
[Android][Changed] - Add some logs

Reviewed By: RSNara

Differential Revision: D31584264

fbshipit-source-id: 11b8bb2c6c9af2266688e3dae95e09f0160de79a
2021-10-12 14:18:42 -07:00
Andrei Shikov e9440508e1 Correctly apply elevation barriers to Android views
Summary:
The elevation barriers that limited view reordering were applied incorrectly, disabling elevation completely for some combinations of views. This change ensures the order of barriers is correct and only disables elevation reorder between the children and not on them.

Changelog: [Internal]

Reviewed By: p-sun

Differential Revision: D31541961

fbshipit-source-id: 2fa4dc6906790053bd4445c841aeda0e2b3830e5
2021-10-11 11:55:06 -07:00
Xin Chen 1a9e2d5d55 Fix issue with scrollTo method in ScrollViews to set actual scroll position
Summary:
The `scrollTo` method in ScrollViews are using the `(x, y)` position they got from upperstream to scroll, and to set the state for Fabric. This diff fixes an edge case where the scroll result is not ended up to `(x, y)`. For example, if we are going to scroll to the last item in the list, the item may not scroll to the `(x, y)` position, but stay at the end position of the view.

- Change `scrollTo` method to use the actual `scrollX` and `scrollY` position after scrolling to set current state.

Changelog:
[Android][Fixed] - scrollTo API in ScrollView will check the actual scroll position before setting the scroll state

Reviewed By: JoshuaGross

Differential Revision: D31492685

fbshipit-source-id: e5513fb735ea68c5014b5c47fadffe461cad5c94
2021-10-08 18:57:34 -07:00
Lulu Wu c901c43d11 Remove shared responsibility between LogBox and ExceptionsManager native module
Summary:
## Context
Right now we are using both LogBox and ExceptionsManager native module to report JS errors in ExceptionsManager.js, from below code we can tell they have some overlapping - when ```__DEV__ === true``` both could report the error.

https://www.internalfb.com/code/fbsource/[5fb44bc926de87e62e6e538082496f22017698eb]/xplat/js/react-native-github/Libraries/Core/ExceptionsManager.js?lines=109-141

## Changes
In this diff overlapping is removed: in ```ExceptionsManager.js``` LogBox will be responsible for showing the error with dialog when ```__DEV__ === true```, when it's prod we'll use ExceptionsManager native module to report the error. As a result LogBox and ExceptionsManager native module don't share responsibilities any more.

Changelog:
[General][Changed] - Remove shared responsibility between LogBox and ExceptionsManager native module

Reviewed By: philIip

Differential Revision: D30942433

fbshipit-source-id: 8fceaaa431e5a460c0ccd151fe9831dcccbcf237
2021-10-08 11:08:43 -07:00
Pieter De Baets cd4bef97d0 Add toString to all MountItem subclasses
Summary:
Useful when Fabric debug logging is enabled

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D31399518

fbshipit-source-id: b5907084604adf1f7093798315147ac63b5876f2
2021-10-06 04:05:00 -07:00
Brent Kelly 25a2c608f7 Addressing various issues with the Appearance API (#28823) (#29106)
Summary:
This PR fixes a few issues with the Appearance API (as noted here https://github.com/facebook/react-native/issues/28823).

1. For the Appearance API to work correctly on Android you need to call `AppearanceModule.onConfigurationChanged` when the current Activity goes through a configuration change. This was being called in the RNTester app but not in `ReactActivity` so it meant the Appearance API wouldn't work for Android in newly generated RN projects (or ones upgraded to the latest version of RN).

2. The Appearance API wasn't working correctly for brownfield scenarios on Android. It's possible to force an app light or dark natively on Android by calling `AppCompatDelegate.setDefaultNightMode()`. The Appearance API wasn't picking up changes from this function because it was using the Application context instead of the current Activity context.

3. The Appearance API wasn't working correctly for brownfield scenarios on iOS. Just like on Android its possible to force an app light or dark natively by setting `window.overrideUserInterfaceStyle`. The Appearance API didn't work with this override because we were overwriting `_currentColorScheme` back to default as soon as we set it.

## 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
-->

### Fixed

https://github.com/facebook/react-native/issues/28823

* [Android] [Fixed] - Appearance API now works on Android
* [Android] [Fixed] - Appearance API now works correctly when calling `AppCompatDelegate.setDefaultNightMode()`
* [iOS] [Fixed] - Appearance API now works correctly when setting `window.overrideUserInterfaceStyle`

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

Test Plan: Ran RNTester on iOS and Android and verified the Appearance examples still worked [correctly.](url)

Reviewed By: hramos

Differential Revision: D31284331

Pulled By: sota000

fbshipit-source-id: 45bbe33983e506eb177d596d33ddf15f846708fd
2021-10-05 20:23:48 -07:00
Xin Chen 93beb83abe Allow overflow scroll to clip the view instead of let it be visible
Summary:
When the overflow style set to 'scroll', React ViewGroup does nothing to the container. Instead it should be clipped just like hidden.

Changelog:
[Android][Changed] - Setting `overflow: scroll` in View component style will clip the children in the View container

Reviewed By: javache

Differential Revision: D31350605

fbshipit-source-id: e0d618f5e872fec9cf9ecb2d4cfe7af9a2f3c063
2021-10-04 17:52:38 -07:00
Samuel Susla 36f3bf2f58 Add option to use raw pointer instead of shared_ptr in EventEmitterWrapper
Summary:
changelog: [internal]

Retaining `EventEmitter` beyond runtime triggers a crash. Let's try to use raw pointer in `EventEmitterWrapper` to see if it fixes some crashes.

Reviewed By: philIip

Differential Revision: D31307332

fbshipit-source-id: cd059b6c56f8dffe985b3ecb62cdafe823ba1462
2021-10-02 09:03:58 -07:00
Samuel Susla ea53d3a9c2 Pass reference instead of shared_ptr to getInspectorDataForInstance
Summary:
changelog: [internal]

This is a pre-condition to get rid of `shared_ptr` from `EventEmitterWrapper`. Also saves us a few copies of shared_ptr, this is negligible though.

Reviewed By: mdvacca

Differential Revision: D31307048

fbshipit-source-id: b84654bed2359b66faf3995795e135e88fe51cb6
2021-10-01 17:47:20 -07:00
Andrei Shikov 086c967286 Use dispatch unique for events that can be coalesced
Summary:
Event merging or "coalescing" is done on Java side from Android, but Fabric also includes some Cxx logic to merge those events. Although Android doesn't need this logic in particular, it is important to follow this path to ensure these events (e.g. scroll) are dispatched as "continuous", allowing for correct prioritization in Concurrent Mode.

`dispatchModernV2` selects between `dispatch` and `dispatchUnique` based on the `canBeCoalesced` parameter of the event, which is exactly what we need. The logic is only used in the "new" event dispatcher at the moment, so I wrapped it with feature flag to validate it doesn't cause any regressions.

Changelog:
[Android][Internal] - Try dispatching coalescing events as unique to Fabric

Reviewed By: sammy-SC

Differential Revision: D31272585

fbshipit-source-id: 6b67b61bd13fbff019d9eb8c5172bdd814a7b5b8
2021-09-30 22:26:33 -07:00
Andrei Shikov 8491edec28 Remove deprecation from `dispatchModern` in `Event.java`
Summary:
Assuming this method was deprecated to mean experimental.
This execution path is used by overwhelming majority of events and it seems as stable as it can be.

Changelog:
[Android][Changed] Removed experimental deprecation from `dispatchModern`

Reviewed By: cortinico

Differential Revision: D31270721

fbshipit-source-id: 5a7e50455ab2850adf9bc86a248773b170bf0ab9
2021-09-30 22:26:33 -07:00
Ramanpreet Nara 40a367e0a3 Make ClipboardModule TurboModule-compatible
Summary:
We forgot to make ClipboardModule TurboModule compatible. I think this was most likely because our codemods targeted all Java classes that extended ReactContextBaseJavaModule. The ClipboardModule extends ContextBaseJavaModule instead.

There are no other NativeModules that extend ContextBaseJavaModule.

Changelog: [Internal]

Reviewed By: sshic

Differential Revision: D31291293

fbshipit-source-id: cf5d21898101699f8c349b013a77e8329339a8d3
2021-09-30 20:49:51 -07:00
Joshua Gross 5c12a84c77 Fix simple typo in comment
Summary:
Fix simple typo in comment.

Changelog: [Internal] comment typo fix

Differential Revision: D31251299

fbshipit-source-id: 210d52f236b00ed4edbd969a715d91eb2ad712a7
2021-09-30 13:11:36 -07:00
David Vacca 2feca00797 Toggle ScrollView.snapToAlignment behavior using ReactFeatureFlag.enableScrollViewSnapToAlignmentProp
Summary:
This diff enables/disables ScrollView.snapToAlignment behavior using ReactFeatureFlag.enableScrollViewSnapToAlignmentProp

changelog: [internal] internal

Reviewed By: motiz88

Differential Revision: D31308300

fbshipit-source-id: 26c01a342cac822f21d83e3474b529bea154aba6
2021-09-30 10:17:07 -07:00
David Vacca 3cffe352b5 Create FeatureFlag to control ScrollView.snapToAlignment prop
Summary:
This diff creates a FeatureFlag to control ScrollView.snapToAlignment prop

changelog: [internal] internal

Reviewed By: motiz88

Differential Revision: D31308301

fbshipit-source-id: 41b41e4e7d2a6c29c405151b2379e15df6eafc8f
2021-09-30 10:17:07 -07:00
Samuel Susla dd99475032 Fix view preallocation during cloning
Summary:
changelog: [internal]

This code assured that view preallocation is only triggered if ShadowNode is cloned from revision 0 to revision 1 (first time ShadowNode is cloned).
Node can go from virtual to view forming in subsequent clones, not just the first one. This is more of a case in Concurrent React where the node can be cloned many times before it is first mounted.

Reviewed By: mdvacca

Differential Revision: D31237719

fbshipit-source-id: 13fe6d10fdc815dbdae785d1d9d86d1c8fd36be4
2021-09-29 08:02:22 -07:00
Andrei Shikov 155a1a8ac9 Set event category for touch events on Android
Summary:
Updates event category deduction to match iOS implementation.
The event priority is used by concurrent mode to prioritize certain events, where Cxx part already assigns the correct priority based on the `ContinuousStart` -> `ContinuousEnd` spans. These spans can be deduced from the touch events, which we do in this implementation.

All events that can be "coalesced" (dispatched through `invokeUnique`) are assigned `Continuous` by default in Fabric core, so scroll/slider change events will never be discrete.

Changelog:
[Internal] Add category deduction to Android touch events

Reviewed By: mdvacca

Differential Revision: D31233233

fbshipit-source-id: f5b039aa137f1b4d2e2b15578bfc29ab6903a081
2021-09-29 06:53:49 -07:00
Andrei Shikov bf4c6b3606 Expose RawEvent::Category to Java callsites
Summary:
For iOS, event category deduction is done from the C++ code, but the touch events are handled on Java layer in Android. This change exposes the category parameter through the `EventEmitterWrapper` called from Java, allowing to define category for events in the future.

Changelog:
[Internal] - Expose event category through JNI

Reviewed By: mdvacca

Differential Revision: D31205587

fbshipit-source-id: f2373ce18464b01ac08eb87df8f421b33d100be2
2021-09-29 06:53:49 -07:00
David Vacca 04184ef851 Extend ScrollView.snapToAlignments in RN Android to reach feature parity with RN iOS
Summary:
This diff extends the current implementation of ScrollView.snapToAlignments from RN Android to reach feature parity with RNiOS

changelog: [Android][Changed] Implement ScrollView.snapToAlignments in RN Android

Reviewed By: javache

Differential Revision: D31206398

fbshipit-source-id: b6534965c476a0a4745ac98b419cbe05dc5c746e
2021-09-29 01:47:45 -07:00
David Vacca e774c037bc Implement snapToAlignment in vertical ScrollView
Summary:
This diff implements the SnapToAlignment functionality in ReactScrollView for RN Android.
In order to use SnapToAlignment, the pagingEnabled prop should be set
Based on the documentation the behavior implemented in this diff is more "advanced" than the one implemendted in RNiOS, because it let you snap without specifying any interval nor offset (it calculates the intervals in real time based on the size of its content)
I still need to verify how different RNiOS and RN Android behaviors are
changelog: [Android][Added] Implement SnapToAlignment in ReactScrollView

Reviewed By: JoshuaGross

Differential Revision: D31182786

fbshipit-source-id: a9b55d9c00326ae21ca9b89575e79c60bf9edcca
2021-09-29 01:47:45 -07:00
David Vacca c6e5640e87 Add snapToAlignment to ReactScrollViewManager
Summary:
This diff adds the new snapToAlignment into ReactScrollViewManager
changelog: [Android][Added] Implement snapToAlignment into ReactScrollViewManager

Reviewed By: JoshuaGross

Differential Revision: D31182787

fbshipit-source-id: 8049ceb462461a11f184dbc1b40ca8079a3e8b60
2021-09-29 01:47:45 -07:00
David Vacca d97a1a52c5 Fix warning in ScrollView classes
Summary:
EZ diff to fix warning in ScrollView classes

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D31175085

fbshipit-source-id: 2aebcf6b53b82f8d96aadf40db3f459652c69fb2
2021-09-29 01:47:45 -07:00
David Vacca b12256394e Implement SnapToAlignment in ReactHorizontalScrollView
Summary:
This diff implements the SnapToAlignment functionality in ReactHorizontalScrollView for RN Android.

In order to use SnapToAlignment, the pagingEnabled prop should be set

Based on the documentation the behavior implemented in this diff is more "advanced" than the one implemendted in RNiOS, because it let you snap without specifying any interval nor offset (it calculates the intervals in real time based on the size of its content)

I still need to verify how different RNiOS and RN Android behaviors are

changelog: [Android][Added] Implement SnapToAlignment in ReactHorizontalScrollView

Reviewed By: JoshuaGross

Differential Revision: D31174544

fbshipit-source-id: 204a82f55e3b7598124ce2528d8ad7d854c0ac77
2021-09-29 01:47:45 -07:00
David Vacca deec1db9fd Add snapToAlignment to ReactHorizontalScrollViewManager
Summary:
This diff adds the new snapToAlignment into ReactHorizontalScrollViewManager

changelog: [Android][Added] Implement snapToAlignment into ReactHorizontalScrollViewManager

Reviewed By: JoshuaGross

Differential Revision: D31174545

fbshipit-source-id: c56bfca207980428be98dd21a5387a0ff6bcd296
2021-09-29 01:47:45 -07:00
fabriziobertoglio1987 132d1d00f8 nested text onPress not working on last character (#30928)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/22747 nested text does not allow you to press on the last character.

The method reactTagForTouch filters touches based on coordinates x and y. Nested Texts are converted into Spans on Android
28fb41a0ab/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java (L111-L112)
https://developer.android.com/guide/topics/text/spans

reactTagForTouch iterates over the span and triggers the onPress handler if the x,y coordinates correspond to one of the span characters.

## 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] - Nested Text Android onPress does not work with last character

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

Test Plan:
This changes fix the Java API which can not be tested as explained in commit 709a441ecf
The java TextTest was excluded from the test suite in commit 709a441ecf as they need the Yoga libraries to run

**<details><summary>TEST - Clicking on the last letter triggers the callback</summary>**
<p>

Clicking on the last letter does not invoke the onPress callback (in this case a console.warn)

| **BEFORE** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/107537789-9060f480-6bc3-11eb-8ad1-1152e466f830.gif" width="700" height="" /> |

Clicking on the last letter does invoke the onPress callback (in this case a console.warn)

| **AFTER** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/107538263-11b88700-6bc4-11eb-9a48-139e053aa68b.gif" width="700" height="" /> |

</details>
</p>

**<details><summary>TEST - Adding and removing Text</summary>**
<p>

<video src="https://user-images.githubusercontent.com/24992535/107541305-48dc6780-6bc7-11eb-8d57-a8aeb57a6879.mp4" />

</details>
</p>

**<details><summary>TEST - Different type of languages</summary>**
<p>

<video src="https://user-images.githubusercontent.com/24992535/107541683-affa1c00-6bc7-11eb-8630-22c2ba4d0973.mp4" />

</details>
</p>

**<details><summary>TEST - Testing other Examples that use onPress handler</summary>**
<p>

<video src="https://user-images.githubusercontent.com/24992535/107541972-f9e30200-6bc7-11eb-9759-6ff9d52bba15.mp4" />

</details>
</p>

**<details><summary>TEST - Text with Inline Images</summary>**
<p>

| Inline View | Inline Image is clipped |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/107542187-357dcc00-6bc8-11eb-9eed-eefbd8be339f.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/107542193-37478f80-6bc8-11eb-8ab3-fa1282dc3fd3.png" width="300" height="" /> |

</details>
</p>

Reviewed By: yungsters

Differential Revision: D31061832

Pulled By: charlesbdudley

fbshipit-source-id: 3034b4f35d4042bfcf1e899a59d5b2f73a990f31
2021-09-28 16:45:53 -07:00
Genki Kondo 3db4046f64 Remove unused viewmanagers
Summary:
Removes unused viewmanagers' *Delegate and *Interface classes.

Changelog: [Internal]

Reviewed By: mgoovaer

Differential Revision: D31242317

fbshipit-source-id: f1c8b04707289182ac9548d8cf688ae736bfbe1d
2021-09-28 16:25:40 -07:00
Xin Chen 652cb541a5 Adding interface to wrap surface interactions for LogBox
Summary:
This diff introduces a new interface named `SurfaceDelegate`. The interface abstracts the API for interacting with a surface, which is required for platforms other than mobile to implement how it wants to show and hide a surface. For existing Mobile use cases, the `LogBoxDialogSurfaceDelegate` is provided as a fallback solution so everything still works.

Changelog:
[Android][Added] - Add SurfaceDelegate abstraction to support interaction in multiple platforms and provide default implementation in LogBoxModule

Reviewed By: mdvacca

Differential Revision: D31132285

fbshipit-source-id: 13315a8bc5b7bcaee9b5e53ef5c6f6cc8cb01f31
2021-09-28 14:57:37 -07:00
fabriziobertoglio1987 8bef3b1f11 compute correct Keyboard Height with Notch (#30919)
Summary:
fixes https://github.com/facebook/react-native/issues/27089 fixes https://github.com/facebook/react-native/issues/30191 fixes https://github.com/facebook/react-native/issues/26296 fixes https://github.com/facebook/react-native/issues/24353
Related https://github.com/facebook/react-native/issues/30052 https://github.com/facebook/react-native/issues/28004 https://github.com/facebook/react-native/issues/26536

The keyboard height of event keyboardDidShow is computed as the difference of two variables:

- The screen height excluding the Android Notch
DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels returns the screen height excluding the Android Notch
- The Visible Area excluding the Keyboard, but including the Android Notch
getWindowVisibleDisplayFrame() which returns the visible area including the Android Notch

The computation of the keyboard height is wrong when the device has an Android Notch.
This pr adds the Android Notch computation for API levels 28+

More info at https://github.com/facebook/react-native/issues/27089#issuecomment-775821333

## 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] - Compute Android Notch in keyboardDidShow height calculation API 28+

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

Test Plan:
adding a ReactRootViewTest for keyboardDidShow verifying correct functionality on API < 28

**<details><summary>TEST CASE - BEFORE FIX</summary>**
<p>

**WITHOUT NOTCH**
- The black view on the bottom is visible
- The keyboard height is 282

| **Full Screen** | **Keyboard Did Show** |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/107212700-a1fd9d00-6a07-11eb-9248-26f9c4d92ae3.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/107212590-7975a300-6a07-11eb-89f4-891a37a7c406.png"  width="300" height="" /> |

**WITH NOTCH**
- The black view on the bottom is **not** visible. The black view is not visible because keyboardDidHide is sending the wrong keyboard height value.
- The keyboard height changes to 234. The keyboard height is the same from the previous test, but the value sent from keyboardDidHide changed for the Notch.

| **Full Screen** | **Keyboard Did Show** |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/107212619-81cdde00-6a07-11eb-9630-7e7c8c34d798.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/107212707-a4f88d80-6a07-11eb-9134-f077059c83a6.png"  width="300" height="" /> |

</p>
</details>

**<details><summary>TEST CASE - AFTER FIX</summary>**
<p>

**WITH NOTCH**
- The black view on the bottom is visible
- The keyboard height is 282

| **Full Screen** | **Keyboard Did Show** |
|:-------------------------:|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/107212619-81cdde00-6a07-11eb-9630-7e7c8c34d798.png" width="300" height="" /> | <img src="https://user-images.githubusercontent.com/24992535/107349053-0d0ea880-6ac8-11eb-9695-33128080b6b8.png"  width="300" height="" /> |

</p>
</details>

Reviewed By: ShikaSD

Differential Revision: D31207989

Pulled By: cortinico

fbshipit-source-id: 0955a3884201122166c5c0ae2aca988a0ed4af53
2021-09-28 10:42:36 -07:00
Samuel Susla ea3e244668 Add option to use RuntimeScheduler in TurboModules
Summary: changelog: [internal]

Reviewed By: RSNara

Differential Revision: D31145372

fbshipit-source-id: b1d9473d5006d055d1116f71f65899293fb85c56
2021-09-28 09:23:57 -07:00
Joshua Gross 04f746d372 Touch events should have same timestmap as native Android MotionEvent
Summary:
When TouchEvent is created in RN, we're currently using System.currentTimeMillis - but this can differ from the MotionEvent timestamp by a few milliseconds.

This difference is very minor but makes it challenging to implement touch telemetry. It's easy and should be zero-impact otherwise to align the timestamps.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D31183733

fbshipit-source-id: 5b275ee534658dc429beb1d3cec0c83a779b5ea3
2021-09-24 18:11:33 -07:00
Joshua Gross f58a3b9ef4 Back out "Send UNIX timestamp along with JS touch events, instead of systemUptime"
Summary:
Original commit changeset: 0f2db726048f

This original change was made in D26705430 (b08362ade5) and D26705429 (69feed518d). The intention was to change the timestamp definition to make touch telemetry easier, but this is (1) unnecessary and (2) causes other issues.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D31183732

fbshipit-source-id: ddc6aafe95dd45fe847524eb65b8a00852381f6d
2021-09-24 18:11:33 -07:00
Andrei Shikov 4090195122 Ensure elevated views are not changing drawing order
Summary:
Uses `enableZ` trick to ensure that Skia doesn't try to reorder the views based on elevation. Unfortunately, it only helps for some cases, but the proper fix would require reimplementing `ViewGroup` completely to remove its internal logic of reordering based on Z coordinate.

Changelog: [Android][Fixed] Ensure elevated views are behind sticky header in FlatList

Reviewed By: cortinico

Differential Revision: D30700566

fbshipit-source-id: d2c59b22332922c610f4f2d415df34e81f5a33c5
2021-09-24 10:05:12 -07:00
Amy Nichol 4e8da9b28f Back out "Fix - ReconnectingWebSocket race condition mClosed"
Summary:
Changelog:[Internal]
Original commit changeset: 48793bd3bea9

Reviewed By: ShikaSD

Differential Revision: D31170947

fbshipit-source-id: cb460e3261fdc2a0df6e3a4597c61bd879ecf38f
2021-09-24 09:44:32 -07:00
Samuel Susla 6d367d70f2 Re-introduce AsyncEventBeatV2 experiment
Summary: changelog: internal

Reviewed By: javache

Differential Revision: D31056006

fbshipit-source-id: 423c81a0fde77b0e2e4b3ddcd6e23c0552b16b3b
2021-09-24 07:16:23 -07:00
Pieter De Baets 133705b130 Re-implement hover state calculation to support nested Text nodes
Summary:
Changelog: [Internal]

Add a path calculation method to TouchTargetHelper to avoid relying on the view hierarchy ourselves and better support virtual touch targets.

Reviewed By: JoshuaGross

Differential Revision: D30993410

fbshipit-source-id: 17577c815413ab0f03bcb6a2140ea1d4c9fd694a
2021-09-24 04:11:49 -07:00
Pieter De Baets 67b62adf4b Reduce LockFreeEventDispatcherImpl logspam
Summary: Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D31116209

fbshipit-source-id: 90dacad32f20148c5956815cff54e2077b7b83a3
2021-09-22 15:45:40 -07:00
Kudo Chien 369b28ce01 Support custom DevSupportManager (#31841)
Summary:
to open possibilities for some DX enhancement, the pr introduces `DevSupportManagerFactory` customization. applications could implement a different DevSupportManager in ReactNativeHost.

## Changelog

[Internal] [Added] - Support custom DevSupportManager

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

Test Plan: this pr just introduces some new interfaces and should not break existing functionalities.

Reviewed By: RSNara

Differential Revision: D30878134

Pulled By: yungsters

fbshipit-source-id: ccdf798caa322b07a876da8312b97002da057388
2021-09-22 10:33:14 -07:00
Pieter De Baets f29ad54534 Pass through coalesce info to Fabric eventEmitter
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D30767649

fbshipit-source-id: d5e730850408afd23a4d4964ef7dd3b17fa44a19
2021-09-22 06:07:35 -07:00
Amy Nichol 94bcfb71a2 Fix - ReconnectingWebSocket race condition mClosed
Summary:
Changelog : [Internal]
Use synchronized blocks to avoid race conditions surrounding mClosed.

Reviewed By: makovkastar

Differential Revision: D31019994

fbshipit-source-id: 48793bd3bea98224d8df344bc4fc8771b517cf72
2021-09-22 01:11:34 -07:00
David Vacca f8e4a783ac Avoid calling getEventData() method twice
Summary:
EZ diff that avoids calling getEventData() method twice

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D31076778

fbshipit-source-id: 63c2a469e8e684202dbdbbf12166487328685976
2021-09-21 11:35:53 -07:00
David Vacca fbb802ca63 Fix typo in Event class
Summary:
Just a fix of a typo

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D31076782

fbshipit-source-id: 192de92ba080a565acd67e038b370917ea9fcddc
2021-09-21 11:35:53 -07:00
Samuel Susla 9a308697e2 Do not retain RuntimeScheduler beyond Runtime's lifetime
Summary:
changelog: [internal]

Retaining RuntimeScheduler beyond Runtime's lifetime can lead to crashes.

Reviewed By: ShikaSD

Differential Revision: D31084763

fbshipit-source-id: df6dd6fcf5aa224b9465ed7df1e64ad0ca964510
2021-09-21 10:24:12 -07:00
Moti Zilberman a7ff7229f0 Centralize HERMES_BYTECODE_VERSION setting
Summary: Changelog: [Internal]

Reviewed By: javache

Differential Revision: D31081032

fbshipit-source-id: e0e18e424a192f42daed6dc802155022b41b0067
2021-09-21 10:24:12 -07:00
Pieter De Baets 6025611bd0 Use real propsParserContext in LayoutAnimation
Summary: Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D31053819

fbshipit-source-id: 8ec21012500f3bfc7e8aea018b5ca72323da2d9e
2021-09-21 04:24:28 -07:00
Lulu Wu f4fdf4b55e Fix currentActivity being null when launching Redbox
Summary:
Try to reuse currentActivity when the new context from "mReactInstanceDevHelper.getCurrentActivity()" is null to fix  "Unable to launch redbox because react activity is not available..."

Changelog:
[Android][Fixed] - Fix currentActivity being null when launching Redbox

Reviewed By: philIip

Differential Revision: D30942434

fbshipit-source-id: faf03390adc545376f3cec223eac5a16bf8233ea
2021-09-20 14:27:26 -07:00
Amy Nichol dd10134bdc Option to use fallback bundle in dev mode
Summary: Changelog: [Android] [Added] - Adds option use fallback bundle instead of cached bundle when the packager isn't running in ReactInstanceManager

Reviewed By: ShikaSD

Differential Revision: D30899295

fbshipit-source-id: 7ea68fb13029bde9c3170cacee92b3c8a0a7367d
2021-09-17 07:25:54 -07:00
Amy Nichol 9f55bda50b Only create one OkHttpClient per ReconnectingWebSocket
Summary:
Changelog:
[Internal]- Share the OkHttpClient within the ReconnectingWebSocket

Reviewed By: makovkastar

Differential Revision: D30763398

fbshipit-source-id: cda931ef83de48075949917b6bd8bc92b5fc2ae8
2021-09-17 07:25:54 -07:00
Nicola Corti 85031d0166 Rename extension to just ReactExtension
Summary:
I'm cleaning up the extension to be just ReactExtension and not ReactAppExtension.
Similarly the name of the extension will be just `react` and not `reactApp`.

Changelog:
[Internal] [Changed] - Rename extension to just ReactExtension

Reviewed By: ShikaSD

Differential Revision: D30964793

fbshipit-source-id: 8a4207825d424e133e51495c34c21284c50363ae
2021-09-16 05:38:51 -07:00
Nicola Corti 022f188750 Merge CodegenPluginExtension inside ReactAppExtension
Summary:
This Diff is merging over all the properties from `CodegenPluginExtension` to
`ReactAppExtension`. Some of the properties were duplicate and generally having two
extensions is creating a lot of confusion for the users (e.g. don't know where to place a
specific property).

Therefore I'm merging the two to have only one. I've also updated the property to use the
Gradle Lazy Configuration API.

Changelog:
[Android] [Changed] - Gradle: Merge CodegenPluginExtension inside ReactAppExtension

Reviewed By: ShikaSD

Differential Revision: D30961343

fbshipit-source-id: 66be3157efef356392c0701aaef2283d058d3161
2021-09-15 09:23:23 -07:00
Nicola Corti c3ff336326 Merge the two Gradle Plugins (#32177)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32177

This diff merges the `react-native-gradle-plugin` and the `react-codegen/android` into a single plugin.
This will allow us to iterate faster on a single plugin, will create less confusion for our users (`react` vs `reactApp`)
and will help us avoid race conditions when the two plugins are applied together (as we will control the whole lifecycle of it).

Changelog:
[Internal] [Changed] - Merged the two Gradle Plugins

allow-large-files

Reviewed By: ShikaSD

Differential Revision: D30765147

fbshipit-source-id: fcb02a181c7d900daa514107c637d0ee0225976c
2021-09-15 03:21:23 -07:00
Krzysztof Borowy 04fe3ed80d Fix: Set "new task flag" for intent method (#29000)
Summary:
Addresses https://github.com/facebook/react-native/issues/28934

## 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] - When sending OS intents, always set "FLAG_ACTIVITY_NEW_TASK" flag (required by OS).

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

Test Plan:
1. Open RNTester on Android
2. Go to Linking section
3. Try opening "POWER_USAGE_SUMMARY" intent
4. App should open settings, instead of crashing

Reviewed By: cortinico

Differential Revision: D30876645

Pulled By: lunaleaps

fbshipit-source-id: e427bfeadf9fb1ae38bf05bfeafd88e6776d71de
2021-09-13 12:56:19 -07:00
Ramanpreet Nara 657c48c21d Rename JavaScriptTimerManager to JavaScriptTimerExecutor
Summary:
This JavaScriptTimerManager interface calls into JavaScript to execute timers. For that reason, I think JavaScriptTimerExecutor is a better name for the interface.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D30851912

fbshipit-source-id: de282068d18693fd67331586e66847105ea16531
2021-09-10 01:20:59 -07:00
Rodolfo d40cb0e1b0 Fix missing webview provider crash on Android (#32165)
Summary:
I applied the changes requested in this PR: https://github.com/facebook/react-native/pull/29089

We upgraded to RN 0.62.2 on our latest release and started to see again the "Failed to load WebView provider: No WebView installed" (see below for Crashlytics screenshot)

![image](https://user-images.githubusercontent.com/870365/131935283-033fbd44-5a3b-49b0-bd25-3d6733f22040.png)

This crash had been fixed by https://github.com/facebook/react-native/pull/24533 but https://github.com/facebook/react-native/pull/26189 (added in 0.62) reverted the fix

Indeed the exception raised in Crashlytics is actually a `AndroidRuntimeException` and `MissingWebViewPackageException` is only part of the message.

For instance, in the screenshot above, the exception message is `android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed`

Now these crashes are quite tricky to reproduce, so to be on the safe side, I'm filtering out all exceptions containing `WebView` as suggested by thorbenprimke on the original fix.

If my reasoning is correct, it should fix siddhantsoni 's issue as well, since `WebView` is included in `MissingWebViewPackageException`
But following that reasoning, I am not sure https://github.com/facebook/react-native/pull/26189 fixed siddhantsoni 's issue, so siddhantsoni if you could check that this PR also fixes your issue, that would be great!

## Changelog

[Android] [Fixed] - Fix missing WebView provider crash in ForwardingCookieHandler

<!-- 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/32165

Test Plan:
I created a version of react native with this patch applied

```
"react-native": "almouro/react-native#release/062-2-fix-missing-webview-provider"
```

Before the fix ~0.1% of our users were impacted on Android, no new crashes have occurred after the update.

This is putting back what was already in place and working for us, but making the check wider to catch more errors.

Reviewed By: lunaleaps

Differential Revision: D30847404

Pulled By: sota000

fbshipit-source-id: fe3b5fa2c9ebde5bedd17a9d6394a52ccdbdf0d0
2021-09-09 15:24:03 -07:00
Aaron Grider b7c023a8c1 Use Updated Android Locale API (#30701)
Summary:
This change migrates fetching locale information from the deprecated Android locale api to the new locale api on sdk version 30+. The old api was deprecated some time ago and should not be used.

https://developer.android.com/reference/android/content/res/Configuration#locale

## Changelog

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

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

Test Plan:
```js
if (Platform.OS === 'android') {
  locale = NativeModules.I18nManager.localeIdentifier; // returns ex. 'EN_us'
}
```

Reviewed By: mdvacca

Differential Revision: D30821396

Pulled By: lunaleaps

fbshipit-source-id: 31622cd9c71c6057ff98ab5245898bc687b5ac60
2021-09-08 16:39:17 -07:00
Samuel Susla 8c2571171e Add feature flag to control to turn on yielding
Summary:
Changelog: [internal]

Add feature flag to turn yielding on/off on Android.

Reviewed By: ShikaSD

Differential Revision: D30487129

fbshipit-source-id: 5d9f60055285cbe7d85493ecaa1dfa17225da9e0
2021-09-06 08:47:51 -07:00
Samuel Susla f679891bd6 Pass RuntimeScheduler to Binding
Summary: changelog: [internal]

Reviewed By: ShikaSD

Differential Revision: D30487037

fbshipit-source-id: 3956606891a313577fd013ae5c2a9f1f90ac5903
2021-09-06 05:42:30 -07:00
Xuan Huang a8ac5ea326 Revert the Android specific max heap size GCConfig
Summary:
Changelog:
[Category][Internal]

This diff reverts the [Androids-specific heap size overrides](github.com/facebook/react-native/commit/63d20d3b1ef35cb4398d63d62f631f7f5d2935c7#diff-4c59ddca85e294a90a0e1bd15ed323ff4e130911d9642680dde44aacbcd7d32c) after
[Hermes has changed its default max heap size to 3GiB](5f2b47d0be).
You can read about more context there.

Reviewed By: yungsters

Differential Revision: D30726067

fbshipit-source-id: 1bcc93fdf4da817f3b3d60bd09c6a5a64166eb7e
2021-09-02 17:04:15 -07:00
Tim Yung 455433f481 Revert D30675510: Remove custom Hermes config for Android
Differential Revision:
D30675510 (a40f973f58)

Original commit changeset: 5eef056893b7

fbshipit-source-id: 25db31c4fbe938d92bba8b0bfe6523bced1524f0
2021-09-02 13:20:04 -07:00
Ashoat Tevosyan a40f973f58 Remove custom Hermes config for Android (#31900)
Summary:
Right now, `react-native` on Android passes in an explicit Hermes config when initializes Hermes. The upcoming version of Hermes shipping with React Native 0.66 will handle this default config itself, so there's no need to override it from Android anymore.

Changelog:
[Android][Changed] - Hermes initialization will no longer need an explicit configuration.

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

Test Plan: I compiled and ran a React Native app using the Android build, making sure to build `ReactAndroid` from source. I confirmed that the config was actually being applied by testing how much memory an application could eat before being killed.

Reviewed By: sshic

Differential Revision: D30675510

Pulled By: yungsters

fbshipit-source-id: 5eef056893b72ddd433ee808eb08d0eb56f22f72
2021-09-02 12:30:48 -07:00
fabriziobertoglio1987 c360b1d92b Fix non selectable Text in FlatList (#28952)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/26264 fixes https://github.com/facebook/react-native/issues/27107
Text is not selectable inside a FlatList on Android. The solution is to invalidate the ReactTextView after a change of the selectable prop. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future and make the Text selectable.

## 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 non selectable Text in FlatList

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

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

The issue was demonstrated in the following [snack](https://snack.expo.io/fabrizio.bertoglio/selectable-bug-in-flatlist) (more info in issue https://github.com/facebook/react-native/issues/26264).

The solution is:

1) Calling `invalidate()` from [setSelectableText][1] after changing the `selectable` prop and `mSelectableText` value. [`invalidate()`](https://developer.android.com/reference/android/view/View#invalidate()) triggers the `onDraw` callback.

[1]: 8027524947/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java (L427-L430)

2) calling `setTextIsSelectable(mSelectableText);` from the [`onDraw`][2] callback

[2]: 8027524947/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java (L456-L460)

The example below is availabe in RNTester FlatList example. Two options (`onPressDisabled` and `textSelectable`) have been added to test the functionality inside a FlatList.

<p align="center">
<img src="https://user-images.githubusercontent.com/24992535/82672536-c2e74d80-9c40-11ea-8fd8-156bfacfac8a.gif" width="200" height="" />
</p>

</p>
</details>

Reviewed By: ShikaSD

Differential Revision: D30000870

Pulled By: lunaleaps

fbshipit-source-id: 4851a294960df0af057d006793aa9ba97c51e3f9
2021-09-01 15:28:30 -07:00
Samuel Susla e2e39808d3 Remove RuntimeSchedulerManager
Summary:
Changelog: [internal]

Remove RuntimeSchedulerManager on Android in favor of different way to initialise RuntimeScheduler.

Reviewed By: ShikaSD

Differential Revision: D30486975

fbshipit-source-id: 9fe38de12be452bd9d2c92bb54cf5933ce7555b5
2021-09-01 11:26:27 -07:00
Andrei Shikov 8b4f5073a1 Log created views with mounting errors
Summary:
Displays views from the surface mounting manager after we hit a crash during mounting.
This change should help with debugging mounting crashes (e.g. when view is added before removal)

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D30681339

fbshipit-source-id: f83cecaf8e418a2fa5aa0713513c51bb1be77013
2021-09-01 07:31:18 -07:00
Nicola Corti 85249cafe8 Update project to build on Gradle 7.0.2 (#32073)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32073

This Diff bumps the version of Gradle used to build the project to
7.0.2. Ideally we could bump to 7.2.x directly, but I'll do one minor version
at a time to exclude potential build problems.

This diff is addressing all the extra build warnings that got raised by the new version.

Changelog:
[Android][Changed] - Bumped Gradle project version to 7.0.2

Reviewed By: ShikaSD

Differential Revision: D30486612

fbshipit-source-id: 70e0f7d18e547013ca7b1d12f8dd64a633df5870
2021-08-31 13:27:27 -07:00
Nicola Corti 24a9ef7384 Suppressing bad file descriptor errors on native builds
Summary:
When running native builds, we experience a lot of
bad file descriptor warnings. This diff is suppressing the issue on local builds (on Mac).

Changelog:
[Internal] [Changed] - Suppressed bad file descriptor on native builds

Reviewed By: ShikaSD

Differential Revision: D30487098

fbshipit-source-id: 8199fb8f2f18d19543d2861f1f2f852fff6ae73b
2021-08-31 10:26:42 -07:00
Neil Dhar 1bc885b8b8 Make JSI a dynamic library
Summary:
Ship libjsi as a standalone dynamic library. This prevents problems
with exception handling caused by duplicate typeinfo across multiple
shared libs, and reduces bundle size by removing duplicate copies of
JSI.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D30599215

fbshipit-source-id: abad1398342a5328daa825f3f684e0067cad7a96
2021-08-27 17:16:49 -07:00
Genki Kondo f3e8ea9c29 Use hyphenationFrequency for text measurement
Summary:
Implements the calculation of measurement and position of Text attachments in Android

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D30586616

fbshipit-source-id: e9ecc002f03477e3465d746855e1dff2e5f0b321
2021-08-27 09:04:01 -07:00
Valentin Shergin 1acf334614 Fixed `alignItems: baseline` for <Text> elements on Android (#31575)
Summary:
This fixes https://github.com/facebook/react-native/issues/20666 and https://github.com/facebook/react-native/issues/21918.

This is pretty much the same as 51b3529f6c but implemented for Android.
Now <Text> exposes the actual base-line offset value that allows Yoga to position it properly when `alignItems: baseline` is requested.

## Changelog
[Android][Fixed] - Fixed `alignItems: baseline` for <Text> elements on Android

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

Test Plan:
The same test case that we have for iOS.
Before:
<img width="487" alt="Screen Shot 2021-05-22 at 7 03 18 PM" src="https://user-images.githubusercontent.com/22032/119277516-d62b5100-bbe5-11eb-9141-3abe56e1a476.png">

After:
<img width="487" alt="Screen Shot 2021-05-22 at 7 01 51 PM" src="https://user-images.githubusercontent.com/22032/119277518-d75c7e00-bbe5-11eb-9139-4c6b5fcd9157.png">

Reviewed By: JoshuaGross

Differential Revision: D28631468

Pulled By: yungsters

fbshipit-source-id: 7c259e469d19d8344298319f066b8437dfdedad0
2021-08-26 21:46:37 -07:00
Genki Kondo a0d30b848a Remove unsupported values for android_hyphenationFrequency
Summary:
hyphenationStrategy must be one of one of Layout#HYPHENATION_FREQUENCY_NONE, Layout#HYPHENATION_FREQUENCY_NORMAL, Layout#HYPHENATION_FREQUENCY_FULL: (https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int))

Thus "high" and "balanced" are not only redundant, but actually don't do what the value indicates - Layout#BREAK_STRATEGY_BALANCED (constant value: 2) and Layout#BREAK_STRATEGY_HIGH_QUALITY (constant value: 1) are only meant to be used for android:breakStrategy

Changelog:
[Android][Changed] - Remove `"high"` and `"balanced"` as values for `android_hyphenationFrequency` on `Text`

Reviewed By: JoshuaGross

Differential Revision: D30531096

fbshipit-source-id: 1a0b6e733bb21ce6b2f104a2025a79c16de3cfea
2021-08-26 10:40:11 -07:00
Sota Ogo d6c879edba Show RedBox for C++ errors
Summary:
This diff is hooking up cxx error with redbox. Before this diff, cxx errors were only shown in log and there was no visible user feedback.

Changelog:
[Android] [Added] - Show Redbox for C++ errors.

Reviewed By: JoshuaGross

Differential Revision: D30421355

fbshipit-source-id: ad473337ba301feb08ba31ee8d82ebaa771ecaeb
2021-08-26 10:06:05 -07:00
Joshua Selbo 369a7ab5d3 Update AndroidX test deps to 1.4.0 (#32084)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32084

Upgrade RN AndroidX test deps after an internal upgrade.

Changelog: [Internal] Update AndroidX test deps after internal upgrade

Reviewed By: sturmen

Differential Revision: D30546422

fbshipit-source-id: 644648c7dcf179e737fb967d996a789cc904a5ca
2021-08-25 14:30:06 -07:00