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

21263 Коммитов

Автор SHA1 Сообщение Дата
Ramanpreet Nara a5a12cffeb Update SchemaValidator test to follow new CodegenSchema
Summary:
NOTE: Flow and Jest won't pass on this diff. Sandcastle, should, however, be green on D24236405 (i.e: the tip of this stack).

Changelog: [Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: PeteTheHeat

Differential Revision: D24236507

fbshipit-source-id: 2ffa0414db731a6ee844a2d1a5b07dc32bc763cb
2020-10-15 22:53:55 -07:00
Ramanpreet Nara abeae870d4 Update Component generator fixtures to follow new ComponentSchema
Summary:
NOTE: Flow and Jest won't pass on this diff. Sandcastle, should, however, be green on D24236405 (i.e: the tip of this stack).

Changelog: [Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: PeteTheHeat

Differential Revision: D24236502

fbshipit-source-id: 288c6d9588bde177732fe8165d3374eeacad999d
2020-10-15 22:53:55 -07:00
Ramanpreet Nara 4ee65f66cf Update Module generator fixtures to follow new NativeModuleSchema
Summary:
NOTE: Flow and Jest won't pass on this diff. Sandcastle, should, however, be green on D24236405 (i.e: the tip of this stack).

Changelog: [Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: PeteTheHeat

Differential Revision: D24236509

fbshipit-source-id: 1b603e8728d7be1e8bdede5878f57d6556b5c52f
2020-10-15 22:53:55 -07:00
Ramanpreet Nara 3d0a626c87 Update NativeModule parser to generate new schema
Summary:
NOTE: Flow and Jest won't pass on this diff. Sandcastle, should, however, be green on D24236405 (i.e: the tip of this stack).

## Changes
1. Update the RN Codegen Module Parser
2. Update all RN Codegen Module Parser Jest tests & snapshots.

Changelog: [Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: PeteTheHeat

Differential Revision: D24236505

fbshipit-source-id: e24a39b4837c75a90fb4c957c56dfcf789511cc9
2020-10-15 22:53:55 -07:00
Ramanpreet Nara 8b1ae7a4ae Annotate Component parser's output with 'Component' type
Summary:
NOTE: Flow and Jest won't pass on this diff. Sandcastle, should, however, be green on D24236405 (i.e: the tip of this stack).

## Changes
1. Update the RN Codegen Component Parser
2. Update all RN Codegen Component Parser snapshots.

Changelog: [Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: PeteTheHeat

Differential Revision: D24236503

fbshipit-source-id: 975d97dd29bb5ca08e5de96e7814290c3dc4357b
2020-10-15 22:53:55 -07:00
Ramanpreet Nara 3a75b376cc Create NativeModuleSchema and ComponentSchema
Summary:
NOTE: Flow and Jest won't pass on this diff. Sandcastle, should, however, be green on D24236405 (i.e: the tip of this stack).

## Description
The Codegen deals with "Modules". Hence:
```
type SchemaType = {
  modules: {
    [moduleName]: ...
  }
};
```

Each "Module" has a name, and represents a file. The `moduleName` is the base name of the file. This file can contain a component specification or a NativeModule specification. Hence:

```
type SchemaType = {
  modules: {
    [moduleName]: ComponentSchema | NativeModuleSchema
  }
};
```

The `ComponentSchema` can contain specifications for many different components. Hence:

```
type ComponentSchema = {
  type: 'Component'
  components: {
    [componentName]: ComponentShape
  }
}
```

The `NativeModuleSchema` contains
1. Type aliases (no surprises/nothing new).
2. One Flow interface that extends `TurboModule`.
3. Potentially many different NativeModule requires (for now) via `TurboModuleRegistry.get(Enforcing)?<specName>('moduleName')`.

Hence, the shape looks like:
```
type NativeModuleSchema = {
  type: 'NativeModule',
  aliases: NativeModuleAliasMap, // nothing new
  spec: NativeModuleSpec,
  moduleNames: $ReadOnlyArray<string>
}

type NativeModuleSpec = {
  properties: $ReadOnlyArray<...>,
}
```

## Major Notes
1. We now parse the NativeModule requires (TurboModuleRegistry.get(Enforcing)?<Spec> calls) and record them in the schema.
2. A Codegen "Module" can contain either a Component schema, or a NativeModule schema, but **not** both.

## Snapshot Updates
The changes to the schema are visible in the snapshots updated in D24236505.

Changelog: [Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: fkgozali

Differential Revision: D24236510

fbshipit-source-id: bd344d67136418725d840e7332fd2f6957326bb4
2020-10-15 22:53:55 -07:00
Samuel Susla 81a97de546 Prevent type conversion in Differentiator
Summary:
changelog: [internal]

Prevents 2 type converions:
1. int <-> size_t
2. int <-> int32_t

# Why is using size_t better when working with indexes.

## 1. Type conversion isn't for free.

Take this example

```
size_t calculate(int number) {
  return number + 1;
}
```

It generates following assembly (generated with armv8-a clang 10.0.0):

```
calculate(int):                          // calculate(int)
sub     sp, sp, #16                     // =16
str     w0, [sp, #12]
ldr     w8, [sp, #12]
add     w9, w8, #1                      // =1
mov     w8, w9
sxtw    x0, w8
add     sp, sp, #16                     // =16
ret
```

That's 9 instructions.

If we get rid of type conversion:

```
size_t calculate(size_t number) {
  return number + 1;
}
```

Assembly (generated with armv8-a clang 10.0.0):

```
calculate(unsigned long):                          // calculate(unsigned long)
sub     sp, sp, #16             // =16
str     x0, [sp, #8]
ldr     x8, [sp, #8]
add     x0, x8, #1              // =1
add     sp, sp, #16             // =16
ret
```

Compiler now produces only 7 instructions.

## Semantics

When using int for indexing, the type doesn't say much. By using `size_t`, just by looking at the type, it gives the reader more information about where it is coming from.

Reviewed By: JoshuaGross

Differential Revision: D24332248

fbshipit-source-id: 87ef982829ec14906ed9e002ea2e875fda4a0cd8
2020-10-15 15:15:41 -07:00
Ramanpreet Nara b70152cdef Fix NativeLinking split
Summary:
In D24324247 (56c363e39a), I split NativeLinking into NativeLinkingManager and NativeIntentAndroid. There was this line in NativeLinking.js, that I didn't migrate correctly:

```
export default ((Platform.OS === 'android'
  ? TurboModuleRegistry.getEnforcing<Spec>('IntentAndroid')
  : TurboModuleRegistry.getEnforcing<Spec>('LinkingManager')): Spec);
```

I separated this conditional statement into two others:
```
export default TurboModuleRegistry.getEnforcing<Spec>('IntentAndroid');
export default TurboModuleRegistry.getEnforcing<Spec>('LinkingManager');
```

The problem here is that now on iOS, we're hard requiring IntentAndroid, and on Android, we're hard requiring LinkingManager. Understandably, this started throwing errors in our e2e infra. This diff fixes this problem by:
1. Changing the relevant `getEnforcing` calls into `get` calls.
2. Wrapping all usages of NativeIntentAndroid, and NativeLinkingManager, which are already guarded by `Platform.OS` checks, by a nullthrows. This should satisfy flow. **Note:** NativeIntentAndroid is only used on Android, where it must be available. Similarly, NativeLinkingManager is only used on iOS, where it must be available.

Changelog: [Internal]

build-break
overriding_review_checks_triggers_an_audit_and_retroactive_review

Oncall Short Name: fbandroid_sheriff

Differential Revision: D24338558

fbshipit-source-id: b0d22cba77e67837834269deaa317dc73d2457dc
2020-10-15 11:49:19 -07:00
Valentin Shergin 0cec0134e6 Fabric: `operator==` for `LayoutContext`
Summary:
We will need it soon.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D24290775

fbshipit-source-id: a312e537a3c3954e709a10c8792b3462b574054a
2020-10-15 10:47:11 -07:00
Valentin Shergin fe8cd5cf3e Fabric: Lazy initialization of RCTSurfaceTouchHandler on the main thread
Summary:
RCTSurfaceTouchHandler is not a thread-safe object and must be used (and initialized) on the main thread. Therefore we need to move the initialization to `view` method which is guaranteed to be called on the main thread.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D24290776

fbshipit-source-id: fc1f2f157599aff6fca053451f89bf7cca3c812a
2020-10-15 10:47:11 -07:00
Samuel Susla 668cc2fbde Remove setNativeProps from core
Summary:
Changelog: [internal]

Fabric uses view commands instead of setNativeProps. This diff removes what's left of setNativeProps from the core.

Reviewed By: JoshuaGross

Differential Revision: D24309999

fbshipit-source-id: 70e54f0a984f8c36f77ba2cd59f59fc6923bc832
2020-10-15 10:41:08 -07:00
Ramanpreet Nara 5a57a538c9 Split NativeAsyncStorage into NativeAsyncLocalStorage and NativeAsyncSQLiteDBStorage
Summary:
Although the interface for both NativeModules is the same, we'd like to enforce 1 `TurboModuleRegistry.get` call per NativeModule spec file. Therefore this diff splits the one spec into two.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24325260

fbshipit-source-id: f18718e4235b7b8ccbfc44a7e48571ecf483a36c
2020-10-15 08:49:28 -07:00
Ramanpreet Nara 56c363e39a Split NativeLinking into NativeIntentManager and NativeLinkingManager
Summary:
The iOS and Android NativeModules are very different. It's better to split the two interfaces, than to have one merged interface.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24324247

fbshipit-source-id: 097273829ffc719eff006ed2dde55f0dd6bd7d95
2020-10-15 08:49:28 -07:00
Ramanpreet Nara 20e7a40b9c Remove TVNavigationEventEmitter
Summary:
This NativeModule is actualy not used! Removing this now.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24324362

fbshipit-source-id: 1322c5e072961f1c6c54bfc6dbd562d42f9e5b3f
2020-10-15 08:49:28 -07:00
Héctor Ramos 62518ba64f Bump react-native-codegen: 0.0.4
Summary:
The codegen output for the native modules in `Libraries/` has been verified to work with RNTester.
Publishing a new version as a prerequisite to start using the codegen at build time in open source.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24314972

fbshipit-source-id: edd0066c1cf33ba8e536cc5f145c057ca992eec1
2020-10-15 06:16:22 -07:00
Ramanpreet Nara dabca52f77 Stop calling RCTNetworking.(add|remove)Listeners?
Summary:
RCTNetworking.startObserving and RCTNetworking.stopObserving don't exist. The main purpose of RCTEventEmitter.addListener is to call these methods, and increment the `_listeners` counter, so that we can start dispatching events when `_listeners > 0`. In D24272560, I made RCTEventEmitter dispatch events even when _listeners <= 0. This is sufficient for us to stop calling these two RCTNetworking methods entirely.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24272663

fbshipit-source-id: de9c968bc71e6e6d69a22b934644e6dfa3266b3f
2020-10-14 21:05:38 -07:00
Ramanpreet Nara 82187bfb6b Dispatch events even when there are no listeners
Summary:
## Rationale
For every 1 call to RCTNetworking.sendRequest, we execute 6 calls to RCTNetworking.addListener. This is followed by at least one call to RCTNetworking.removeListeners. Aside from incrementing and decrementing the `_listeners` integer, these two methods accomplish nothing else: RCTNetworking doesn't implement the `startObserving` and `stopObserving` methods.

This diff makes RCTEventEmitter dispatch events without looking at the listeners integer. In the future, this will allow us to stop making these ~8 unnecessary NativeModule calls for every Network request we send.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24272560

fbshipit-source-id: 7996eba5abfa4669a89c43a3ffa536c0faa214a8
2020-10-14 21:05:38 -07:00
Lorenzo Sciandra fb14fd42b3 Chore: Upgrade Detox to 16.7.2 (#30084)
Summary:
With Xcode 12 being the latest, Detox 15.x has issues - in particular, it means that if you try to `yarn install` the dependencies for the repo, you'll be greeted by this error:

```bash
error /<stuff>/react-native/node_modules/detox: Command failed.
Exit code: 1
Command: node scripts/postinstall.js
Arguments:
Directory: /<stuff>/react-native/node_modules/detox
Output:
/<stuff>/Library/Detox/ios/5824c837515589f21c08f09b716a6eda088aa31f was found, but could not find Detox.framework inside it. This means that the Detox framework build process was interrupted.
         deleting /<stuff>/Library/Detox/ios/5824c837515589f21c08f09b716a6eda088aa31f and trying to rebuild.
Extracting Detox sources...
Building Detox.framework from /<stuff>/Developer/OSS/react-native/node_modules/detox/ios_src...
child_process.js:637
    throw err;
    ^
```

With the {emoji:1f44d} of hramos & alloy I've prep'd up a small defensive PR that can be quickly merged before cutting 0.64, that bumps the version of Detox from 15.4.4 to the highest version available within the reach of "no breaking changes" in changelog.

The main reason why with 16.x this error doesn't happen is that from [16.0.0](https://github.com/wix/Detox/releases/tag/16.0.0):

> Detox now comes as a prebuilt framework on iOS, thus lowering npm install times and saving some build issues that happen due to unexpected Xcode setups.

It would have been better to update directly to latest (at the time of writing 17.7.1) but there are at least two versions that had changelogs that seem to involve bigger changes:

* https://github.com/wix/Detox/releases/tag/17.4.7
* https://github.com/wix/Detox/releases/tag/16.8.0

Hopefully CI will will show that the bump doesn't break any test �

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

[Internal] [Changed] - Bumped Detox in the repo to 16.7.2 for Xcode 12 compatibility

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

Test Plan: Running yarn in the main repo with Node 14 & Xcode 12, without this change, will cause the error copy-pasted above. After upgrading to this version, the error disappear.

Reviewed By: cpojer

Differential Revision: D24293226

Pulled By: hramos

fbshipit-source-id: 2b4d23b033be621274966262ec19200bee44df58
2020-10-14 12:06:06 -07:00
Paige Sun 38eb3f8dcb Fix: Set image loader module name synchronously
Summary: Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24290066

fbshipit-source-id: e2bad9ed8c126c7b49356bc7a2c1114160149fd3
2020-10-14 11:25:44 -07:00
Paige Sun cd6ebcdd82 Set MobileConfig for Fabric logging in FBReactModule
Summary: Changelog: [RN][iOS] Allow gate to be set for Fabric logging from the React Module

Reviewed By: fkgozali

Differential Revision: D24256546

fbshipit-source-id: 7b290efb9abd3035559f743e6e5b6701e02053e1
2020-10-14 03:15:19 -07:00
Lulu Wu ea93151f21 Make RCTEventDispatcher TurboModule-compatible
Summary:
This diff ended up being a bit more complicated than I anticipated, since the source files in `ReactInternal` were depending on `RCTEventDispatcher`. I made the following changes:
1. Make `RCTEventDispatcher` a `protocol`, keep it in `ReactInternal`.
2. Rename the `RCTEventDispatcher` NativeModule to `RCTEventDispatcherModule`, make it conform to the `RCTEventEmitter` `protocol`, and move it to `CoreModules`.
3. Where necessary, replace categories of `RCTEventDispatcher` with functions.

Changelog:
[iOS][Added] - Make RCTEventDispatcher TurboModule-comaptible

Reviewed By: fkgozali

Differential Revision: D18439488

fbshipit-source-id: b3da15c29459fddf884519f33b0c3b8c036b5539
2020-10-14 02:40:10 -07:00
Joshua Gross d5076c6c8f Fix some JNI table leaks, more aggressively clean up memory
Summary:
There are a few places where we have JNI table ref leaks, and more places where we can aggressively clean up smart pointers immediately instead of waiting for them to be cleaned up at some later point.

In theory these smart pointers should be cleaned up immediately, but in cases where many components are being measured at once, the JNI table could grow until all measure calls are done. In extreme cases this
could cause a crash, which I want to avoid. At the very least, freeing memory more aggressively in this case can't hurt.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D24293775

fbshipit-source-id: 159741ba955e5a6fe02caf6e65d1e4d6d4afadee
2020-10-14 00:01:21 -07:00
Scott Kyle 42d232901c Fix ASAN crash in RCTMessageThread
Summary:
This should fix a race condition uncovered by ASAN build that results in `m_shutdown` being referenced after destruction.

This mirrors a similar fix made in react-native-macos: ea7767a211

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D24263156

fbshipit-source-id: 5fb1e7053c107dfb7050242fce8fcf0435e5592c
2020-10-13 15:37:52 -07:00
Peter Argany 8f45db3b9e RCTPicker handwritten view config
Summary: This completes the Picker stack. Use a handwritten view config to avoid calling `requireNativeComponent` in Bridgeless mode.

Differential Revision: D23663596

fbshipit-source-id: 5d0811014fd6f66956803a1db5fee8fd1119d5bc
2020-10-13 11:19:30 -07:00
Peter Argany 3113e47b9b Remove type union in PickeriOS/PickerNativeComponent
Summary:
This builds on the last diff to remove type a type union from Picker. This diff focuses on Picker internals.

Changelog: [JS] Remove type union in PickeriOS/PickerNativeComponent

Reviewed By: sammy-SC

Differential Revision: D24254615

fbshipit-source-id: f788a2e123135c1e8b9909870c40f53b2dea0227
2020-10-13 11:19:29 -07:00
Peter Argany b05d90e8bb Remove type union in Picker.js
Summary:
Flow type unions don't play well with Fabric components. This diff removes a union in `Picker.js` and fixes all the flow errors.

Before this diff, all these surfaces would crash with the new Fabric Picker impl, because the impl asserts that this field is a string.

Reviewed By: sammy-SC

Differential Revision: D24236317

fbshipit-source-id: 6e646c84fcd16658aaabe5e93507f5f33b346a65
2020-10-13 11:19:29 -07:00
Peter Argany ccc4f0153d Fabric Picker Native Command support
Summary:
This adds support for a controlled  `<Picker/>` component .

Changelog: [iOS][Fabric] Fabric Picker support

Reviewed By: sammy-SC

Differential Revision: D24005475

fbshipit-source-id: c50e9918f74f6ef5cdfbfe67cb6c132c12d64916
2020-10-13 11:19:29 -07:00
Peter Argany 51e8e0b7e1 Fabric Picker styling support
Summary:
This adds support for `<Picker style={}/>` prop for text styling. It reuses most of conversion logic from BaseText. This means that it actually supports more styles than Paper Picker supported. (Paper picker only supported ~4 styles, this supports everything that Text supports, so 10+ styles).

The only tricky thing is that Picker supports multiple ways of setting text color. Both

      <Picker
        itemStyle={{color: '#008BD0'}} >
        <Picker.Item label="Java" value="java" />
        <Picker.Item label="JavaScript" value="js" />
      </Picker>

and

      <Picker>
        <Picker.Item label="Java" value="java" color={'#008BD0'} />
        <Picker.Item label="JavaScript" value="js" />
      </Picker>

technically work in Paper. I've decided to maintain this behaviour (since there's lots of product code callsites to both options).

Changelog: [iOS][Fabric] Fabric Picker support

Reviewed By: sammy-SC

Differential Revision: D23980319

fbshipit-source-id: e469a837e28af0ad97cf0e171df26ee19adff3ab
2020-10-13 11:19:29 -07:00
Peter Argany 251d5e1bbe Fabric Picker onChange event
Summary:
Implements `onChange` prop for `<Picker/>`.

Changelog: [iOS][Fabric] Fabric Picker support

Reviewed By: sammy-SC

Differential Revision: D23975689

fbshipit-source-id: 7aa81c203d420a8971e4309911a41ecfd377a318
2020-10-13 11:19:29 -07:00
Peter Argany c2e7ac1b35 Fabric picker item parsing
Summary:
This builds on previous diff to properly parse `<Picker.Item/>` into a cpp struct.

This fixes the dummy text and text color TODOs.

Changelog: [iOS][Fabric] Fabric Picker support

Reviewed By: sammy-SC

Differential Revision: D23964557

fbshipit-source-id: f42c6c9cf410bfc5e66ff078645b6378548481de
2020-10-13 11:19:29 -07:00
Peter Argany 38cb06cbd3 Initial commit for Fabric Picker
Summary:
This is a starting point for the handwritten Fabric Picker component. It is incomplete, and needs to be landed with the rest of the stack above it.

In general, this creates a new `ComponentView`, `ComponentDescriptor`, `ShadowNode`, `Props` and a few other boilerplate classes for Picker. A bunch of the logic in `ComponentView` was copied over from the Paper `RCTPicker` and `RCTPickerManager`.

What works in this diff:
- A `<Picker>` with items can be created in JS, and a corresponding `UIPicker` is created in native with placeholder text, default styling and the correct amount of items

What doesn't work yet (implemented in later diffs):
- Parsing items to use correct text and styling in native
- Events/commands

Reviewed By: sammy-SC

Differential Revision: D23941821

fbshipit-source-id: e049ca6004757fbd1361985644d5dbb8f53e1ce6
2020-10-13 11:19:29 -07:00
Joshua Gross 71bb19827b NativeAnimatedModule: fix crash that can occur when animated node setup races with NativeAnimatedModule setup
Summary:
When switching between non-Fabric and Fabric screens, I believe that `initializeEventListenerForUIManagerType` is not always being called on the NativeAnimatedNodesManager if
`NativeAnimatedModule.initializeLifecycleEventListenersForViewTag` is being called before the NativeAnimatedNodesManager ivar has been set. This should occur very infrequently, but logs
indicate that it /does/ happen in some marginal cases. Protecting against these cases should be trivial, by using the `getNodesManager` method which is responsible for returning a nodes manager or creating a new one.

The existing uses of the `NativeAnimatedNodesManager` ivar also occur on different threads and we were not protecting against this, so I'm changing it to an atomic. It's very likely that
the inconsistency issues in the past were caused not by ordering errors, but thread races.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24267118

fbshipit-source-id: 68abbff7ef3d0b2ecc9aa9977165663ad9447ab8
2020-10-12 22:53:40 -07:00
Nick Gerleman 4d247fe058 Avoid Repo Structure Assumptions in RNTester Imports (#30141)
Summary:
RNTester has some imports left over that operate on directory traversal, assuming it is contained within react-native sources. This change makes these imports relative to react-native, enabling usage outside of the RN repo.

Relates to https://github.com/microsoft/react-native-windows/issues/6210

## Changelog

[Internal] [Fixed] - Avoid File Structure Assumptions in RNTester Imports

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

Test Plan: Validated we can bundle and flow-check both iOS + Android

Reviewed By: cpojer

Differential Revision: D24259628

Pulled By: appden

fbshipit-source-id: 0c21b5d354b01785d8402599da3b0a5be81b4c6d
2020-10-12 19:56:09 -07:00
Peter Argany 760c10a5aa Fix new RCTDeviceInfo assert to work in bridgeless mode
Summary:
shergin added a new assert to dimensions calculations in D24038911 (e853722981). This crashes in bridgeless mode b/c no bridge.

 This diff uses `turboModuleRegistry` as a bridge workaround.  The registry is a [weak property](https://www.fburl.com/diffusion/sunv3bx9) so retain cycles shouldn't be an issue here, let me know if that's incorrect.

As a nice bonus, this fixes dynamic font sizing in bridgeless mode. It was broken before since it relied on the bridge.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D24256338

fbshipit-source-id: 141d36239ac6a6e9e87ca96eea7aeec56729095d
2020-10-12 12:49:29 -07:00
simek b7167c23fc PlatformColors: add missing clearColor for iOS (#30054)
Summary:
This small PR adds missing [`clearColor`](https://developer.apple.com/documentation/uikit/uicolor/1621945-clearcolor?language=objc) to the avaiable PlatformColors on iOS.

**Please let me know** if you would like to see ["Fixed colors"](https://developer.apple.com/documentation/uikit/uicolor/standard_colors?language=objc) added to the `PlatformColors`. I can address this within this PR or create a separate one.

## 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] [Added] - PlatformColors: add missing `clearColor`

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

Test Plan:
[(I had to disable the Dark Mode to fix the RNTester readability problems)](https://user-images.githubusercontent.com/719641/94453196-b35cb000-01b0-11eb-8d7d-73d48ceecf53.PNG)

Transparent/clear color has been added to the RNTester PlatformColors API example:
![IMG_6782](https://user-images.githubusercontent.com/719641/94453172-ae97fc00-01b0-11eb-9bef-1a1a387ac009.PNG)

Reviewed By: shergin

Differential Revision: D24241160

Pulled By: sammy-SC

fbshipit-source-id: 41fb51677329cc3b3f915d5d08694c07b4ef2cf3
2020-10-12 02:14:42 -07:00
Samuel Susla eb7701c1ec Search for Fabric managed view when creating Touch
Summary:
Changelog: [Internal]

If `uiTouch.view` isn't managed by Fabric, go up the view hierarchy to find first view that is.

This is important for host views wrapped by <Touchable>, otherwise touches are not delivered to the component.

Reviewed By: yungsters

Differential Revision: D24219223

fbshipit-source-id: 17b4e3460735371553ee0d30b41776a977f8eafb
2020-10-12 01:59:49 -07:00
Mark Sinkovics 748aa13747 fix: crash when insert nil value into a dictionary (#30066)
Summary:
This PR attempts to fix issue https://github.com/facebook/react-native/issues/28278 and https://github.com/facebook/react-native/issues/29525

On Crashlytics, the following error occurs in file `RCTWebSocketModule.m` at method `-[RCTWebSocketModule webSocket:didFailWithError:]` when a nil value is inserted into a dictionary as a value.

```
Fatal Exception: NSInvalidArgumentException
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
```

This PR is following the suggestion of this: https://github.com/facebook/react-native/issues/28278#issuecomment-597461650 and it replaces the values of any property if it is nil. In detail:
- it converts `error` to empty NSString if the original value is nil
- it converts `socketID` to a NSNumber object, which stores `-1` if the original value is nil

## Changelog

[iOS] [Fixed] - A crash in WebSocket module

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

Test Plan: We were not able to reproduce the crash, but the report itself provided enough information to find a solution for this issue.

Reviewed By: shergin

Differential Revision: D24241147

Pulled By: sammy-SC

fbshipit-source-id: d5d632b49ca77b5d8be8b9c32358bef68f17d30a
2020-10-12 01:47:49 -07:00
Janic Duplessis 6685aba462 Update template to xcode 12 (#30150)
Summary:
This makes a few change to the template xcodeproj

- Update to recommended settings for Xcode 12
- Remove the main.jsbundle file that doesn't exists, this file is included automatically in the app bundle and doesn't need to be in xcode (it won't even be at that path).
- Add -e to the bundle images script. It seems like Xcode doesn't fail the build on script errors anymore so this makes it so the build stop. If it doesn't stop the app will launch and crash because the bundle doesn't exist (note this is only if running the app in release mode since in debug we don't generate the bundle).

## Changelog

[iOS] [Added] - Update template to xcode 12

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

Test Plan: Made the same changes in an app and made sure it ran well.

Reviewed By: cpojer

Differential Revision: D24237481

Pulled By: sammy-SC

fbshipit-source-id: 2b06a24c510c423eb45a1a840ea365b64506321b
2020-10-12 01:28:32 -07:00
Riley Dulin d8b0e9d9ab Add HeapProfiler.lastSeenObjectId and HeapProfiler.heapStatsUpdate to inspector
Summary:
When taking a heap timeline, Hermes wasn't showing any data until the timeline
was written to disk and then reloaded.

Turns out we were missing support for two events:
* `HeapProfiler.lastSeenObjectId`: This event reports the most recently
allocated object ID. Used to know when objects were allocated in the
timeline.
* `HeapProfiler.heapStatsUpdate`: Report how many objects and bytes
exist for a "time fragment", represented by a fragment index. Later updates
to the same index can decrease the amount of live memory, which show up
as grey spikes instead of blue spikes

Previously, we only supported these by writing out to a file, and they didn't work
with a "live" profiling view. To fix this, I changed the periodic sampling thread
to instead be a periodic flush of a sample every few allocations. The performance
impact is tucked away only when profiling is turned on, and it's very non-invasive to
the rest of the GC. The flush calls a callback with the relevant information if the
inspector is on, and the inspector sends a message back to the browser.

Changelog: [Internal] Fix for Hermes heap timeline profiling

Reviewed By: neildhar

Differential Revision: D23993363

fbshipit-source-id: 8e0b571130cbb7e839dfb009b04f584f5179085d
2020-10-10 13:26:13 -07:00
Ramanpreet Nara 9a7f2b590e Log QPL Events from TM + NM, when Perf. Logging is enabled
Summary:
## Previously
- When TurboModules system was on, we'd only log events from the TurboModules system.
- When TurboModules system was off, we'd only log events from the NativeModule system.

This ultimately gives us less data to analyze both systems in production.

## Changes in This Diff
When perf. logging is on, we'll log events from both systems. Each QPL event now include an annotation of which system the event is coming from. Concretely, this will allow us to see how much of the NativeModule system is being exercised in the TurboModule test group.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24232594

fbshipit-source-id: 7dff57bd74fc7ef744d3e06ff174304f25790456
2020-10-10 02:51:59 -07:00
Luna Wei f9dec99284 Introduce multi-flush logger
Summary:
Changelog:
[Internal][Changed] - export types of performance logger

Reviewed By: rubennorte

Differential Revision: D24099293

fbshipit-source-id: 023459baa3754fb8bfaf6bf7a9061873af5756f9
2020-10-10 02:06:06 -07:00
Joshua Gross f40cdcdfe7 LayoutAnimations: remove "ConsecutiveMetadata" adjustment concept, adjust immediate and delayed mutation indices at the same time
Summary:
Index adjustment is tricky. Seems more reliable to adjust each immediate mutation, and then immediately adjust delayed mutations based on it, rinse and repeat.

Previously it was possible to construct examples where the UI would get into a weird state because index adjustment caused items to be inserted in the wrong location.

Changelog: [Internal]

Reviewed By: kacieb

Differential Revision: D24232926

fbshipit-source-id: f8c445213528c2d2aedacf3e0c73c5bbeb62bc3d
2020-10-09 19:02:19 -07:00
Samuel Susla fa20f25480 Enable multitouch on RCTViewComponentView
Summary:
Changelog: [internal]

RCTViewComponent view should have multipleTouchEnabled set to YES.
Paper has it enabled by default as well.

Reviewed By: JoshuaGross, yungsters

Differential Revision: D24219076

fbshipit-source-id: 74c18632457147b944a8abbacdbecb57e57f62ef
2020-10-09 17:11:43 -07:00
Panagiotis Vekris 254d455103 Add type annotations to prevent issues with planned Flow changes
Summary:
We're planning a fix in Flow (D24112595) that uncovers some existing errors that were
previously suppressed. Adding these annotations prevents them from surfacing during the
deploy of the fix.

Changelog: [Internal]

Reviewed By: dsainati1

Differential Revision: D24147994

fbshipit-source-id: fef59a9427da6db79d4824e39768dd5ad0a8d1a3
2020-10-09 15:52:21 -07:00
Joshua Gross 3aa4de7912 Add debugging mode to non-Fabric NativeViewHierarchyManager
Summary:
Just helpful for debugging sessions.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D24207622

fbshipit-source-id: 904cbaa4512c03581d6a5c3efd69ebfca7972d42
2020-10-09 12:16:50 -07:00
George Zahariev 0c438be6c7 Clean up other Xplat .flowconfigs
Summary:
Types First and the various esproposal flags are on by default as of 0.135

Clean up flowconfigs that have to be in sync with the main one

Changelog: [Internal]

Reviewed By: jimmy623

Differential Revision: D24221995

fbshipit-source-id: 5da2867e2f013ad729a436ada192ecab690cb413
2020-10-09 11:20:41 -07:00
Joshua Gross 0d02c60bae Don't call FabricUIManager.stopSurface from ReactRootView with invalid ID
Summary:
There are cases under investigation where unmountReactApplication is called before the ReactRootView gets an ID; in some or all of those cases, UIManagerBinding.stopSurface cannot get the ReactFabric JSI module and crashes there.

It's still unclear why `unmountReactApplication` is being called in these circumstances - maybe another crash causing React Native teardown?

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D24214712

fbshipit-source-id: 796594653f4ff6d87088c4841b89f06cc873b46f
2020-10-09 03:15:35 -07:00
Héctor Ramos b581bcaae0 TurboModule iOS: Use react-native-codegen FBReactNativeSpec output
Summary:
Use the ObjC++ native modules files generated by `react-native-codegen` for the FBReactNativeSpec library.

People working with the core native modules may now re-generate these ObjC++ files using `USE_CODEGEN=1 pod install` or `scripts/generate-native-modules-specs.sh`.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D22249978

fbshipit-source-id: a12db23defacdba36099a24ce0b8475c8973bd6d
2020-10-09 00:15:16 -07:00
Valentin Shergin 7ebb71a32f Back out "Align multi-line TextInput onSubmitEditing behavior"
Summary:
This is a revert of D22488870 (521b16730d). (https://github.com/facebook/react-native/pull/29177)
We have to revert it because we realized that it's a breaking change without a very good reason. We have to figure out a better way to unify platform behaviors.

Changelog:
[iOS][Fixed] - Reverted recent change in TextInput (#29177)

Reviewed By: fkgozali

Differential Revision: D24200517

fbshipit-source-id: af0e561a6b8d9ade487be6b197a5d79d326442b6
2020-10-08 16:08:24 -07:00
simek 38bc5dff36 Remove 'qs' dependency, update yarn lock (#30125)
Summary:
This PR removes unused `qs` package (query string parser) from the main `package.json` file.

I was not able to find any explicit usage of this package in the repository. Looking at the commit which introduced this package it is not clear why it has been added, query string is not processed in any way.

I have also run ` yarn update-lock` to clean up lock after latest dependencies bumps. There are no `qs` package entry removal in yarn lock, because it is already required by `request` package.

Refs: b4785e5144

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

[Internal] [Removed] - remove unused `qs` dependency

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

Test Plan: This change should not affect the code base.

Reviewed By: appden

Differential Revision: D24184372

Pulled By: cpojer

fbshipit-source-id: 4f159f3c554c48ed21839370c8370848df181046
2020-10-08 01:28:19 -07:00