Commit Graph

3614 Commits

Author SHA1 Message Date
Ramanpreet Nara a30fbc28c9 Give NativeAnimatedTurboModule its own TurboModule interface
Summary:
Unfortunately, the new codegen doesn't allow us to import types from other files. Therefore, I've inlined the interface specification of NativeAnimatedModule into NativeAnimatedTurboModule.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D22858790

fbshipit-source-id: 759bb960240afaba6b70c2730c3359b7e8c46c83
2020-07-31 13:48:41 -07:00
David Vacca 3093010ea5 move fabric to ReactCommon/react/renderer
Summary:
This diff moves fabric C++ code from ReactCommon/fabric to ReactCommon/react/renderer
As part of this diff I also refactored components, codegen and callsites on CatalystApp, FB4A and venice

Script: P137350694

changelog: [internal] internal refactor

Reviewed By: fkgozali

Differential Revision: D22852139

fbshipit-source-id: f85310ba858b6afd81abfd9cbe6d70b28eca7415
2020-07-31 13:34:29 -07:00
Ramanpreet Nara 826067736f Instrument TurboModuleManager.getModule
Summary:
This instruments the following marker:
- MODULE_CREATE

**Note:** This marker isn't necessary to test the JS TurboModule codegen, since the JS codegen should only affect the C++ portion of the TurboModule infra. However, I implemented this while I was in this area of the code, for completeness.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22679888

