Commit Graph

5392 Commits

Author SHA1 Message Date
Joshua Gross 35e2a63b8d Batch Animated calls into one JSI call per frame
Summary:
We introduce a few optimizations:

(1) Previous diff: We defer calling any NativeAnimatedModule methods by waiting 1ms before flushing the queue, and debouncing until no flush is requested. Practically, this just means that we'll call NativeAnimatedModule methods N times at once, at the end of a render loop, instead of N times smeared throughout the render loop.
(2) Additionally, instead of calling N methods, we create multi-operation argument buffer and call a single NativeAnimatedModule API, which should essentially throttle NativeAnimatedModule API calls to once-ish per frame. On the native side, this also reduces a lot of overhead associated with scheduling work on the UI thread (we schedule 1 function to run on the UI thread and perform N operations, as opposed to scheduling N functions to run on the UI thread).

TODO:
- implement stubs for iOS
- write gating code so this can be properly tested in VR and in fb4a

Changelog: [Internal]

Reviewed By: genkikondo

Differential Revision: D36338606

fbshipit-source-id: 29ac949b53b874683128a76525586c22def3143b
2022-05-17 16:42:41 -07:00
Tianyu Li d5a6bee35f Assign the right oncall with best guess to miscellaneous xplat test modules
Summary:
We try to remove the use test_ownership_2020 oncall, which was created to enforce oncall field in test module. This diff stack tries its best to guess who the right oncall is for these "unowned" tests.

If you don't think this belongs to you, please
1. Either re-assign to another team to your best knowledge
2. Or delete the test

Every test should have an owner!

Differential Revision: D36404812

fbshipit-source-id: daf57e860d3700928ae4518897d87247a672eae4
2022-05-16 18:46:04 -07:00
Pieter De Baets 7c5d9ccb46 Fix NativeAnimatedNodesManager registering event listener multiple times
Summary:
Noticed that (LockFree)EventDispatcherImpl had NativeAnimatedNodesManager as a listener 100+ times, as listener registration can happen multiple times from Animated node creation. Since listener management on event dispatcher is thread-safe, we can avoid the thread hop for this.

Changelog: [Internal]

Reviewed By: genkikondo

Differential Revision: D36316102

fbshipit-source-id: f2f417b69885def87f88460d8b1e0b35b66726cb
2022-05-16 14:06:58 -07:00
Xin Chen a093fe5f2f Queue the event for preallocated but not mounted view to dispatch later
Summary:
This diff fixed an edge case that event dispatching is failed after pre-allocation of a view and before the view is mounted.

