Commit Graph

20500 Commits

Author SHA1 Message Date
David Vacca 61cd596137 Remove unused dependency
Summary:
Remove unused dependency

changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D22470766

fbshipit-source-id: e49180d1a9eb01e8380fb2bde16b8d4378018693
2020-07-14 21:27:38 -07:00
Joshua Gross c0e7e1bd9c Back out "Introducing LayoutableShadownode::getContentOriginOffset and use it in ScrollView"
Summary:
Original commit changeset: 6fd54661305a

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D22532594

fbshipit-source-id: 5ca25328cfe11416a9721a90611eff56e14cb49f
2020-07-14 19:03:13 -07:00
Valentin Shergin d3fb036d6e Using YGPositionTypeAbsolute value where we compare absolute vs relative
Summary:
Now Yoga.cpp does not use the `YGPositionTypeRelative` value/constant, it uses `YGPositionTypeAbsolute` instead.
Now `YGPositionType` can only be `YGPositionTypeRelative` or `YGPositionTypeAbsolute`, so expressions `x == YGPositionTypeRelative` and `x != YGPositionTypeAbsolute` are equivalent.
The reasoning behind the change is that in all cases we actually check a node to be (or not to be) `absolute`, not `relative`. This will make a difference in the coming diffs in the stack when we will introduce a new value for the type: `static`.

We need to differentiate `static` and `relative` values t implement the `stacking context` feature in the W3C-compliant way (to fix bugs and avoid developer confusion). Read more here:
https://developer.mozilla.org/en-US/docs/Web/CSS/position

Changelog: [Internal] Internal change in Yoga.

Reviewed By: SidharthGuglani

Differential Revision: D22386733