fbshipit-source-id: aa04822bd5a7c889813fcd13ca23c0b7a1d8444a
2020-07-31 12:49:15 -07:00
Ramanpreet Nara 9c35b5b8c4 Dispatch promise methods to the NativeModules thread
Summary:
In D17480605 (https://github.com/facebook/react-native/commit/689233b018bd533a7eecd38e38a7fb84b849cf88), I made all methods with void return types dispatch to the NativeModules thread. This diff makes the same change to methods with promise return types.

**Note:** The changes are disabled for now. I'll add an MC so that we can test this in production in a later diff.

Changelog:
[Android][Fixed] - Make promise NativeModule methods dispatch to NativeModules thread

Reviewed By: PeteTheHeat

Differential Revision: D22489338

fbshipit-source-id: d5b030871f9f7b3f48eb111225516521493cb05e
2020-07-31 12:49:14 -07:00
Anton Bryukhov aa1d31ebca Use recent Vibrator Android API (#29534)
Summary:
Android's `VibrationModule` uses deprecated `vibrate(long milliseconds)` and `vibrate(long[] pattern, int repeat)` methods. Deprecation notes: [[1]](https://developer.android.com/reference/android/os/Vibrator#vibrate(long)) [[2]](https://developer.android.com/reference/android/os/Vibrator#vibrate(long[],%20int)).
Changes in this pull request use recent `Vibrator` API for devices with API Level >= 26 (since mentioned methods were depreceted in API Level 26).

## 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] [Internal] - Use non-deprecated `Vibrator` API in `VibrationModule`

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

Test Plan: API is the same as before, but it uses recent `Vibrator` API.

Reviewed By: makovkastar

Differential Revision: D22857382

Pulled By: mdvacca

fbshipit-source-id: 6793a7d165fa73d81064865861ed55af2de83d52
2020-07-31 11:25:37 -07:00
David Vacca 9b34aa261c Cleanup unsed code in ReactScrollView
Summary:
This diff cleansup unsed code in ReactScrollView

changelog: [Android][Deprecated] Remove code used by Android API level < 16

Reviewed By: JoshuaGross

Differential Revision: D22771910

fbshipit-source-id: d02f7da209d3f313b22f3d4b8f6c413b32f7bc44
2020-07-31 10:44:06 -07:00
David Vacca b133427778 Cleanup unsed code on AccessibilityInfoModule
Summary:
This diff cleansup unused code on AccessibilityInfoModule class

changelog: [Android][Deprecated] Remove code used by deprecated Android API levels

Reviewed By: JoshuaGross

Differential Revision: D22771912

fbshipit-source-id: f32808fa93f75c10324e8875b85fe4e541b284b8
2020-07-31 10:44:05 -07:00
David Vacca b7d8641a28 Cleanup ForwardingCookieHandler class
Summary:
This diff cleansup the class ForwardingCookieHandler, refactoring constants and adding annotations to avoid lint errors

changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D22771914

fbshipit-source-id: 4fdff2df5ea103f93519c2f4504288202114b1fc
2020-07-31 10:44:05 -07:00
David Vacca f829722b54 Remove old android APIs code from ReactViewGroup
Summary:
This diff removes code that was used to support android APIs < kitkat
changelog: [Android][Deprecated] Remove calls to Android API < Kitkat

Reviewed By: JoshuaGross

Differential Revision: D22771913

fbshipit-source-id: b9bba9e94fbc8e18889b821050dcd6eace4c202d
2020-07-31 10:44:05 -07:00
David Vacca 25a40cbc61 Clean old code on ReactViewBackgroundDrawable
Summary:
This diff removes unnecessary API checks in ReactViewBackgroundDrawable

changelog: [Android][Deprecated] Remove JellyBeans Android API checks in ReactViewBackgroundDrawable classes

Reviewed By: JoshuaGross

Differential Revision: D22771911

fbshipit-source-id: bbbf3dd3fd1c3cf3f5ce294fc32bd0a31ca0f67c
2020-07-31 10:44:05 -07:00
Joshua Gross 3c6c5f057a Trivial: fix typos in log messages of NativeAnimatedModule
Summary:
Fix typos.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22808108

fbshipit-source-id: 7a0406d902ac92bc27ecd49fd061704539266bf2
2020-07-29 17:42:10 -07:00
Joshua Gross 934561b295 Remove complex NativeAnimated queueing mechanisms
Summary:
After D22801173 (https://github.com/facebook/react-native/commit/9e6ba9ddb8608d4e3a4a80d0138600130b766d4c) has landed, the native mechanisms in NativeAnimated to delay queued items from immediate execution are no longer necessary.

Fabric and non-Fabric animations both look smooth after deleting this code.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22807906

fbshipit-source-id: 9241fff84376f6aa9a35049cc40dfd6561effaa1
2020-07-29 17:42:10 -07:00
Joshua Gross 949dedca9f Implement BackgroundExecutor for layouts
Summary:
As a followup to D22743723 (https://github.com/facebook/react-native/commit/d53fc8a3cd44c7ec7e6eade985daf3d4feb2d736) on the iOS side, I implement a BackgroundExecutor that can be used from C++ to schedule layouts on their own thread, off the JS and UI thread.

This is a potential perf improvement that we will experiment with.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22826795

fbshipit-source-id: 899bd67fe1b86f52910951e9536b59a1414a304c
2020-07-29 15:41:22 -07:00
David Vacca 7ccb67a49c Fix render of ARTShape using null paths
Summary:
This diff fixes the rendering of ART Shapes that uses null paths

changelog: [internal] internal fix

Reviewed By: JoshuaGross

Differential Revision: D22780163

fbshipit-source-id: 2aded726ad47fce243ec1c28fbd4c39dd71820ef
2020-07-27 17:35:37 -07:00
Joshua Gross 07722cf746 Ignore exceptions when a Delete instruction is in the same BatchMountItem as its corresponding Create instruction during stopSurface
Summary:
See title. Basically during stopSurface a single BatchMountInstruction can contain both the Create and Delete MountItem for a single view, which will cause *only* the deletion to be executed.

There isn't really a way to prevent this and we're just trying to clean up as aggressively as possible, so we can safely ignore this.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22779189

fbshipit-source-id: c44fd736835b04c5de776346ec3d34afa4860199
2020-07-27 16:58:47 -07:00
Joshua Gross 3bab643e5d NativeAnimated: lower SoftException to NoCrashSoftException
Summary:
This exception will be more disruptive during development than necessary.

This can be upgraded again if there's a reasonable root-cause, but right now this error isn't actionable enough, is too common, and the repercussions aren't obvious.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22775734

fbshipit-source-id: 2cd9449f5b78025f7a230fbbd5f2e87bce183d04
2020-07-27 16:22:25 -07:00
Lulu Wu a23596f70f Enable registerSegment in Venice
Summary:
Enable registerSegment in Venice and verify bundle splitting works for Pokes with Venice.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D22666115

fbshipit-source-id: 74ef830b802634b1019d4371873aba599438de37
2020-07-27 06:36:21 -07:00
Joshua Gross 41fb336ff2 NativeAnimated: Fabric constructs partial animation graphs often; warn instead of crashing
Summary:
Due to subtle differences in lifecycle on the native side, as well as in JS, Fabric constructs partial graphs more frequently than non-Fabric RN did.

We still crash if we detect a cycle, which we check for more explicitly now; and we still always crash in non-Fabric. But if we detect a partial graph in Fabric,
we warn instead of crashing. We also print the state of the graph before crashing/warning, to assist in debugging in production.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22752291

fbshipit-source-id: f452892678fbe7b5a49f93644d39d3b6ae5bda75
2020-07-25 13:45:11 -07:00
Joshua Gross ab5e87fd95 Pretty-print Native AnimatedNode values
Summary:
For debugging, add prettyPrint method to AnimatedNode classes.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22752292

fbshipit-source-id: ce1f08fc4fd97f38629dd82151c6ea762026c7c9
2020-07-25 13:45:11 -07:00
Emily Janzer eddf90f756 Clean up RuntimeExecutor experiment and remove jsContext param
Summary:
Cleaning up the test for switching to the shared RuntimeExecutor, and removing the jsContext arg from Fabric's Android APIs entirely.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22026752

fbshipit-source-id: df70faa70eaa2a04717ae89e8ad3216dfd486a35
2020-07-24 16:48:36 -07:00
Riley Dulin 63d20d3b1e Set the max heap size for OSS apps on Android to be 1 GB for Hermes
Summary:
The max heap size currently is 512 MB for OSS apps using Hermes on Android.

Some users (see https://github.com/facebook/hermes/issues/295) are experiencing
long pauses when reaching this ceiling.
Increasing this limit to 1 GB should reduce the frequency of these pauses occurring
for apps where the expected heap usage is near 512 MB.

Changelog: [Internal] Set Hermes's default max heap size to 1 GB

Reviewed By: mhorowitz

Differential Revision: D22577343

fbshipit-source-id: 2d7d688e38e95a082692dca52d010d0449a6e64b
2020-07-23 10:26:19 -07:00
Joshua Gross 1e819b71ad If there's a FabricUIManager crash during execution, log all MountItems being executed
Summary:
This could help somewhat with solving crashes in production.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D22631593

fbshipit-source-id: 2caebf1d6611d98764bccf5a6608040e5c892614
2020-07-20 13:25:52 -07:00
David Vacca 35128f45d1 Fix NoSuchMethodException when calling DisplayMetricsHolder.initDisplayMetrics in Android API level <= 16
Summary:
This diff fixex a NoSuchMethodException when calling DisplayMetricsHolder.initDisplayMetrics in Android API level <= 16.

changelog: [Android][Fixed] Fix NoSuchMethodException when calling DisplayMetricsHolder.initDisplayMetrics in Android API level <= 16

Reviewed By: fkgozali

Differential Revision: D22630603

fbshipit-source-id: d2a95445beb5745a89ee1eefdf0d24ce3e0b8893
2020-07-20 12:24:32 -07:00
Valentin Shergin ec60ebe792 Introducing YGPositionTypeStatic
Summary:
Changelog: [Internal] Fabric-specific internal change.
This diff introduces a new value for `YGPositionType`: `YGPositionTypeStatic`.
No part of Yoga, RN, Litho or CK uses this value yet. `relative` and `static` values behave the same way for now. We also do not change any defaults. So, it should be fine.

Reviewed By: SidharthGuglani

Differential Revision: D22386732

fbshipit-source-id: 39cd9e818458ac2a91efb175f24a74c8c303ff08
2020-07-20 00:33:22 -07:00
Joshua Gross f00795dc90 Prevent NPE in measure during measure/teardown race
Summary:
When stopSurface is called, Fabric might be processing a commit and performing measurements even as the context is being removed from the FabricUIManager map.

Just return a 0 from `measure` if we can't get a context. This prevents crashes during teardown for measured views that will never be visible anyway.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22604716

fbshipit-source-id: 67be8d272afd35fc4c2b51b371939c5623e97f73
2020-07-17 15:33:14 -07:00
David Vacca ee8a0cfa5a Fix ConcurrentModificationException while registering events
Summary:
This diff fixes a ConcurrentModificationException that is thrown when registering events in React Native.
This bug was introduced by D22483508 (https://github.com/facebook/react-native/commit/80f13412e548c8666b6ad770e6d3d5c54a717bc2), before event listeners were registered in the NativeModule Thread, now they are registered in the UI Thread.

As part of this diff I change the type of mListeners variable to use CopyOnWriteArrayList instead of ArrayList because this variable is accessed from different threads. This will prevent the exception to happen, but additionally we need to verify if the change of threading made in D22483508 (https://github.com/facebook/react-native/commit/80f13412e548c8666b6ad770e6d3d5c54a717bc2) will cause any other issue (e.g. events not being delivered becuase the listeners are registered too late in the UI Thread)

changelog:[Internal]

Reviewed By: JoshuaGross

Differential Revision: D22599747

fbshipit-source-id: 5c5e46710c4a559badbd713f536e6e6e464fda23
2020-07-17 11:51:22 -07:00
Joshua Gross 980900c634 Workaround for NativeAnimatedModule queue race condition
Summary:
Apparently it's possible for `!isEmpty()` to be true and `peek` to be non-null, but for `poll()` to be false. It doesn't really make sense to me, and I don't have a repro, but that's what logs are showing.

I suspect a teardown race condition or /maybe/ a Fabric/non-Fabric handoff race condition. Neither of those make a ton of sense, though.

The mitigation is fairly straightforward: we are just much more cautious with how we treat the queue and assume everything could be null.

This impacts Fabric and non-Fabric equally.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D22593924

fbshipit-source-id: 7748121951a64941fa6da2bd25ebf070be6dc89c
2020-07-17 01:06:23 -07:00
David Vacca 3d1e127976 Refactor destruction of ReactInstanceManager during Memory Pressure in FB4A
Summary:
This diff refactors the destruction of the ReactInstanceManager when the app is experiencing low memory.

As part of this refactor, I setup an experiment to understand at what level of memory pressure is convenient to destroy the RN bridge.

The experiment is divided in six levels described in the following table:

https://pxl.cl/1dzx8

https://www.internalfb.com/intern/qe2/fb4a_react_native_memory/android_fb4a_instance_unload_pressure_v2/setup

changelog: [internal] Internal

Reviewed By: JoshuaGross

Differential Revision: D22577553

fbshipit-source-id: 37f8f561099a1ba6239795f5907090ced3b5dd18
2020-07-16 14:47:53 -07:00
David Vacca de094396e3 Update InitialLifeCycleState used when initializing RN in FB4A
Summary:
This diff changes the InitialLifeCycleState used when initializing RN in FB4A from BEFORE_RESUME to BEFORE_CREATE.
The value of this field is used during the teardown of RN to determine if RN is actually running or not

The intention of this change is to represent the right behavior of RN during initialization, also this will allow RN to be turn down in case of memory pressure when the bridge has been initialized but before the user has navigated to a RN screen (preloading)

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D22577555

fbshipit-source-id: e54ef596cfe4429745611fe6022eb000051a93d0
2020-07-16 14:47:52 -07:00
Emily Janzer e12cf7d069 Add bridgeless check so that we notify listeners if activity is already resumed
Summary:
When a native module registers itself as a lifecycle event listener, ReactContext will immediately call `onHostResume` if the activity is already in a resumed state. We rely on this behavior for things like NativeAnimatedModule, which only enqueues the frame callback in onHostResume. However, ReactContext only does this if `hasActiveCatalystInstance()` returns true - which makes sense, because we don't want to notify listeners if the instance has been destroyed. But in bridgeless mode, `hasActiveCatalystInstance` returns false, and we never call `onHostResume` in this case.

This diff fixes an issue where native driver animations don't work the first time you navigate to a screen with bridgeless mode enabled.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22560314

fbshipit-source-id: 1a60cb482896308e21d6e438eb9a7314f580ad04
2020-07-16 11:40:13 -07:00
Joshua Gross 11990c5a08 NativeAnimatedModule: ensure that all operations execute in order when switching between Fabric and non-Fabric screens
Summary:
There are potential race conditions in the old implementation that could result in operations being executed out-of-order when the user transitions between Fabric/non-Fabric screens.

Specifically, if the non-Fabric path queues up a batch of operations to execute on the next UI tick, it is possible that Fabric lifecycle events fire /before/ that next UI tick and synchronously execute a batch of animation operations on the UI thread, before their predecessors have executed.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22564633

fbshipit-source-id: 91c24547d5a682e61fc0c433302667330349a5f1
2020-07-15 23:14:14 -07:00
Emily Janzer fc285f2f06 Add support for bridgeless mode to UIManagerHelper.getUIManager()
Summary:
`UIManagerHelper.getUIManager()` relies on the bridge (CatalystInstance) to get the proper UIManager depending on which renderer is being used. Unfortunately, this means it will always return null in bridgeless mode, where the CatalystInstance doesn't exist. This diff replaces the implementation of `BridgelessReactContext.getJSIModule()` to return the FabricUIManager from the ReactHost/Instance.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22480968

fbshipit-source-id: 640e3f22a5b39b315ed2f0397be3cba39e80529a
2020-07-15 19:34:49 -07:00
fabriziobertoglio1987 45954ac5dc keyboardDidHide wrong screenY coordinates with windowTranslucentStatus=true (#29292)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/27526, related issue https://github.com/facebook/react-native/issues/27089
Avoid returning the wrong screenY coordinates on event keyboardDidHide.
getWindowVisibleDisplayFrame retrieves the overall visible display size in which the window this view is attached to has been positioned in. This takes into account screen decorations above the window, for both cases where the window itself is being position inside of them or the window is being placed under then and covered insets are used for the window to position its content inside. In effect, this tells you the available area where content can be placed and remain visible to users, since anything below the StatusBar is not visible to the user, the method does not work with translucent StatusBar (android:windowTranslucentStatus).

This commit fixes this issues removing the white bar at the bottom of the view when using windowTranslucentStatus.

## 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] - keyboardDidHide wrong screenY coordinates with windowTranslucentStatus=true

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

Test Plan:
Works in all scenarios, but **I did not change RNTester `windowTranslucentStatus`**. I would like to discuss the potential breaking changes connected to not using [getWindowVisibleDisplayFrame](https://developer.android.com/reference/android/view/View#getWindowVisibleDisplayFrame(android.graphics.Rect)) with `keyboardDidHide`.

I would be happy to build an alternative functionality to calculate the WindowVisibleDisplayFrameHeight under request from the Facebook Team.

**WITHOUT** `android:windowTranslucentStatus`

| **BEFORE** |
|:-------------------------:|
|  <img src="https://user-images.githubusercontent.com/24992535/86804255-0eca4680-c077-11ea-8c79-95ba297d05ba.gif"  />|

| **AFTER** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/86804265-10940a00-c077-11ea-8cb8-a304cc5de363.gif"  /> |

**WITH** `android:windowTranslucentStatus`

| **BEFORE** |
|:-------------------------:|
|  <img src="https://user-images.githubusercontent.com/24992535/86804458-3a4d3100-c077-11ea-8f3e-7c43eaa08d70.gif"  height="" />|

| **BEFORE (log)** |
|:-------------------------:|
|  <img src="https://user-images.githubusercontent.com/24992535/86806330-0d018280-c079-11ea-9266-c3bcf23a35da.png"  height="" />|

| **AFTER** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/86804464-3b7e5e00-c077-11ea-8487-34c87f076e5f.gif" height="" /> |

| **AFTER (log)** |
|:-------------------------:|
| <img src="https://user-images.githubusercontent.com/24992535/86806042-c4e26000-c078-11ea-9c3c-cac5319bef65.png" height="" /> |

RNTester **WITHOUT** `android:windowTranslucentStatus`

| **BEFORE** | **AFTER** |
|:-------------------------:|:-------------------------:|
|  <img src="https://user-images.githubusercontent.com/24992535/86805348-176f4c80-c078-11ea-8e2a-e2d84af5c278.gif"  width="300" height="" />| <img src="https://user-images.githubusercontent.com/24992535/86805324-13432f00-c078-11ea-9e70-fa2606eee86b.gif" width="300" height="" /> |

I remain available to do improvements. Thanks a lot. Fabrizio.

Reviewed By: JoshuaGross

Differential Revision: D22521125

Pulled By: mdvacca

fbshipit-source-id: e2cb90163abb1baa00b1916e431971b011522565
2020-07-15 13:14:41 -07:00
Lulu Wu 9b8ffeee4c Fix the redbox when running Metro with Venice enabled.
Summary:
1, Fix the redbox on Pokes route when running Metro with Venice enabled.
2, Fix CrashReactRoute stucking with the loading indicator issue.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D22477500

fbshipit-source-id: 65e908ac360e031e5f3562a21c09cb0d7ddaf7a0
2020-07-15 03:47:45 -07:00
Marcel Lasaj a71f37b951 Fix error message for DebugCorePackage.getModule IllegalArgumentExc… (#29304)
Summary:
…eption

This is a minor change in `DebugCorePackage.getModule()` method that corrects the `IllegalArgumentException`'s error message, which was probably copy-pasted from `CoreModulePackage`.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->
[Android] [Fixed] - Fixed error message in DebugCorePackage.getModule

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

Test Plan: No tests needed.

Reviewed By: RSNara

Differential Revision: D22521091

Pulled By: mdvacca

fbshipit-source-id: 19205f9beb0fc26249985ce2c865e284c4a4add1
2020-07-14 14:49:08 -07:00
Ramanpreet Nara ec18e35cd3 Instrument events emitted by TurboModuleManager
Summary:
TurboModuleManager can emit the following events:
- JS Require Beginning
- JS Require Ending
- Module Create (for C++-only TurboModules)

This diff instruments JS Require beginning, and JS Require ending. It also serves as a good stopgap to verify that TurboModule perf logging is set up correctly.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22485529

fbshipit-source-id: a41b88b56627ad2bbcaadac87bf9d530bf07ae81
2020-07-11 09:38:45 -07:00
Ramanpreet Nara 41d948c8d6 Introduce TurboModulePerfLogger Java class
Summary:
We need to instrument the following markers for TurboModules in Java:
- **Java:** moduleDataCreate
- **Java:** moduleCreate

**Problem:** Perf-logging can be on or off in production. This means that we have to guard every perf-logger call, which can be a bit tedious. Therefore, this diff introduces a Java class called `TurboModulePerfLogger`, which:
1. Enables perf-logging by accepting a `NativeModulePerfLogger` `jni::HybridObject` in its `enableLogging` method.
2. Exposes static methods that call into the `NativeModulePerfLogger`'s Java part, when perf-logging is enabled.

We actually have C++ markers as well:
- **C++:** moduleJSRequireBeginning
- **C++:** moduleJSRequireEnding
- **C++:** syncMethodCall
- **C++:** asyncMethodCall
- **C++:** asyncMethodCallExecution

Therefore, `TurboModulePerfLogger.java` also calls its native method `jniEnableCppLogging` to setup C++ TurboModule perf-logging.

TurboModule C++ logging is done via a similar setup (to Java), using `TurboModulePerfLogger.cpp`. The `jniEnableCppLogging` native method calls into `TurboModulePerfLogger::enableLogging` with the C++ part of `NativeModulePerfLogger`. Then, the TurboModules C++ infra uses the static methods on `TurboModulePerfLogger.cpp` to start/end markers.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22444246

fbshipit-source-id: 66f191056cdcf5d7932ff1916a1de70b82e5f32b
2020-07-11 09:38:45 -07:00
Ramanpreet Nara c0dd11e532 Introduce JNativeModulePerfLogger
Summary:
## Description
This diff introduces `NativeModulePerfLogger.java`, the Android extension (a `jni::HybridClass`) to `NativeModulePerfLogger`.

### Why is this a Hybrid class?
Because we have C++ and Java markers, and the perf-logger has both a Java and a C++ interface that the application must implement. `jni::Hybrid` classes are a convenient solution for these constraints.

Changelog:
[Android][Added] - Introduce JNativeModulePerfLogger

Reviewed By: ejanzer

Differential Revision: D21318052

fbshipit-source-id: 2f43853b243fa2a629068bb4aced1e3f12f038ba
2020-07-11 09:38:45 -07:00
Joshua Gross 46d6e7f575 NativeAnimatedModule: animations should still run if there isn't a Fabric commit for multiple frames
Summary:
See videos. In some cases when an `Animated.timing` animation was triggered, there are not necessarily any corresponding Fabric commits. This causes the animations to be queued up but never execute... until there's some Fabric commit at a distant point in the future.

We can't immediately flush all animation operations (see inline comments) but we also shouldn't wait forever. Thus, we wait 2 frames and then flush.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22490650

fbshipit-source-id: 1669bfed00f2a92b50f9558fc7ccaf71dc636980
2020-07-10 23:34:47 -07:00
Joshua Gross 7bf56e1902 NativeAnimatedModule: don't restore default values when disconnected nodes in Fabric
Summary:
See title.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22488069

fbshipit-source-id: a0cb2dc65e5ea4befd7921acd194a67840b1498d
2020-07-10 23:34:47 -07:00
Joshua Gross 80f13412e5 Expose resolveCustomDirectEventName from UIManager interface
Summary:
Expose `resolveCustomDirectEventName` from UIManager interface for Bridgeless Mode+NativeAnimatedModule.

We cannot remove the interface from the Non-Fabric UIManagerModule yet, as it would break downstream open-source dependencies, so I just marked it deprecated.

Note that this still doesn't totally fix issues with Bridgeless mode: generally I have to navigate to a Bridgeless surface, exit it, and then navigate back, and only on the 2nd navigation does everything seem to work properly...

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22483508

fbshipit-source-id: 685126e7e51aa5d0fd60ad5d4ecc44e8c6c3029d
2020-07-10 23:34:47 -07:00
Joshua Gross 95d05fc415 NativeAnimatedModule: subscribe to Fabric lifecycle events in more cases
Summary:
The previous assumption was that any animations would result in `addAnimatedEventToView` being called. That's not true in all cases, so sometimes we never subscribed to Fabric lifecycle events, preventing animations from working on some screens and for Venice.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22483509

fbshipit-source-id: c97576675902b4b9e1d4e659c7c1e24c5fe92946
2020-07-10 23:34:47 -07:00
Joshua Gross 3503d722a1 Fix race between teardown and PreAllocateView/CreateView MountItem creation
Summary:
Commits can happen during navigation/teardown which creates mount items. If we throw an exception during
teardown because we expect the Context to still be around, we crash too often. Instead, I will rely on
logic in FabricUIManager to ignore queued MountItems if we try to execute them after the surface has been torn down;
and we move the IllegalStateException to actual execution of the mount item in case there's an edge-case we're missing.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22470102

fbshipit-source-id: ad98c03994969a3c3f300d6551e90b6516ed2d8b
2020-07-09 20:50:00 -07:00
Santiago Alfonso Muñoz Rodriguez 1930039261 Move CameraRoll Android files to FB Internal
Summary: Changelog: [Lean Core][Android] Removed CameraRoll from RN Android

Reviewed By: RSNara

Differential Revision: D22410115

fbshipit-source-id: 5cdb5b87a7bf5b4a8a4c2953c14ba3751b125d07
2020-07-09 06:10:42 -07:00
Hein Rutjes cfa4260598 Add support for shadowColor on Android (API >= 28) (#28650)
Summary:
This PR adds support for the `shadowColor` style on Android.

This is possible as of Android P using the `setOutlineAmbientShadowColor` and `setOutlineSpotShadowColor` View methods. The actual rendered color is a multiplication of the color-alpha, shadow-effect and elevation-value.

## Changelog

`[Android] [Added] - Add support for shadowColor on API level >= 28`
Pull Request resolved: https://github.com/facebook/react-native/pull/28650

Test Plan:
- Only execute code on Android P
- Added Android `BoxShadow` tests to RNTester app

![image](https://user-images.githubusercontent.com/6184593/79457137-fe627c80-7fef-11ea-8e88-3d9423a4f264.png)

Reviewed By: mdvacca

Differential Revision: D21125479

Pulled By: shergin

fbshipit-source-id: 14dcc023977d7a9d304fabcd3c90bcf34482f137
2020-07-07 23:32:38 -07:00
Devon Deonarine 8c42c01977 Fix debugging on android for 0.63 (#29204)
Summary:
Currently on react native 0.63-rc.0 and 0.63-rc.1 enabling debugging throws an exception. It looks like something may have been missed in unregistering JSDevSupport in this commit c20963e

![crash](https://user-images.githubusercontent.com/14797029/85500252-2acae400-b5b1-11ea-938a-674b55e649b2.gif)

This should fix https://github.com/facebook/react-native/issues/28746 and https://github.com/facebook/react-native/issues/29136

## Changelog
[Android] [Fixed] - Fix crash when enabling debug

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

Test Plan:
To recreate the bug:

npx react-native init RN063 --version 0.63.0-rc.1
react-native start
react-native run-android
Enable debug mode from react native dev menu

After this commit, the crash no longer occurs

![non crash](https://user-images.githubusercontent.com/14797029/85500241-269ec680-b5b1-11ea-8cfe-85bfda4dd222.gif)

Reviewed By: TheSavior

Differential Revision: D22395406

Pulled By: RSNara

fbshipit-source-id: 046df77ae1c1de96870fb46f409d59e7d6a68c0d
2020-07-07 12:06:16 -07:00
Sean Wang 824d3a9770 Move iOS CameraRoll files into FB internal
Summary:
This moves ios CameraRoll files from React Native open source into FB internal as part of the Lean Core effort.

Changelog: [Breaking][ios] Remove CameraRoll from React Native

Reviewed By: cpojer

Differential Revision: D22208352

fbshipit-source-id: 894d6aff34ece94648dad68060c13b44974c93bb
2020-07-06 20:22:25 -07:00
Christoph Nakazawa 6d6c68c2c6 "The Metro Server" -> Metro
Summary:
Pet Peeve: Metro is a brand name. You don't say "the Metro server" just like you don't say "the iPhone phone". This is a leftover from when it used to be called "the packager server".

Note: It makes sense to refer to "the Metro server" when talking about it in the context of Metro's features, like if you are discussing "Metro's bundling" and "Metro's server". However, when talking about the tool itself, just Metro is enough.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D22330966

fbshipit-source-id: 667618363c641884df543d88cac65d1e44956ad3
2020-07-02 14:51:18 -07:00
almouro f23feced42 Fix font variant crash on Android < 4.4 (#29176)
Summary:
In RN 0.62 support for `fontVariant` was added on Android.
Using that prop crashes the app on Android below KitKat (4.3 and below)

To reproduce just add any Text with the `fontVariant` styling prop in the app:
```js
<Text style={{fontVariant: ['tabular-nums']}}>This will crash</Text>
```
It will crash any device running Android below KitKat with the error:

![image](https://user-images.githubusercontent.com/4534323/85073452-18206b80-b1bb-11ea-8d7e-96f27fa1a320.png)

This is caused by `java.utils.Objects` only being available on Android 4.4+

## Changelog

[Android] [Fixed] - Fix font variant crash on Android < 4.4
Pull Request resolved: https://github.com/facebook/react-native/pull/29176

Test Plan:
[TextUtils.equals](https://developer.android.com/reference/android/text/TextUtils#equals) was added as soon as API level 1, so no compatibility issue here.
Tested on Emulator running Android 4.1, no crash anymore.

I've searched for other occurences of `java.utils.Objects` in the project, and this was the only one, so no need to remove other occurences 

Reviewed By: JoshuaGross

Differential Revision: D22337316

Pulled By: mdvacca

fbshipit-source-id: 5507b21b237a725d596d47b5c01e269895b16d4a
2020-07-01 19:12:22 -07:00
fabriziobertoglio1987 7d8aeb4955 do not call setHyphenationFrequency on AndroidSdk < 23 (#29258)
Summary:
JoshuaGross This issue fixes https://github.com/facebook/react-native/issues/28279 as discussed in https://github.com/facebook/react-native/pull/29157#issuecomment-649993571
Avoid calling [setHyphenationFrequency](https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int)) on Android Sdk < 23.

## 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] - do not call setHyphenationFrequency on AndroidSdk < 23
Pull Request resolved: https://github.com/facebook/react-native/pull/29258

Test Plan:
| **BEFORE** | **AFTER** |
|:-------------------------:|:-------------------------:|
|  <img src="https://user-images.githubusercontent.com/24992535/86214122-05bf0e00-bb7b-11ea-93b5-2174812bfec9.png"  width="300" height="" />| <img src="https://user-images.githubusercontent.com/24992535/86214130-08216800-bb7b-11ea-9fc0-68b28638bf57.png" width="300" height="" /> |

The warning displayed with `adb logcat | grep -P "ReactTextAnchorViewManager"`

![image](https://user-images.githubusercontent.com/24992535/86214242-34d57f80-bb7b-11ea-9945-30ae25332bfb.png)

I remain available to do improvements. Thanks a lot. Fabrizio.

Reviewed By: JoshuaGross

Differential Revision: D22337095

Pulled By: mdvacca

fbshipit-source-id: d0943397af180929c48044ccbc7a9388549021b8
2020-07-01 17:45:34 -07:00