When a cached image is loaded, we will dispatch the event to JS immediately. This is could happen after the view is created during pre-allocation phase, when the event emitter is not instantiated yet. In that case, we will see [an error](https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java#L927) and the event will effectively be ignored.

To fix that we introduced a queue in this diff for those events. They will be dispatched in order when the view is mounted and the event emitter is non-null.

Changelog:
[Android][Fixed] - Fixed an edge case that event dispatching is failed after pre-allocation of a view and before the view is mounted.

Reviewed By: mullender

Differential Revision: D36331914

fbshipit-source-id: cd065b0b36978cb5f0aac793d8d16f07a48f0881
2022-05-13 18:40:17 -07:00
Derek Thurn e2dd2e2a6e Allows a Typeface object to be added to ReactFontManager
Summary:
Currently on Android, React Native can only accept font resource IDs which it internally converts into Typeface objects. This change allows ReactFontManager to be passed a Typeface at runtime to enable e.g. downloading fonts on demand.

Changelog:
[Android][Added] - Ability to pass a Typeface object to ReactFontManager in addition to a font resource ID

Reviewed By: makovkastar

Differential Revision: D36138123

fbshipit-source-id: b314e8c7fc28174b5caa017076b6eb3d4f6dbaa8
2022-05-13 12:42:32 -07:00
Pieter De Baets 3337add547 Pass string by ref in TurboModule lookup path
Summary:
Avoid unnecessary string copies

Changelog: [internal]

Reviewed By: nlutsenko

Differential Revision: D36312750

fbshipit-source-id: caf0985f988eb497de3be3c0526809593b01a9e2
2022-05-13 07:12:48 -07:00
Pieter De Baets 51e029ec3c Simplify ViewManagerOnDemandReactPackage.getViewManagerNames to return Collection
Summary:
This way we can avoid unnecessary ArrayList copies.

Changelog: [Android][Changed] Generalized the return type of ViewManagerOnDemandReactPackage.getViewManagerNames

Reviewed By: nlutsenko

Differential Revision: D36131516

fbshipit-source-id: 6a42c76cadbcce4c3720875d80062e1ee237bc2f
2022-05-13 06:50:04 -07:00
Pieter De Baets d4b59cd9d0 Expose lazyViewManagers option on ReactNativeHost
Summary: Changelog: [Android][Added] Option to enable lazyViewManager support with `ViewManagerOnDemandReactPackage`

Reviewed By: RSNara

Differential Revision: D36130066

fbshipit-source-id: b8b04b46f59248baacdf1717f7e32b45e56dd2b8
2022-05-12 03:25:17 -07:00
Joshua Gross 6915fce898 Log more metadata when throwing error for non-existent viewState
Summary:
Collecting more telemetry to address or debug T112157805 further.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D36295635

fbshipit-source-id: 7896d641a0a745537c8dedf25f44913f47b83876
2022-05-10 16:45:31 -07:00
Harry Yu ee1a191cb1 Avoid crash by handling missing views in dispatchViewManagerCommand (#33795)
Summary:
Based on Google Play crash logs, crashes due to the assertions in `dispatchViewManagerCommand` is our top source of crashes:

```
com.facebook.react.uimanager.IllegalViewOperationException: Unable to execute operation dispatchViewManagerCommand: blur on view with tag: 17549, since the view does not exists
        at com.facebook.react.uimanager.UIImplementation.assertViewExists(UIImplementation.java:830)
        at com.facebook.react.uimanager.UIImplementation.dispatchViewManagerCommand(UIImplementation.java:713)
        at com.facebook.react.uimanager.UIManagerModule.dispatchCommand(UIManagerModule.java:739)
        at com.facebook.react.uimanager.UIManagerModule.dispatchViewManagerCommand(UIManagerModule.java:726)
        at com.facebook.react.uimanager.ReanimatedUIManager.dispatchViewManagerCommand(ReanimatedUIManager.java:233)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
        at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java:-2)
```

There are many other places in UIImplementation that instead of throwing a fatal exception, just log a message and continues execution.

Logging a message and discarding the command should be safe for commands like "blur this view". We keep the previous behavior in debug mode, but just log and discard commands in production.

## Changelog

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

[Android] [Fixed] - Avoid crash by handling missing views in dispatchViewManagerCommand

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

Test Plan: We had a tough time reproducing specific crashes, but we ran with this binary in the latest release of our app and it has eliminated this class of crashes from Google Play and Bugsnag instrumentation.

Reviewed By: cortinico

Differential Revision: D36285603

Pulled By: JoshuaGross

fbshipit-source-id: db0be74926c4cb83f07686398579236da8e586bf
2022-05-10 12:38:35 -07:00
Hetan Thakkar c663c0ec9d Fixed and added support for dataUri in form data (#33675)
Summary:
Continuation of https://github.com/facebook/react-native/issues/33548
 Fixes https://github.com/facebook/react-native/issues/25790. The issue resulted because the [getFileInputStream() method of RequestBodyUtil failed to return an inputStream of the given dataUri ](https://github.com/facebook/react-native/blob/16397e0d3c0dd3374ddb642599725ca41f092a8a/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java#L427) This happened because the openInputStream() method of [context.getContentResolver() expects a content or a file](https://developer.android.com/reference/android/content/ContentResolver#openInputStream(android.net.Uri)) in its parameter but instead received dataUri which resulted in FileNotFoundException.

![issue](https://user-images.githubusercontent.com/38756320/161345967-fd79d3e2-54a8-4a0e-8a6b-189ce9883a78.jpeg)

**Solution**:

I've now converted the dataUri to bitmap and then attached an inputStream to the compressed bitmap. This way we won't have to store the image temporarily. I think converting the dataUri to Bitmap is necessary as there is no method that lets us convert the dataUri to inputStream directly. And regarding large size images, converting them to bitmap is the only(efficient) step I can think of, as the conversion is handled by in-built java function.

This issue has been unresolved for quite some time now, so resolving this PR would be greatly appreciated.
## Changelog

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

[Android] [Added] - Support for dataUri in form data

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

Reviewed By: christophpurrer, mdvacca

Differential Revision: D36205586

Pulled By: cortinico

fbshipit-source-id: bfc83efcec0b2fcb1df42e4bf1d43c966de8f40e
2022-05-10 10:59:40 -07:00
Christoph Purrer 1f6451bd3f Add CompositeReactPackageTurboModuleManagerDelegate [RFC]
Summary:
This diff adds a CompositeReactPackageTurboModuleManagerDelegate which can be used to combine 1 or more TurboModuleManagerDelegates into a single one.

This is useful when both the app and one or multiple of its libraries provides a TurboModuleManagerDelegate

Changelog:
[Internal] [Changed] - Add CompositeReactPackageTurboModuleManagerDelegate

Reviewed By: mdvacca

Differential Revision: D36187694

fbshipit-source-id: 88f1d689342345b4cb7e67186791ad5bd1a6f21b
2022-05-09 23:45:45 -07:00
Mike Masam 24a1f5c66c Handle possible null exception on ReactEditText with AppCompat 1.4.0 (#33769)
Summary:
This Change fixes a possible null exception as the user uses AppCompat 1.4.0
as a dependency in their App and uses a `TextInput` component.

The exception may happen as `mFabricViewStateManager` is accessed during
the constructor of the superclass, and is not yet initialized.
- For reference, commit #e21f8ec34984551f87a306672160cc88e67e4793 fixes the crash which was already happening.

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
Possible null exception as `mFabricViewStateManager` is accessed during
the constructor of the superclass, white it is not yet initialized.
This commit #e21f8ec34984551f87a306672160cc88e67e4793 fixes the crash which was already happening, accessing of mFabricViewStateManager before initialization, and left another one of the call of the same nature.
## 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
-->
Fix: accessing `mFabricViewStateManager` before initialization.

[JavaScript] [Fixed] - accessing `mFabricViewStateManager` before initialization.

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

Test Plan: no external tool was used.

Reviewed By: javache

Differential Revision: D36205441

Pulled By: cortinico

fbshipit-source-id: f3fca69224c7794757514f026a5293b213986186
2022-05-09 10:18:37 -07:00
Pieter De Baets 80f7367149 Replace NativeRunnable with fbjni implementation (#33776)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33776

The implementations of these modules is pretty much identical, and we're already shipping the fbjni version of this anyway.

Changelog: [Internal]

Reviewed By: mhorowitz

Differential Revision: D36200330

fbshipit-source-id: 135ee621e1e4c5eb9616ce7f442fc6d4b946f865
2022-05-09 05:13:38 -07:00
Anandraj Govindan 883a93871c Working around Long paths limitation on Windows (#33784)
Summary:
Cherry picking https://github.com/facebook/react-native/pull/33707 to main branch

This change is extending the changes made by alespergl to reduce the file paths and command lengths of ndk build commands
Essentially we are shortening the length of the source files by using relative paths instead of absolute paths as enumerated by the wildcard expression
This commit is extending the fix by including all the new modules introduced into RN for the new architecture, including the generated modules.
We are also reverting the ndk bump as ndk23 is crashing frequently when building RN with new arch. The reduced file paths lengths ensures the ndk bump is not required for relatively short application paths.

Fix building RN with new architecture on Windows boxes by using relative paths for C++ sources

## Changelog

Fix building RN with new architecture on Windows boxes by using relative paths for C++ sources

[CATEGORY] [TYPE] - Message

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

Test Plan: Verified building on windows box

Reviewed By: javache

Differential Revision: D36241928

Pulled By: cortinico

fbshipit-source-id: 1ce428a271724cbd3b00a24fe03e7d69253f169b
2022-05-09 04:42:53 -07:00
Pieter De Baets 0d9e054ec4 Cleanup JBackgroundExecutor and support thread naming (#33780)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33780

Currently this just has a default ThreadPool name, which can be confusing in systraces and crash reports.

Changelog: [Internal]

Reviewed By: ryancat

Differential Revision: D36200090

fbshipit-source-id: 22918993e7c822ed721ccaf79cdcd9d2a972193d
2022-05-09 02:07:26 -07:00
Kudo Chien 6b6adcc111 add back hermes inspector support (#33778)
Summary:
the `WITH_INSPECTOR` build flag is missing from cmake migration. original we had it in [Application.mk](https://github.com/facebook/react-native/blob/ed46ea2058b909a2dd401347d68956324961ec2c/ReactAndroid/src/main/jni/Application.mk#L29)

this pr adds back the build flag and make hermes inspector (or debugging hermes in flipper) work again.

## Changelog

[Android] [Fixed] - add back hermes inspector support

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

Test Plan: test on rn-tester hermes variant

Reviewed By: cipolleschi

Differential Revision: D36204525

Pulled By: cortinico

fbshipit-source-id: 417874a7d0e05b5ee886f3160d526ff9c2df44ee
2022-05-06 11:38:00 -07:00
Pieter De Baets bf405d7083 Fix definition of NativeAnimated.isEmpty
Summary:
Noticed in D36098912 (https://github.com/facebook/react-native/commit/5de0f145eca36d3263cb8a9928add278cdfffa2b) that the definition of NativeAnimatedModule's OperationQueue.isEmpty was incorrect as it didn't account for `mPeekedOperation`, while `drainQueueIntoList`  did.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D36109810

fbshipit-source-id: afd7059975ce6e5c65d1975d168a03f0881bd7c1
2022-05-06 02:45:47 -07:00
Janic Duplessis 6ab7a99518 Pass react build dir to cmake (#33736)
Summary:
The ReactAndroid cmake build assumes that the build directory is ReactAndroid/build, but this is not always the case if gradle is configured with a different build location. Instead of assuming the build location in cmake, pass it from gradle.

## Changelog

[Android] [Fixed] - Pass react build dir to cmake

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

Test Plan:
Tested in an app with a custom build dir that RN now builds properly after this change.

In build.gradle add:

```groovy
allprojects {
    buildDir = "${System.getProperty("user.home")}/.gradle/builds/${rootProject.name}/${project.name}"
}
```

Reviewed By: christophpurrer

Differential Revision: D36128556

Pulled By: cortinico

fbshipit-source-id: cdb8283c93ea7c384ec94cd3e24012220965b6dc
2022-05-06 01:56:33 -07:00
Christoph Purrer e5469c48e3 Back out > Add CompositeReactPackageTurboModuleManagerDelegate
Summary:
This change caused some internal regression in release builds, hence reverting it

Changelog:
[Internal] [Changed] - Back out > Add CompositeReactPackageTurboModuleManagerDelegate

Reviewed By: alsun2001

Differential Revision: D36182014

fbshipit-source-id: e49fc897f3b1a2e9d33fcb7687244be74020c5be
2022-05-05 16:29:19 -07:00
Lulu Wu bf6884dc90 Remove assertion when current activity is null
Summary:
Assertion failure would lead to a crash, in real world not being able to start an activity shouldn't crash - usually a navigation won't happen as expected, user could try again.

Changelog:
[Android][Changed] - Don't assert on current activity when call startActivityForResult

Reviewed By: cortinico

Differential Revision: D35746652

fbshipit-source-id: 0b77ca5a69b2f3f3b0b969d84980ed8290ac9b1f
2022-05-04 15:52:47 -07:00
Christoph Purrer 7d037ddd6a Fix Circle CI for CompositeReactPackageTurboModuleManagerDelegate (#33758)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33758

This fails to compile in our CircleCI builds
```
/root/react-native/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackageTurboModuleManagerDelegate.java:52: error: incompatible types: java.util.List<java.lang.Object> cannot be converted to java.util.List<com.facebook.react.ReactPackage>
        delegates.add(delegatesBuilder.build(context, Collections.emptyList()));
```
Make the empty collection generic should solve the issue

Changelog:
[Internal] [Changed] - Fix Circle CI for CompositeReactPackageTurboModuleManagerDelegate

Reviewed By: cortinico, dmitryrykun

Differential Revision: D36130573

fbshipit-source-id: 9615311798fbbd7c000838dfbc043f450c2d9e2e
2022-05-04 10:01:11 -07:00
Pieter De Baets 5de0f145ec Avoid allocating empty lists
Summary: Changelog: [Internal] Optimize Fabric memory allocations on Android

Reviewed By: genkikondo

Differential Revision: D36098912

fbshipit-source-id: 8d34a652db019865a8306bc070a08f5ddfef96bf
2022-05-04 04:22:40 -07:00
Christoph Purrer 3f09b48487 Add CompositeReactPackageTurboModuleManagerDelegate
Summary:
This diff adds a CompositeReactPackageTurboModuleManagerDelegate which can be used to combine 1 or more TurboModuleManagerDelegates into a single one.

This is useful when both the app and one or multiple of its libraries provides a TurboModuleManagerDelegate

Changelog:
[Internal] [Changed] - Add CompositeReactPackageTurboModuleManagerDelegate

Reviewed By: cortinico

Differential Revision: D36057036

fbshipit-source-id: bf131fa7315941b3353c0522e4d77d909b82914b
2022-05-04 04:02:39 -07:00
Xin Chen 72c1a770fe Disable preallocation for panel apps
Summary: Disable preallocation for panel apps to mitigate some crashes.

Reviewed By: javache

Differential Revision: D35866301

fbshipit-source-id: e6277e6be7a86682867c6a7ecfe60f7cf1ab549d
2022-05-03 14:47:47 -07:00
Xin Chen 16f30fc0ec Update overflowInset flag to use public static field
Summary: There's no need to use private feature flag for overflowInset feature. This makes future refactor on feature flags easier.

Reviewed By: javache

Differential Revision: D35866302

fbshipit-source-id: a3fde212ff40cd6d4c68832bb39b34de5a17a8d4
2022-05-03 14:47:47 -07:00
Aniket Mathur 2e1e62f2bf Fix import path breakage (#33746)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33746

https://github.com/facebook/react-native/runs/6262282188?check_suite_focus=true

Cell imports aren't compatible with open source buck builds.

Reviewed By: alexmalyshev

Differential Revision: D36073197

fbshipit-source-id: 0b7c27cea2516c980e19c89eb4f313817b63c628
2022-05-02 19:23:38 -07:00
Aniket Mathur 05c594d2f5 Fixup query errors
Reviewed By: alexmalyshev

Differential Revision: D36068791

fbshipit-source-id: bf841fe8fcafae0fb60f6eefc2473784afbae5de
2022-05-02 11:27:38 -07:00
Christoph Purrer eb2a83b0be Allow ReactInstrumentationTest to use custom JSIModules
Summary:
Update ReactInstrumentationTest to allow passing in custom JSIModules

Also: 'Fixed' some improper ordering of Nullable annotations

Changelog:
Internal

Reviewed By: cortinico

Differential Revision: D35961806

fbshipit-source-id: aa1513bee34e04ac3aae37f794d9d2771e7cc501
2022-04-28 07:48:54 -07:00
Nicola Corti c11785b90d Update the hermesc output to be inside the $buildDir
Summary:
Currently, we build Hermes by specifying the Cmake flag `-B ./hermes`. That means
that the output out the build is going to be placed along side the source code.

This is fine, as long as the user doesn't use the `REACT_NATIVE_OVERRIDE_HERMES_DIR`,
which is used inside the Hermes CI. In that case, the source location of Hermes can be
changed, leading to scenarios where `hermesc` can't be found.

Here I'm changing the flag to be `-B $buildDir/hermes`. Therefore the build output
will always be located within the `./ReactAndroid/hermes-engine/build` folder.
This is a more robust solution as the build output will be encapsulated within the
`build/` folder.

Changelog:i
[Internal] [Changed] - Update the hermesc output to be inside the $buildDir

Reviewed By: cipolleschi

Differential Revision: D35964402

fbshipit-source-id: aa7e0775b282897d5a99c1c46265884d19c5f289
2022-04-27 09:41:11 -07:00
Xin Chen 36c4e42d82 Add null check for gesture ended notifier
Summary:
The `notifyNativeGestureEnded` API is added to notify user gesture ended, so that any optimization we had during handling the gesture can be restored.

It's possible that when the gesture finishes, the RootView is already unmounted from the native side. This might happen when user starts a gesture that caused leave of the RN screen, or close the app.

Changelog:
[Android][Internal] - Avoid NPE for gesture notifier

Reviewed By: javache

Differential Revision: D35902523

fbshipit-source-id: 9bb5819a53dd053290031eebaae1b8f0318ae534
2022-04-26 14:18:17 -07:00
Nicola Corti c12423cbdc Use Android SDK version of CMake rather than an external one
Summary:
This diff updates the CMake command used for configuring the Hermes build
from `cmake` from $PATH to the `cmake` bundled with the Android SDK.
If not found, fallsback to the previous behavior.

This relaxes the requirement of having to ask our users to install CMake
in their CLIs.

Changelog:
[Internal] [Changed] - Use Android SDK version of CMake rather than an external one

Reviewed By: neildhar

Differential Revision: D35931306

fbshipit-source-id: 8d6c554e5e9040e3bd4fed5f72fbdb0eb61d745a
2022-04-26 07:19:00 -07:00
Nicola Corti 1730949e94 Expose scheduler through FabricUIManager
Summary:
Allows to access `react::renderer::Scheduler` given `FabricUIManager` from Java side.

Changelog: [Added] Added `FabricUIManager` binding with FBJNI

Reviewed By: javache

Differential Revision: D35313399

fbshipit-source-id: 54e7adcceae40368c2735ddfc8a083f87b08dc5e
2022-04-26 05:11:05 -07:00
Xin Chen f40976cd24 Refactor findTargetPathAndCoordinatesForTouch to improve perf of event delivery
Summary:
Refactor of TouchTargetHelper.findTargetPathAndCoordinatesForTouch to avoid unnecessary lookup of views during the dispatching of Hover Events

changelog: [internal] internal

Reviewed By: lunaleaps, mdvacca

Differential Revision: D32296003

fbshipit-source-id: 93834c37331ad5d75645a5665a1c8c3d965765fb
2022-04-25 14:11:11 -07:00
Steven Vascellaro c6dc01fac6 Fix typo in comments (#33694)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33694

Fixes a pluralization typo

Changelog:
[General][Fixed] - Fixed a pluralization typo in docstrings.

Reviewed By: javache

Differential Revision: D35856572

fbshipit-source-id: 88118be36107025b0b513bf2ec6671304d789204
2022-04-25 10:15:36 -07:00
Carmi Grushko 4f855c8a2a @allow-large-files [MSDK] Update ktfmt component on FBS:master
Reviewed By: strulovich

Differential Revision: D35774317

fbshipit-source-id: ce59de8c38e385827a9ee62473b57a1791f18d27
2022-04-25 03:08:51 -07:00
Alex Liang 7454044542 Make ReactModuleSpecProcessor print stacktrace when typeElement.getAnnotation fails
Summary:
WHen porting TurboModules or adding new TurboModules, ReactModuleSpecProcessor may fail during buck build, and when the failure is caused by typeElement.getAnnotation, no useful information gets collected, making it difficult to debug.
So here I am adding a try & catch so we can get useful debugging info.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D35767207

fbshipit-source-id: 7e1f9dfbfd31339ab37af19c51d85085e100955a
2022-04-22 16:57:51 -07:00
Nicola Corti 56fd85e371 Customize the Hermes version using the RN one
Summary:
This diff allows to customize the Hermes version exposed by the VM with
a version provided by React Native. This will make clearer that a specific
version of Hermes was built at a specific point of the RN release process.

Changelog:
[Internal] [Changed] - Customize the Hermes version using the RN one

Reviewed By: neildhar

Differential Revision: D35820268

fbshipit-source-id: 3e76db921c12a599743fb9312f52edd06d223bad
2022-04-22 07:52:27 -07:00
Nicola Corti d7b64b8d4b Expose an API to enable Concurrent Root on Android (#33645)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33645

With React 18, we now need to allow users on Fabric to opt-in for Concurrent Root.

This commit adds a new method that can be called on the ReactActivityDelegate
that can be used to set the `concurrentRoot` flag on the `initialProps` on the Render.

Changelog:
[Android] [Added] - Expose an API to enable Concurrent Root on Android

Reviewed By: mdvacca

Differential Revision: D35614879

fbshipit-source-id: 2de83e8115d3748c0346cdec6f31b2ab1f899478
2022-04-20 08:03:21 -07:00
Moti Zilberman a12959546a Revert D34518929: TalkBack support for ScrollView accessibility announcements (list and grid)
Differential Revision:
D34518929 (https://github.com/facebook/react-native/commit/dd6325bafe1a539d348f3710e717a6344576b859)

Original commit changeset: 410a05263a56

Original Phabricator Diff: D34518929 (https://github.com/facebook/react-native/commit/dd6325bafe1a539d348f3710e717a6344576b859)

fbshipit-source-id: 114d0910970c5f5caefb98c378722faba283f2a1
2022-04-20 06:48:19 -07:00
Xin Chen cf55fd587e Add scrollEventThrottle prop support in Android
Summary:
This diff adds `scrollEventThrottle` prop to Android platform. See [public doc](https://reactnative.dev/docs/scrollview#scrolleventthrottle-ios) for this prop. Currently this is only supported in iOS.

The throttling logic is [following](https://github.com/facebook/react-native/blob/main/React/Views/ScrollView/RCTScrollView.m#L650) iOS existing one.

Changelog:
[Android][Added] - Add scrollEventThrottle prop support in Android

Reviewed By: mdvacca

Differential Revision: D35735978

fbshipit-source-id: 97b73b4d5fbb93696555917b9252e95fd79ca581
2022-04-19 20:28:17 -07:00
fabriziobertoglio1987 dd6325bafe TalkBack support for ScrollView accessibility announcements (list and grid) (#33180)
Summary:
This issue fixes [30977][17] . The Pull Request was previously published by [intergalacticspacehighway][13] with [31666][19].
The solution consists of:
1. Adding Javascript logic in the [FlatList][14], SectionList, VirtualizedList components to provide accessibility information (row and column position) for each cell in the method [renderItem][20] as a fourth parameter [accessibilityCollectionItem][21]. The information is saved on the native side in the AccessibilityNodeInfo and announced by TalkBack when changing row, column, or page ([video example][12]). The prop accessibilityCollectionItem is available in the View component which wraps each FlatList cell.
2. Adding Java logic in [ReactScrollView.java][16] and HorizontalScrollView to announce pages with TalkBack when scrolling up/down. The missing AOSP logic in [ScrollView.java][10] (see also the [GridView][11] example) is responsible for announcing Page Scrolling with TalkBack.

Relevant Links:
x [Additional notes on this PR][18]
x [discussion on the additional container View around each FlatList cell][22]
x [commit adding prop getCellsInItemCount to VirtualizedList][23]

## Changelog

[Android] [Added] - Accessibility announcement for list and grid in FlatList

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

Test Plan:
[1]. TalkBack announces pages and cells with Horizontal Flatlist in the Paper Renderer ([link][1])
[2]. TalkBack announces pages and cells with Vertical Flatlist in the Paper Renderer ([link][2])
[3]. `FlatList numColumns={undefined}` Should not trigger Runtime Error NoSuchKey exception columnCount when enabling TalkBack. ([link][3])
[4]. TalkBack announces pages and cells with Nested Horizontal Flatlist in the rn-tester app ([link][4])

[1]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1050452894
[2]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1050462465
[3]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1032340879
[4]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1050618308
[10]:https://github.com/aosp-mirror/platform_frameworks_base/blob/1ac46f932ef88a8f96d652580d8105e361ffc842/core/java/android/widget/AdapterView.java#L1027-L1029 "GridView.java method responsible for calling setFromIndex and setToIndex"
[11]:https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1042518901 "test case on Android GridView"
[12]:https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1050452894 "TalkBack announces pages and cells with Horizontal Flatlist in the Paper Renderer"
[13]:https://github.com/intergalacticspacehighway "github intergalacticspacehighway"
[14]:https://github.com/fabriziobertoglio1987/react-native/blob/80acf523a4410adac8005d5c9472fb87f78e12ee/Libraries/Lists/FlatList.js#L617-L636 "FlatList accessibilityCollectionItem"
[16]:https://github.com/fabriziobertoglio1987/react-native/blob/5706bd7d3ee35dca48f85322a2bdcaec0bce2c85/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java#L183-L184 "logic added to ReactScrollView.java"
[17]: https://github.com/facebook/react-native/issues/30977
[18]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/6
[19]: https://github.com/facebook/react-native/pull/31666
[20]: https://reactnative.dev/docs/next/flatlist#required-renderitem "FlatList renderItem documentation"
[21]: https://github.com/fabriziobertoglio1987/react-native/commit/75147359c5d070406ebbe488c57c3cd94c08c19d "commit that introduces fourth param accessibilityCollectionItem in callback renderItem"
[22]: https://github.com/facebook/react-native/pull/33180#discussion_r826748664 "discussion on the additional container View around each FlatList cell"
[23]: https://github.com/fabriziobertoglio1987/react-native/commit/d50fd1a68112f40f4be3ac3aa4d67f96df33e387 "commit adding prop getCellsInItemCount to VirtualizedList"

Reviewed By: kacieb

Differential Revision: D34518929

Pulled By: blavalla

fbshipit-source-id: 410a05263a56162bf505a4cad957b24005ed65ed
2022-04-19 19:45:10 -07:00
Luna Wei 361b9a808c PointerEvents: Reset childHandlingNativeGesture on first ACTION_DOWN
Summary:
Changelog: [Internal] - Reset the mChildHandlingNativeGesture on the first ACTION_DOWN after it's been set.

I noticed this issue when scrolling sometimes in the event log for the W3CPointerEvents example, none of the pointer events would get captured because we'd call [`notifyNativeGestureStarted`](https://www.internalfb.com/code/fbsource/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/NativeGestureUtil.java?lines=25-25) which would prevent any pointerevents being fired.

Reviewed By: vincentriemer

Differential Revision: D35685378

fbshipit-source-id: 01fc255afc5e22dc6c42f7eb11a8aa5a9a091b87
2022-04-19 15:22:00 -07:00
Brett Lavalla 70fcab76a4 Fix RN accessibility links with UIAutomator
Summary:
D34687371 (https://github.com/facebook/react-native/commit/7b5b114d578142d18bf4a7a5279b179a9ac8d958) unfortunately caused a regression with UIAutomator, where it would no longer be able to see any Views that have the ReactAccessibilityDelegate attached to them. This was because the delegate was changed to extend ExploreByTouchHelper which implements its own default AccessibilityNodeProvider, which does nothing in the case of a view without any virtual children.

This diff simply *only* uses the node provider if the view in question has virtual children, otherwise defaulting to the standard behavior from the View class.

Changelog:
[Android][Fixed] - Fixed issue where any node with an AccessibilityDelegate set (which was any node with any accessibility propoerty), was using ExploreByTouchHelper's built in AccessibilityNodeProvider, and not properly populating their AccessibilityNodeInfo's, leading to focus issues and issues with automated test services like UIAutomator.

Reviewed By: kacieb

Differential Revision: D35601320

fbshipit-source-id: 92e009c6e8b4ddcab860e2c91e6bd1a8f95359f0
2022-04-13 16:05:29 -07:00
Vladyslav Stepanov 86f8d0bb52 Fix Android implementation for Linking.sendIntent()
Summary:
Changelog:
[Android][Fixed] - Fix Extras usage in Android implementation of Linking.sendIntent()

The implementation of sendIntent() has a bug in a way it uses extras map.

From JS layer the API sends and array of map, where each map contains exactly 2 entries: {"key" -> "name_of_extra_to_use", "value" -> value_of_extra_to_use}

However Java parsing was just picking a random pair out of this map and was sending it as extra.

Most frequently the result was "value" -> value_of_extra_to_use in Intent instead of name_of_extra_to_use -> value_of_extra_to_use

This diff fixes the problem

Reviewed By: lunaleaps

Differential Revision: D35516496

fbshipit-source-id: 7da0a1cb3b8aa30463004dbb47008c83d8e95bd1
2022-04-12 16:35:40 -07:00
David Vacca fbeb51ef51 Fix NullPointerException when disaptching events
Summary:
This diff fixes a NullPointerException when disaptching events while the SurfaceMountingManager is being destroyed

changelog: [android] android

Reviewed By: cortinico

Differential Revision: D35559550

fbshipit-source-id: c07f74493384fb1b306338ec1bc8b96f1b6f1f41
2022-04-12 12:18:14 -07:00
Luna Wei de09bd3b84 Dispatch enter/leave for ancestor hit path
Summary: Changelog: [Internal] - Fix pointer event dispatch to also fire enter/leave for ancestors in the hit path. Compared the event order with web on the RNTester W3C pointer example

Reviewed By: appden

Differential Revision: D35403076

fbshipit-source-id: 726e45e49a901b1d97ad3e20f5898701fd1f763b
2022-04-11 17:17:10 -07:00
Marces Engel dac56ce077 fix: Android headless JS timeout (#33044)
Summary:
Fixes https://github.com/facebook/react-native/issues/33043 and thereby https://github.com/invertase/react-native-firebase/issues/3955.

The issue arised because when there currently is no available React context, `HeadlessJsTaskService` will create a new one in background and start the task using `onReactContextInitialized` of `ReactInstanceManager.addReactInstanceEventListener`.
https://github.com/facebook/react-native/blob/7ef14af81f3a1532ca1a703da666ea2e5a70a265/ReactAndroid/src/main/java/com/facebook/react/HeadlessJsTaskService.java#L94-L113
The `TimingModule` however is initialized asynchronously, meaning the headless JS is started before its initialization. That's an issue because the `TimingModule` is only run when there is JS code executing (meaning if the application is running or there is a headless task running) - this is checked by registering a `HeadlessJsTaskEventListener` on the `HeadlessJsTaskContext` in `TimingModule.initialize()`.
https://github.com/facebook/react-native/blob/7ef14af81f3a1532ca1a703da666ea2e5a70a265/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.java#L69-L75
However this event listener is never invoked because the task was started before `TimingModule.initialize()` is called -> `TimingModule.onHeadlessJsTaskStart(...)` is not called and the timer never resumes.

In order to fix this we can just invoke `HeadlessJsTaskEventListener.onHeadlessJsTaskStart(...)` for all currently running tasks when a new listener is added to `HeadlessJsTaskContext`. This call then needs to be `synchronized` as otherwise there's a race condition with `HeadlessJsTaskContext.finishTask(...)` where `onHeadlessJsTaskFinish(...)` could be called before `onHeadlessJsTaskStart(...)`. See the diff for the exact changes.

## 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] [Fix] - Fixed `TimingModule` related functions for headless JS tasks, eg. `setTimeout`

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

Test Plan: I did a local build with the changes and tested the provided example code from https://github.com/facebook/react-native/issues/33043 there.

Reviewed By: sshic

Differential Revision: D34006573

Pulled By: dmitryrykun

fbshipit-source-id: d6a821bbd6476ba278c1d8895edb4a0ba16d889e
2022-04-11 06:58:37 -07:00
Nicola Corti bfc39353d1 Do not specify a Kotlin version in the RN rootProject (#33589)
Summary:
As we introduced KGP inside `ReactAndroid` (cc ShikaSD), we now need to specify a version for it (as users will consume that build on Android New Architecture.

Currently, the version is loaded in the RN `rootProject` which is not available on user's project. I'm cleaning this up.

## Changelog

[Internal] - Do not specify a Kotlin version in the RN rootProject

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

Test Plan:
Tested on a nightly version with

```
npx react-native init RNNightly --version nightly
```

Reviewed By: mdvacca

Differential Revision: D35476777

Pulled By: cortinico

fbshipit-source-id: 5a819ef5fa9a6886d7b7b683f31d59cb05a49f29
2022-04-08 03:44:56 -07:00
Nicola Corti c5babd993a Improve support for Android users on M1 machine
Summary:
This is a follow up to my previous diff. It applies the same customization for M1 users to the :ReactAndroid:hermes-engine build.

The two diffs are split so the first one can be cherry-picked into 0.68.1 if needed.

Changelog:
[Android] [Fixed] - Improve support for Android users on M1 machine

Reviewed By: mdvacca

Differential Revision: D35468658

fbshipit-source-id: c07822f6708f872456971378f44257f6c1e967ee
2022-04-07 10:55:32 -07:00