fbshipit-source-id: 8e2c2b88b404660639f845783c8f93f0c62c0fbb
2020-07-14 15:22:33 -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 9f3b6082da Only show deadlock warning when TM eager init is on
Summary:
During setup, TurboModules may synchronously dispatch to the main queue, if they require main queue setup. This is dangerous because it could cause the app to deadlock during TurboModule require. This is why D21654637 (https://github.com/facebook/react-native/commit/e206e34175c091a753c0e733abeda41b662241d4) added a warning aginst this. However, this diff had a mistake. We only want to display the warning if TurboModule eager initialization is enabled, because then, we can eagerly initialize the TurboModules before the bridge starts to avoid the problem. D21654637 (https://github.com/facebook/react-native/commit/e206e34175c091a753c0e733abeda41b662241d4) instead showed the warning if TurboModule eager init **wasn't** enabled. This isn't useful, because there's no way to avoid the problem with TurboModu eager initialization off.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D22529780

fbshipit-source-id: 15238483758b66b1a6addcad948203c64dca96ad
2020-07-14 14:29:59 -07:00
Matthieu Harlé 7694b32a88 Exclude okhttp from flipper dependency (#29260)
Summary:
This fixes https://github.com/facebook/react-native/issues/28481. As explained in [this comment](https://github.com/facebook/react-native/issues/28481#issuecomment-645546195), the flipper network plugin pulls a more recent version of okhttp (3.14), but only versions of okhttp up to 3.12 works on Android API 21 and less.

This prevented being able to run the app in debug mode, it was still working fine in release mode.

## 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 unable to run in debug mode on Android API < 21

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

Test Plan:
Using `yarn react-native run-android` the app would instantly crash with this error in `adb logcat`:
```
E/AndroidRuntime( 5079): java.lang.RuntimeException: Unable to create application com.awesometsproject.MainApplication: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
E/AndroidRuntime( 5079):        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4154)
E/AndroidRuntime( 5079):        at android.app.ActivityThread.access$1300(ActivityThread.java:130)
E/AndroidRuntime( 5079):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
E/AndroidRuntime( 5079):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 5079):        at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 5079):        at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime( 5079):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 5079):        at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 5079):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime( 5079):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime( 5079):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 5079): Caused by: java.lang.RuntimeException: Requested enabled DevSupportManager, but DevSupportManagerImpl class was not found or could not be created
E/AndroidRuntime( 5079):        at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:90)
E/AndroidRuntime( 5079):        at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:238)
E/AndroidRuntime( 5079):        at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:281)
E/AndroidRuntime( 5079):        at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:87)
E/AndroidRuntime( 5079):        at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:39)
E/AndroidRuntime( 5079):        at com.awesometsproject.MainApplication.onCreate(MainApplication.java:47)
E/AndroidRuntime( 5079):        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
E/AndroidRuntime( 5079):        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151)
E/AndroidRuntime( 5079):        ... 10 more
E/AndroidRuntime( 5079): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 5079):        at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 5079):        at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
E/AndroidRuntime( 5079):        at com.facebook.react.devsupport.DevSupportManagerFactory.create(DevSupportManagerFactory.java:80)
E/AndroidRuntime( 5079):        ... 17 more
E/AndroidRuntime( 5079): Caused by: java.lang.NoClassDefFoundError: java.util.Objects
E/AndroidRuntime( 5079):        at okhttp3.CertificatePinner.withCertificateChainCleaner(CertificatePinner.java:231)
E/AndroidRuntime( 5079):        at okhttp3.OkHttpClient.<init>(OkHttpClient.java:238)
E/AndroidRuntime( 5079):        at okhttp3.OkHttpClient$Builder.build(OkHttpClient.java:1015)
E/AndroidRuntime( 5079):        at com.facebook.react.devsupport.DevServerHelper.<init>(DevServerHelper.java:132)
E/AndroidRuntime( 5079):        at com.facebook.react.devsupport.DevSupportManagerImpl.<init>(DevSupportManagerImpl.java:183)
E/AndroidRuntime( 5079):        ... 20 more
W/ActivityManager( 1456):   Force finishing activity com.awesometsproject/.MainActivity
```

With this fix, the app launch successfully in debug mode, without having to remove flipper altogether from our config.

Reviewed By: passy

Differential Revision: D22521109

Pulled By: mdvacca

fbshipit-source-id: 3c0263642438bd7c0d09b045e15a933bd8a26734
2020-07-14 13:54:25 -07:00
Jiayan Zhuang 4320359686 Reword the guide words
Summary:
Changelog:
[Internal] - Reword the guide words to make it more generic.

Considering the case that some languages are RTL so swiping right cannot guarantee to move to the link. iOS can handle the order of the words and accessibilityElements according to the language. But the accessibilityHint we hardcoded would be an issue. So we decided to reword it to be more generic.

Reviewed By: PeteTheHeat

Differential Revision: D22422498

fbshipit-source-id: 175711317961663d0b0b47e04d2ab600f63446fe
2020-07-14 11:24:32 -07:00
Jiayan Zhuang 550c66ea64 Change accessibilityRole to an enum
Summary:
Changelog:
[Internal] - Change the accessibilityRole from a string to an enum.

The change aims to save storage especially when scaling. Also, the enum makes it more difficult to input wrong because it gets checked when compiling.

Reviewed By: sammy-SC

Differential Revision: D22396351

fbshipit-source-id: b46ce0bd156c7705020ef5b061d8ac29e2cf3948
2020-07-14 09:55:32 -07:00
Jiayan Zhuang 8c602e271e Solve truncation attributed string case
Summary:
Changelog:
[Internal] - Add a `accessibilityHint` to the first accessibilityElement so that it will tell user double tap to expand or truncate the text after reading the whole text. Also add the `accessibilityRole` in `FBTextWithEntities` when shouldTruncated is true, which allow us to specially distinguish the shouldTruncated text.

Reviewed By: sammy-SC

Differential Revision: D22339875

fbshipit-source-id: ce22fe9d86eeba5a2750022acd2cdd2c06a1dc79
2020-07-14 09:55:32 -07:00
Jiayan Zhuang fd660fd0c5 Add importantForAccessibility to AccessibilityProps and wire with FormsStakingContext
Summary:
Changelog:
[iOS][Added] - Add `importantForAccessibility` to `AccessibilityProps`

Reviewed By: shergin

Differential Revision: D22490327

fbshipit-source-id: aec7ff64ea6ddfe29bad085b87d09906fa8ee029
2020-07-14 09:29:13 -07:00
simek e5a8f4270e fix StatusBar showHideTransition flow type issue (#29034)
Summary:
This small PR adds third, missing [`StatusBarAnimation`](https://github.com/facebook/react-native/blob/master/Libraries/Components/StatusBar/StatusBar.js#L45) possible value to the `showHideTransition` prop validation - `'none'`.

This fixes the following issue when `<StatusBar showHideTransition="none" />` code  is used:

<img width="970" alt="Screenshot 2020-06-02 at 22 39 37" src="https://user-images.githubusercontent.com/719641/83567510-f6b85200-a521-11ea-9f1c-48825d0285bf.png">

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

[iOS] [Fixed] - fix StatusBar showHideTransition flow type issue

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

Test Plan: I have run the `flow` check in the test project which uses local working copy of `react-native` with this change included.

Reviewed By: GijsWeterings

Differential Revision: D22493825

Pulled By: cpojer

fbshipit-source-id: 463badec67e6725cb8711a79aa43d84f9b09f796
2020-07-14 08:38:39 -07:00
simek 1c634a9218 move Hermes badge from template to NewAppScreen library (#28783)
Summary:
Refs https://github.com/facebook/react-native/issues/28711

This PR moves Hermes badge component from the template to the `NewAppScreen` library. The main motivation behind this change was to simplify a bit template code.

I assumed that it is not important to expose `global.HermesInternal` to the template users:
* If this assumption is true, I think that there are no other reason to leave this component inside `App` in comparison to other `NewAppScreen` components,
* If this assumption is false, I can adjust this PR and move `HermesInternal` check from the badge component to the `App`.

I was trying to avoid calling `useColorScheme` when Hermes is disabled, but placing hook inside the conditional branch causes ESLint warning (react-hooks/rules-of-hooks).

This PR includes also small style tweaks for the badge - since there are no background padding can be omitted and spacing can be added adjusted tweaking `top` and `left` properties and `fontSize` has been adjusted just for the readability.

In the last commit, I have gone a bit further and moved `HermesBadge` to the `Header` component and I have also changed slightly the `Header` title (React -> React Native) and it's styling.
> I'm not sure if after this change `HermesBadge` export in `NewAppScreen` components list is still required, but maybe this badge will be useful for someone. If it's a mistake I can update the PR and remove this export.

## Changelog

[Internal][Changed] move Hermes badge from the template to the NewAppScreen library

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

Test Plan:
Template app do not redbox on Android emulator with and without Hermes enabled.

## Preview
Android with Hermes enabled and adjusted header:

![Screenshot_1588164908](https://user-images.githubusercontent.com/719641/80599357-16dc8900-8a2b-11ea-8b3e-9a2cb26d3470.png)

iOS with adjusted header:

![IMG_6551](https://user-images.githubusercontent.com/719641/80599445-3bd0fc00-8a2b-11ea-8215-318625ddad13.PNG)

Reviewed By: GijsWeterings

Differential Revision: D22493822

Pulled By: cpojer

fbshipit-source-id: 3440e10f2d59f268ca8851a6e002f0ff23fa839c
2020-07-14 06:29:00 -07:00
Vince Picone 4a97791341 Fix eslint-plugin README.md (#29337)
Summary:
The `eslint-plugin` package intent notice at the top of the README mistakenly refers to itself, it should instead refer to `react-native-community/eslint-config`

## Changelog
[Internal] [Fixed] - Fix typo in `eslint-plugin` README

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

Test Plan: 1. ensure link works properly

Reviewed By: GijsWeterings

Differential Revision: D22493834

Pulled By: cpojer

fbshipit-source-id: 16b8173d3c2add7a85e142eac4ab36aef685062b
2020-07-14 06:07:39 -07:00
Samuel Susla 0060b5de55 Introducing LayoutableShadownode::getContentOriginOffset and use it in ScrollView
Summary:
Changelog: [Internal]

When calling "measure" on ScrollView's children, origin needs to be adjusted for ScrollView's content offset.
For this scrollView uses `getTransform` to adjust frames of its children.

This is wrong because transform is applied to ScrollView as well.

Example:
ScrollView is scrolled 900 points and its origin is {0, 0}, if you call "measure" on the ScrollView, our current measure infra will report its origin being {0, 900}.

Reviewed By: shergin

Differential Revision: D22456266

fbshipit-source-id: 6fd54661305ad46def8ece93fcf61d66817b3e01
2020-07-13 06:00:00 -07:00
Ankit Tiwari f898bb65fa Fix alert screen crash in android in RNTester app (#29150)
Summary:
fixes - https://github.com/MLH-Fellowship/react-native/issues/21

[Reviewed by jevakallio](https://github.com/MLH-Fellowship/react-native/pull/22)

## Changelog

Before:

![image](https://user-images.githubusercontent.com/22813027/84471321-ba63bf00-aca2-11ea-92c0-3b43a8bdd28a.png)

After:

<img width="305" alt="Screenshot 2020-06-12 at 11 49 31 AM" src="https://user-images.githubusercontent.com/22813027/84471351-c8b1db00-aca2-11ea-9844-2b06da36e590.png">
Pull Request resolved: https://github.com/facebook/react-native/pull/29150

Test Plan:
1. Run the RNTester app locally on both android and iOS.
2. Open the Alert API screen.
3. Alert examples should be visible and functional in both android and iOS.

Screenshot for both android and iOS screens-

<img width="688" alt="Screenshot 2020-06-12 at 11 52 21 AM" src="https://user-images.githubusercontent.com/22813027/84471544-2d6d3580-aca3-11ea-9142-5f31a3daaf4e.png">

Reviewed By: cpojer

Differential Revision: D22067670

Pulled By: rickhanlonii

fbshipit-source-id: e7c43b77a30ae2e258303ce84f7fc4dee63776e6
2020-07-12 19:57:12 -07:00
makitake2013 320398afe5 Test fixes related to changes in Jest's Fake Timer behavior (#29011)
Summary:
Fixed tests related to changing Jest's fake timer behavior.
And some of the test code in LogBoxData-test.js itself was incorrect so I am fixing it.

LogBoxData-test.js fails when I try to build a new local development environment and fork the React Native source to run a JavaScript test.
The error message is:
runAllImmediates is not available when using modern timers

After checking, runAllImmediates could not be used with the following modification.
https://github.com/facebook/jest/commit/71631f6bf9ccf8937f02a5ecfb64b62712b86c19

## Changelog

[Internal] [Fixed] - Test fixes related to changes in Jest's Fake Timer behavior

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

Test Plan: Ran JavaScript Tests locally.

Reviewed By: cpojer

Differential Revision: D22494991

Pulled By: rickhanlonii

fbshipit-source-id: 4deeaf82b5092ff8b60c4606eb45549beb452a5f
2020-07-12 00:28:53 -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
Rick Hanlon 8e6e83be0c Switch to react-shallow-renderer
Summary:
Replace react-test-renderer/shallow with react-shallow-renderer.

We should follow up with teams to remove these tests because they will no longer be supported. I would have just removed them but test like `BillingReauthorizeCreditCardContainer-test` seem important.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D22225642

fbshipit-source-id: a6bd559311422cb14576a574165ed7dc0279919d
2020-07-10 14:06:38 -07:00
Dan Abramov ac87e90fa5 Update React Hooks rule
Summary:
Includes better support for optional chaining.

Changelog:
[General][Changed] - Updated the React Hooks ESLint Plugin

Reviewed By: rickhanlonii, trueadm

Differential Revision: D22479305

fbshipit-source-id: 08740449ea797ce0971ccae358eb7de1ae102d7d
2020-07-10 13:28:30 -07:00
Héctor Ramos 120ff7ccde Disable Detox tests on Circle CI (#29329)
Summary:
Disabling Detox tests on Circle CI as the `test_ios_detox*` tests have been broken for a while.

Changelog:
[Internal]

Test Plan: Verified these no longer trigger on Circle CI

Reviewed By: cpojer

Differential Revision: D22476861

Pulled By: hramos

fbshipit-source-id: 3d46786cd7d088d363409e4d35a327e3e997a227
2020-07-10 07:15:29 -07:00
Samuel Susla 34ff9b7259 Add view hierarchy drawings to tests
Summary:
Changelog: [Internal]

Add view hierachy drawings to tests to make it easier to picture view hierarchy.
The sketches do not reflect sizing but relationship among the views.
I removed unnecessary reset of transform value to identity matrix.

Reviewed By: JoshuaGross, shergin

Differential Revision: D22456267

fbshipit-source-id: 480d0b938ffd0281fc94148570c412b0fcc22f42
2020-07-10 02:11:44 -07:00
David Vacca d5bc0a7bff Fix inconsistency on AndroidTextInput view configs
Summary:
BubblingEventTypes are inconsistent between AndroidTextInputViewConfig.js and ReactTextInputManager.java, this diff fixes this inconsistency

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D22470096

fbshipit-source-id: 3940dcc0ae67a42ac070c06ec2d54bc365eab6b7
2020-07-09 22:20:53 -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
Ramanpreet Nara e549f6984e Gate TurboModule eager initialization
Summary:
TurboModule eager initialization is a bit dangerous if we get it wrong, which we did (twice): T69449176.

This diff gates TurboModule eager init behind a MC, so that we can control (i.e: turn off/on, and do gradually rollout of) TurobModule eager initialization in isolation from the larger TurboModules experiment.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22460359

fbshipit-source-id: 3b8dce0529f1739bd68b8b16d6a28aa572d82c2c
2020-07-09 16:24:31 -07:00
Tim Yung caf010914c RN: Remove fbjs/performanceNow Dependency
Summary:
Replaces `fbjs/performanceNow` call sites in React Native with `performance.now`.

We did not originally polyfill this in `InitializeCore`, but now we do (and back it with a proper `nativePerformanceNow` implementation). Also, added the missing polyfill to our Jest setup.

Changelog:
[Internal]

Reviewed By: cpojer

Differential Revision: D22445948

fbshipit-source-id: dcfd9867c050617f6e2a3d0a1eb6f48a44771dda
2020-07-09 11:40:57 -07:00
Tim Yung ae193942fe RN: Remove fbjs/{keyMirror,keyOf} Dependencies
Summary:
Removes `fbjs/keyMirror` and `fbjs/keyOf` call sites from React Native.

Changelog:
[Internal]

Reviewed By: cpojer

Differential Revision: D22438238

fbshipit-source-id: 0f84b6e9d81811f95a2a24886f38ad16b8e6e74f
2020-07-09 11:40:57 -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
Rick Hanlon f28c7505fa Fix LogBox.ignoreAllLogs used with no argument (#29310)
Summary:
When you call `LogBox.ignoreAllLogs()` it should ignore logs.

This fixes a bug that made this equivalent to `LogBox.ignoreAllLogs(false)`

## Changelog

[General] [Fixed] - LogBox.ignoreAllLogs() should ignore logs

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

Test Plan: Added tests

Reviewed By: TheSavior

Differential Revision: D22448436

Pulled By: rickhanlonii

fbshipit-source-id: 6ba12b9d9c1f29cf3ac503946ac5ca0097425a7a
2020-07-08 18:51:58 -07:00
Eloy Durán ffa3d7f638 Build macOS framework and add CocoaPods podspec (#285)
Summary:
Supersedes https://github.com/facebook/hermes/issues/239

Currently used in our macOS fork of React Native https://github.com/microsoft/react-native-macos/pull/473. (Although we’re using a build of Hermes v0.4.1, as we’re at RN 0.62.0.)

* On Apple platforms build a [dynamic] framework bundle when `HERMES_BUILD_APPLE_FRAMEWORK` is set. When set to `FALSE` it will produce a `dylib`, like previously. Defaults to `TRUE`.
* On Apple platforms create a debugging symbols bundle.
* Add `HERMES_ENABLE_FUZZING`, which is enabled by default.
* Add `HERMES_ENABLE_TEST_SUITE`, which is enabled by default.
* Add a CocoaPods podspec that can build from source or use a binary.

A standalone macOS app that pulls in Hermes as a CocoaPods pod can be found here https://github.com/alloy/TestHermesMaster.

## Framework variant (default)

```
$ ./src/utils/build/configure.py --distribute --cmake-flags='-DCMAKE_INSTALL_PREFIX:PATH=../destroot_release' build
$ cd build && ninja install && cd ..
$ tree destroot_release/
destroot_release/
├── Library
│   └── Frameworks
│       ├── hermes.framework
│       │   ├── Headers -> Versions/Current/Headers
│       │   ├── Resources -> Versions/Current/Resources
│       │   ├── Versions
│       │   │   ├── 0
│       │   │   │   ├── Headers
│       │   │   │   │   ├── CompileJS.h
│       │   │   │   │   ├── DebuggerAPI.h
│       │   │   │   │   ├── Public
│       │   │   │   │   │   ├── Buffer.h
│       │   │   │   │   │   ├── CrashManager.h
│       │   │   │   │   │   ├── CtorConfig.h
│       │   │   │   │   │   ├── DebuggerTypes.h
│       │   │   │   │   │   ├── GCConfig.h
│       │   │   │   │   │   ├── GCTripwireContext.h
│       │   │   │   │   │   └── RuntimeConfig.h
│       │   │   │   │   ├── SynthTrace.h
│       │   │   │   │   ├── SynthTraceParser.h
│       │   │   │   │   ├── TraceInterpreter.h
│       │   │   │   │   ├── TracingRuntime.h
│       │   │   │   │   ├── hermes.h
│       │   │   │   │   └── hermes_tracing.h
│       │   │   │   ├── Resources
│       │   │   │   │   └── Info.plist
│       │   │   │   └── hermes
│       │   │   └── Current -> 0
│       │   └── hermes -> Versions/Current/hermes
│       └── hermes.framework.dSYM
│           └── Contents
│               ├── Info.plist
│               └── Resources
│                   └── DWARF
│                       └── hermes
├── bin
│   ├── hbcdump
│   ├── hdb
│   ├── hermes
│   ├── hermesc
│   └── hvm
└── include
    ├── hermes
    │   ├── CompileJS.h
    │   ├── DebuggerAPI.h
    │   ├── Public
    │   │   ├── Buffer.h
    │   │   ├── CrashManager.h
    │   │   ├── CtorConfig.h
    │   │   ├── DebuggerTypes.h
    │   │   ├── GCConfig.h
    │   │   ├── GCTripwireContext.h
    │   │   └── RuntimeConfig.h
    │   ├── SynthTrace.h
    │   ├── SynthTraceParser.h
    │   ├── TraceInterpreter.h
    │   ├── TracingRuntime.h
    │   ├── hermes.h
    │   └── hermes_tracing.h
    └── jsi
        ├── JSIDynamic.h
        ├── decorator.h
        ├── instrumentation.h
        ├── jsi-inl.h
        ├── jsi.h
        ├── jsilib.h
        └── threadsafe.h
```

# dylib variant

```
$ ./src/utils/build/configure.py --distribute --cmake-flags='-DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=false -DCMAKE_INSTALL_PREFIX:PATH=../destroot_release' build
$ cd build && ninja install && cd ..
$ tree destroot_release/
destroot_release/
├── bin
│   ├── hbcdump
│   ├── hdb
│   ├── hermes
│   ├── hermesc
│   └── hvm
├── include
│   ├── hermes
│   │   ├── CompileJS.h
│   │   ├── DebuggerAPI.h
│   │   ├── Public
│   │   │   ├── Buffer.h
│   │   │   ├── CrashManager.h
│   │   │   ├── CtorConfig.h
│   │   │   ├── DebuggerTypes.h
│   │   │   ├── GCConfig.h
│   │   │   ├── GCTripwireContext.h
│   │   │   └── RuntimeConfig.h
│   │   ├── SynthTrace.h
│   │   ├── SynthTraceParser.h
│   │   ├── TraceInterpreter.h
│   │   ├── TracingRuntime.h
│   │   ├── hermes.h
│   │   └── hermes_tracing.h
│   └── jsi
│       ├── JSIDynamic.h
│       ├── decorator.h
│       ├── instrumentation.h
│       ├── jsi-inl.h
│       ├── jsi.h
│       ├── jsilib.h
│       └── threadsafe.h
└── lib
    ├── libhermes.dylib
    └── libhermes.dylib.dSYM
        └── Contents
            ├── Info.plist
            └── Resources
                └── DWARF
                    └── libhermes.dylib
```

Pull Request resolved: https://github.com/facebook/hermes/pull/285

Reviewed By: willholen

Differential Revision: D22398354

Pulled By: mhorowitz

fbshipit-source-id: 732524275cf273866171fc6e2ac2acb062185fbd
2020-07-08 17:15:09 -07:00
Jordan Brown a5151c2b5f Deploy 0.129 to xplat/js
Summary:
Changelog: [Internal]

Deploy 0.129 to xplat
allow-large-files

Reviewed By: dsainati1

Differential Revision: D22439823

fbshipit-source-id: 60edf32abcb6e134363cee9ec9b23657a8fe0fae
2020-07-08 15:31:36 -07:00
Ramanpreet Nara e206e34175 Add a warning if TurboModule init uses dispatch_sync for main queue
Summary:
When you require a TurboModule on thread that isn't the main thread, but the TurboModule requires main queue setup, we are forced to `dispatch_sync` the set up to the main queue. This is hazardous, because it can lead to deadlocks. Therefore, I'm migrating over a warning from the legacy infra that warns against this use-case.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D21654637

fbshipit-source-id: 99dc45708c533603d2111fe6163d40e807d2a513
2020-07-08 11:49:32 -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
Ramanpreet Nara e96f1e1d83 Refactor: Attach TurboModuleRegistry to bridge in FBReactModule
Summary:
The changes in this diff are inconsequential. Just thought it was weird that TurboModuleManager was responsible for assigning itself to the bridge. Seems like that should be done by an entity that owns both the bridge and the TurboModuleManager.

Changelog:
[Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22406172

fbshipit-source-id: cb32f097f4d377a3b85a6d165b7b06be8e6a185b
2020-07-07 16:25:11 -07:00
Ramanpreet Nara a27c295f53 Rename RCTTurboModuleLookupDelegate to RCTTurboModuleRegistry
Summary:
## Why?
1. RCTTurboModuleLookupDelegate sounds a bit nebulous.
2. In JS and Java, we use a `TurboModuleRegistry` interface to require TurboModules. So, this diff will make JS, Java, and ObjC consistent.

Changelog:
[Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22405754

fbshipit-source-id: 30c85c246b39d198c5b8c6ca4432a3196ca0ebfd
2020-07-07 16:25:11 -07:00
Ramanpreet Nara 103c863eaa Eagerly initialize TurboModules before executing JS bundle
Summary:
## Context
1. In FBReactModule jsExecutorForBridge, we asynchronously initialize a list of TurboModules on the main queue: https://fburl.com/diffusion/i56wi3px
2. After initializing the bridge, we start executing the JS bundle, here: https://github.com/facebook/react-native/blob/e23e9328aa164d0a70fe4f16042c982e7801d924/React/CxxBridge/RCTCxxBridge.mm#L414-L417. Since bridge initialization knows nothing about TurboModule eager initialization, this happens concurrently with 1, and starts requiring NativeModules/TurboModules on the JS thread.

## The Race
1. Both the main thread and the JS thread race to create a TurboModule that requires main queue setup.
2. The JS thread wins, and starts creating the TurboModule. Meanwhile, the main thread blocks, waiting on a signal here, in RCTTurboModuleManager: https://github.com/facebook/react-native/blob/e23e9328aa164d0a70fe4f16042c982e7801d924/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm#L430
3. The JS thread tries to dispatch_sync to the main queue to setup the TurboModule because the TurboModule requires main queue setup, here: https://github.com/facebook/react-native/blob/e23e9328aa164d0a70fe4f16042c982e7801d924/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm#L402
4. We deadlock.

## The fix
Succinctly, NativeModule eager initialization finishes before execute the JS bundle, but TurboModule initialization doesn't. This diff corrects that mistake.

The changes in this diff:
1. The RN application via the TurboModuleManager delegate can now optionally provide the names of all eagerly initialized TurboModules by implementing two methods `getEagerInitModuleNames`, `getEagerInitMainQueueModuleNames`.
2. The TurboModuleManager grabs these two lists from the delegate, and exposes them to its owner via the `RCTTurboModuleRegistry` protocol.
3. The RCTCxxBridge, which already owns a `id<RCTTurboModuleRegistry>` object, uses it to eagerly initialize the TurboModules in these two lists with the correct timing requirements.

This is exactly how we implement eager initialization in Android.

**Note:** Right now, phase one and two of TurboModule eager initialization happen after phase one and two of NativeModule eager initialization. We could make the timing even more correct by initializing the TurboModules at the exact same time we initialize the NativeModules. However, that would require a bit more surgery on the bridge, and the bridge delegate. I think this is good enough for now.

Changelog:
[iOS][Fixed] - Fix TurboModule eager init race

Reviewed By: PeteTheHeat

Differential Revision: D22406171

fbshipit-source-id: 4715be0bceb478a8e4aa206180c0316eaaf287e8
2020-07-07 16:25:10 -07:00
Ramanpreet Nara 5c24746a48 Correct JSRequireEnding marker start in RCTModuleData gatherConstants
Summary:
`RCTModuleData gatherConstants` is [used by `RCTModuleData exportedConstants` to compute and return the constants exported to JS](https://fburl.com/diffusion/ssg4jbeu). However, `RCTModuleData gatherConstants` is also [used by `RCTCxxBridge` to pre-compute NativeModule constants during bridge startup](https://fburl.com/diffusion/nfmjc1ke). Therefore, since `RCTModuleData gatherConstants` can be used outside the context of a JS require, we cannot start the JSRequireEnding marker inside `RCTModuleData gatherConstants` directly.

This diff moves the body of `RCTModuleData gatherConstants` into `gatherConstantsAndSignalJSRequireEnding:(BOOL)startMarkers`:
 - `RCTModuleData gatherConstants` calls `RCTModuleData gatherConstantsAndSignalJSRequireEnding:NO`
 - `RCTModuleData exportedConstants` calls `RCTModuleData gatherConstantsAndSignalJSRequireEnding:YES`. **Note:** This is okay, because `RCTModuleData exportedConstants` is only called inside `RCTNativeModule::getConstants()`.

This should make sure that we don't start the JSRequireEnding marker outside of a JS require.

Reviewed By: PeteTheHeat

Differential Revision: D22371889

fbshipit-source-id: de17b857259572fb0f840a22072a16b5e465cabd
2020-07-07 15:33:49 -07:00
Joshua Gross 90287ca536 Make ShadowTreeRegistry remove API safer
Summary:
Currently the `remove` API returns an owned unique_ptr of the removed ShadowTree but it's not used anywhere, so we can simplify the API.

Because of that change, we can make the API safe even if the SurfaceId has already been removed.

For context, on Android there is a race between RootView.unmountReactApplication and C++ teardown which removes all SurfaceIds. This currently causes a crash, but after this diff the 2nd call to `remove` for a given SurfaceId will noop.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D22416471

fbshipit-source-id: dbba44c276aab8e81097b92a89e0becdcb7b28ba
2020-07-07 13:01:47 -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
Valentin Shergin f2fdc1a5df Fabric: Simplifying RCTPerformMountInstructions
Summary:
This diff inlines all mount-instruction functions into a single one - RCTPerformMountInstructions.
The main purpose is to reduce the number of calls to `RCTComponentViewRegistry` for some instructions. E.g., before the change, the `Insert` (or `Update`) instruction had seven identical calls to the registry. That's not a huge deal but there is no need to pay for it either. Maybe it can save us a couple of milliseconds during TTI.

The code of those functions is quite straight-forward, so this change probably even improves readability.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22402987

fbshipit-source-id: 043a4114ba42622e9ed226f4d5e41ed45c1b066c
2020-07-07 12:01:56 -07:00
Valentin Shergin e23e9328aa Fabric: Geometry.h is spit to several separate files
Summary:
We are about to add several additional functions to this file, so we need to split it to keep it manageable. All changes in this diff are cosmetical.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22384429

fbshipit-source-id: d22592fba17ef04edb44388b4e1ff22112e9c020
2020-07-06 20:57:46 -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
Jiayan Zhuang ac0f4b42c5 Add additional accessibilityElements for embedded links
Summary:
Changelog:
[Internal] - Add the additional accessibilityElement for embedded links

Reviewed By: sammy-SC

Differential Revision: D22296547

fbshipit-source-id: 286cd3cb19d288d584ecd94a8201a28851ca042f
2020-07-06 15:00:58 -07:00
Jiayan Zhuang c4c6204029 Add accessibilityRole to RCTAttributedTextUtils
Summary:
Changelog:
[Internal] - Add `accessibilityRole` to `RCTAttributedTextUtils`. AccessibilityRole was in `TextAttributes` which is a Fabric's abstraction so cannot be detected when enumerating attributedString.  Mapping accessibilityRole from `TextAttributes` to `NSAttributedString` could provide the attributeName when iterating over attributedString and then successfully find the range of the fragment whose `accessibilityRole` has value @"link".

Reviewed By: shergin

Differential Revision: D22286747

fbshipit-source-id: eb039d6a35e77d1860f86ba287391ccb56fbe7b5
2020-07-06 15:00:58 -07:00
Jiayan Zhuang 96708d58e4 Add getRectWithAttributedString() to RCTTextLayoutManager
Summary:
Changelog:
[iOS][Added] - `getRectWithAttributedString()` aims to get the rect of the fragment with embedded link, which is necessary when building the `accessibilityElement`. In this function, we first enumerate attributedString to find the range of fragments whose `accessibilityRole` is @"link". Then we calculate the rect of the fragment and send to the block and we would define what to do in the block in `RCTParagraphComponentAccessibilityProvider`.

Reviewed By: shergin

Differential Revision: D22286733

fbshipit-source-id: 4d11cb54375a4e9e72869e646fcb484de089b14b
2020-07-06 15:00:58 -07:00