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

19955 Коммитов

Автор SHA1 Сообщение Дата
Vojtech Novak bd3868643d add ripple config object to Pressable (#28156)
Summary:
Motivation is to support ripple radius just like in TouchableNativeFeedback, plus borderless attribute. See https://github.com/facebook/react-native/pull/28009#issuecomment-589489520

In the current form this means user needs to pass an `android_ripple` prop which is an object of this shape:
```
export type RippleConfig = {|
  color?: ?ColorValue,
  borderless?: ?boolean,
  radius?: ?number,
|};
```
Do we want to add methods that would create such config objects - https://facebook.github.io/react-native/docs/touchablenativefeedback#methods ?

## Changelog

[Android] [Added] - support borderless and custom ripple radius on Pressable
Pull Request resolved: https://github.com/facebook/react-native/pull/28156

Test Plan:
Tested locally in RNTester. I noticed that when some content is rendered after the touchables, the ripple effect is "cut off" by the boundaries of the next view. This is not specific to Pressable, it happens to TouchableNativeFeedback too but I just didn't notice it before in https://github.com/facebook/react-native/pull/28009. As it is an issue of its own, I didn't investigate that.

![pressable](https://user-images.githubusercontent.com/1566403/75098762-785f2200-55ba-11ea-8842-e648317610e3.gif)

I changed the Touchable example slightly too (I just moved the "custom ripple radius" up to show the "cutting off" issue), so just for completeness:

![touchable](https://user-images.githubusercontent.com/1566403/75098763-81e88a00-55ba-11ea-9528-e0343d1e054b.gif)

Reviewed By: yungsters

Differential Revision: D20071021

Pulled By: TheSavior

fbshipit-source-id: cb553030934205a52dd50a2a8c8a20da6100e23f
2020-04-03 18:37:10 -07:00
Ramanpreet Nara 21733641a8 Make TurboModules dispatch method calls via native CallInvoker
Summary:
This diff:
1. Has ObjC NativeModules use the native `CallInvoker` to invoke JS -> native sync/async calls.
2. Integrates the native `CallInvoker` for each ObjC NativeModule with the bridge. This way, the bridge is informed of all JS -> native TurboModule method calls, and dispatches `onBatchComplete` appropriately.

Changelog:
[iOS][Fixed] Integrate ObjC TurboModules async method calls with the bridge

Reviewed By: fkgozali

Differential Revision: D20831545

fbshipit-source-id: da1cbb4ecef4cae85841ca7ef625ab8e380760cd
2020-04-03 17:57:20 -07:00
Kacie Bawiec 3246f68952 Remove console warnings for innerViewNode/Ref
Summary:
Remove these warnings until the methods in ScrollResponder have been moved into ScrollView, so that unactionable warnings aren't firing.

Changelog:
[General][Removed] Remove console warnings for innerViewNode/Ref in ScrollView

Reviewed By: TheSavior

Differential Revision: D20850624

fbshipit-source-id: ce90988e204c3cc3b93536842ec3caa12cf6994e
2020-04-03 17:52:08 -07:00
Héctor Ramos 5c086b4e11 Rename ScrollViewSimpleExample
Summary:
Changelog:
[Internal] - Rename ScrollViewSimpleExample in RNTester

Reviewed By: fkgozali

Differential Revision: D20846977

fbshipit-source-id: 397589cb0a17beaf37a25b91ad8efa4a2bc62358
2020-04-03 17:07:48 -07:00
Eli White 8824955da9 Bump react-native-codegen to 0.0.2
Summary: Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D20843514

fbshipit-source-id: c611bf91d311c6ce8a7e469d267a0417b2ee58e5
2020-04-03 16:35:06 -07:00
Daniel Cohen Gindi fb2900e185 Fixed scrollview inset when RN view is embedded in another view (#27607)
Summary:
I'm using RNN, which embeds RN view inside native view controllers.

On iOS 13, a modal view controller is "floating" and is offset from the top of the screen.

This causes the calculation of inset in `KeyboardAvoidingView` incorrect as it mixes local view controller coordinate space, with keyboard's screen coordinate space.

## Changelog

[iOS] [Fixed] - Fixed `KeyboardAvoidingView` inset in embedded views (i.e modal view controllers on iOS 13)
Pull Request resolved: https://github.com/facebook/react-native/pull/27607

Test Plan:
1. Tested before and after in a simple view controller (should stay the same)
2. Tested before and after in a modal view controller (should be offset before, and fixed after)
3. Repeated no. 2 with each device rotation (upsideDown, landscapeLeft, landscapeRight)

Reviewed By: cpojer

Differential Revision: D20812231

Pulled By: TheSavior

fbshipit-source-id: fbd72739fb7152655028730e284ad26ff4a5da73
2020-04-03 16:09:37 -07:00
Joshua Gross 5c4425a456 Fix Fabric SSTs, so they actually run in Fabric instead of Paper, convert ServerSnapshotTestsAppImpl to functional component
Summary:
Update instrumentation test infra for Fabric tests.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D19961919

fbshipit-source-id: 17264b6308712dddece730effd57832817e148cf
2020-04-03 14:04:51 -07:00
Pavlos Vinieratos fb89730e66 Rename duplicate name `<ScrollView>` example on RNTester (#28515)
Summary:
Tiny change. When searching for `scro` in the RNTester, two `<ScrollView>`s come up, from different example files. One is the "simple" one and the other is the "regular" one.

Before:
<img width="370" alt="Screen Shot 2020-04-03 at 17 14 01" src="https://user-images.githubusercontent.com/100233/78377338-c6ab0c00-75cf-11ea-9c45-2dcdd6460f6d.png">

After:
<img width="369" alt="Screen Shot 2020-04-03 at 17 13 38" src="https://user-images.githubusercontent.com/100233/78377371-cf034700-75cf-11ea-89ea-aa3ff2f3988c.png">

## Changelog

[Internal] [Changed] - Rename the "simple" ScrollView example in RNTester to "ScrollSimpleView".
Pull Request resolved: https://github.com/facebook/react-native/pull/28515

Test Plan: - Try to search for `scro` in RNTester.

Reviewed By: fkgozali

Differential Revision: D20842264

Pulled By: hramos

fbshipit-source-id: 3db54a826ae774108e62690e7f154e85b541520f
2020-04-03 12:43:34 -07:00
Ramanpreet Nara 553729f3d6 Create method queues for NativeModules that neither provide nor request one
Summary:
## Problem:
Let `A` be the set of all ObjC NativeModules that neither provide nor reqeust a method queue.

The TurboModule system dispatches all method calls to NativeModules in `A` synchronously to the JS thread. Here is the relevant logic:

**RCTTurboModule.mm:**
Link: https://fburl.com/diffusion/nz9gqje8
```
jsi::Value performMethodInvocation(
  // ...
)
{
  // ...

  dispatch_queue_t methodQueue = NULL;
  if ([instance_ conformsToProtocol:protocol(RCTBridgeModule)] &&
      [instance_ respondsToSelector:selector(methodQueue)]) {
    methodQueue = [instance_ performSelector:selector(methodQueue)];
  }

  if (methodQueue == NULL || methodQueue == RCTJSThread) {
    // This is the default mode of execution: on JS thread.
    block();
  } else if (methodQueue == dispatch_get_main_queue()) {

```

**Why does this end up happening?**
1. NativeModules that request a method queue have `synthesize methodQueue = _methodQueue` in their `implementation` section. This generates a `methodQueue` getter for the NativeModule, and also creates an ivar to back that getter. The TurboModule system generates a `dispatch_queue_t` and uses ObjC's KVC API to write to the ivar. So in the above logic, for NativeModules that provide a method queue, methodQueue will neither be `NULL` nor `RCTJSThread`, so we don't dispatch synchronously to the JS thread.
2. NativeModules that provide a method queue will return something that is not `NULL` or something that is `RCTJSThread`. If they return `NULL`, the infra will throw an error early. If they return `RCTJSThread`, we'll dispatch synchronously to the JS thread, as we should (...wait. For async NativeModule methods that dispatch to `RCTJSThread`, should we dispatch asynchronously to the JS thread, via jsInvoker? **Edit:** Nope: https://fburl.com/diffusion/ivt9b40s.). In all other cases, we dispatch to appropriately to the respective method queue.
3. For NativeModules that neither provide nor request a method queue (i.e: NativeModules in `A`), they don't implement the `methodQueue` selector. Therefore, we dispatch synchronously to the JS thread.

## The fix (Part 1):
The first step towards fixing this problem is to generate `dispatch_queue_t`s for NativeModules in `A`.

That's what this diff accomplishes.

Changelog:
[iOS][Fixed] - Create method queue for NativeModules that don't provide nor request one.

Reviewed By: fkgozali

Differential Revision: D20821054

fbshipit-source-id: 17a73550ad96766c5c7e719e28e1cc879e36465c
2020-04-03 12:28:43 -07:00
Cristiano Santos f9df93385e Fixes iOS reload through metro "r" command key (#28477)
Summary:
This allows the iOS device to be reloaded through the metro command line, besides the fact that whenever packagerServerHost is called, it will only get the IP address once when debugging.

## Changelog

[iOS] [Fixed] - Fixed connection of metro reload command to iOS device
Pull Request resolved: https://github.com/facebook/react-native/pull/28477

Test Plan:
- Build any react-native project in debug mode to an iOS device connected through USB
- Press the “r” key on the terminal that is running metro
- The device should now reload the project

Reviewed By: cpojer

Differential Revision: D20818462

Pulled By: TheSavior

fbshipit-source-id: 6d9792447d205223dad8fbd955518885427cbba8
2020-04-03 12:11:16 -07:00
Héctor Ramos 25836bc239 Upgrade tests to Xcode 11.3.1 (#28498)
Summary:
Upgrade Sandcastle and Circle CI tests to use Xcode 11.3.1 across the board.

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

Changelog:
[Internal] - Use Xcode 11.3.1 in iOS tests

Reviewed By: fkgozali

Differential Revision: D20821844

fbshipit-source-id: b250ca82bdf2c9fb7faa765d3e2433eb46efd692
2020-04-03 11:56:21 -07:00
Pavlos Vinieratos 74ee32c77e Make the link easier to copy. (#28516)
Summary:
Making a PR from GitHub, I need to copy-paste the link, and it would be easier to just triple-click a line with the URL rather than carefully selecting the URL from the text.

<img width="723" alt="Screen Shot 2020-04-03 at 17 33 47" src="https://user-images.githubusercontent.com/100233/78378550-6c12af80-75d1-11ea-93a4-2eae568ce602.png">

## Changelog

[General] [Changed] - Make PR template easier to use with changelog URL.
Pull Request resolved: https://github.com/facebook/react-native/pull/28516

Reviewed By: fkgozali

Differential Revision: D20842238

Pulled By: hramos

fbshipit-source-id: 3fef7a994f36a996bbbc52556600d468a56210a9
2020-04-03 11:52:35 -07:00
Jesse Katsumata cb1bdd648d docs: add README and specify file in package.json (#28507)
Summary:
Adding a README for `react-native-codegen` since the package was published.
Also added a `files` prop in package.json so unused file won't be included in the package.

## Changelog

[Internal] [Changed] - Add README for react-native-codegen.
Pull Request resolved: https://github.com/facebook/react-native/pull/28507

Test Plan: verify js files to function correctly without including files other than `src`

Reviewed By: rickhanlonii

Differential Revision: D20836113

Pulled By: cpojer

fbshipit-source-id: e860f14760e9c1dbe121f5fb95ccf72d4ddb2af1
2020-04-03 11:34:58 -07:00
Héctor Ramos f9c2157141 Add Author Feedback label automatically (#28484)
Summary:
Improve issue triage by automatically adding the "Needs: Author Feedback" label.

NOTE: The old label-actions app should be disabled when this PR is merged: https://github.com/apps/label-actions/installations/7445225

## Changelog

[Internal] - Issue Triage
Pull Request resolved: https://github.com/facebook/react-native/pull/28484

Test Plan: Verified the same `label-actions.yml` and workflow config on a private repo.

Reviewed By: cpojer

Differential Revision: D20817443

Pulled By: hramos

fbshipit-source-id: 39732dd67509c9fb9cf6ff7306913f5ec088266d
2020-04-03 10:52:31 -07:00
Ramanpreet Nara aef0ef4b31 Export Instance::getDecoratedNativeCallInvoker from RCTCxxBridge
Summary:
`RCTTurboModuleManager` will create a native `CallInvoker` for each ObjC NativeModule. This `CallInvoker` will be used to dispatch calls from JS to native. Before passing the native `CallInvoker` to the `ObjCTurboModule`, it'll first use `RCTCxxBridge decorateNativeCallInvoker` to get a bridge-aware decorated native `CallInvoker`. That way, the bridge remains informed about async TurboModule method calls that took place since the last time it was flushed. This ensures that we don't end up dispatching `onBatchComplete` any less with TurboModules on than we do with TurboModules off.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D20831546

fbshipit-source-id: b2eb4e0097e0dabf8c4bd8fdc4c850a0858af699
2020-04-03 09:47:42 -07:00
Ramanpreet Nara de56649430 Add CallInvoker::invokeSync
Summary:
We'll be using a native CallInvoker to dispatch sync and async method calls to ObjC NativeModules. This native CallInvoker will hold a reference to the ObjC NativeModule's method queue.

**Why is the native CallInvoker required for ObjC NativeModules?**
In the case where the ObjC NativeModule neither provides nor requests a method queue, we must create a method queue for it. When we go to invoke a method from JS, for these NativeModules specifically, there is no way to access this method queue. A native CallInvoker is a convenient abstraction that holds on to that method queue. For async calls, we'll just call `CallInvoker::invokeAsync`, and for sync calls, we'll just call `CallInvoker::invokeSync`.

**Why do we need sync call support for native `CallInvoker`?**
In ObjC, sync NativeModule method calls block the JS thread, then execute synchronously on the NativeModule's method queue, and then unblock the JS thread. This is what'll be implemented by `CallInvoker::invokeSync`.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D20829955

fbshipit-source-id: efb9d5408a1ade81069a943c865f232d4d10acfe
2020-04-03 09:47:42 -07:00
Ramanpreet Nara eb4e2baaa9 Rename Instance::getNativeCallinvoker to Instance::getDecoratedNativeCallInvoker
Summary:
Now, instead of accepting a `std::function` that schedules work, and returning a `CallInvoker`, `Instance::getDecoratedNativeCallInvoker`  will accept a `CallInvoker` that schedules work, and return a decorated `CallInvoker`.

I think this change will help with readability. It also clarifies that the bridge is adding additional behaviour to the native `CallInvoker`.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20826885

fbshipit-source-id: a2c5681d10a4544ee3d2a0d1f1cbd386ef06d0e6
2020-04-03 09:47:41 -07:00
Jesse Katsumata 83fee73ae6 eslint-config: add version badge and add homepage for eslint-config (#28506)
Summary:
Add version badge to README of eslint-config, and add specific url for the homepage so people looking at the npm package can find out where the package is from.

## Changelog

[Internal] [Changed] - Add version badge to README of eslint-config
Pull Request resolved: https://github.com/facebook/react-native/pull/28506

Test Plan: Not required as the only changes are made in README and homepage prop of package.json

Differential Revision: D20837085

Pulled By: cpojer

fbshipit-source-id: 820d3b44b069780ec8764c6152d2e7fd5220933c
2020-04-03 06:40:22 -07:00
Ramanpreet Nara 3a11f0536e Make RCTTurboModuleManagerDelegate getTurboModule accept native CallInvoker and PerfLogger
Summary:
Might be worthwhile to just kill this method instead, since we're having all NativeModules provide their TurboModule jsi::HostObjects. But I'll leave that decision to a later time.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D20809201

fbshipit-source-id: ee73d4b5454a76460832a54f9b864841e5b2b9c0
2020-04-03 02:27:10 -07:00
Ramanpreet Nara 69698b25fc Codemod all getTurboModuleWithJsInvoker methods to accept a native CallInvoker
Summary:
To make iOS TurboModules integrate with the bridge's onBatchComplete event, they need to use a native CallInvoker. This call invoker is created by the `NativeToJsBridge`, and ObjCTurboModule will use this native CallInvoker to dispatch TurboModule method calls. This diff makes sure that ObjCTurboModules are created with that native CallInvoker.

## Script
```
var withSpaces = (...args) => args.join('\s*')

var regexString = withSpaces(
  '-',
  '\(',
  'std::shared_ptr',
  '<',
  '(?<turboModuleClass>(facebook::react::|react::|::|)TurboModule)',
  '>',
  '\)',
  'getTurboModuleWithJsInvoker',
  ':',
  '\(',
  'std::shared_ptr',
  '<',
  '(?<callInvokerClass>(facebook::react::|react::|::|)CallInvoker)',
  '>',
  '\)',
  '(?<jsInvokerInstance>[A-Za-z0-9]+)',
  'perfLogger',
  ':',
  '\(',
  'id',
  '<',
  'RCTTurboModulePerformanceLogger',
  '>',
  '\)',
  '(?<perfLoggerInstance>[A-Za-z0-9]+)',
  '{',
  'return',
  'std::make_shared',
  '<',
  '(?<specName>(facebook::react::|react::|::|)Native[%A-Za-z0-9]+SpecJSI)',
  '>',
  '\(',
  'self',
  ',',
  '\k<jsInvokerInstance>',
  ',',
  '\k<perfLoggerInstance>',
  '\)',
  ';',
  '}',
)

var replaceString = `- (std::shared_ptr<$<turboModuleClass>>)
    getTurboModuleWithJsInvoker:(std::shared_ptr<$<callInvokerClass>>)$<jsInvokerInstance>
                  nativeInvoker:(std::shared_ptr<$<callInvokerClass>>)nativeInvoker
                     perfLogger:(id<RCTTurboModulePerformanceLogger>)$<perfLoggerInstance>
{
  return std::make_shared<$<specName>>(self, $<jsInvokerInstance>, nativeInvoker, $<perfLoggerInstance>);
}`

const exec = require('../lib/exec');
const abspath = require('../lib/abspath');
const relpath = require('../lib/relpath');
const readFile = (filename) => require('fs').readFileSync(filename, 'utf8');
const writeFile = (filename, content) => require('fs').writeFileSync(filename, content);

function main() {
  const tmFiles = exec('cd ~/fbsource && xbgs -n 10000 -l getTurboModuleWithJsInvoker:').split('\n').filter(Boolean);

  tmFiles
    .filter((filename) => !filename.includes('microsoft-fork-of-react-native'))
    .map(abspath)
    .forEach((filename) => {
      const source = readFile(filename);
      const newSource = source.replace(new RegExp(regexString, 'g'), replaceString);

      if (source == newSource) {
        console.log(relpath(filename));
      }

      writeFile(filename, newSource);
    });
}

if (!module.parent) {
  main();
}
```

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D20809202

fbshipit-source-id: 5d39b3cacdaa5681b70ce1803351d0432dd74550
2020-04-03 02:27:10 -07:00
Ramanpreet Nara 7e16a9d5e2 Manual changes required to make ObjCTurboModule accept native CallInvoker
Summary: Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D20809200

fbshipit-source-id: d540eec9a3360a031f75d76a6ab9fb15303f8af5
2020-04-03 02:27:10 -07:00
Ramanpreet Nara b1b2f3016e Pass native CallInvoker to ObjCTurboModule constructor
Summary:
This is necessary to integrate TurboModule async method dispatch with the bridge's `onBatchComplete` event. See D20717931 for more details.

This diff is similar to D20480971.

**Note:** This stack doesn't really make any functional changes, since the native CallInvoker is `nullptr` right now.

Changelog:
[Internal]

Reviewed By: fkgozali

Differential Revision: D20809199

fbshipit-source-id: bf465a3a51bdddb8b56d1e696ca510fdf071f9ec
2020-04-03 02:27:09 -07:00
David Vacca 3ed1b1f4ff Add a React Feature Flag to control TextInlineView fix
Summary:
This diff adds a temporary Feature Flag to control a fix in TextInlineView (see previous diffs of the stack)

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D20812920

fbshipit-source-id: 90fece9b29ba173546d96e4d9baf1ccabb3031b2
2020-04-02 14:11:17 -07:00
David Vacca 21eb540d6e Fix TextInlineViews when UIImplementation processes two roots at the same time
Summary:
This diff cleans the variable NativeViewHierarchyOptimizer.mTagsWithLayoutVisited right after all the view updates for a rootShadowNode have been processed by the UIImplementation class.

This intends to fix the bug reported in the task: T61185028, which root cause seems related to the fact that the variable NativeViewHierarchyOptimizer.mTagsWithLayoutVisited is not cleaned up when updating multiple rootShadowNodes as part of the same batch

changelog: [Android][internal] internal bug fix

Reviewed By: JoshuaGross

Differential Revision: D20812921

fbshipit-source-id: 28067ee29a931d7a9e9c33c90aceb4e3512dac1a
2020-04-02 14:11:17 -07:00
Héctor Ramos 46f41099e7 Loosen up restrictions for internal changelogs (#28486)
Summary:
Do not nag on PRs that contain internal changelogs (meaning, the change doesn't need to be called out in release notes).

## Changelog

[Internal] - This should be acceptable.
Pull Request resolved: https://github.com/facebook/react-native/pull/28486

Test Plan: See PR.

Reviewed By: cpojer

Differential Revision: D20817454

Pulled By: hramos

fbshipit-source-id: a7082c4db05ec53ad27349db7e5bce2cfffd6930
2020-04-02 12:50:21 -07:00
Samuel Susla 2c3a6ab5b2 Fix crash caused by <Modal> trying to present view controller twice
Summary:
Changelog: [Internal]

`_viewController` was being presented twice causing following exception

```
'Application tried to present modally an active controller <FBReactRootViewController: 0x7fe741818b80;
```

Reviewed By: shergin

Differential Revision: D20820395

fbshipit-source-id: 5c9489011e5f99d8bd37befbd544d2d55a650589
2020-04-02 12:50:21 -07:00
Valentin Shergin b145a82964 Fixed crash in JSIExecutor::NativeModuleProxy
Summary:
JSIExecutor::NativeModuleProxy is an object created by JSIExecutor and essentially representing that in JavaScript world. Before this change, JSIExecutor::NativeModuleProxy had a raw reference to JSIExecutor which (I believe) caused a crash because JSIExecutor can be deallocated before JSIExecutor::NativeModuleProxy. Now, instead of storing a pointer to JSIExecutor, we store a weak pointer to JSINativeModules which we can safely validate before calling on it.

Changelog: [Internal] Fixed crash in JSIExecutor

Now the configuration looks like this:

```
                                                         + - - - - - - - - - - - - - - - - - - - - -
                                                                        Something else              |
                                                         |     shared_ptr<jsi::Runtime> runtime      --+
                                                                                                    |  |
                                                         + - - - - - - - - - - - - - - - - - - - - -   |
                                                                                                       |
                                                                                                       |
 +------------------------------------------+                                                          |
 |                                          |                                                          |
 |            JSExecutorFactory             |                                                          |        +--------------------------------+-------------------------------+
 |                                          |                                  +-----------------------+        |                                |                               |
 +------------------------------------------+                                  |                                |                                v                               |
                                                                               |                                |          +------------------------------------------+          |
                                                                               +--------------------------+     |          |                                          |          |
                                                                               |                          |     |          |              ModuleRegistry              |          |
                                                                               v                          |     |          |                                          |          |
                                                         +------------------------------------------+     |     |          +------------------------------------------+          |
                                                         |            HermesRuntimeImpl             |     |     |          |                                                     |
                                                         |              (jsi::Runtime)              |--+  |     |          +->+------------------------------------------+       |
                                                         |                                          |  |  |     |          |  |std::unordered_map<std::string, size_t>   |       |
                                                         +------------------------------------------+  |  |     |          |  |modulesByName_                            |       |
                                                                                                       |  |     |          |  |                                          |       |
                                                                                                       |  |     |          |  +------------------------------------------+       |
                                                                                                       |  |     |          +->+------------------------------------------+       |
                                                                               +-----------------------+  |     |             |std::vector<std::unique_ptr<NativeModule>>|       |
                                                                               |                          |     |             |modules_                                  |       |
                                                                               |                          |     |             |                                          |       |
                                                                               v                          |     |             +------------------------------------------+       |
                                                         +------------------------------------------+     |     |                                                                |
                                                         |                                          |     |     |                                                                |
                                                         |      JSIExecutor::NativeModuleProxy      |     |     |                                                                |
                                                         |                                          |     |     |                                                                |
                                                         +------------------------------------------+     |     |                                                                |
+------------------------------------------+             |                                                |     |                                                                |
|                                          |             +->+------------------------------------------+  |     |                                                                |
|             NativeToJsBridge             |                |shared_ptr<JSINativeModules>              |  |     |                                                                |
|                                          |                |nativeModules_                            |  |     |                                                                |
+------------------------------------------+                +------------------------------------------+--+-----+------------------------------------+                           |
|                                                                                                         |     |                                    |                           |
+->+------------------------------------------+                                                           |     |                                    |                           |
|  |unique_ptr<JSExecutor>                    |                                                           |     |                                    |                           |
|  |m_executor                                |                                                           |     |                                    |                           |
|  |(`::destroy()` resets it.)                |                                                           |     |                                    |                           |
|  +------------------------------------------+--------------------------------+                          |     |                                    |                           |
+->+------------------------------------------+                                |                          |     |                                    |                           |
|  |shared_ptr<JsToNativeBridge>              |                                |                          |     |                                    |                           |
|  |m_delegate                                |                                |                          |     |                                    |                           |
|  +------------------------------------------+--+                             v                          |     |                                    |                           |
+->+------------------------------------------+  |       +------------------------------------------+     |     |                                    |                           |
   |shared_ptr<MessageQueueThread>            |  |       |                                          |     |     |                                    |                           |
   |m_executorMessageQueueThread              |  |       | HermesExecutor: JSIExecutor: JSExecutor  |     |     |                                    |                           |
   +------------------------------------------+  |       |                                          |     |     |                                    |                           |
                                                 |       +------------------------------------------+     |     |                                    |                           |
                                                 |       |                                                |     |                                    |                           |
                                                 |       +->+------------------------------------------+  |     |                                    |                           |
                                                 |       |  |shared_ptr<jsi::Runtime>                  |  |     |                                    |                           |
                                                 |       |  |runtime_                                  |  |     |                                    |                           |
                                                 |       |  +------------------------------------------+--+     |                                    |                           |
                                                 |       +->+------------------------------------------+        |                                    |                           |
                                                 |       |  |shared_ptr<JSINativeModules>              |        |                                    |                           |
                                                 |       |  |nativeModules_                            |        |                                    |                           |
                                                 |       |  +------------------------------------------+--------+------------------------------------+                           |
                      +--------------------------+       +->+------------------------------------------+        |                                    |                           |
                      |                                     |std::shared_ptr<ExecutorDelegate>         |        |                                    v                           |
                      |                                     |delegate_                                 |        |              +------------------------------------------+      |
                      |                                     +------------------------------------------+--+     |              |                                          |      |
                      |                                                                                   |     |              |             JSINativeModules             |      |
                      |                                                                                   |     |              |                                          |      |
                      |                                                                                   |     |              +------------------------------------------+      |
                      |                                                                                   |     |              |                                                 |
                      |                                                                                   |     |              +-->+------------------------------------------+  |
                      +-----------------------------------------------------------------------------------+     |                  |m_moduleRegistry                          |  |
                      |                                                                                         |                  |(shared_ptr)                              |  |
                      |                                                                                         |                  +------------------------------------------+--+
                      |                                                                                         |
                      |                                                                                         |
                      v                                                                                         |
+------------------------------------------+                                                                    |
|                                          |                                                                    |
|    JsToNativeBridge: ExecutorDelegate    |                                                                    |
|                                          |                                                                    |
+------------------------------------------+                                                                    |
|                                                                                                               |
+->+------------------------------------------+                                                                 |
   |shared_ptr<ModuleRegistry>                |                                                                 |
   |m_registry                                |                                                                 |
   +------------------------------------------+-----------------------------------------------------------------+

```

Reviewed By: RSNara

Differential Revision: D20817257

fbshipit-source-id: 9ae378dbe880aaabfef7ae783dae2f94ee4b0af5
2020-04-02 11:16:13 -07:00
Samuel Susla 3d61dc9f36 Back out "Fix controlled TextInput with child nodes"
Summary:
Changelog: [Internal]

Original commit changeset: 1b8a2efabbfa

Original diff D20587681 breaks non-controlled text input.

Reviewed By: motiz88

Differential Revision: D20815935

fbshipit-source-id: 70577ed1e5701850ff0e30a6592945a31c2a8bec
2020-04-02 08:26:04 -07:00
maciej simka 6f627f684b Split loadApplicationScript into initializeRuntime and loadBundle (#27844)
Summary:
This is the first of three PRs related to enabling multi-bundle support in React Native. More details, motivation and reasoning behind it can be found in RFC [here](https://github.com/react-native-community/discussions-and-proposals/issues/152).

Logic responsible for installing globals was pulled out from `loadApplicationScript` to `initializeRuntime` since it should be ran only once, what was left was renamed to `loadBundle`.

It's based on dratwas work from [here](https://github.com/callstack/react-native/tree/feat/multibundle/split-load-application), but applied to current `master` to avoid rebasing 3-months old branch and issues that come with that.

## Changelog

[Internal] [Changed] - split `loadApplicationScript` into `initializeRuntime` and `loadBundle` to enable multi-bundle support in the future
Pull Request resolved: https://github.com/facebook/react-native/pull/27844

Test Plan: Initialized new RN app with CLI, set RN to build from source and verified the still app builds and runs OK using code from this branch.

Reviewed By: rickhanlonii

Differential Revision: D19888605

Pulled By: ejanzer

fbshipit-source-id: 24ace48ffe8978796591fe7c6cf53a61b127cce6
2020-04-01 17:52:39 -07:00
Joshua Gross eab7fc008f Remove unused feature flag: logDroppedViews
Summary:
Remove unused internal feature flag, logDroppedViews.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D20797353

fbshipit-source-id: 1bfea7fcce9e80cdb92cda59a89c7dd817d4a581
2020-04-01 17:07:07 -07:00
Joshua Gross 00ed57eb91 Remove unused feature flag: enableExtraWebViewLogs
Summary:
Hard-coded to false everywhere, and write-only. We never read from this.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20788252

fbshipit-source-id: ae117ebc51db7045947b9713602527ff4220833e
2020-04-01 17:07:07 -07:00
Joshua Gross 3963f34980 Remove unused Feature Flag: lazilyLoadViewManagers
Summary:
Remove unused feature flag. This is not used within Facebook and I'm not aware of usage outside of FB.

Changelog: [Removed] Removing Android feature flag: lazilyLoadViewManagers

Reviewed By: mdvacca

Differential Revision: D20788210

fbshipit-source-id: 435316e3de7830d7cb7f14537351883e4fc6eeaa
2020-04-01 17:07:06 -07:00
Joshua Gross e7c3f9d838 Remove unused feature flag: useMapNativeAccessor
Summary:
useMapNativeAccessor isn't being used anywhere.

Changelog: [Internal] Removing unused internal feature flags: mUseMapNativeAccessor and mUseArrayNativeAccessor

Reviewed By: mdvacca

Differential Revision: D20788147

fbshipit-source-id: bf670508326813602cb544f86d3d2164651d3394
2020-04-01 17:07:06 -07:00
Rick Hanlon 52b3105f65 Implement RCTWarn equivalent on Android
Summary:
## Overview
This diff is an RFC to port a logging feature from iOS to Android.

Changelog: [Internal]

## Motivation
On iOS we have the following log functions and behaviors available for logging native warnings and errors:

- **Warnings** (`RCTLogWarn`)
  - Log level 'warn' to console
  - Display warning in LogBox
- **Errors** (`RCTLogError`)
  - Log level 'error' to console
  - Display a native RedBox (needs converted to show a LogBox if available)
- **Logs**
  - We also have `RCTLog`, `RCTTrace`, `RCTAdvice`, `RCTInfo`, which just log to the console.

In Java, we have:
- **Warnings**
  - **None**, added in this diff
- **Errors** (`DevSupportManager.showNewJavaError`)
  - Log level 'error' to console with `FLog.e`
  - Display a native RedBox (needs converted to show a LogBox if available
- **Logs**
  - `ReactSoftException` (crashes the app??)
  - `ReactNoCrashSoftException` (only logs??)
  - Others?

## Details

This diff adds a method to pair with `RCTLogWarn`, `DevSupportManager.showNewJavaWarning`, which will log to the console and show a LogBox warning if LogBox is available.

## Concerns

I have a few concerns/questions about the state of logging on Android:
- Should/can we move all of the logging to it's own class, like how RCTLog works?
- Why does some logging happen on DevSupportManager and some in other classes?
- If we moved it all to it's own class, how could we access the reactContext to call the RCTLog JS module

Reviewed By: JoshuaGross

Differential Revision: D20056394

fbshipit-source-id: 32d57e300685e46da8039fc77cb22b4084acf81a
2020-04-01 16:45:54 -07:00
Rick Hanlon ec0c65c4b2 Improve component stack parsing
Summary:
Update the error log message parsing to fix missing component stacks in console.errors.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D20801985

fbshipit-source-id: ae544200315a8c3c0310e8370bc38b0546734f38
2020-04-01 16:43:15 -07:00
Andrew Coates (REDMOND) 5b267091ed More consistent snapshots on windows (#28482)
Summary:
Get jest tests to be runnable on windows, and match current snapshots

## Changelog

[Internal] [Fixed] - More consistent snapshots on windows
Pull Request resolved: https://github.com/facebook/react-native/pull/28482

Test Plan: run `yarn test` on a windows machine, and hit the test_windows circleci tests

Reviewed By: hramos

Differential Revision: D20799002

Pulled By: cpojer

fbshipit-source-id: da3db0171c34a43199c7d3dc17b622b37bc91701
2020-04-01 15:10:41 -07:00
Sidharth Guglani 2e085a388b Fix Yoga flexshrink with min-width sizing issue
Summary:
While resolving the flexible items we calculate totalFlexShrinkScaledFactors which uses the flexBasis or initial width of node (Not min-width).

At a later stage during distribution of space we are subtracting value from this which also takes care of min-width.

For example
If node has flexShrink 1 and width 100 and min-width 301  then totalFlexShrinkScaledFactors will become -1*100 = -100
but later we are subtracting -1 * 301 (min-width) = -301 which is ambiguous and causing layout inconsistencies with how web behaves.

Fixed this by only using the flexBasis or width for these calculations.

Changelog:
[Internal][Yoga] Fix layout issue when flexShrink and min-width are used together

Reviewed By: pasqualeanatriello

Differential Revision: D20219419

fbshipit-source-id: 948fbc06ca541d4ad307c88c8a2df65d157778b1
2020-04-01 14:41:38 -07:00
Marc Horowitz 8970ee9f32 Make HermesRuntime::description() always include "HermesRuntime"
Summary:
If name is passed in as part of RuntimeConfig, that is included
in the description, too.
Changelog: [Internal]

Reviewed By: dulinriley

Differential Revision: D20716320

fbshipit-source-id: f2fba6df32f496090dee787d8b7f55a6a4dd8ed8
2020-04-01 13:42:56 -07:00
Ramanpreet Nara 9b94a541d8 Get CallInvokers from the bridge
Summary:
## Context
For now, assume TurboModules doesn't exist.

**What happens when we call an async NativeModule method?**
Everytime JS calls an async NativeModule method, we don't immediately execute it. The legacy infra pushes the call into some queue managed by `MessageQueue.js`. This queue is "flushed" or "emptied" by the following events:
- **Flushed:** A C++ -> JS call. NativeModule async methods can called with an `onSuccess` and/or `onFail` callback(s). Calling `NativeToJsBridge::invokeCallback` to invoke one of these callbacks is one way for ObjC++/C++/Java to call into JS. Another way is via JSModule method calls, which are initiated by `NativeToJsBridge::callFunction`.
- **Flushed:** When `JSIExecutor::flush` is called. Since TurboModules don't exist, this only happens when we call `JSIExecutor::loadApplicationScript`.
- **Emptied:** When more than 5 ms have passed, and the queue hasn't been flushed/emptied, on the next async NativeModule method call, we add to the queue. Afterwards, we empty it, and invoke all the NativeModule method calls.

**So, what's the difference between flushed and emptied?**
> Note: These are two terms I just made up, but the distinction is important.

If the queue was "flushed", and it contained at least one NativeModule method call, `JsToNativeBridge` dispatches the `onBatchComplete` event. On Android, the UIManager module is the only module that listens to this event. This `onBatchComplete` event doesn't fire if the queue was "emptied".

**Why does any of this matter?**
1. TurboModules exist.
2. We need the TurboModules infra to have `JsToNativeBridge` dispatch `onBatchComplete`, which depends on:
   - **Problem 1:** The queue being flushed on calls into JS from Java/C++/ObjC++.
   - **Problem 2:** There being queued up NativeModule async method calls when the queue is flushed.

In D14656466, fkgozali fixed Problem 1 by making every C++/Java/Obj -> JS call from TurboModules also execute `JSIExecutor::flush()`. This means that, with TurboModules, we flush the NativeModule async method call queue as often as we do without TurboModules. So far, so good. However, we still have one big problem: As we convert more NativeModules to TurboModules, the average size of the queue of NativeModule method calls will become smaller and smaller, because more NativeModule method calls will be TurboModule method calls. This queue will more often be empty than not. Therefore, we'll end up dispatching the `onBatchComplete` event less often with TurboModules enabled. So, somehow, when we're about to flush the NativeModule method call queue, we need `JsToNativeBridge` to understand that we've executed TurboModule method calls in the batch. These calls would have normally been queued, which would have led the queue size to be non-zero. So if, during a batch, some TurboModule async method calls were executed, `JsToNativeBridge` should dispatch `onBatchComplete`.

**So, what does this diff do?**
1. Make `Instance` responsible for creating the JS `CallInvoker`.
2. Make `NativeToJsBridge` responsible for creating the native `CallInvoker`. `Instance` calls into `NativeToJsBridge` to get  the native `CallInvoker`.
3. Hook up `CatalystInstanceImpl`, the Android bridge, with the new JS `CallInvoker`, and the new native `CallInvoker`. This fixes `onBatchComplete` on Android. iOS work is pending.

Changelog:
[Android][Fixed] - Ensure `onBatchComplete` is dispatched correctly with TurboModules

Reviewed By: mdvacca

Differential Revision: D20717931

fbshipit-source-id: bc3ccbd6c135b7f084edbc6ddb4d1e3c0c7e0875
2020-04-01 11:39:18 -07:00
Samuel Susla 3591b7a956 Promote shadowColor to formsStackingContext property
Summary:
Changelog: [Internal]

View with `ShadowColor` was getting flattened and therefore views didn't have shadow property set.
This is fixed by promoting ShadowColor so in case it is set, it forms stacking context.

Reviewed By: shergin

Differential Revision: D20792201

fbshipit-source-id: 1033ac00e32047ffbb14e61b7c26348c578d132d
2020-04-01 10:42:51 -07:00
Samuel Susla e653cb06f8 Pass isRTL flag from FabricUIManager Fabric core
Summary:
Changelog: [Internal]

Send `isRTL` flag and `doLeftAndRightSwapInRTL`  flags from Java to Fabric Core.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D20776005

fbshipit-source-id: 946c239d9a11ebea958b0a6d04f2316b7cd77311
2020-04-01 08:39:53 -07:00
Christoph Nakazawa c5a54ec1b1 Fix inline-view-configs test on Windows.
Summary:
*facepalm* The file path is platform specific.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D20793023

fbshipit-source-id: 4fbcbf982911ee449a4fa5067cc0c5d81088ce04
2020-04-01 07:31:18 -07:00
Samuel Susla 46722dcfc2 Swap left and right yoga position with start and end in RTL context
Summary:
Changelog: [Internal]

Paper swaps right and left in RTL setting, this logic is in [RCTShadowView.m](https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/React/Views/RCTShadowView.m?commit=cdd504cfbee66ae0659495604c4ff7b5764a1d9e&lines=529-549).

For Fabric instead of doing it during yoga props assignment, I swap the left/right with start/end just before we pass yoga nodes to layout calculation.

Reviewed By: shergin

Differential Revision: D20420040

fbshipit-source-id: b777f2658f56c173743b2034b8b5059e3e0c9840
2020-04-01 05:42:20 -07:00
Christoph Nakazawa f6de7b826d Use `buildCodeFrameError` in babel-plugin-inline-view-configs
Summary:
The next version of Babel changes how it prints file names in errors. This diff fixes the test by using `/` as the `cwd` and switches the plagin to use `path.buildCodeFrameError` so errors will be more helpful for users.

I renamed the `nodePath` variable to `path` because that's what babel plugins usually do.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D20781805

fbshipit-source-id: cc149dce6389aa9402ce70ea30035c74a6150ea3
2020-04-01 05:33:11 -07:00
Joshua Gross 2b062eadc8 Fix bug in optimized differ
Summary:
The differ was still producing correct, but not minimal, instruction sets in some cases due to an optimization that was buggy.

This affected cases where 2+ nodes were inserted at the beginning of a list. It would trigger the old behavior where all nodes after the first would be removed, deleted, then reinserted.

See the test case (which was failing and now passed) and P128190998 (the 3->4 transition) for samples.

Changelog: [Internal] Fabric differ

Reviewed By: mdvacca

Differential Revision: D20785729

fbshipit-source-id: 2fea6a816753066abb358ed7bb51003140cd5fc4
2020-03-31 19:36:45 -07:00
Héctor Ramos 23d0e7cae9 Circle CI Housekeeping: Windows, e2e (#28471)
Summary:
Circle CI Housekeeping:
* Integrate Windows job into `tests` workflow
* Add parametrized e2e tests command
* Move js e2e tests out of the disabled test quarantine area
* Parametrize and split `test_ios` job to reduce total execution time by ~13 minutes

**Before:**

Longest running iOS job at 39 minutes.

| Setup Job Runtime | Job | Job Runtime | Total Runtime |
| - | - | - | - |
| 01:24 | test_ios | 38:04 | **39:28** |
| 01:24 | test_ios_frameworks | 38:02 | 39:26 |

![Screen Shot 2020-03-31 at 12 40 29 PM](https://user-images.githubusercontent.com/165856/78068308-044c3280-734d-11ea-96bf-2e50691a0ef7.png)

**After:**

Longest running iOS job down to 26 minutes.

| Setup Job Runtime | Job | Job Runtime | Total Runtime |
| - | - | - | - |
| 01:26 | test_ios_unit | 20:48 | 22:14 |
| 01:26 | test_ios_unit_frameworks | 22:52 | 24:18 |
| 01:26 | test_ios_detox | 24:35 | 39:28 |
| 01:26 | test_ios_detox_frameworks | 24:54 | **26:20** |

![Screen Shot 2020-03-31 at 12 39 22 PM](https://user-images.githubusercontent.com/165856/78068294-fe565180-734c-11ea-96da-8836231d7747.png)

## Changelog

[Internal] [CI] - CI Housekeeping
Pull Request resolved: https://github.com/facebook/react-native/pull/28471

Test Plan: Circle CI

Reviewed By: cpojer

Differential Revision: D20774521

Pulled By: hramos

fbshipit-source-id: 4a2f5a4083cd76dcb51d5ccaf726cd204fca222e
2020-03-31 17:39:20 -07:00
Chatura Atapattu 4a2232bd7b Apply buckformat in preparation for updating buildifier
Summary: Changelog: [Internal]

Reviewed By: zertosh

Differential Revision: D20773287

fbshipit-source-id: 144bb13191312eef246646b99e1dc06304c6d210
2020-03-31 16:33:44 -07:00
Jesse Katsumata ad86a18305 chore: update lint config in template (#28443)
Summary:
Updating the eslint config and metro-preset used in project template.

## Changelog

[General] [Changed] - Upgrade eslint-config and metro-preset in project template
Pull Request resolved: https://github.com/facebook/react-native/pull/28443

Test Plan:
- Start new project with `npx react-native init TestLint`
- upgrade lint and metro-config
- run lint and start up emulator on iOS and android

Reviewed By: cpojer

Differential Revision: D20771048

Pulled By: hramos

fbshipit-source-id: a6d387b8687cee348681bcb10d22c7e3de291ed7
2020-03-31 13:51:18 -07:00
Jacob Bower ed3054927c Plumb through memory allocation profiler feature to Chrome Inspector
Summary: Changelog: Make allocation profiler feature of Chome Inspector work

Reviewed By: dulinriley

Differential Revision: D20383003

fbshipit-source-id: 8a10c310d5a639a6644763adb53f2f0017057587
2020-03-31 11:02:41 -07:00
Jacob Bower 8454975d2c Save/restore IP when leaving the interpreter
Summary:
This diff implements the instruction pointer save/restore trick Tzvetan came up with; allowing us to observe and modify the IP from outside the interpreter loop with negligible overhead.

From Tzvetan's internal post on the subject:

> [Today] the interpreter IP is just a local variable in the interpreter function, so there is no way to get to its value from outside the function. It lives in a register and we don't want to make it a Runtime field since the overhead [of accessing it via memory in the interpeter loop] would kill us.

> However, if you really think about it, it only lives in a register while the interpreter function is running. For the rest of the time, it is spilled by the C++ compiler onto the stack.
So, precisely when we need it, it is actually stored in memory. The only problem is, we don't know where! Admittedly, that is an annoying problem, but it feels like it should be solvable.

> What if, instead of relying on the compiler to spill the IP register, we manually spill it ourselves, to a known location? It works. Example: https://godbolt.org/z/ftSDnp

This diff implements this approach across the whole interpreter loop: whenever we call out of the loop we capture/publish the IP and restore it again immediately after the external call returns. This means we can now see the IP outside the interpret loop and even change it. This is effectively "for free" as the compiler now skips spilling/restoring the IP behind the scenes.

The immediate benefit of this is knowing the current IP allows us to have more accurate stack-traces during execution. In future this may enabled tricks like changing the IP before returning to the interpreter loop, allowing things outside the interpreter to affect program flow without adding logic to the interpreter loop.

Reviewed By: tmikov

Differential Revision: D20151091

fbshipit-source-id: 3814382639800208d8985a32ede31ba8f7ff7c80
2020-03-31 11:02:41 -07:00