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

3112 Коммитов

Автор SHA1 Сообщение Дата
Logan Daniels f4538e5777 Back out "UIViewController-based status bar management"
Summary:
Original commit changeset: 9ae1384ee20a

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D20289822

fbshipit-source-id: 0db9d99bea458e150d33b3407c256b862dedb9c1
2020-03-05 15:58:43 -08:00
radex 80e6d672f3 UIViewController-based status bar management (#25919)
Summary:
{emoji:26a0} This is a follow up to https://github.com/facebook/react-native/issues/25425 -- which isn't merged yet… See 2a286257a6..125aedbedc for actual diff

Currently, StatusBar native module manages the status bar on iOS globally, using `UIApplication.` APIs. This is bad because:

- those APIs have been deprecated for 4 years
- Apple really, really wants you to have an explicitly defined view controller, and control the status bar there
- it [breaks external native components](https://github.com/facebook/react-native/issues/25181#issuecomment-506792819)
- it's [not compatible with iPadOS 13 multi window support](https://github.com/facebook/react-native/issues/25181#issuecomment-506690818)

for those reasons I we should transition towards view controller-based status bar management.

With that, there is a need to introduce a default React Native root view controller, so I added `RCTRootViewController`. Using it is completely opt-in and there is no breaking change here. However I believe this should be a part of the template for new RN iOS apps.

Additionally, I added `RCTRootViewControllerProtocol` with hooks needed for RCTStatusBarManager to control the status bar. This means apps that want to have total control over their view controller can still opt in to react native VC-based status bar by conforming their root view controller to this protocol.

## Changelog

[iOS] [Added] - Added `RCTRootViewController` and `RCTRootViewControllerProtocol`
[iOS] [Fixed] - `UIViewControllerBasedStatusBarAppearance=YES` no longer triggers an error as long as you use `RCTRootViewController`
[iOS] [Fixed] - Status bar style is now correctly changed in multi-window iPadOS 13 apps if you use `RCTRootViewController` and set `UIViewControllerBasedStatusBarAppearance=YES`
Pull Request resolved: https://github.com/facebook/react-native/pull/25919

Test Plan: - Open RNTester → StatusBar → and check that no features broke

Reviewed By: fkgozali

Differential Revision: D16957766

Pulled By: hramos

fbshipit-source-id: 9ae1384ee20a06933053c4404b8237810f1e7c2c
2020-03-04 14:25:12 -08:00
radex b58e176af0 Moving towards UIWindowScene support (#28058)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/28058

I'm taking the first step towards supporting iOS 13 UIScene APIs and modernizing React Native not to assume an app only has a single window. See discussion here: https://github.com/facebook/react-native/issues/25181#issuecomment-505612941

The approach I'm taking is to take advantage of `RootTagContext` and passing it to NativeModules so that they can identify correctly which window they refer to. Here I'm just laying groundwork.

- [x] `Alert` and `ActionSheetIOS` take an optional `rootTag` argument that will cause them to appear on the correct window
- [x] `StatusBar` methods also have `rootTag` argument added, but it's not fully hooked up on the native side — this turns out to require some more work, see: https://github.com/facebook/react-native/issues/25181#issuecomment-506690818
- [x] `setNetworkActivityIndicatorVisible` is deprecated in iOS 13
- [x] `RCTPerfMonitor`, `RCTProfile` no longer assume `UIApplicationDelegate` has a `window` property (no longer the best practice) — they now just render on the key window

Next steps: Add VC-based status bar management (if I get the OK on https://github.com/facebook/react-native/issues/25181#issuecomment-506690818 ), add multiple window demo to RNTester, deprecate Dimensions in favor of a layout context, consider adding hook-based APIs for native modules such as Alert that automatically know which rootTag to pass

## Changelog

[Internal] [Changed] - Modernize Modal to use RootTagContext
[iOS] [Changed] - `Alert`, `ActionSheetIOS`, `StatusBar` methods now take an optional `surface` argument (for future iPadOS 13 support)
[iOS] [Changed] - RCTPresentedViewController now takes a nullable `window` arg
[Internal] [Changed] - Do not assume `UIApplicationDelegate` has a `window` property
Pull Request resolved: https://github.com/facebook/react-native/pull/25425

Test Plan:
- Open RNTester and:
- go to Modal and check if it still works
- Alert → see if works
- ACtionSheetIOS → see if it works
- StatusBar → see if it works
- Share → see if it works

Reviewed By: PeteTheHeat

Differential Revision: D16957751

Pulled By: hramos

fbshipit-source-id: ae2a4478e2e7f8d2be3022c9c4861561ec244a26
2020-03-04 14:25:12 -08:00
Samuel Susla 3ee1e5312a Back out "Rename measure to measureContent and pass it LayoutContext"
Summary:
Original commit changeset: 8928b59d5194

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D20246918

fbshipit-source-id: 0b9142d9bc4774a07304769126411a34cc8c33c5
2020-03-04 05:01:53 -08:00
Samuel Susla 74034ba23a Back out "Font size in Text now respects preferredContentSizeCategory"
Summary:
Original commit changeset: 3965a127069a

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D20246919

fbshipit-source-id: d2238f279f44ac4394557949c8f148f08a60647e
2020-03-04 05:01:53 -08:00
Samuel Susla 08dda02347 Font size in Text now respects preferredContentSizeCategory
Summary:
Changelog: [Internal]

Use LayoutContext to pass `fontSizeMultiplier` down to ParagrapShadowNode.

Reviewed By: shergin

Differential Revision: D20184596

fbshipit-source-id: 3965a127069a21328ed19cb3f9732f0a2d1c4d58
2020-03-03 04:14:04 -08:00
Samuel Susla b40f0562f5 Rename measure to measureContent and pass it LayoutContext
Summary:
In order to build dynamic text sizing, `LayoutableShadowNode::measure` needs to accept `LayoutContext`

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D20184598

fbshipit-source-id: 8928b59d51948caf3654f40049212a89a91dceb6
2020-03-03 04:14:04 -08:00
Tom Underhill f4de45800f PlatformColor implementations for iOS and Android (#27908)
Summary:
This Pull Request implements the PlatformColor proposal discussed at https://github.com/react-native-community/discussions-and-proposals/issues/126.   The changes include implementations for iOS and Android as well as a PlatformColorExample page in RNTester.

Every native platform has the concept of system defined colors. Instead of specifying a concrete color value the app developer can choose a system color that varies in appearance depending on a system theme settings such Light or Dark mode, accessibility settings such as a High Contrast mode, and even its context within the app such as the traits of a containing view or window.

The proposal is to add true platform color support to react-native by extending the Flow type `ColorValue` with platform specific color type information for each platform and to provide a convenience function, `PlatformColor()`, for instantiating platform specific ColorValue objects.

`PlatformColor(name [, name ...])` where `name` is a system color name on a given platform.  If `name` does not resolve to a color for any reason, the next `name` in the argument list will be resolved and so on.   If none of the names resolve, a RedBox error occurs.  This allows a latest platform color to be used, but if running on an older platform it will fallback to a previous version.
 The function returns a `ColorValue`.

On iOS the values of `name` is one of the iOS [UI Element](https://developer.apple.com/documentation/uikit/uicolor/ui_element_colors) or [Standard Color](https://developer.apple.com/documentation/uikit/uicolor/standard_colors) names such as `labelColor` or `systemFillColor`.

On Android the `name` values are the same [app resource](https://developer.android.com/guide/topics/resources/providing-resources) path strings that can be expressed in XML:
XML Resource:
`@ [<package_name>:]<resource_type>/<resource_name>`
Style reference from current theme:
`?[<package_name>:][<resource_type>/]<resource_name>`
For example:
- `?android:colorError`
- `?android:attr/colorError`
- `?attr/colorPrimary`
- `?colorPrimaryDark`
- `android:color/holo_purple`
- `color/catalyst_redbox_background`

On iOS another type of system dynamic color can be created using the `IOSDynamicColor({dark: <color>, light:<color>})` method.   The arguments are a tuple containing custom colors for light and dark themes. Such dynamic colors are useful for branding colors or other app specific colors that still respond automatically to system setting changes.

Example: `<View style={{ backgroundColor: IOSDynamicColor({light: 'black', dark: 'white'}) }}/>`

Other platforms could create platform specific functions similar to `IOSDynamicColor` per the needs of those platforms.   For example, macOS has a similar dynamic color type that could be implemented via a `MacDynamicColor`.   On Windows custom brushes that tint or otherwise modify a system brush could be created using a platform specific method.

## Changelog

[General] [Added] - Added PlatformColor implementations for iOS and Android
Pull Request resolved: https://github.com/facebook/react-native/pull/27908

Test Plan:
The changes have been tested using the RNTester test app for iOS and Android.   On iOS a set of XCTestCase's were added to the Unit Tests.

<img width="924" alt="PlatformColor-ios-android" src="https://user-images.githubusercontent.com/30053638/73472497-ff183a80-433f-11ea-90d8-2b04338bbe79.png">

In addition `PlatformColor` support has been added to other out-of-tree platforms such as macOS and Windows has been implemented using these changes:

react-native for macOS branch: https://github.com/microsoft/react-native/compare/master...tom-un:tomun/platformcolors

react-native for Windows branch: https://github.com/microsoft/react-native-windows/compare/master...tom-un:tomun/platformcolors

iOS
|Light|Dark|
|{F229354502}|{F229354515}|

Android
|Light|Dark|
|{F230114392}|{F230114490}|

{F230122700}

Reviewed By: hramos

Differential Revision: D19837753

Pulled By: TheSavior

fbshipit-source-id: 82ca70d40802f3b24591bfd4b94b61f3c38ba829
2020-03-02 15:12:09 -08:00
Mihai 06b8b15b0a Fix Image component crashing when uri is null (#28061)
Summary:
This fixes https://github.com/facebook/react-native/issues/28060 with a fix similar to f940e7c4a6

## Changelog

[iOS] [Fixed] - Fix Image component crashing when uri is null
Pull Request resolved: https://github.com/facebook/react-native/pull/28061

Test Plan:
Run an app on iOS that renders `<Image source={{ uri: null }} />`. It should not crash.
![error](https://user-images.githubusercontent.com/4928274/74492398-6bb23e00-4ed7-11ea-8482-664e1786bba8.png)

Reviewed By: sammy-SC

Differential Revision: D20080680

Pulled By: PeteTheHeat

fbshipit-source-id: 119766a4d7eb6804ffd668418a1f158a712a4fe0
2020-02-28 13:36:45 -08:00
Kevin Gozali 30822e3923 make RN infra labels public
Summary:
Internal build target labeling.

Changelog: [Internal]

Reviewed By: zlern2k

Differential Revision: D20152676

fbshipit-source-id: 89615a0b3a6f3994b18f2c07b86d0ae93e052327
2020-02-28 12:46:49 -08:00
Arjan Zuidema 0a9cc34dd8 Added userInterfaceStyle prop to ActionSheetmanager to override user interface style for iOS 13 (#26401)
Summary:
Support to override actionsheet and share interface style to match your app. For example, when your app has it's own theming you want to match the stying on actionsheet and the share menu.

## Changelog

[iOS] [Added] - Added userInterfaceStyle for ActionSheetIOS and Share to override user interface style on IOS 13
Pull Request resolved: https://github.com/facebook/react-native/pull/26401

Test Plan:
Set dark style
![dark](https://user-images.githubusercontent.com/30040390/64685321-12a53080-d487-11e9-8846-f2ef89e114a2.jpg)
Set light style
![light](https://user-images.githubusercontent.com/30040390/64685322-12a53080-d487-11e9-9dfd-1e07b9fe0ce2.jpg)

Differential Revision: D17314080

Pulled By: hramos

fbshipit-source-id: f84278ca99ba20347d17e27295f661d6690fa68c
2020-02-28 00:08:54 -08:00
Mo Gorhom 576ddfb3a8 Dark mode support for RCTPerfMonitor (#28130)
Summary:
Hi There 👋,

While I'm developing on iOS with dark appearance enabled, i notice that `Pref Monitor` view doesn't support dark mode yet, so here is the PR to fix it :)

## Changelog

[iOS] [Fixed] - Fix Pref Monitor in dark appearance
Pull Request resolved: https://github.com/facebook/react-native/pull/28130

Test Plan:
Run any React Native app on iOS > Turn on dark appearance
### Before
![Before](https://user-images.githubusercontent.com/4061838/74872974-8b75b600-535e-11ea-8550-763a598547ec.png)
### After
![After](https://user-images.githubusercontent.com/4061838/74872978-8ca6e300-535e-11ea-9862-4d3014e849f7.png)

Reviewed By: RSNara

Differential Revision: D20080019

Pulled By: PeteTheHeat

fbshipit-source-id: 9365daa3f7193a11760bc1372b8de2c3896def5c
2020-02-27 17:31:23 -08:00
Ramanpreet Nara 6a9a76e420 Make RCTDevLoadingView TurboModule-compatible
Summary:
This is a redo of D16969764, with a few extensions.

## Changes
1. Move `RCTDevLoadingView.{h,m}` to `CoreModuels/RCTDevLoadingView.{h,mm}`
2. Extract ObjC API of `RCTDevLodingView` into `RCTDevLoadingViewProtocol` in `ReactInternal`.
3. Create API `RCTDevLoadingViewSetEnabled.h` in `ReactInternal` to enable/disable `RCTDevLoadingView`

Changelog:
[iOS][Added] - Make RCTDevLoadingView TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18642554

fbshipit-source-id: 6b62e27e128d98254b7a6d018399ec1c06e274fc
2020-02-27 17:06:13 -08:00
Valentin Shergin 041ce53002 Proper `nativeID` prop type in `UIView+React` category implementation
Summary:
`nativeId` type is `NSString`, not `NSNumber`. The `.h` file already has the proper type but `.mm` had a wrong one.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D20135465

fbshipit-source-id: e5f9fbf4940d3883334c910f96f0aa850a069d8c
2020-02-27 13:05:22 -08:00
Valentin Shergin 6589b64518 Codemod: Clang-format for all files in `React/Fabric` directory
Summary:
We are moving towards 100%-prettified files. That's another step when we apply Clang Format for `React/Fabric`.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20112417

fbshipit-source-id: 020d818e5cb8e2f509c5276738c8f252f6817a56
2020-02-26 21:31:12 -08:00
Tommy Nguyen d0a32c2011 iOS: Make RCTKeyWindow multi-window aware and add UIScene support to RCTRedBox (#28147)
Summary:
`RCTRedBox` doesn't appear in apps implementing `UISceneDelegate`.

## Changelog

[iOS] [Changed] - `RCTKeyWindow()` is now multi-window aware
[iOS] [Fixed] - `RCTRedBox` doesn't appear in apps implementing `UISceneDelegate`
Pull Request resolved: https://github.com/facebook/react-native/pull/28147

Test Plan:
- Trigger an error in RNTester
- Trigger an error in an app implementing `UISceneDelegate`

![Simulator Screen Shot - iPhone 11 Pro Max - 2020-02-21 at 14 17 54](https://user-images.githubusercontent.com/4123478/75037702-14066a80-54b5-11ea-9373-b56b467be845.png)

Reviewed By: PeteTheHeat

Differential Revision: D20036399

Pulled By: hramos

fbshipit-source-id: 07d83e985b02296f930114e3c7100c2077e82300
2020-02-26 19:55:14 -08:00
Tommy Nguyen 74b667dbc2 iOS: Fix RCTDevLoadingView not showing up with UIScene (#27916)
Summary:
Attaches the loading view to a `UIScene` in apps using the new Scenes API (iOS 13+).

## Changelog

[iOS] [Fixed] - Fix RCTDevLoadingView not showing up with UIScene
Pull Request resolved: https://github.com/facebook/react-native/pull/27916

Test Plan:
Create a new app based on UIScene and integrate React Native.

| Before | After  |
|:------:|:------:|
 | <img width="453" alt="image" src="https://user-images.githubusercontent.com/4123478/73485717-eccfe800-43a3-11ea-96fd-f7077a348345.png"> | <img width="453" alt="image" src="https://user-images.githubusercontent.com/4123478/73485749-f9ecd700-43a3-11ea-8a18-2e2185e62e78.png"> |

Reviewed By: PeteTheHeat

Differential Revision: D20104655

Pulled By: hramos

fbshipit-source-id: 86c1902c00f791fd23f75ea7562b44c92e719c5e
2020-02-26 19:06:02 -08:00
Samuel Susla f936b65883 Creating new state should now correctly increment state revision
Summary:
Changelog: [Internal]

# Problem

Calling `UIManager::updateState` does not increment state revision because it calls `ConcreteComponentDescriptor::createState` which creates new state with state revision 1.

# How did this propagate?

This error propagated itself in TextInput when trying to input a value, you would be only allowed to type in 1 character.

Reviewed By: JoshuaGross

Differential Revision: D20072844

fbshipit-source-id: 37b8173307e1d91d6e9c41b5ff2e185dde31cc38
2020-02-26 03:32:19 -08:00
Samuel Susla af5ecb2916 Fix layer.mask not being reset after recycle
Summary:
Changelog: [Internal]

If `layer.mask` was set and the view got reused without having a different `layer.mask`, this value would persist between reuses.

I also added a call to `super finalizeUpdates` as it is best practice to call super, the parent class right now doesn't do anything but in the future we might add there some default logic.

Reviewed By: shergin

Differential Revision: D20030174

fbshipit-source-id: c90be3f4e9a8f3814000f177a3d50061f5aa120c
2020-02-25 07:04:58 -08:00
Logan Daniels 10c13fd811 Move requiresMainQueueSetup to the right implementation in RCTDevSettings
Summary: Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D20068813

fbshipit-source-id: fcf522ae2a075ba396d074cbf59f1ecc016b7c90
2020-02-24 15:14:09 -08:00
Rachel Nabors c0d8c1db90 Updating the URLs to point at new domain name reactnative.dev
Summary:
We recently updated React Native's docs site to have its own domain reactnative.dev and needed to update the URLs in the source code

CHANGELOG:
[INTERNAL]

Reviewed By: hramos

Differential Revision: D20072842

fbshipit-source-id: 1970d9214c872a6e7abf697d99f8f5360b3b308e
2020-02-24 13:09:11 -08:00
Varun Patel 8c10147ed5 Revert D20008608: iOS: Fix RCTDevLoadingView not showing up with UIScene
Differential Revision:
D20008608

Original commit changeset: ce59fd0b000d

fbshipit-source-id: aff385a9586de92c4033f994839617ba675ff365
2020-02-21 19:04:14 -08:00
Saumya Mukul 1e7ed81d16 Prevent modal dismissal with swipe gestures
Summary:
(Fixing the problems in this diff https://our.intern.facebook.com/intern/diff/D19836548/)

iOS 13 introduced interactive dismissal for modals https://medium.com/hacknicity/view-controller-presentation-changes-in-ios-13-ac8c901ebc4e.
This breaks react modals. We're disabling this feature for react modals
Changelog: [iOS][Fixed]  Prevent interactive dismissal for non-fullscreen modals

Reviewed By: shergin

Differential Revision: D19880343

fbshipit-source-id: e2ad82db3dd827812824862f432d549c865216b9
2020-02-20 17:31:38 -08:00
Tommy Nguyen 8ce27df08a iOS: Fix RCTDevLoadingView not showing up with UIScene (#27916)
Summary:
Attaches the loading view to a `UIScene` in apps using the new Scenes API (iOS 13+).

## Changelog

[iOS] [Fixed] - Fix RCTDevLoadingView not showing up with UIScene
Pull Request resolved: https://github.com/facebook/react-native/pull/27916

Test Plan:
Create a new app based on UIScene and integrate React Native.

| Before | After  |
|:------:|:------:|
 | <img width="453" alt="image" src="https://user-images.githubusercontent.com/4123478/73485717-eccfe800-43a3-11ea-96fd-f7077a348345.png"> | <img width="453" alt="image" src="https://user-images.githubusercontent.com/4123478/73485749-f9ecd700-43a3-11ea-8a18-2e2185e62e78.png"> |

Reviewed By: cpojer

Differential Revision: D20008608

Pulled By: hramos

fbshipit-source-id: ce59fd0b000d7dee51985a5533d9b5791687f592
2020-02-20 15:38:16 -08:00
Sharon Gong aebf54aee4 Add localized accessibility strings to React Core pod (#27995)
Summary:
The accessibility roles and states description strings are not able to be localized on iOS platform. Those strings are exposed to the end users so it should be localized. This PR is to add localized strings as a resource bundle to the React Core Pod so that any React Native app integrating the React Native dependencies using CocoaPods can get the localized accessibility roles and states description.

## Changelog

[iOS] [Added] - Add localized accessibility strings to React Core pod
Pull Request resolved: https://github.com/facebook/react-native/pull/27995

Test Plan: Verified with RNTester app.

Differential Revision: D19975587

Pulled By: PeteTheHeat

fbshipit-source-id: f8eb4e25194f0cd603c98a6221ec87503a2826ed
2020-02-20 14:31:03 -08:00
Janette Cheng a793ed7598 Unbreak the build
Summary:
build-break
overriding_review_checks_triggers_an_audit_and_retroactive_review

fbshipit-source-id: 316b879368503114ea1af16276643301601bcca8
2020-02-20 08:30:46 -08:00
Logan Daniels adf87dd7ed Implement requiresMainQueueSetup in RCTDevSettings.mm
Summary: Changelog: [Fixed] Implement requiresMainQueueSetup in RCTDevSettings

Reviewed By: PeteTheHeat, RSNara

Differential Revision: D19944271

fbshipit-source-id: 5163a5de2aab6ec2bb130589191a2b66d1b30c18
2020-02-18 13:59:28 -08:00
Rick Hanlon cb749f1c52 LogBox - Revert back to RedBox window strategy
Summary: This diff reverts the iOS LogBox module back to the UIWindow strategy used by Redbox.

Reviewed By: sammy-SC

Differential Revision: D19941390

fbshipit-source-id: 4aea09137ea9e8bfc166a733272647a79102bf35
2020-02-18 06:19:44 -08:00
Samuel Susla cebc2c9d3e Do not switch queues if not necessary
Summary:
Changelog: [Internal]

Switching queue here is not necessary if we are already on the main queue.

 This is important for Fabric SSTs, otherwise images are missing.

Reviewed By: shergin

Differential Revision: D19907908

fbshipit-source-id: 52e82484afc8e2f591d0c5cc126952990d992e96
2020-02-18 03:40:51 -08:00
Peter Argany 824e171117 Refactor HotModuleReloadClient setup call from bridge to RCTDevSettings
Summary:
This refactors some logic which sets up HMRClient in JS. The logic should live in RCTDevSettings, so it is shared in bridge/bridgeless mode.

This also means the logic will be compiled out when `RCT_DEV_MENU` is false.

Reviewed By: RSNara

Differential Revision: D19563629

fbshipit-source-id: 5c2553be9fd686a2a178f03bb5eed7a82cbadb1b
2020-02-13 12:27:47 -08:00
Shu Lin 66f89e2e36 Revert D19836548: Prevent modal dismissal with swipe gestures
Differential Revision:
D19836548

Original commit changeset: 2b8c80b86356

fbshipit-source-id: c8118f671e2a5e4d2b2f32a704b0cdc227d5c6c5
2020-02-12 10:41:40 -08:00
Josh Leibsly ca431c2179 Remove product/platform/infra layers from ios supermodules
Summary:
Context: https://fb.workplace.com/groups/2116332615111503/permalink/2773825422695549/

build-break
overriding_review_checks_triggers_an_audit_and_retroactive_review
allow-large-files
allow_many_files

Differential Revision:
D19858113
Ninja: master broken

fbshipit-source-id: d9e531f9579bfe7ef87097f0d50512722eb1de5e
2020-02-12 10:25:27 -08:00
Saumya Mukul 7e8a18840f Prevent modal dismissal with swipe gestures
Summary:
iOS 13 introduced interactive dismissal for modals https://medium.com/hacknicity/view-controller-presentation-changes-in-ios-13-ac8c901ebc4e.

This breaks react modals. We're disabling this feature for react modals

Changelog: [iOS][Fixed]  Prevent interactive dismissal for non-fullscreen modals

Reviewed By: shergin

Differential Revision: D19836548

fbshipit-source-id: 2b8c80b863569af48ff1c2cf74658393b1b583fd
2020-02-11 13:09:22 -08:00
Rick Hanlon 6ba2aeefa8 LogBox - Deallocate _rootViewController to release surface reference and break cycle
Summary:
This def breaks a reference cycle in logbox causing a memory leak in development.

Changelog: [iOS] [Fix] LogBox - Fix dependency cycle

Reviewed By: PeteTheHeat

Differential Revision: D19768068

fbshipit-source-id: 518b9c66499aa092465a9213f955965bffeebd88
2020-02-11 06:58:15 -08:00
Samuel Susla 291a2ffea2 Change behaviour of view command setTextAndSelection
Summary:
Changelog: [Internal]

When I was originally implementing this view command (D19471025), I misunderstood the desired behaviour.

The text parameter isn't meant to change text in the specified `select` but it is supposed to override text of entire text input.

Reviewed By: shergin

Differential Revision: D19793484

fbshipit-source-id: 64ba36ddfa27ac5a0adf48495cb4e985a429e005
2020-02-10 04:25:01 -08:00
Valentin Shergin ed11a12a7c Revert D19235758: Implement onRequestClose for iOS 13+ modals
Differential Revision:
D19235758

Original commit changeset: c0f1d946c77c

fbshipit-source-id: c4a9d7876aa8d07ff5b8419f097b02e9c28e2880
2020-02-06 14:45:42 -08:00
Jorge Bernal 8e5fac89bb Implement onRequestClose for iOS 13+ modals (#27618)
Summary:
Starting on iOS 13, a View Controller presented modally will have a "bottom sheet" style unless it's explicitly presented full screen.

Before this, modals on iOS were only being dismissed programatically by setting `visible={false}`. However, now that the dismissal can happen on the OS side, we need a callback to be able to update the state.

This PR reuses the `onRequestClose` prop already available for tvOS and Android, and makes it work on iOS for this use case.

Should fix https://github.com/facebook/react-native/issues/26892

## Changelog

[iOS] [Added] - Add support for onRequestClose prop to Modal on iOS 13+
Pull Request resolved: https://github.com/facebook/react-native/pull/27618

Test Plan:
I tested this using the RNTester app with the Modal example:

1. Select any presentation style other than the full screen ones
2. Tap Present and the modal is presented
3. Swipe down on the presented modal until dismissed
4. Tap Present again and a second modal should be presented

![Screen Recording 2019-12-26 at 14 05 33](https://user-images.githubusercontent.com/8739/71477208-0ac88c80-27e9-11ea-9342-8631426a9b80.gif)

Differential Revision: D19235758

Pulled By: shergin

fbshipit-source-id: c0f1d946c77ce8d1baab209eaef7eb64697851df
2020-02-05 21:42:17 -08:00
Marcus Zarra 30790be1b5 Adding [super initialize] to correct misreporting by MDCD
Summary:
In working to remove dead code from the code base, we identified that a number of classes that subclassed `RCTEventEmitter` were being reported as unused when they are in active use.  That was due to a lack of a `[super initialize]`.  This diff adds the call to super.

Changelog:
[General] [Added] - Call to `super` in `+initialize` of `RCTEventEmitter`

Reviewed By: javache

Differential Revision: D19727783

fbshipit-source-id: 19c6c7f08e7a8b2f764988fdfcd70f92dbf1b74b
2020-02-05 09:26:56 -08:00
Samuel Susla 12b43ef418 Implement RCTFabricSurface.synchronouslyWaitForStage
Summary:
Changelog: [Internal]

Exposes `synchronouslyWaitForStage` to `RCTFabricSurface`.

This is a first step towards having screenshot tests rendered with Fabric.

Reviewed By: shergin

Differential Revision: D19603837

fbshipit-source-id: 26c14cf3bbd67fea96319ff08d3321557ddcdd9c
2020-01-30 10:11:12 -08:00
Rick Hanlon 2f9d94418d Don't log for unavailable modules during reload
Summary:
Removes logging for known invalid states.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D18966536

fbshipit-source-id: 483dce1d2bf0c6c92458f618789cf98dcf92ee97
2020-01-29 04:33:04 -08:00
Leo Natan f501ed682a Use Apple unified logging API (os_log) (#27892)
Summary:
As discussed in https://github.com/facebook/react-native/issues/27863, the following changes were made to modernize the internal default logging function:

- `RCTDefaultLogThreshold` is now set to `RCTLogLevelTrace` in both release and debug builds—the Apple logging system will discard uncollected log entires, while allowing for collection when needed
- `RCTLogLevel` is translated to the appropriate log type
- The log subsystem is "com.facebook.react.log"
- `RCTLogSource` translates to the appropriate category ("native"/"javascript")
- Log the provided message using `os_log_with_type`

Closes https://github.com/facebook/react-native/issues/27863

## Changelog

[iOS] [Changed] - Use Apple unified logging API (os_log)
Pull Request resolved: https://github.com/facebook/react-native/pull/27892

Test Plan:
## From Original PR

Ran a test app in the iOS simulator, and verified that logs are correctly displayed in Console.app as well as using the following command:
```sh
/usr/bin/xcrun simctl spawn booted log stream --level debug --style compact --predicate 'process=="ReactNativeTesterApp" && subsystem=="com.facebook.react.log"'
```

## Peter's Test Plan

1. Apply P125583473
2. Verify log output in Xcode P125583504
3. Apply this diff
4. Verify log output in Xcode P125583597

These appear unchanged, after digging into why, I realized that FB doesn't even use the default log function, we inject a custom one [here](https://fburl.com/diffusion/887a1axs). So this PR shouldn't affect us at all. :)

Differential Revision: D19605414

Pulled By: PeteTheHeat

fbshipit-source-id: 1d70fb702c337a759905d4a65a951a31353ce775
2020-01-28 15:23:59 -08:00
Samuel Susla af1762cce5 Fix crash in RCTImageComponentView.didReceiveImage
Summary:
Changelog: [Internal]

I went over the ownership model in this call `_state->getData().getImageRequest().getImageInstrumentation().didSetImage();`

1. `getData()` returns reference to an object that is copied to state.
2. `getImageRequest()` returns a reference to an object that is strongly owned by `ImageState`.
3. `getImageInstrumentation()` returns a reference to an object that is strongly owned by `ImageRequest`.

I don't think any of these can cause a crash, however `_state` can be nullptr.

Reviewed By: shergin

Differential Revision: D19599258

fbshipit-source-id: 317f03cd9a53d83f64ccbb9f9abfce10fcc1fae5
2020-01-28 12:04:31 -08:00
Nicolas Charpentier 56dfc86d64 Enable dev keyboard shortcuts on Mac Catalyst (#27479)
Summary:
This enables the dev menu to bo opened from keyboard shortcuts in dev from a Mac Catalyst app.

cc TheSavior andymatuschak radex

## Changelog

[iOS] [Fixed] - Enable dev keyboard shortcuts on Mac Catalyst
Pull Request resolved: https://github.com/facebook/react-native/pull/27479

Test Plan:
It depends on https://github.com/facebook/react-native/issues/27469 (to have working WebSocket in debug).

![image](https://user-images.githubusercontent.com/7189823/70629346-d3a68880-1bf7-11ea-8949-7553157a2f9c.png)

Differential Revision: D19576528

Pulled By: shergin

fbshipit-source-id: 32b4f8424fb7d270640af4bc50dba24f488bef4f
2020-01-26 19:57:18 -08:00
Nikita Shanin 6237cfb325 disable momentum scrolling for vertical ScrollView (#27666)
Summary:
Following up changes added in https://github.com/facebook/react-native/issues/24045 I had the same use case for vertical ScrollView. This PR just enables existing `disableIntervalMomentum` property to work with vertical ScrollViews: restricts vertical pagination when page height is less than height of ScrollView.

## Changelog

[General] [Changed] - changed property `disableIntervalMomentum` to work with both horizontal and vertical ScrollViews
Pull Request resolved: https://github.com/facebook/react-native/pull/27666

Test Plan:
No new tests at the moment

`iOS`
```
All tests
Test Suite RNTesterUnitTests.xctest started
RCTAllocationTests
    ✓ testBridgeIsDeallocated (0.045 seconds)
    ✓ testContentViewIsInvalidated (0.006 seconds)
    ✓ testModuleMethodsAreDeallocated (0.002 seconds)
    ✓ testModulesAreDeallocated (0.022 seconds)
    ✓ testModulesAreInvalidated (0.017 seconds)
RCTAnimationUtilsTests
    ✓ testClampExtrapolate (0.002 seconds)
    ✓ testExtendExtrapolate (0.002 seconds)
    ✓ testIdentityExtrapolate (0.001 seconds)
    ✓ testManySegments (0.003 seconds)
    ✓ testSimpleOneToOneMapping (0.002 seconds)
    ✓ testWiderInputRange (0.003 seconds)
    ✓ testWiderOutputRange (0.002 seconds)
RCTBlobManagerTests
    ✓ testCreateFromParts (0.002 seconds)
    ✓ testRemove (0.001 seconds)
    ✓ testResolve (0.001 seconds)
    ✓ testResolveMap (0.001 seconds)
    ✓ testResolveURL (0.001 seconds)
RCTBundleURLProviderTests
    ✓ testBundleURL (0.041 seconds)
    ✓ testIPURL (0.005 seconds)
    ✓ testLocalhostURL (0.005 seconds)
RCTComponentPropsTests
    ✓ testNeedsOffscreenAlphaCompositing (0.019 seconds)
    ✓ testResetBackgroundColor (0.008 seconds)
    ✓ testResetProps (0.012 seconds)
    ✓ testSetProps (0.009 seconds)
RCTConvert_NSURLTests
    ✓ test_basic (0.002 seconds)
    ✓ test_documentsFolder (0.001 seconds)
    ✓ test_filePath (0.001 seconds)
    ✓ test_filePathWithEncodedSpaces (0.001 seconds)
    ✓ test_filePathWithSpaces (0.001 seconds)
    ✓ test_fileURL (0.001 seconds)
    ✓ test_fullURL (0.001 seconds)
    ✓ test_imageAt2XPath (0.001 seconds)
    ✓ test_imageFile (0.001 seconds)
    ✓ test_imageURL (0.001 seconds)
    ✓ test_imageURLWithSpaces (0.001 seconds)
    ✓ test_null (0.001 seconds)
    ✓ test_unicodeURL (0.001 seconds)
    ✓ test_urlWithEncodedSpaces (0.001 seconds)
    ✓ test_urlWithSpaces (0.001 seconds)
    ✓ testDataURL (0.003 seconds)
RCTConvert_YGValueTests
    ✓ testNumberPoints (0.002 seconds)
    ✓ testStringPercent (0.002 seconds)
    ✓ testUndefined (0.001 seconds)
RCTDevMenuTests
    ✓ testClosingActionSheetAfterAction (0.009 seconds)
    ✓ testShowCreatingActionSheet (0.017 seconds)
RCTEventDispatcherTests
    ✓ testBasicCoalescingReturnsLastEvent (0.006 seconds)
    ✓ testCoalescingEventIsImmediatelyDispatched (0.001 seconds)
    ✓ testDifferentEventTypesDontCoalesce (0.001 seconds)
    ✓ testDifferentViewTagsDontCoalesce (0.001 seconds)
    ✓ testLegacyEventsAreImmediatelyDispatched (0.001 seconds)
    ✓ testMultipleEventsResultInOnlyOneDispatchAfterTheFirstOne (0.001 seconds)
    ✓ testNonCoalescingEventIsImmediatelyDispatched (0.001 seconds)
    ✓ testRunningTheDispatchedBlockResultInANewOneBeingEnqueued (0.001 seconds)
    ✓ testSameEventTypesWithDifferentCoalesceKeysDontCoalesce (0.001 seconds)
RCTFontTests
    ✓ testFamily (0.029 seconds)
    ✓ testFamilyAndStyle (0.001 seconds)
    ✓ testFamilyAndWeight (0.002 seconds)
    ✓ testFamilyStyleAndWeight (0.002 seconds)
    ✓ testInvalidFont (0.002 seconds)
    ✓ testSize (0.001 seconds)
    ✓ testStyle (0.003 seconds)
    ✓ testStyleAndWeight (0.002 seconds)
    ✓ testVariant (0.002 seconds)
    ✓ testWeight (0.002 seconds)
RCTFormatErrorTests
    ✓ testSymbolication (0.002 seconds)
RCTGzipTests
    ✓ testDontRezipZippedData (0.004 seconds)
    ✓ testGzip (0.002 seconds)
    ✓ testRequestBodyEncoding (0.003 seconds)
RCTImageLoaderTests
    ✓ testImageDecoding (0.010 seconds)
    ✓ testImageLoaderUsesImageDecoderWithHighestPriority (0.003 seconds)
    ✓ testImageLoaderUsesImageURLLoaderWithHighestPriority (0.004 seconds)
    ✓ testImageLoading (0.004 seconds)
RCTImageUtilTests
    ✓ testLandscapeSourceLandscapeTarget (0.001 seconds)
    ✓ testPortraitSourceLandscapeTarget (0.001 seconds)
    ✓ testPortraitSourcePortraitTarget (0.001 seconds)
    ✓ testRounding (0.001 seconds)
    ✓ testScaling (0.001 seconds)
RCTJSONTests
    ✓ testDecodingArray (0.001 seconds)
    ✓ testDecodingMutableArray (0.001 seconds)
    ✓ testDecodingObject (0.001 seconds)
    ✓ testDecodingString (0.001 seconds)
    ✓ testEncodingArray (0.001 seconds)
    ✓ testEncodingNSError (0.023 seconds)
    ✓ testEncodingObject (0.001 seconds)
    ✓ testEncodingString (0.001 seconds)
    ✓ testErrorPointer (0.002 seconds)
    ✓ testLeadingWhitespace (0.001 seconds)
    ✓ testNaN (0.001 seconds)
    ✓ testNotJSONSerializable (0.001 seconds)
    ✓ testNotUTF8Convertible (0.004 seconds)
RCTMethodArgumentTests
    ✓ testAttributes (0.001 seconds)
    ✓ testGenericArray (0.001 seconds)
    ✓ testGenericDictionary (0.001 seconds)
    ✓ testGenericSet (0.001 seconds)
    ✓ testNamespacedCxxStruct (0.001 seconds)
    ✓ testNestedGenericArray (0.001 seconds)
    ✓ testNewlines (0.001 seconds)
    ✓ testNullability (0.001 seconds)
    ✓ testOneArgument (0.001 seconds)
    ✓ testSemicolonStripping (0.001 seconds)
    ✓ testSpaces (0.001 seconds)
    ✓ testTwoArguments (0.001 seconds)
    ✓ testUnnamedArgs (0.001 seconds)
    ✓ testUntypedUnnamedArgs (0.001 seconds)
    ✓ testUnused (0.001 seconds)
RCTModuleInitNotificationRaceTests
    ✓ testViewManagerNotInitializedBeforeSetBridgeModule (0.009 seconds)
RCTModuleInitTests
    ✓ testCustomInitModuleInitializedAtBridgeStartup (0.005 seconds)
    ✓ testCustomSetBridgeModuleInitializedAtBridgeStartup (0.006 seconds)
    ✓ testExportConstantsModuleInitializedAtBridgeStartup (0.005 seconds)
    ✓ testInjectedModulesInitializedDuringBridgeInit (0.003 seconds)
    ✓ testLazyInitModuleNotInitializedDuringBridgeInit (0.005 seconds)
RCTModuleMethodTests
    ✓ testFunctionType (0.001 seconds)
    ✓ testNonnull (0.001 seconds)
    ✓ testNumbersNonnull (0.001 seconds)
    ✓ testReturnsNilForDefaultFunction (0.001 seconds)
    ✓ testReturnsValueForSyncFunction (0.001 seconds)
    ✓ testReturnTypeForSyncFunction (0.001 seconds)
    ✓ testStructArgument (0.001 seconds)
    ✓ testWhitespaceTolerance (0.001 seconds)
RCTMultipartStreamReaderTests
    ✓ testMultipleParts (0.001 seconds)
    ✓ testNoCloseDelimiter (0.001 seconds)
    ✓ testNoDelimiter (0.001 seconds)
    ✓ testSimpleCase (0.001 seconds)
RCTNativeAnimatedNodesManagerTests
    ✓ testAdditionNode (0.002 seconds)
    ✓ testAnimationCallbackFinish (0.001 seconds)
    ✓ testCritcallyDampedSpringAnimation (0.003 seconds)
    ✓ testDecayAnimation (0.004 seconds)
    ✓ testDecayAnimationLoop (0.012 seconds)
    ✓ testFramesAnimation (0.001 seconds)
    ✓ testFramesAnimationLoop (0.002 seconds)
    ✓ testHandleStoppingAnimation (0.002 seconds)
    ✓ testInterpolationNode (0.002 seconds)
    ✓ testMultiplicationNode (0.001 seconds)
    ✓ testNativeAnimatedEventDoNotUpdate (0.001 seconds)
    ✓ testNativeAnimatedEventDoUpdate (0.002 seconds)
    ✓ testNodeValueListenerIfListening (0.001 seconds)
    ✓ testNodeValueListenerIfNotListening (0.001 seconds)
    ✓ testSpringAnimationLoop (0.007 seconds)
    ✓ testSpringTrackingRetainsSpeed (0.007 seconds)
    ✓ testTracking (0.002 seconds)
    ✓ testTrackingPausesWhenEndValueIsReached (0.001 seconds)
    ✓ testUnderdampedSpringAnimation (0.003 seconds)
    ✓ testViewReceiveUpdatesIfOneOfAnimationHasntStarted (0.001 seconds)
    ✓ testViewReceiveUpdatesWhenOneOfAnimationHasFinished (0.001 seconds)
RCTPerformanceLoggerTests
    ✓ testLabelCountInSyncWithRCTPLTag (0.001 seconds)
RCTShadowViewTests
    ✓ testAncestorCheck (0.001 seconds)
    ✓ testApplyingLayoutRecursivelyToShadowView (0.002 seconds)
    ✓ testAssignsSuggestedHeightDimension (0.001 seconds)
    ✓ testAssignsSuggestedWidthDimension (0.001 seconds)
    ✓ testDoesNotAssignSuggestedDimensionsWhenStyledWithFlexAttribute (0.001 seconds)
    ✓ testDoesNotOverrideDimensionStyleWithSuggestedDimensions (0.001 seconds)
RCTUIManagerTests
    ✓ testManagingChildrenToAddRemoveAndMove (0.001 seconds)
    ✓ testManagingChildrenToAddViews (0.001 seconds)
    ✓ testManagingChildrenToRemoveViews (0.001 seconds)
RCTURLUtilsTests
    ✓ testAppendParam (0.001 seconds)
    ✓ testDuplicateParamTakesLatter (0.001 seconds)
    ✓ testGetEncodedParam (0.001 seconds)
    ✓ testGetQueryParam (0.001 seconds)
    ✓ testIsLocalAssetsURLParam (0.001 seconds)
    ✓ testNilURLAppendQueryParam (0.001 seconds)
    ✓ testNilURLGetQueryParam (0.001 seconds)
    ✓ testQueryParamNotFound (0.001 seconds)
    ✓ testRemoveParam (0.001 seconds)
    ✓ testReplaceEncodedParam (0.001 seconds)
    ✓ testReplaceParam (0.001 seconds)
RCTUnicodeDecodeTests
    ✓ testEmojis (0.001 seconds)
    ✓ testNiqqud (0.001 seconds)

         Executed 167 tests, with 0 failures (0 unexpected) in 0.530 (0.667) seconds
```
`Android`
```
PASS      8.4s  7 Passed   0 Skipped   0 Failed   com.facebook.react.animated.NativeAnimatedInterpolationTest
PASS     16.7s 23 Passed   0 Skipped   0 Failed   com.facebook.react.animated.NativeAnimatedNodeTraversalTest
PASS     13.5s  4 Passed   0 Skipped   0 Failed   com.facebook.react.bridge.BaseJavaModuleTest
PASS     341ms  4 Passed   0 Skipped   0 Failed   com.facebook.react.bridge.FallbackJSBundleLoaderTest
PASS    <100ms  1 Passed   0 Skipped   0 Failed   com.facebook.react.bridge.JavaOnlyArrayTest
PASS     13.0s 10 Passed   0 Skipped   0 Failed   com.facebook.react.devsupport.JSDebuggerWebSocketClientTest
PASS      6.3s  4 Passed   0 Skipped   0 Failed   com.facebook.react.devsupport.MultipartStreamReaderTest
PASS      6.1s  5 Passed   0 Skipped   0 Failed   com.facebook.react.devsupport.StackTraceHelperTest
PASS     13.9s  6 Passed   0 Skipped   0 Failed   com.facebook.react.modules.blob.BlobModuleTest
PASS      6.7s  5 Passed   0 Skipped   0 Failed   com.facebook.react.modules.camera.ImageStoreManagerTest
PASS      5.2s  1 Passed   0 Skipped   0 Failed   com.facebook.react.modules.clipboard.ClipboardModuleTest
PASS      3.8s  5 Passed   0 Skipped   0 Failed   com.facebook.react.modules.dialog.DialogModuleTest
PASS    <100ms 10 Passed   0 Skipped   0 Failed   com.facebook.react.modules.network.HeaderUtilTest
PASS      3.3s 14 Passed   0 Skipped   0 Failed   com.facebook.react.modules.network.NetworkingModuleTest
PASS      1.4s  9 Passed   0 Skipped   0 Failed   com.facebook.react.modules.network.ProgressiveStringDecoderTest
PASS      1.6s  4 Passed   0 Skipped   0 Failed   com.facebook.react.modules.network.ReactCookieJarContainerTest
PASS      2.2s  2 Passed   0 Skipped   0 Failed   com.facebook.react.modules.share.ShareModuleTest
PASS      5.1s  6 Passed   0 Skipped   0 Failed   com.facebook.react.modules.storage.AsyncStorageModuleTest
PASS      2.7s  9 Passed   0 Skipped   0 Failed   com.facebook.react.modules.timing.TimingModuleTest
PASS      9.2s  9 Passed   0 Skipped   0 Failed   com.facebook.react.packagerconnection.JSPackagerClientTest
PASS      7.3s  4 Passed   0 Skipped   0 Failed   com.facebook.react.uimanager.layoutanimation.InterpolatorTypeTest
PASS      8.9s  2 Passed   0 Skipped   0 Failed   com.facebook.react.uimanager.BaseViewManagerTest
PASS      6.7s  4 Passed   0 Skipped   0 Failed   com.facebook.react.uimanager.MatrixMathHelperTest
PASS      8.8s  3 Passed   0 Skipped   0 Failed   com.facebook.react.uimanager.SimpleViewPropertyTest
PASS    <100ms  1 Passed   0 Skipped   0 Failed   com.facebook.react.util.JSStackTraceTest
PASS      9.5s  1 Passed   0 Skipped   0 Failed   com.facebook.react.views.image.ImageResizeModeTest
PASS     15.7s  4 Passed   0 Skipped   0 Failed   com.facebook.react.views.image.ReactImagePropertyTest
PASS      9.2s  4 Passed   0 Skipped   0 Failed   com.facebook.react.CompositeReactPackageTest
PASS      9.2s  2 Passed   0 Skipped   0 Failed   com.facebook.react.RootViewTest
```

Differential Revision: D19576473

Pulled By: shergin

fbshipit-source-id: 35a6bce9f7dd3efec0cfcdbb00796852e1a79d6c
2020-01-26 19:10:01 -08:00
Peter Argany 58d226f0b5 Guard against nil bridge during RCTAppState change
Summary: Somehow, `RCTAppState` is still trying to send events without the bridge. This diff effectively silences the warning, since I still believe there is no point sending events to JS if the bridge is nil.

Reviewed By: fkgozali

Differential Revision: D19560149

fbshipit-source-id: 5077335f6a47fe7d1896e078668c1eb4da1339de
2020-01-24 14:20:43 -08:00
Josh Leibsly efc2344868 Rename isolation root to "default" in fbobjc
Summary:
The reason for this change is that it is the primary root that we want people to be using and the naming should reflect that.

#nocancel

build-break
overriding_review_checks_triggers_an_audit_and_retroactive_review

Changelog: [Internal]

Oncall Short Name: fbobjc_sheriff

Differential Revision: D19431128

fbshipit-source-id: c7208e20ed0f5f5eb6c2849428c09a6d4af9b6f3
2020-01-24 08:26:36 -08:00
Valentin Shergin f92b161eb3 SafeAreaView: Custom `description` method extended with inset values
Summary:
That should help with debugging SafeAreaView-related issues (esp. to see the info inside view hierarchy recursive description).

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D19539216

fbshipit-source-id: 1bee481c2766ad2d130e435582876d9f5ed27b3c
2020-01-23 12:53:49 -08:00
Valentin Shergin a69abb419a Fabric: Using State::getRevision() instead of TextInputState::revision
Summary:
Previously, State revision number was implemented manually as part of the StateData. Now we have it as a built-in concept in State, so we can rely on that.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D19467161

fbshipit-source-id: cac907265090730cdb89207aad2b52141cda5dc6
2020-01-23 10:39:14 -08:00
Samuel Susla 6449cc4363 Implement setMostRecentEventCount and setTextAndSelection commands in TextInput
Summary:
Implements JS interface and commands in native, however it isn't connected anywhere.
Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19471025

fbshipit-source-id: 7ec53c04b38cb27b84ef06dea7a0fdb9e1deee60
2020-01-22 05:12:11 -08:00
Kudo Chien a27e31c059 Upgrade Folly to v2020.01.13.00 (#27810)
Summary:
Upgrade Folly to v2020.01.13.00. Fixes https://github.com/facebook/react-native/issues/27640

## Changelog

[iOS] [Changed] - Upgrade Folly to v2020.01.13.00
Pull Request resolved: https://github.com/facebook/react-native/pull/27810

Test Plan: Test by building and running RNTester

Reviewed By: mdvacca

Differential Revision: D19483115

Pulled By: fkgozali

fbshipit-source-id: 4a85325a95b5f7857da75995d587218740d8b077
2020-01-21 12:44:00 -08:00
Valentin Shergin b9ac1d52c9 Fabric: Image, checking for instrumentation not being null before calling on it
Summary:
There is no guarantee that the pointer is not null, so we have to check for it. And particularly, the `instrumentation` pointer is null when the `ImageSource`'s type is `invalid`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D19482208

fbshipit-source-id: e1eab02841b1594136388e51d9d5b5c881ab9366
2020-01-21 07:54:26 -08:00
Samuel Susla f43c9316e1 Add blur and focus native commands to TextInput
Summary:
Add Native Commands handlers to TextInput.
It is intentionally done in a way so that it can be easily swapped for codegened implementation once we properly type TextInput.

We also add native commands to view managers for backwards compatibility.

Changelog: [Internal]

Reviewed By: TheSavior, shergin

Differential Revision: D19412026

fbshipit-source-id: 8dc64275cf1da599b1bd5992a41035d51dd4148f
2020-01-20 03:08:23 -08:00
Peter Argany 8fe04cfd7e Migrate RCTDevSettings to TM
Summary: As titled. The work to write the spec and make this module compatible were done in D18148890.

Reviewed By: RSNara

Differential Revision: D19442016

fbshipit-source-id: 369bb4247d6590d41ec414f93c79d98d4a6bed88
2020-01-17 17:22:14 -08:00
Kevin Gozali 58a6a40eac Re-land [RN] iOS - deprecate iOS 9 support by removing runtime checks for 10.0+
Summary:
Re-landing the reverted change:

This removes all callsites that rely on runtime checks to detect the target deployment version. We no longer need to check for iOS 10+ in a few places. Note: for this to compile, the hosting app needs to target iOS 10.0+.

Changelog: [iOS] [Deprecated] - Deprecate iOS 9

Reviewed By: sammy-SC

Differential Revision: D19411136

fbshipit-source-id: ec0a957dc57819f0ee7d138c858209cabe3e5102
2020-01-15 09:23:30 -08:00
Jiawei Lv f11937ef65 Revert D19271321: iOS - deprecate iOS 9 support by removing runtime checks for 10.0+
Differential Revision:
D19271321

Original commit changeset: 424ad7e21612

fbshipit-source-id: 2bd9599e8fb31914dbcbc03f732379d6c8103028
2020-01-14 21:43:08 -08:00
Kevin Gozali d3e81d5832 iOS - deprecate iOS 9 support by removing runtime checks for 10.0+
Summary:
This removes all callsites that rely on runtime checks to detect the target deployment version. We no longer need to check for iOS 10+ in a few places. Note: for this to compile, the hosting app needs to target iOS 10.0+.

Changelog: [iOS] [Deprecated] - Deprecate iOS 9

Reviewed By: hramos

Differential Revision: D19271321

fbshipit-source-id: 424ad7e2161261d148cb436cc20b4c531a4ba5b7
2020-01-14 18:23:49 -08:00
Nate Stedman 644eb0a961 Revert D19400656: Revert D19377037: [fb_apple_library][codemod][12/12] Add extension API parameters to libraries
Differential Revision:
D19400656

Original commit changeset: 57deddfd6006

fbshipit-source-id: 5271e9faa002ff64508d8e52d0c60bf7a362ff02
2020-01-14 15:27:31 -08:00
Shubho Sadhu 89823c944b Revert D19377037: Add extension API parameters to libraries
Differential Revision:
D19377037

Original commit changeset: 3026a3400570

fbshipit-source-id: 57deddfd6006c6d171a005f4dd35e1d1df30de64
2020-01-14 14:45:39 -08:00
Samuel Susla 6bdfd84a45 Move event structs into event emitter namespace
Summary:
In codegen we generate structs that represents events. These structs are later dispatched by generated `EventEmitter`.
They had unpleasant naming, for example `SliderOnValueChangeStruct`. This diff changes the code generated so it becomes `SliderEventEmitter::OnValueChange`, this better expresses the relationship of the two classes.

Changelog: [Internal]

Motivation: Better express relationship between EventEmitter and classes that represent events.

Reviewed By: rickhanlonii, shergin

Differential Revision: D19373850

fbshipit-source-id: a5eea085013dbc119169e2b06ba9f9fe44c7fcd9
2020-01-14 06:39:33 -08:00
Samuel Susla f15b80b675 Migrate Keyframes to Fabric using interop layer
Summary:
Adds Keyframes to interop whitelist of supported components.
In `RCTKeyframesManager.m` we look into subviews in order to find `RCTKeyframesView`, this is because the view returned from paper's `UIManager` is interop itself.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19309355

fbshipit-source-id: f9b598ee6ad5340a4e4b3914330c70eea9f43926
2020-01-14 06:30:35 -08:00
Samuel Susla 139bf7cffe Add plugin assertion to ensure image component is loaded
Summary:
With plugins being used for components, there is danger that someone will remove buck target as dependency and component in the target won't be available for Fabric.

That's where `plugin_assertion` comes into play. For now I hardcoded a list of components. In the future, this list will be generated from JS components that are used in the app.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19197548

fbshipit-source-id: 0d31f53b573c343561715a8fb6fc7f0abfdb5b76
2020-01-14 04:05:16 -08:00
Nate Stedman 8d57691a60 Add extension API parameters to libraries
Summary: Changelog: [Internal]

Differential Revision: D19377037

fbshipit-source-id: 3026a34005707fb371df60eaacd142988b012751
2020-01-13 23:26:15 -08:00
Valentin Shergin 8219db9a4a Fabric: The basic implementation of <TextInput> for iOS
Summary:
This is the partial implementation of Fabric-compatible <TextInput> component on iOS. All features are supported besides those:
 * `focus()`, `blur()`, `clear()` imperative calls;
 * Controlled TextInput as the whole feature in general;
 * Controlling selection from JavaScript side;
 * `autoFocus` prop;
 * KeyboardAccessoryView.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D17400907

fbshipit-source-id: 0ccd0e0923293e5f504d5fae7b7ba9f048f7d259
2020-01-13 23:22:10 -08:00
Valentin Shergin 41557966b5 Fabric: <TextInput> component on iOS: RCTTextInputUtils
Summary:
RCTTextInputUtils contains a bunch of conventions and convenience functions that we use in TextInput.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D19226658

fbshipit-source-id: df72dcdc052b96b6daef2cc0839235761005d914
2020-01-13 23:22:10 -08:00
Samuel Susla cfbd93ccd5 Fix crash when accessing nullptr imageRequest
Summary:
ImageState if created with default constructor is created with `imageRequest_` being nullptr.
Calling `getObserverCoordinator()` on it was causing a crash.

We create initial state data with `imageRequest` populated.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19332711

fbshipit-source-id: 0266222551dbfb10b3f86e72a43d5306650fd09b
2020-01-13 23:19:26 -08:00
Peter Argany a6c0f5a120 Fix typo in RCTSurface log
Summary:
title

Changelog: [iOS][Internal] Fix typo in RCTSurface log

Reviewed By: zackargyle, sammy-SC

Differential Revision: D19334748

fbshipit-source-id: 61cc984072d2f109d5ae8bce70688094d9fbe67c
2020-01-13 14:23:54 -08:00
Valentin Shergin 5e6c61e449 Fabric: Fixing incorrect retaining policy for RCTSurfacePreseter (crash in RCTNativeAnimatedModule)
Summary:
This fixing a crash in RCTNativeAnimatedModule caused by accessing an `RCTSurfacePreseter` instance as "Objective-C runtime associated object" which was retained with `OBJC_ASSOCIATION_ASSIGN` policy. The documentation for `OBJC_ASSOCIATION_ASSIGN` says "Specifies a weak reference to the associated object." but it's a lie ( https://stackoverflow.com/questions/16569840/using-objc-setassociatedobject-with-weak-references) ). The policy is actually `ASSIGN` (aka `unsafe-unretained`).
That's why it's crashing.

We change that to `OBJC_ASSOCIATION_RETAIN` to retain the object (which meets the expectation of the interface of the category).

We also should not have over-retaining issues because:
* SurfacePresenter does not retain a Bridge or any object that can retain a Bridge;
* SurfacePresenter is a long-living object, we don't recreate it during bridge reloading or stuff like that.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D19333869

fbshipit-source-id: 1ff03659a880f2742b909c5668c47144719eeee2
2020-01-13 13:36:36 -08:00
Jesse Katsumata e8f577e541 feat: add custom color for iOS13 segmented control (#27643)
Summary:
Addresses Issue from https://github.com/react-native-community/react-native-segmented-control/issues/16

SegmentedControlIOS changed how it looks in iOS13.

This PR allows allows more customization of SegmentedControl for iOS13.

## Changelog

[iOS] [Added] - add textColor and backgroundColor props for iOS >=13
Pull Request resolved: https://github.com/facebook/react-native/pull/27643

Test Plan:
| Before | After |
| --- | --- |
| <img src="https://user-images.githubusercontent.com/6936373/71608475-e68ff580-2bc4-11ea-9fe4-b85b99130356.png" width="320" /> | <img src="https://user-images.githubusercontent.com/6936373/71608757-dc6ef680-2bc6-11ea-85be-aa31f25ecf36.png" width="320" /> |

Differential Revision: D19296783

Pulled By: cpojer

fbshipit-source-id: 81a31b2d5ae3085a6fd1874e7d72e75be4c51318
2020-01-06 22:19:37 -08:00
Peter Argany b4d5ffb804 Guard against nil bridge during teardown
Summary:
A UBN surfaced in v252 because [this assert](https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/React/Modules/RCTEventEmitter.m?commit=e5d1e6375a640d0387bb7016d3becd262c22c327&lines=40) started firing, originating from `RCTAppState`.

This appears to be a race condition during RN teardown. RN receives a memory warning and attempts to forward to JS, but the bridge is already destroyed.

IMO, if the bridge is already destroyed, then there shouldn't be a need to send a memory warning to JS? This is just a hunch though, if anyone feels otherwise, please let me know :)

See the UBN task for further details.

Changelog: [iOS][Internal] Guard against nil bridge during teardown

Reviewed By: shergin

Differential Revision: D19293063

fbshipit-source-id: 566f21af30d3d9bcd25a673ce664f8caddc701ca
2020-01-06 17:03:06 -08:00
Valentin Shergin bd0c37e456 Back out "Fabric: Temporary workaround for a deadlock in RCTSurfacePresenter"
Summary:
This is a backout of the temporary workaround.
A proper fix was landed as D19249490.

Original commit changeset: 53d19e90e080

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D19252609

fbshipit-source-id: 4a6239944440f392ef8a0e85a5038ee5f4d774f0
2020-01-06 12:44:56 -08:00
Samuel Susla b920bf8736 Fabric: remove LocalData from mounting layer
Summary:
Changelog: [Internal]

We are moving away from LocalData in favour of State.
LocalData isn't used on iOS anymore, this diff removes it so it can't be reintroduced

Reviewed By: shergin

Differential Revision: D19250731

fbshipit-source-id: aaa5d79b4d885b6bf9b2df2d67d80ecd3d6982bc
2020-01-06 05:25:24 -08:00
Samuel Susla 0c64733c6b Fabric: migrate Slider from LocalData to State
Summary:
Changelog: [Internal]
We are moving away from LocalData in favour of State.

Reviewed By: shergin

Differential Revision: D19250592

fbshipit-source-id: 6d2eef9a0c0e53e0146da609ba0c24fa09766433
2020-01-06 05:25:23 -08:00
Samuel Susla 3d6f5f50a7 Fabric: Migrate Image to State from LocalData
Summary:
Changelog: [Internal]

We are moving away from LocalData in favour of State.

Reviewed By: shergin

Differential Revision: D19247031

fbshipit-source-id: 8884133b13dd111e8d9e2cd4936bf90bfc5b4932
2020-01-06 05:25:23 -08:00
Samuel Susla 8a4f9b31b3 Implement RCTComponentViewClassWithName in single place with conditional compilation
Summary:
Instead of defining `RCTComponentViewClassWithName` in every single app. It is easier to use conditional compilation to determine whether iOS plugins are available or not.

Based on that a plugin for given name will be either come from plugin system or generated map of components.

Changelog: [internal]

Reviewed By: shergin

Differential Revision: D19168527

fbshipit-source-id: cb130fc563a15882e2b163c84ea37aaa3849c16d
2020-01-06 03:45:38 -08:00
Rick Hanlon 88813761ec LogBox - Double sync rendering timeout
Summary:
On slower devices , 0.5s is not fast enough and we frequently render a black screen. Let's bump the sync rendering timeout to 1s.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D19282619

fbshipit-source-id: 0d9ae60f4869b0de7c4523c2cb33fbbf320c6438
2020-01-05 05:22:01 -08:00
Kevin Gozali 674b591809 iOS: Deprecate iOS 9 / tvOS 9 SDK support
Summary:
It is time to target SDK version 10.0+.

Changelog: [iOS] [Deprecated] - Deprecating support for iOS/tvOS SDK 9.x, 10.0+ is now required

Reviewed By: mdvacca

Differential Revision: D19265731

fbshipit-source-id: 93b6f9e8f61c5b36ff69e80d3f18256aa96cc2c0
2020-01-02 12:52:12 -08:00
Valentin Shergin 9c1412882e Fabric: Using shared mutex to protect scheduler object in RCTSurfacePresenter
Summary:
This fixes a deadlock caused by recursive calling of `-[RCTSurfacePresenter setMinimumSize:minimumSize:]` (because of an attempt to lock the mutex which was already locked upper the call stack).
Seems there is no reason why this operation should not be allowed. This diff replaces a regular mutex with a shared one which allows multiple shared locks and this prevents the deadlock. A Scheduler is already a thread-safe object and the mutex only protected the mutation of a pointer to it.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D19249490

fbshipit-source-id: 00e8934c6502328f34b78ea6ec004b7216665db1
2019-12-30 11:21:42 -08:00
Valentin Shergin b2d095d9b3 Fabric: Temporary workaround for a deadlock in RCTSurfacePresenter
Summary:
This fix should stop T59424871 from bleeding. This is just an ugly workaround, I need some time to figure out a proper solution for that.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D19244682

fbshipit-source-id: 53d19e90e080d6c3816c78869826ed2ec0c982eb
2019-12-28 08:58:03 -08:00
Valentin Shergin 23d2a6248c Fabric: Fixed crash in RCTSurfaceTouchHandler (`unordered_set::at()`)
Summary:
It's not fully clear why it happens but sometimes UIKit cancels (calling some UIGersureRecognizer interface) some UITouch events that seem never previously started. That might be a bug in UIKit or in our local registry.
That happens extremely rarely but happens.
After this change, RCTSurfaceTouchHandler will ignore those touches in production but crash in debug mode (I hope we can find a repro case and fix it).

Anyway, ignoring canceling of touches that RCTSurfaceTouchHandler is not aware of should not be a big deal.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D19221204

fbshipit-source-id: 77ce773f7bcc31725bf90a182a91789fd5deeedb
2019-12-23 16:55:53 -08:00
Valentin Shergin 2c09f65f63 Fabric: Codestyle for RCTSurfaceTouchHandler
Summary:
Trivial. I need this to make the next diff readable.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D19221205

fbshipit-source-id: 0f8b608866ea974272901b2b2e208e9cd88c8e0a
2019-12-23 16:55:53 -08:00
Peter Argany 2c40cc714c Make RCTEventEmitter a RCTJSInvokerModule [2/n]
Summary:
Diff 1/N explained how calls to `[_bridge enqueueJSCall:]` can be replaced with `_invokeJS` in a bridgeless world.

This diff replaces RCTEventEmitter's usage of `enqueueJSCall` if the bridge isn't available.

Changelog: [Internal][iOS] Make RCTEventEmitter a RCTJSInvokerModule

Reviewed By: RSNara

Differential Revision: D18941955

fbshipit-source-id: 1b81e46585432e005cff5aa0ab4d151f50ea051b
2019-12-23 13:52:03 -08:00
Peter Argany f0d0c1c688 Introducing RCTJSInvokerModule [1/N]
Summary:
Problem: Certain turbo modules use the bridge to access JS directly by calling something like `[_bridge enqueueJSCall:]`. In a bridgeless world, this API no longer works.

Solution: These turbo modules can implement the new protocol defined here. This protocol provides a block during module init which can be used to call JS directly (using `ReactContext`) instead of going through the bridge.

Changelog: [Internal][iOS] - Introducing RCTJSInvokerModule, a new protocol for turbo modules which call js

Reviewed By: RSNara

Differential Revision: D18941933

fbshipit-source-id: 8d581df06be59debf83575124e7d221145c5afb8
2019-12-23 13:52:03 -08:00
Valentin Shergin 2237ea6d2e Fabric: Fixed crash in RCTGenericDelegateSplitter (collection was mutated while being enumerated)
Summary:
The concept of the class cannot guarantee that the set of delegates cannot be removed as a side-effect of calling a delegate, so we must make a copy of the delegates before calling on them.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D19213549

fbshipit-source-id: 7040b2994433d83e3148ec73820e051729be9e29
2019-12-23 07:46:27 -08:00
Zack Argyle fa65b156d4 Add RCTOverrideAppearancePreference to iOS Appearance module
Summary:
In order to enable more fine-grained control of theming in brownfield apps, this adds RCTOverrideAppearancePreference to RCTAppearance.

## Changelog:
[iOS] [Added] - Adds RCTOverrideAppearancePreference to the iOS Appearance module

Reviewed By: sammy-SC

Differential Revision: D19187657

fbshipit-source-id: 52783c497d32d36af2523fce6f040d6cfb5aac3c
2019-12-20 11:20:48 -08:00
Emilio 7a4753d76a tapping on iOS status bar should scroll inverted ScrollViews to their top (#27574)
Summary:
React Native ScrollViews are flipped upside down when the prop inverted is set to true. This is the root of a bug: tapping on the status bar in iOS should scroll the Flatlist up to the top but currently it does to the bottom.

The solution proposed is to detect natively if the ScrollView is inverted, on such case, prevent it from scrolling it to the beginning of the ScrollView (as a non-inverted ScrollView would do) and force a scroll to the end of it.

I've been careful enough not to force the scroll if the user explicitly selected not to do it or if it's happening in a nested ScrollView, as it is the default behaviour in iOS.

Fixes https://github.com/facebook/react-native/issues/21126

## Changelog

[iOS] [Fixed] - Inverted ScrollViews scroll to their bottom when the status bar is pressed
Pull Request resolved: https://github.com/facebook/react-native/pull/27574

Test Plan:
- on iOS, add a ScrollView and put enough content to overflow the screen size so it can be scrolled
- add the prop `inverted={true}` to the ScrollView
- go to the screen the Scrollview is in and press the status bar
- it should scroll to top (previously it scrolled to the bottom)

![v](https://user-images.githubusercontent.com/807710/71188640-a0ac6680-2281-11ea-91a7-d1e46aba8b14.gif)

Differential Revision: D19185270

Pulled By: hramos

fbshipit-source-id: 5445093ff38f4ba4082f1d883d8ed087e9565eaf
2019-12-19 15:29:54 -08:00
Samuel Susla 5fc3b442ec Migrate Image to Plugins
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19088558

fbshipit-source-id: 10dfcef8d2a244318ded4d55b4e4805663d8139e
2019-12-19 07:35:38 -08:00
Samuel Susla e33b276084 Component views are now loaded through C function rather than delegate
Summary:
I moved towards C function to return component class instead of delegate.

We need this in order to register components that are optimistically registered, such as View, Image and Text.

In D19088558, we need this in order to register Image.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D19088559

fbshipit-source-id: 061f3ba15dfb44b9acce7be2dc6828b9afbecbfa
2019-12-19 07:35:37 -08:00
Valentin Shergin c89ead313c Fabric: Proper implementation of ScrollView::contentOffset-aware measure functions (iOS only for now)
Summary:
This diff re-enables propagation of ScrollView's content-offset value down to the ShadowTree layer and enables measure fucntions opt-in incorporating this info to result.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: zackargyle

Differential Revision: D18981891

fbshipit-source-id: a6c0f4e690703b0ee07d45efab161750cfcc4b60
2019-12-18 10:48:40 -08:00
Andy Matuschak f21fa4ecb7 Enabling RCTWebSocket on UIKitForMac (macOS Catalyst) (#27469)
Summary:
In https://github.com/facebook/react-native/issues/25427, radex added initial support for running React Native projects on macOS via Catalyst. However, `RCTWebSocket` was disabled for that target because of some compilation issues. This meant that running projects via a connection to the packager wasn't possible: no live reload, and projects must be run in "Release" mode. It also meant making manual changes to Xcode projects deploying to macOS and scattering a number of conditional checks throughout the codebase.

In this change, I've implemented support for `RCTWebSocket` on the macOS target and re-enabled the affected features. Live reload and the inspector now work for macOS targets. Manual modifications of Xcode build settings are no longer necessary for react-native projects running on macOS.

![Screen Shot 2019-12-10 at 8 36 38 AM](https://user-images.githubusercontent.com/2771/70549905-ce7b0800-1b29-11ea-85c6-07bf09811ae2.png)

### Limitations

There's no binding which displays the developer menu (since there's no shake event on macOS). We'll probably want to add one, perhaps to the menu bar.

I've chosen not to commit the modifications to RNTester which enable macOS support, since that would imply more "official" support for this target than I suspect you all would like to convey. I'm happy to add those chunks if it would be helpful.

## Changelog

[iOS] [Added] - Added web socket support for macOS (Catalyst), enabling debug builds and live reload
Pull Request resolved: https://github.com/facebook/react-native/pull/27469

Test Plan:
* Open RNTester/RNTester.xcodeproj with Xcode 11.2.1, run it like a normal iOS app -- make sure it compiles and runs correctly (no regression)
* Select "My Mac" as device target, and run. You may need to configure a valid development team to make signing work.
* RNTester should run fine with no additional configuration. Modify a file in RNTester, note that live reload is now working.
* Test the developer inspector. To display the developer menu, you'll need to manually show it; here's an example diff which does that:
```
 diff --git a/RNTester/js/RNTesterApp.ios.js b/RNTester/js/RNTesterApp.ios.js
index 8245a68d12..a447ad3b1b 100644
 --- a/RNTester/js/RNTesterApp.ios.js
+++ b/RNTester/js/RNTesterApp.ios.js
@@ -19,6 +19,8 @@ const React = require('react');
 const SnapshotViewIOS = require('./examples/Snapshot/SnapshotViewIOS.ios');
 const URIActionMap = require('./utils/URIActionMap');

+import NativeDevMenu from '../../Libraries/NativeModules/specs/NativeDevMenu';
+
 const {
   AppRegistry,
   AsyncStorage,
@@ -143,6 +145,7 @@ class RNTesterApp extends React.Component<Props, RNTesterNavigationState> {

   UNSAFE_componentWillMount() {
     BackHandler.addEventListener('hardwareBackPress', this._handleBack);
+    NativeDevMenu.show();
   }

   componentDidMount() {
```

Reviewed By: sammy-SC

Differential Revision: D18945861

Pulled By: hramos

fbshipit-source-id: edcf02c5803742c89a845a3e5d72bc7dacae839f
2019-12-17 16:52:29 -08:00
Kevin Gonzales 0a525b6d9d Support for accessibility Label prop to the Picker component (#27342)
Summary:
With a Picker we would like to allow accessibility labels to be passed as a prop for situations where we want go give more detail. For example if we have a number picker that will be used for a timer instead of just saying 3, we might want to say 3 hours.

## Changelog
[General] [Added] - Picker test with an accessibility label prop
[General] [Added] - Support for accessibility Label prop to the Picker component
Pull Request resolved: https://github.com/facebook/react-native/pull/27342

Test Plan: Test plan is testing in RNTester making sure the examples work

Differential Revision: D18770184

Pulled By: hramos

fbshipit-source-id: e6f8ab4a9c50f3fb46342198441ecc71394913d3
2019-12-17 16:48:17 -08:00
zhongwuzw 948cbfdacc Add autorelease pool for each run loop for JS Thread (#27395)
Summary:
Fixes https://github.com/facebook/react-native/issues/27327 , we need to create autorelease pool for each run loop in secondary thread, otherwise application may have memory issues. More details can refer to [CreatingThreads](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html)
![image](https://user-images.githubusercontent.com/5061845/70033738-05fa2980-15eb-11ea-9adb-f01bee937766.png)

## Changelog

[iOS] [Fixed] - Add autorelease pool for each run loop for JS Thread
Pull Request resolved: https://github.com/facebook/react-native/pull/27395

Test Plan: Example can be found in https://github.com/facebook/react-native/issues/27327. No memory spikes any more.

Reviewed By: PeteTheHeat

Differential Revision: D19132504

Pulled By: fkgozali

fbshipit-source-id: d1747f27d36e9a7934966b34aa46d344e06193b3
2019-12-16 23:31:38 -08:00
Kevin Gozali 55142efd3a iOS Fabric: added support for image instrumentation [1]
Summary:
Added basic hook to enable image instrumentation. The hook passes information to the existing image loader, where instrumentation is done, specific for each app, if any.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D19047899

fbshipit-source-id: 6c013806cce98bcf1ea240d696a7ede9697e5cd9
2019-12-16 22:50:44 -08:00
Kevin Gozali 6ceef13a9c iOS Logbox: always return a turbomodule instance
Summary:
We have assertion to ensure that `getTurboModuleWithJsInvoker:` returns non-nullptr, so conditionally returning `nullptr` is not going to work.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D19103125

fbshipit-source-id: 663850c01e4db40cca96d254950ea5a7bf6b96b7
2019-12-16 15:04:27 -08:00
Rick Hanlon 586d55d54f LogBox - lazily initialize on iOS, use sync APIs
Summary:
Update LogBox on iOS to lazily initialize, using a synchronous RCTSurface, behind RCTSharedApplication checks.

This results in faster of LogBox, without keeping around a long lived window in the background, and only used when LogBox is used.

On Android, we still start the react app in the background but we create a dialog when it's shown and then destroy it when it's hidden. Once we have the sync APIs on android we can update it to use the same strategy.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D18925538

fbshipit-source-id: 1a72c39aa0fc26c8ba657d36c7fa7bc0ae777eb9
2019-12-13 03:09:00 -08:00
Valentin Shergin 294cf84469 Fabric: Debouncing `insets` value in SafeAreaView
Summary:
iOS/UIKit prop `safeAreaInsets` sometimes produces values (and calls `safeAreaInsetsDidChange`) that practically the same but differ just enough to make operator `==` return `false`. That causes an indefinite state update loop and dizzying of the interface.

We do the same in Paper component as well.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D18964089

fbshipit-source-id: 4c714d2554fdee0f6e999921f69b95676080b8fa
2019-12-12 12:53:13 -08:00
Valentin Shergin f798e2bc8d RCTAssertJSThread was removed
Summary:
RCTAssertJSThread is a specific to RCTCxxBridge assert that ensured that the code is executed on JavaScript thread. It was here from the very beginning. Now we need to remove it.
Reasons:
- The overall concept of limiting the execution of JavaScript code to a single thread is gone. Now we think about this as some queue, not thread. Fabric heavily relies on that and that asserts fires in Fabric.
- The assert is already far from being trivial: it checks for a custom executor, and if it's not nil, it does not fire. We can introduce another special flag for Fabric that will also disable that... but that's pointless. Such kinda asserts should not be complex to be useful.
- This asserts was used only in two places, and both of them are not exposed as public API.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18946388

fbshipit-source-id: 1e5fc732abdcb4bff3cfadcba24f7a433f1a480e
2019-12-12 12:53:09 -08:00
Spencer Ahrens 7a72c35a20 emit Dimensions change enent when app goes split screen
Summary:
Fixes https://github.com/facebook/react-native/issues/26830 by removing version gating around `RCTUserInterfaceStyleDidChangeNotification` sent by `RCTRootView` and observing that notif for `Dimensions` changes.

Also centralizes `RCTUserInterfaceStyleDidChangeNotification` constant definition in new `RCTConstants` file.

Changelog:
[iOS] [Fixed] - `Dimensions` module now updates on initial split screen

Reviewed By: sammy-SC

Differential Revision: D18931098

fbshipit-source-id: e9784be3f544f3b10360fbc2d6ad0324273b1a8f
2019-12-11 10:04:20 -08:00
Valentin Shergin 2e864c176c Fabric: Fixing a crash in UIScrollView on deallocation
Summary:
UIScrollView sometimes calls its delegate during its own deallocation and that causes a crash. This change introducing nil-ing the delegate before the deallocation to prevent this.

We already had this implemented in  D17924429 but D18752886 broke that. This diff fixes that one more time.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18933934

fbshipit-source-id: 8da22ff4b1fefee712ced25cf0f1c239535554da
2019-12-11 09:56:00 -08:00
Kevin Gozali 3b9c721996 LogBox iOS: don't initialize logbox window if redbox flag is disabled
Summary:
If redbox flag is disabled, don't initialize LogBox window even if the native module exists. This makes the module noop.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D18927309

fbshipit-source-id: 3dc6c08ed537925594cabf77d1142568d47132e9
2019-12-10 21:49:33 -08:00
Samuel Susla 1051b59af6 Move core components to iOS Plugins
Summary:
Move core components to iOS Plugins infra

Changelog:[internal]

Reviewed By: shergin

Differential Revision: D18749786

fbshipit-source-id: 910cff4ec4c8b6de0768605c8561c4a28d410a70
2019-12-10 03:11:31 -08:00
Rick Hanlon 6b22a4e802 Add NativeLogBox module on iOS
Summary:
This diff adds a NativeLogBox module implementation on iOS to manage rendering LogBox the way we render RedBox, except rendering a React Native component instead of a native view.

The strategy here is:
- initialize: will create a hidden window (the way redbox does) and render the LogBox to it
- show: will show the window
- hide: will hide the window

Most of this is copied from the way RedBox works, the difference here is that we eagerly initialize the window with the `initialize` function so that it's warm by the time LogBox needs to render.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D18750008

fbshipit-source-id: 013e55ded55c8572bb08e0219ff4cd0060ebe0da
2019-12-10 02:31:37 -08:00
Samuel Susla 5ee8202b26 Add missing accessibilityTraits in Fabric
Summary:
`accessibilityTraits` was missing, this diff adds it.

Also there is a name mis match, in javascript it is called `accessibilityRole`.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D18857668

fbshipit-source-id: 10656e8fb4e8c1d771a72c7f354b845e41cfc313
2019-12-09 06:41:27 -08:00
Valentin Shergin 3aba90b58a Fabric: Workaround for mysterious crash in `synchronouslyUpdateViewOnUIThread:props:`.
Summary:
We are seeing some non-trivial amount of crashes happened because `[RCTSurfacePresenter synchronouslyUpdateViewOnUIThread:props:]` requests a Component Descriptor which does not register in the registry.
And the problem here is that ComponentDescriptors are not being designed to be used outside of C++ UIManager, and we only use that in RCTSurfacePresenter only because it's an old workaround that makes Native Animation Driver works with Fabric.

Messing with ComponentDescriptors are in general dangerous. Accessing them outside of UIManager means that they might be deallocated at any time, extending their lifetime will cause other crashes on the other side. So, that's why this is "BROKEN".

This diff does not make the code worse, it just designates the problem that was there for a long time, so it kinda makes it better.

We don't know for sure why some ComponentDescriptors are not registered but this diff at least makes it not crash in such case.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D18869651

fbshipit-source-id: 9d945ac7a2bd24a69a9bbb83b4fdd3cd19808f87
2019-12-06 17:58:35 -08:00
Binh Nguyen e341489521 Fix spinner is not shown on beginRefreshingProgrammatically on IOS (#27397)
Summary:
It closes https://github.com/facebook/react-native/issues/24855
In the endRefreshProgrammatically of RCTRefreshControl.m there is calculation for content offset when spinner is shown CGPoint offset = {scrollView.contentOffset.x, scrollView.contentOffset.y - self.frame.size.height};
However self.frame.size.height is always 0 and therefore spinner is not visible
This change should fix that

Since the owner of the following PR is quite busy and won't be able to resolve the merge conflict anytime soon, I created this PR here to get the fix merged soon.
Ref: https://github.com/facebook/react-native/pull/27236
Thanks to [IgnorancePulls](https://github.com/IgnorancePulls)

## Changelog

[iOS] [Fixed] - Fix spinner visibility on beginRefreshingProgrammatically
Pull Request resolved: https://github.com/facebook/react-native/pull/27397

Test Plan:
IOS tests passed
Check whether this issue is reproduced or not for the repro which is described inside the issue.
https://github.com/facebook/react-native/issues/24855

Reviewed By: sammy-SC

Differential Revision: D18801307

Pulled By: hramos

fbshipit-source-id: d12af236778441a136dbe6b03dfd3495a465ae0f
2019-12-06 12:06:44 -08:00
Samuel Susla 0bbe3205ca Use plugins for RCTScrollViewComponentView
Summary:
Use plugin architecture for `RCTScrollViewComponentView`

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D18743825

fbshipit-source-id: d25162252d2dc4ac6ee67d48394b4dfa9ad134cb
2019-12-06 10:51:17 -08:00
Rick Hanlon 13992f90e4 Reconnect to debugger after reload
Summary:
This diff allows re-connecting to the debugger websocket after reloading so that if, for example, metro has restarted, we'll reconnect to allow for debugging. Previously you would need to kill the app and re-open it to re-register the debugger websocket.

Changelog: [iOS] [Fixed] Reconnect to debugger websocket after metro is restarted.

Reviewed By: motiz88

Differential Revision: D18820399

fbshipit-source-id: ddbfa4476e70a6313c877a050ef2d77c04d1657e
2019-12-06 04:59:22 -08:00
Rick Hanlon dbf6113937 Add requiresMainQueueSetup YES to top offenders
Summary:
Adds requiresMainQueueSetup YES to top 16 components warning to help clean up the console. This should cut down ~50% of native warnings from React Native.

This should not change any behavior, just make the existing behavior explicit.

Changelog: [Internal]

Reviewed By: mmmulani

Differential Revision: D18774349

fbshipit-source-id: 5a74967280812ebfd859d7d976487d264b5820c7
2019-12-04 07:48:54 -08:00
Valentin Shergin f697836cfa Fabric: Disabling ScrollView's contentOffset propagation to ShadowNode tree
Summary:
This diff disables the feature that propagates ScrollView's content offset to ShadowNode hierarchy making measuring content-offset-aware.
Seems that feature breaks FlatList because it does not expect measure calls to be content-offset-aware. We need to validate which legacy `measure*` calls should be content-offset-aware and which should not, and then verify that actual feature works (it's not clear why it worked with FlatList before) well before re-enabling this.

For now, the most safer choice is to disable this feature because I don't think some call sites actually rely on it now.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18777939

fbshipit-source-id: 20d6c1081e7d2cc3b5a7a172ed947a9ae9cdfaab
2019-12-03 08:12:13 -08:00
Samuel Susla 6803cd7546 Add codegen for core components + land blocking tests
Summary: Changelog: [Internal]

Reviewed By: fkgozali, mdvacca

Differential Revision: D18505903

fbshipit-source-id: 9de45c3f8591efaf1be7e2a21fe7d6c77965dc8f
2019-12-02 03:07:45 -08:00
Samuel Susla 01a3edcc7a Reland: [RN][iOS] Extend Fabric iOS plugins to include Core components
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D18638769

fbshipit-source-id: bc27de0ebfd3689aa427f3aef7e194f3938d893c
2019-12-02 03:07:45 -08:00
Valentin Shergin a69c18cfbc Fabric: Moving ScrollView's delegate splitter to RCTEnhancedScrollView
Summary:
This diff moves the delegate splitter from RCTScrollViewComponentView class to RCTEnhancedScrollView. Now, it's a key feature of RCTEnhancedScrollView.
We need this to make `delegate` property of our UIScrollView subclass as resilient to any abuse as possible. E.g., if some other part of the app, unrelated to RN (e.g. BottomSheet component), nils the property, all dependent RN specific infra should continue to work. To make it possible, we make an exposed property to use the internal delegate splitter instead of providing direct access to the property of a superclass.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18752886

fbshipit-source-id: 04ec4758afefb8e17481d69471d53c61ab396698
2019-11-30 12:31:42 -08:00
Valentin Shergin 4350132932 Fabric: Storing a pointer to a ComponentView in ActiveTouch
Summary:
Surprisingly, `UITouch::view` property might be nil in some cases (the documentation does not specify in which ones), and that actually happens. That breaks the calculation of a touch position relative to a view on which the touch began. This diff implements storing the view inside ActiveTouch, so we always can access it when we need it. That's similar to how it's implemented in Paper's TouchHandler.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18752887

fbshipit-source-id: b412047132238ab4fc265e6c4fbcfb732ed27518
2019-11-30 12:31:42 -08:00
Chunlok Lo 2968450195 Allow extensions to set their own presentedViewController
Summary:
Since extensions does not have access to sharedApplication, give them an option to set the presentedViewController.
This will allow modules such as RCTAlertsManager to function correctly in extensions.
Changelog: [General] [Added] - Added RCTUtilsUIOverride as a way to shortcut obtaining presentedViewController from sharedApplication to a supplied view controller for extensions.

Reviewed By: PeteTheHeat

Differential Revision: D18620886

fbshipit-source-id: c752a6e328588f388e23be5270bf7da277182cca
2019-11-22 00:47:22 -08:00
Ramanpreet Nara 1ad0862363 Revert D16969764: Make RCTDevLoadingView TurboModule-compatible
Differential Revision:
D16969764

Original commit changeset: 47e6682eea3f

fbshipit-source-id: d95b76eb8e57bbaff840b3d85f3745b13d622ce0
2019-11-21 08:43:12 -08:00
Daryl Johnas Sison 0cefcd642c Revert D18504437: Extend Fabric iOS plugins to include Core components
Differential Revision:
D18504437

Original commit changeset: 815dd0799f87

fbshipit-source-id: d9bbc617b43b9e520210fdecb0ff788f1b61c7c2
2019-11-21 05:56:44 -08:00
Samuel Susla a59b33a286 Extend Fabric iOS plugins to include Core components
Summary:
Changelog: [Internal]

Load components only if they are used. This way we avoid upfront cost associated with loading components that are not used.

Reviewed By: fkgozali

Differential Revision: D18504437

fbshipit-source-id: 815dd0799f87e254ce0b899ee52a9bec8da45451
2019-11-21 04:46:55 -08:00
Ramanpreet Nara 294e31b7c2 Make RCTDevLoadingView TurboModule-compatible
Summary:
RCTDevLoadingView wasn't hooked up to the codegen. This diff makes RCTDevLoadingView type-safe and also makes it TurboModule-compatible.

Changelog:
[iOS][Added] - Make RCTDevLoadingView TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D16969764

fbshipit-source-id: 47e6682eea3fc49d3f0448c636b5f616d5bce220
2019-11-20 11:20:12 -08:00
Samuel Susla 1926feea2b Fix missing nullability in PickerManager.setNativeSelectedIndex
Summary:
Changelog: [Internal]

To ensure compatibility with Android, nullability needs to be specified.

Reviewed By: shergin

Differential Revision: D18590634

fbshipit-source-id: 9cd969f4f187e8f1d004f03692dd9b29c4f37f95
2019-11-19 10:22:24 -08:00
Samuel Susla 2d80a248cd Migrate RefreshControl to Native Commands
Summary:
Changelog: [Internal]

Introduce native command `setNativeRefreshing`, it has the word Native in order to avoid name conflict with setRefreshing in Android implementation. Even this component is iOS only, it would make it easier to merge them in the future.

Introduce `RCTRefreshableProtocol` and make `RCTRefreshControl` and `RCTPullToRefreshViewComponentView` to conform to the protocol so view manager can forward command to both, Paper and Fabric component.

Reviewed By: mmmulani

Differential Revision: D18475804

fbshipit-source-id: 4c19225784efc931b7b8f2d2671cc839bce429bf
2019-11-19 10:06:56 -08:00
Valentin Shergin 83f0210cee Fabric: Attempt to fix a crash in RCTMountingTransactionObserverCoordinator
Summary:
We see a quite small but probably dangerous crash in RCTMountingTransactionObserverCoordinator, it's unclear why exactly it happens but seems it's somehow connected with a shape of RCTComponentViewDescriptor struct.
Specifying storage attribute (`__strong`) correctly/explicitly might fix the issue.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18567763

fbshipit-source-id: 57d9f96c4609a38ddf44ce02df53f2d713dfb116
2019-11-19 09:50:52 -08:00
Samuel Susla 5a9b7d7adc Make views tappable with screen reader
Summary:
Changelog: [Internal]

In paper implementation:
`accessibilityActivate` returns NO in case `onAccessibilityTap` is nil.

In Fabric we have no option to detect whether `onAccessibilityTap` is nil or isn't but we don't want to prevent VoiceOver from tapping an element. This could potentially trigger action associated with element twice.

Let's say you have `onPress` and `onAccessibilityTap`, it will trigger both if you trigger action through VoiceOver.

Reviewed By: shergin

Differential Revision: D18572432

fbshipit-source-id: c5ac002317c798a10045b6f05738299d0ae27456
2019-11-19 07:54:16 -08:00
Valentin Shergin e6d566fcb9 Fabric: More asserts in RCTMountingTransactionObserverCoordinator
Summary:
Just asserts to be sure that we don't over-insert or over-erase to/from the collection.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18567732

fbshipit-source-id: 569dbce6e62380ae3a0716448ad10bf418aa4f9c
2019-11-18 18:25:01 -08:00
Valentin Shergin e4a23f72d5 Fabric: Removing some code leftovers from RCTComponentViewRegistry
Summary:
The removed code is fragments of one of failed approches to implement the functionality of RCTMountingTransactionObserverCoordinator.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18567733

fbshipit-source-id: cd7d6abc91394a2755866c35ff43d2c4f0271470
2019-11-18 18:25:01 -08:00
Valentin Shergin ccc05cd054 Fabric: Fixed onLoadEnd event in RCTImageComponentView
Summary:
`onLoadEnd` event should be called when load either succeeds or fails.
Before the fix, we didn't call it on error case.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18566996

fbshipit-source-id: 92727e91be167eb1e8eec4a40e90097972097c05
2019-11-18 18:25:00 -08:00
Peter Argany f38a225e34 Fix Reload stats
Summary: Changelog: [iOS][Internal] Add bundleURL to RCTReloadCommand

Reviewed By: rickhanlonii

Differential Revision: D18576008

fbshipit-source-id: 2b6ef7377d299f3b2daf9adf4b93cd4506a3e080
2019-11-18 16:17:09 -08:00
Mehdi Mulani 3ceb95954a Enable dev loading view in build-on-device
Summary: Changelog: [iOS] [Changed] - Added another build flag for DevLoadingView

Reviewed By: JoshuaGross

Differential Revision: D18579773

fbshipit-source-id: e53733ac96ddcdb45e3d4ef23612f87ecb6dccd3
2019-11-18 15:24:32 -08:00
Valentin Shergin 5f0435fb85 Fabric: Support for interleaving/followup transactions in RCTMountingManager (iOS)
Summary:
Imagine a case where we initiate a synchronous state update right in the middle of the mount transaction. With the current implementation, the mount transaction caused by the change will be mounted right inside the in-flight transaction, which will probably cause a crash or incorrect mounting side-effects (which will cause a crash later).
Instead of executing all mounting instructions cased by the state change, we actually need to execute them right after the end of the current transaction (synchronously, inside the same main run loop tick).
This diff implements exactly this.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D18444730

fbshipit-source-id: 3e777a7aa70ff28205d40588970c7478869b6899
2019-11-18 14:28:44 -08:00
Samuel Susla d1f0826f2c Lay groundwork for Fabric iOS plugins
Summary: Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D18397243

fbshipit-source-id: bae51800e93259e50db51dac2d9d7b4b52d8ef23
2019-11-18 06:59:24 -08:00
Valentin Shergin 59e8bd9560 Fabric: ScrollViewComponentView: Calling `onScrollEndDrag` in `scrollViewDidEndDragging:`
Summary:
* Previously we called `onScrollEndDrag` in `scrollViewWillEndDragging` which was not correct.
* Now we also call `_updateStateWithContentOffset` in the method to update the stored in state `contentOffset`. This fixes all `measure*` infra.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18563050

fbshipit-source-id: ade696eda579642c22927c8a56ff122cd61a7534
2019-11-17 10:45:27 -08:00
Kevin Gozali 446705df33 iOS: attach rootTag to the native component instance for easy access
Summary:
Changelog: [Internal]

The main use-case here is to get the rootTag off RCTImageView, for image loading instrumentation. The fact is, each RCTView subclass already has `reactTag` attached today. We already have the `rootTag` when the view is created by the UIManager, so why not just attach it like reactTag? If we don't, looking up the rootTag from the native component is non-trivial and extremely inefficient (have to jump to shadow queue, back to main queue, etc).

Reviewed By: sammy-SC

Differential Revision: D18497002

fbshipit-source-id: 8409e3a1c95e09accedd959592cbf178fab0b2c3
2019-11-16 00:13:48 -08:00
Kevin Gozali 13a9a03203 Fabric iOS: pass in surfaceId when requesting to download image
Summary:
Changelog: [Internal]

For attribution purpose, pass in the surfaceId and let the app-specific image loader handle it.

Reviewed By: shergin

Differential Revision: D18494106

fbshipit-source-id: e22ca339a2dd12c5bd619b596c7db9c49dc111d0
2019-11-16 00:13:48 -08:00
Moti Zilberman 33ee724501 Extract RCTFormatStackTrace function from RCTFormatError
Summary:
Extracts a new `RCTFormatStackTrace` function from `RCTFormatError`.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D18114387

fbshipit-source-id: 4466f52d75d9da3a257cd1cc7067492a0c19a7d5
2019-11-14 10:33:14 -08:00
Valentin Shergin 1da6d2b2c0 Fabric: Removing UIEdgeInsetsFromBorderInsets from RCTViewComponentView
Summary:
We already have the exact same function in RCTConvertions.h, why have a copy of it here?

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18444731

fbshipit-source-id: ba1ebd538f92145c2ec0c30e0f7d14f1d05b381c
2019-11-13 14:22:17 -08:00
Andres Suarez 8c63dd3b1a Tidy up license headers
Summary: Changelog: [General] [Fixed] - License header cleanup

Differential Revision: D18440278

fbshipit-source-id: e641438267fc070350a8d20ee8eaccd425903014
2019-11-11 17:59:06 -08:00
Samuel Susla 620f83aae5 Fix crash when accessing _viewRegistry
Summary:
Changelog: [internal] Fixes fabric specific crash

`_viewRegistry` is not thread safe and accessing it on another thread can cause a crash.
Calling it inside `RCTUnsafeExecuteOnMainQueueSync` shouldn't degrade performance because it is only used as a fallback.

Changelog: [Internal]

Reviewed By: rickhanlonii

Differential Revision: D18421789

fbshipit-source-id: 2adff434afe0a3c19318c95b051ee91ccf6293e5
2019-11-11 03:01:26 -08:00
Samuel Susla 8f607a7967 Fabric: add native commands support to ScrollView
Summary:
ScrollView isn't using codegen, therefore we need to manually write commands interface. I also typed commands so it uses `Double` instead of `number`.

Changelog: [Internal]

Reviewed By: TheSavior

Differential Revision: D18371887

fbshipit-source-id: 3bd11b9969b80ce6d2302e2f0da28884e9221b7e
2019-11-10 17:19:00 -08:00
Ramanpreet Nara 0ee1fd9e59 Make RCTTiming a regular NativeModule
Summary:
There's a Wilde OOM. We suspect that RCTTiming's conversion to TurboModule could be the cause. There could be a memory leak in the TurboModule system that RCTTiming exposes, or RCTTiming itself could have a memory leak. Therefore, I'm making RCTTiming a regular NativeModule for now.

Changelog:
[iOS][Changed] - Make RCTTiming a regular NativeModule

Reviewed By: fkgozali

Differential Revision: D18410788

fbshipit-source-id: 29567f899dcb82988bc265242e98cc35e878e749
2019-11-08 17:28:23 -08:00
Peter Argany 7a1d96e8aa Remove main thread constraint from RCTReloadCommand
Summary:
In D17880909 I migrated `[bridge reload]` to RCTReloadCommand.

One thing I didn't consider too much is the plethora of things which trigger a reload, and the `RCTAssertMainQueue()` constraint. I'd rather use locking (to protect listeners list) than requiring reloads be called from main thread.

Changelog: [iOS][Fixed] Fix potential assert firing in RCTReloadCommand

Reviewed By: rodrigos-facebook

Differential Revision: D18353156

fbshipit-source-id: d20b851fc5fe6c3518dfa3db8f1fc075cf7edee9
2019-11-08 15:32:46 -08:00
Ramanpreet Nara 777e603075 Separate PushNotification from ReactInternal
Summary:
PushNotificationiOS wasn't used by anything in ReactInternal, so I just removed it from the target.

## Codemod
Everywhere we required `ReactInternal`, we now also require `RCTPushNotification`:
```
> xbgr -f 'BUCK$' 'ReactInternal"' -l | xargs -I {} sed -i '' $'s|ReactInternal",|ReactInternal",\"fbsource//xplat/js:RCTPushNotification",|g' $HOME/{}
> xbgr -f 'BUCK$' 'ReactInternalApple"' -l | xargs -I {} sed -i '' $'s|ReactInternalApple",|ReactInternalApple",\"fbsource//xplat/js:RCTPushNotificationApple",|g' $HOME/{}
> arc f
```

Changelog:
[Internal] - Separate RCTPushNotification from ReactInternal

Reviewed By: PeteTheHeat

Differential Revision: D18363643

fbshipit-source-id: b8d123f40741c6d200dc9e736e64e885c2572e15
2019-11-08 14:14:46 -08:00
Ramanpreet Nara d73ae1baa3 Make RCTWebSocketModule TurboModule-compatible
Summary:
Changelog:
[iOS][Added] - Make RCTWebSocketModule TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18353766

fbshipit-source-id: fde0f6593dd203ab3dcb8f9cf40012ba4761d6ba
2019-11-08 14:14:46 -08:00
Ramanpreet Nara 525703de5b Separate RCTLinking from ReactInternal
Summary:
None of the code inside `ReactInternal` depended on the `RCTLinkingManager` NativeModule. So I extracted `RCTLinking` into its own BUCK target. This will make it easier to make `RCTLinkingManager` TurboModule-compatible.

## Codemod
Everywhere we required `ReactInternal`, we now also require `RCTLinking`:
```
> xbgr -f 'BUCK$' 'ReactInternal"' -l | xargs -I {} sed -i '' $'s|ReactInternal",|ReactInternal",\"fbsource//xplat/js:RCTLinking",|g' $HOME/{}
> xbgr -f 'BUCK$' 'ReactInternalApple"' -l | xargs -I {} sed -i '' $'s|ReactInternalApple",|ReactInternalApple",\"fbsource//xplat/js:RCTLinkingApple",|g' $HOME/{}
> arc f
```

Changelog:
[Internal] - Separate RCTLinking from ReactInternal

Reviewed By: fkgozali

Differential Revision: D18314747

fbshipit-source-id: d9b5f536a6e93a0aca8721801a2ee5d446e0d4a6
2019-11-08 14:14:45 -08:00
Valentin Shergin 5db27077cb Fixed a race in RCTDevSettings
Summary:
The diff moves an invocation of `_synchronizeAllSettings` from the constructor to `setBridge`. The side-effects of `_synchronizeAllSettings` rely on a bridge not being nil, so we need to ensure that the bridge is assigned to the instance before calling `_synchronizeAllSettings`.
Before the fix, enabling JavaScript debugger caused a stale and opening many copies of a debugger in Chrome.

Changelog: [Internal] Fixed race and possible stale in RCTDevSettings

Reviewed By: RSNara

Differential Revision: D18379596

fbshipit-source-id: 9f64b9bc5426720948113de61bc9ccc8c39193b4
2019-11-07 14:20:18 -08:00
Samuel Susla a0ccd899e3 Add support for commands to interop layer
Summary:
Interop layer can now forward commands to paper components.

Changelog: [internal]

Reviewed By: shergin

Differential Revision: D18285766

fbshipit-source-id: 33fe071c3000569d52fedcbcdeccc354dfe277d9
2019-11-07 08:19:51 -08:00
Valentin Shergin 5b19464b81 Fabric: <UnimplementedView>, a new way to react on missing component
Summary:
This implement new <UnimplementedView> (only for iOS for now) that relies on the new "reactive component registration" functionality.
The `UnimplementedView` component is the perfect example of that. It's simple and uniquely required some constraints that we want to implement: the same component class registered several times with different handles and names.

This change serves two needs:
1. Providing an example of how that functionality can be used in more complex cases.
2. That will allow removing some `UnimplementedView`-specific code from the core (and very hot pathes of the system) and make them `noexcept`. That will eventually allow removing some public APIs from RawValue (constructing from folly::dynamic) that currently impose some implementation details and probably prevent us from making it slightly faster. There are only two consumers of this API, this is one of them.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D17211913

fbshipit-source-id: df1a1ac1a36289ef79904d509d38ee8b3f5588fb
2019-11-06 22:21:31 -08:00
Valentin Shergin b642677a97 Fabric: Removing `ComponentDescriptorProviderRegistry::remove()`
Summary:
This diff removes `ComponentDescriptorProviderRegistry::remove()` and two derivative interfaces.
First, we don't use that and there is no concrete idea why we would need to use that. Those were originally built only for symmetry with limited knowledge about what exactly we need.
Second, those methods are actually dangerous and probably must not be supported by design. Removing a ComponentDescriptorProvider destroys already registered `ComponentDescriptor`s, and at the same time we might have ShadowNodes referring to that (which will cause a crash), and there is no reasonable way to check for the existence of those nodes.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18285497

fbshipit-source-id: b461e38b923c217a256e1155689311397a994feb
2019-11-06 14:43:41 -08:00
Peter Argany 18e3303cd4 Ensure RCTDisplayLink and RCTTurboModuleManager are cleaned up properly [3/N]
Summary: Changelog: [Internal][Fixed] Ensure RCTDisplayLink and RCTTurboModuleManager are dealloc-ed correctly,

Reviewed By: RSNara

Differential Revision: D18283011

fbshipit-source-id: 981b02b7f9a94b8b8c3ad4233df353925b7a4fa4
2019-11-06 14:20:56 -08:00
Ramanpreet Nara 40c588e0de Fix invariant violation on launch
Summary:
Revert some changes from D18148890 as they broke loading of RN surfaces with following error
``Invariant Violation: Expected HMRClient.setup() call at startup`

Changelog: [internal]

Reviewed By: mmmulani

Differential Revision: D18324764

fbshipit-source-id: f1b4af630f8330444f70a4d93be2b53f6d8e31c2
2019-11-06 04:22:45 -08:00
Samuel Susla c6b16ecc41 Interop: move event interceptor lifecycle into separate class
Summary:
In next diff Coordinator will have get more responsibilities therefore it's better to separate the concerns to different class

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D18304834

fbshipit-source-id: 168a68969ed9da5772895f2da87e5273dccbaf30
2019-11-05 12:33:06 -08:00
Radek Czemerys e1d03b4cc0 Reverts "Timing: Fixes timer when app get into background (#24649)" (#27073)
Summary:
This PR reverts commit 338298417f that is causing https://github.com/facebook/react-native/issues/26696 #26995.
> app would be closed immediately after going to background on iOS 13.1/13.2 and was investigated by minhtc https://github.com/facebook/react-native/issues/26696#issuecomment-548056694. The commit that is being reverted is apparently causing the app to be closed immediately. This has to be reverted in master separately as the file differs there.

Similar PR for 0.61. branch https://github.com/facebook/react-native/pull/27065

## Changelog

[iOS] [Fixed] - Fix apps crashing on iOS 13.x when running timer in the background
Pull Request resolved: https://github.com/facebook/react-native/pull/27073

Test Plan: Try [this](338298417f (commitcomment-35745287)) snippet on iOS 13.1/13.2, the app should not crash anymore

Differential Revision: D18323679

Pulled By: cpojer

fbshipit-source-id: 3af7036a0e1d3811924e581c649b16e5a4667e83
2019-11-05 03:32:55 -08:00
Samuel Susla 254f0e4c01 Use generated interface for commands in Switch component
Summary:
Use codegened native commands in Switch

changelog: [internal]

Reviewed By: TheSavior

Differential Revision: D18266849

fbshipit-source-id: a2de0e7342619c437f6d34f8dbf413f2f2888548
2019-11-05 02:12:11 -08:00
Valentin Shergin 89add2582d Fabric: Collecting mounting time inside `MountingTelemetry`
Summary:
Now we also collect mounting time inside MountingTelemetry.
We will use it soon.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D18285826

fbshipit-source-id: 512fc62c210a111614b0defb0d76cbd6228fe89f
2019-11-04 18:21:13 -08:00
Ramanpreet Nara 3beb8341fd Make RCTTVNavigationEventEmitter TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTTVNavigationEventEmitter TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18142252

fbshipit-source-id: c633a5a0abd9e980346379921b34219228153348
2019-11-04 16:07:24 -08:00
Ramanpreet Nara 7e5de4e241 Make RedBox TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RedBox TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18142255

fbshipit-source-id: 2d130aca93a88ac7c983ce0e4848955ffb0be518
2019-11-04 16:07:23 -08:00
Ramanpreet Nara fe3ae9dce8 Make RCTDevMenu and RCTDevSettings TurboModule-compatible
Summary:
Changelog:
[iOS][Added] - Make RCTDevMenu and RCTDevSettings TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18148890

fbshipit-source-id: bd4f0b2797e299cd963e34fa47044a9e1232efe0
2019-11-04 16:07:23 -08:00
Samuel Susla 1cfa1e6fa2 Remove -Wno-unguarded-availability from ReactInternal
Summary:
This will allow us to catch cases where we use iOS 10-only APIs on iOS 9

Changelog: [Internal]

Reviewed By: TheSavior, mmmulani

Differential Revision: D18275225

fbshipit-source-id: dc9c515415208db40750be997173ce5bd6eb494f
2019-11-04 12:03:10 -08:00
Peter Argany dc3b5ad275 Remove unneeded NSNotification center removeObserver
Summary:
A very common pattern I've seen in RN codebase:

     - (instancetype) init {
        [[NSNotificationCenter defaultCenter] addObserver:self ...]
      }

    - (void) dealloc {
       [[NSNotificationCenter defaultCenter] removeObserver:self ...]
     }

From Apple:

https://developer.apple.com/documentation/foundation/nsnotificationcenter/1413994-removeobserver?language=objc

> If your app targets iOS 9.0 and later or macOS 10.11 and later, you don't need to unregister an observer in its dealloc method.

RN targets iOS9+

Changelog: [Internal][Cleanup] Remove unneeded NSNotification center removeObserver

Reviewed By: shergin

Differential Revision: D18264235

fbshipit-source-id: 684e5f5555cec96b055b13cd83daaeb393f4fac9
2019-11-04 10:19:30 -08:00
Ramanpreet Nara 38678f75b4 Fix podspecs
Summary:
I kept on running `USE_FRAMEWORKS=1 update-pods && open RNTesterPods.xcworkspace` and adding missing dependencies until `RNTesterPods` started compiling without failure.

**Note:** I made sure to only commit the podfile changes from `update-pods`, **without** `USE_FRAMEWORKS=1`.

Changelog:
[iOS][Fixed] - Fix all RN Podspecs

Reviewed By: fkgozali

Differential Revision: D18284535

fbshipit-source-id: 44d288ae0e52dd2cbbe26bebe7df73ce05644b5d
2019-11-01 19:34:46 -07:00
Ramanpreet Nara 809d01095e Make RCTPerfMonitor TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTPerfMonitor TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18145947

fbshipit-source-id: df2f0d60a4924f094cc4ec311b6bf570fb9fb7e1
2019-11-01 12:06:21 -07:00
Ramanpreet Nara 7233ae4f11 Make RCTAppState TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTAppState TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18142253

fbshipit-source-id: 5bd8afa6e3ee98f92aac3b2ebdfe63b9f7afc775
2019-11-01 12:06:21 -07:00
Ramanpreet Nara 6481a124da Make RCTKeyboardObserver TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTKeyboardObserver TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18130902

fbshipit-source-id: 79dff2aeede7cb2485d48597a1f80e546c107e7a
2019-11-01 12:06:20 -07:00
Ramanpreet Nara dc12676e3a Make RCTStatusBarManager TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTStatusBarManager TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18130374

fbshipit-source-id: 3ec226bcff17e47ffd9eba05e32c1eb68d6135b2
2019-11-01 12:06:20 -07:00
Valentin Shergin 41cf6da074 Fabric: Implementation of `RCTMountingTransactionObserving` protocol
Summary:
This diff finally uses all facilities from the previous diffs to build an implementation of  `RCTMountingTransactionObserving` protocol which does *not* require using expensive Objective-C runtime features.

In the coming diffs, we will see how it can/should be used.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18217101

fbshipit-source-id: 34f411dcb527dc81570c2f2833ce13b40e1450db
2019-11-01 09:38:25 -07:00
Valentin Shergin 20a0f224ba Fabric: Introducing `RCTMountingTransactionObserving` protocol
Summary:
See the comment in RCTMountingTransactionObserving first.

I think we have to add this to the iOS mounting layer to be able reasonably easy implement things like:

* MovableNavigationBar: seems, currently we don't handle the situation when the container was mounted first and the nested scroll view second.
* TTI component: It does not have access to telemetry.

The protocol is meant to replace `RCTSurfacePresenterObserver`.

Changelog: [Internal] Fabric-specific change.

Reviewed By: mdvacca

Differential Revision: D16270107

fbshipit-source-id: 2d4bdb7d0092cc214cc433fc633e41e58f6677df
2019-11-01 09:38:25 -07:00
Valentin Shergin c583822504 Fabric: Introducing `RCTComponentViewClassDescriptor`
Summary:
RCTComponentViewClassDescriptor is a pretty much the same as RCTComponentViewDescriptor but for *classes*. RCTComponentViewFactory uses a map of those data structures to create RCTComponentViewDescriptor instances (which reflects the same properties) efficiently.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18217103

fbshipit-source-id: ab7ab6b0712048d0085b61a3604b284b1fb5a68b
2019-11-01 09:38:25 -07:00
Valentin Shergin 93ded152d9 Fabric: Introducing `RCTComponentViewDescriptor`
Summary:
This diff introduces RCTComponentViewDescriptor - the container for a view and associated with this view properties which mounting infra uses for bookkeeping (and recycling) views.
The previous implementation used raw Objective-C pointers to `UIView`s to store and manipulate them. The new way has a bunch of advantages:
* It allows using high-performant C++ data collections for storing views and their properties (in future diffs).
* The new approach allows us to avoid hacks around NSMapTable (such as ` [_registry setObject:componentView forKey:(__bridge id)(void *)tag];`) that were needed because NSMapTable wasn't designed for our use-case.
* Dealing with `RCTComponentViewDescriptor` which stores a pointer to a view sometimes is actually more efficient than dealing with those pointers themselfs because we can deal with `const &` to a descriptor which does not require a ref-counter bump.
* A new approach is much more flexible, it allows us to store additional data alongside view instances which we will use in coming diffs.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18217102

fbshipit-source-id: 063e6c7df794a2e1fd690c194fb31ad6833eaba7
2019-11-01 09:38:24 -07:00
Valentin Shergin 8a1937ace6 Fabric: `RCTComponentViewRegistry::findComponentViewWithTag` was split into two methods
Summary:
In addition to already exiting method `componentViewByTag`, this diff adds a new one `findComponentViewWithTag` which does pretty much the same thing but returns `nil` in a case when it cannot find a view with a given tag. The first method now returns a non-nullable object, whereas the second (new) one return nullable.

We need this to explicitly designate call-sites that are resilient to such kind of errors, where such errors are expected because of still-existing consistency problems (because of some legacy implementation approaches).
At the same time, for the call-sites where a missing view situation is unrecoverable, we should throw early and stop paying for nullability overhead.
In the future diffs, we will change the internal implementation of the registry where the price for dealing with nullability will be actually meaningful.

This is the first diff on the road to an implementation of `RCTMountingTransactionObserving` protocol.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18217099

fbshipit-source-id: dc50033ecadd43c43c5a65fed62649a1a7acf2b5
2019-11-01 09:38:24 -07:00
Valentin Shergin 746e697038 Fabric: Removing `RCTComponentViewRegistry::tagByComponentView`
Summary:
This method has no any usages.

Changelog: [Internal] Fabric-specific, internal change.

Reviewed By: sammy-SC

Differential Revision: D18217100

fbshipit-source-id: 7aabd9e83413c2a1040bdd6c1510d6e4a4c6446a
2019-11-01 09:38:24 -07:00
Tim Yung 548aad4ff1 RN: Delete Apple TV Props
Summary:
With tvOS (Apple TV) now residing in a separately maintained fork, this removes the residual props from React Native. This only includes the JavaScript changes. The Objective-C changes will come later.

Specifically, the following props have been removed:

- `isTVSelectable`
- `tvParallaxProperties`
- `tvParallaxShiftDistanceX`
- `tvParallaxShiftDistanceY`
- `tvParallaxTiltAngle`
- `tvParallaxMagnification`

Note that `hasTVPreferredFocus` is still being used by Android TV, so it remains.

Changelog:
[Removed] Apple TV View Props

Reviewed By: TheSavior

Differential Revision: D18266278

fbshipit-source-id: 9d1448bf2f434a74e6eb23c70d3a37971e406768
2019-11-01 08:49:26 -07:00
Valentin Shergin 1a520e7b5a Fabric: Fixing a typo in RCTSurfacePresenterBridgeAdapter
Summary:
Shameful copy-pasta error.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18220281

fbshipit-source-id: 96a6babc2abb654b0fc8463d151307fe9ef97037
2019-10-31 21:41:11 -07:00
Samuel Susla a82ebeb6f3 Fabric: Use padding instead of size for SafeAreaView
Summary:
Use padding instead of setting size of SafeAreaView, this should make it more consistent with Paper component.

changelog: [internal]

Reviewed By: shergin

Differential Revision: D18225793

fbshipit-source-id: 08dccbdae0e4f7a7847501a06e17d4c26473462a
2019-10-31 21:25:37 -07:00
Samuel Susla cd1abb3bca Fabric: Fix order of arguments in RCTEdgeInsetsFromUIEdgeInsets
Summary:
Order of arguments for `RectangleEdges` was incorrect

changelog: [internal]

Reviewed By: shergin

Differential Revision: D18231825

fbshipit-source-id: 188d7af405ce801437ff67999a8f7dae77ae03c0
2019-10-31 21:25:37 -07:00
Rick Hanlon 6b783b4fb0 LogBox - Don't show native redbox for JS errors
Summary:
This diff switches the exception manager over to the reportException native module function on iOS and adds a new field `extraData.showRedbox` as a temporary hack to control hiding/showing native redboxes for LogBox.

Once LogBox is rolled out we'll remove this field, so we're hacking it into the available unused and untyped extraData bag, which will simplify gutting it in the future.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D18212047

fbshipit-source-id: f14e31d90359b7d455a73c2368ce010c28364a5c
2019-10-31 16:26:42 -07:00
Samuel Susla fbfce92e97 Use ReactTag to map events to component view
Summary:
Use `reactTag` instead of address of `UIView` to map events from paper components to Fabric.

changelog: [internal]

Reviewed By: shergin

Differential Revision: D17954974

fbshipit-source-id: 0d8bf748e58f4cb6769e107bc7fd0e66b93d8f12
2019-10-31 14:42:47 -07:00
Samuel Susla 03fd80c937 Refactor RCTLegacyViewInteropComponentView
Summary:
Simplify logic in `RCTLegacyViewManagerInteropComponentView` by caching views that are mounted and unmounted and applying it in finalise.

changelog: [internal]

Reviewed By: shergin

Differential Revision: D17954975

fbshipit-source-id: 11c8ec9e6eabb8a838a83f5fc2428912f4ec9523
2019-10-31 14:42:47 -07:00
Samuel Susla 19f58f4935 Add FBGroupsLandingView to LegacyViewManagerInterop whitelist
Summary:
Allow components outside of React-Native core to be registered with LegacyViewManagerInterop

changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D17912238

fbshipit-source-id: 67a9109c427c5e3efb8ebb6c6f8c13c2931461a3
2019-10-31 14:42:47 -07:00
Peter Argany 2a13f12106 Re-implement reload reason [7/n]
Summary:
This diff adds back RN reload reason, which was removed earlier in the stack. cc/Rick

For callsites which already had a reason, I kept the string exactly the same. For callsites which didn't have a reason, I made up something reasonable.

Changelog: [Internal][Fixed] Re-implemented bridge reload reason text.

Reviewed By: RSNara

Differential Revision: D18074478

fbshipit-source-id: 64a3cd7718674a7ba7228a80e34791ce9f153f9f
2019-10-30 12:23:25 -07:00
Peter Argany 5ca0df64a1 Deprecate RCTBridgeWillReloadNotification [3/n]
Summary:
`RCTBridgeWillReloadNotification` has one job: whenever bridge reloads - trigger a reload in `RCTSurfacePresenter`.

Diff 1/2 deprecated bridge reloading APIs, and replaced them with `RCTReloadCommand`. Use that in `RCTSurfacePresenter` instead .

Changelog: [iOS][Deprecate] Deprecate RCTBridgeWillReloadNotification

Reviewed By: shergin

Differential Revision: D17880926

fbshipit-source-id: 00adc4d56d11d40ab371d81bb17a05609c184769
2019-10-30 12:23:24 -07:00
Peter Argany d98cd7d3a1 Migrate bridge reload to RCTReloadCommand [2/n]
Summary:
Motivation described in diff 1/N.

This diff replaces calls to `[bridge reload]` with calls to `RCTReloadCommand`. This shouldn't have any change in behaviour since RCTBridge listens to RCTReloadCommand and calls `[bridge reload]` [here](https://fburl.com/diffusion/kemzkrei).

It will allow us to customize who listens and reacts to RN lifecycle.

Changelog: [Internal][Changed] - Migrated [bridge reload] calls to RCTReloadCommand

Reviewed By: shergin

Differential Revision: D17880909

fbshipit-source-id: 80b26c6badd4b216656fed6dd04554e9877f4bb7
2019-10-30 12:23:24 -07:00
Peter Argany ffe2306164 Deprecate bridge reload API [1/n]
Summary:
Testing the waters with an idea for unifying RN lifecycle with/without bridge.

### Motivation/Background

RN bridge is being reloaded from [several different places](https://fburl.com/codesearch/ae3zeatt). When this happens, the bridge does a bunch of things:
1. Post `RCTBridgeWillReloadNotification` (RCTSurfacePresenter listens to this and reloads)
2. Invalidate batched bridge, which does:
    a. invalidate display link
    b. post `RCTBridgeWillInvalidateModules/RCTBridgeDidInvalidateModules` (TurboModuleManager listens to this and reloads modules)
    c. clear js thread state
    d. clear some local caches
3. Set up (reload bundle and batched bridge)

In a bridgeless world, there isn't one thing which owns all these peices of infra, and can reload them.

### Plan

Use `RCTReloadCommand` to handle reloads. This light class previously only handled CMD+R. The new workflow looks like this:
1. Anything which cares about reloads can register itself as a listener. (RCTBridge, RCTSurfacePresenter, TurboModuleManager...)
2. Anything that previously called `bridge reload` now calls `RCTTriggerReloadCommandListeners`.
3. Delete old notifications

### Alternate Plan

Use yet another NSNotification. I like `RCTReloadCommand` better.

### Unknowns

Looks like we log the reason for bridge reloading [here](https://fburl.com/diffusion/lc9jj8la), do we want to save this behaviour? Does anyone look at why bridge is being reloaded cc/Rick? If so, I can add back that functionality to `RCTReloadCommand`.

It should be possible to customize the order/priority of what gets reloaded first. There may be some racy behaviour that I haven't thought about yet.

Changelog: [iOS][Deprecated] Deprecate [bridge reload] API - prefer RCTReloadCommand

Reviewed By: shergin

Differential Revision: D17869635

fbshipit-source-id: 81f39eaa2c3ce08ea1bc6f2193684c2630d81a2d
2019-10-30 12:23:24 -07:00
Andrew Monshizadeh 35b8b06db9 Fix unrecognized selector for iOS 9
Summary:
Refresh control is only available in iOS 10+

> https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol?language=objc

changelog: Fix crash in RCTPullToRefreshViewComponentView on iOS 10

Reviewed By: sammy-SC

Differential Revision: D18201528

fbshipit-source-id: 0dd3dad7cabe08589a597039c1dae44da868e1e5
2019-10-30 11:23:58 -07:00
Adam Foxman fe9cba74fa Expose [RCTBundleURLProvider isPackagerRunning] publicly (#27012)
Summary:
The private API isPackagerRunning is useful. Rather than duplicating it, I am exposing it here so that I can make use of it in future PRs, and so others can do the same.

## Changelog

[iOS] [Changed] - Expose the isPackagerRunning methods on RCTBundleURLProvider
Pull Request resolved: https://github.com/facebook/react-native/pull/27012

Test Plan: This change doesn't impact any runtime code, though it does impact build. I used a vanilla test app (react-native init) and built it using xcode as well as react-native run-ios.

Differential Revision: D18174316

Pulled By: cpojer

fbshipit-source-id: 523d134882303f68a1f69521e31f29d7dbfb666c
2019-10-30 08:36:45 -07:00
Victor Fernandez 7468a6c903 Fix Share dialog not resolving promise when dismissed on iOS (#26842)
Summary:
On iOS the promised returned by `Share.share(content, options)` isn't resolved if the user dismisses the dialog by either pressing "Cancel" or pressing outside the shared dialog. This PR fixes this issue.

This fixes https://github.com/facebook/react-native/issues/26809.

## Changelog

[iOS] [Fixed] - Fix promised returned by `Share.share(content, options)` not resolving if share dialog dismissed
Pull Request resolved: https://github.com/facebook/react-native/pull/26842

Test Plan:
1. on iOS, open a share dialog with:

```typescript
const onShare = async () => {
  const result = await Share.share({ message: 'example message' });
}
```

2. Dismiss the opened share dialog and the returned promised should resolve.

Differential Revision: D18189755

Pulled By: cpojer

fbshipit-source-id: 1269932e9549026afefdaa8478ff7d33bbaeb86f
2019-10-28 16:24:16 -07:00
Dratwas 2f8328dbb0 Remove max depth parameter while measuring layout of shadow view (#26986)
Summary:
Searching for the ancestor view while measuring a shadow view layout relative to the ancestor is limited to `30`. I couldn't find the reason nor commit where it was introduced (because I have no access to internal facebook commits).
I think we should keep looking for an ancestor view until the shadow view has the superview property.

## Changelog

[iOS] [Fixed] - Remove maximum searching depth while measuring layout.
Pull Request resolved: https://github.com/facebook/react-native/pull/26986

Test Plan:
- Tested if RNTester works as expected.
- Tested in app with a lot of nested flatlists where sometimes I was facing this redbox because of the max depth limit.
<img width="297" alt="Screenshot 2019-10-24 at 14 40 11" src="https://user-images.githubusercontent.com/16336501/67486474-6309d380-f66c-11e9-9eab-15e8fb8372a5.png">

Differential Revision: D18175568

Pulled By: shergin

fbshipit-source-id: cd59a18032d10bc6dd5707981e69813810f65b5a
2019-10-28 13:17:09 -07:00
Samuel Susla 4c4948b6e8 Fix unrecognised selector crash on iOS 9
Summary:
Refresh control is only available in iOS 10+

> https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol?language=objc

changelog: Fix crash in `RCTPullToRefreshViewComponentView` on iOS 10

Reviewed By: cpojer

Differential Revision: D18161020

fbshipit-source-id: c789433f132e68fc71c875e1da79bfe4fd799a44
2019-10-28 00:07:19 -07:00
Adam Ernst bdaab3c2e5 Run depslint on fb_plugin_apple_library rules
Summary: Changelog: [Internal]

Differential Revision: D18152380

fbshipit-source-id: f33f6cb2f6baeba0719a91c5189357be33a38f59
2019-10-26 13:47:15 -07:00
Valentin Shergin 34816f4d47 Fabric: Suspending all Fabric screens on bridge invalidation
Summary:
Previously, Fabric (RCTSurfacePresenter) was unaware of the bridge being valid or not. That caused the strange situations where the bridge might be already dead is still running.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D18050888

fbshipit-source-id: 34e3ec4b6991034410a40c041cfdcca36be8d743
2019-10-24 17:45:41 -07:00
Valentin Shergin 7a20964e9d Introducing `RCTBridgeWillBeInvalidatedNotification`
Summary:
This diff introduces a new broadcasting event for Bridge that communicates that the bridge is being invalidated. This notification can be used by interested parties as a signal to start tearing down all bridge-dependant processes.

The biggest difference between the new event and `RCTBridgeWillInvalidateModulesNotification` is that the latter is being called asynchronously on the JavaScript thread, whereas the new one is being called on whatever thread caused the Bridge invalidation (deallocation) *synchronously*. In most cases that happens on the main thread that allows destroying strictly-main-threaded infra (mostly UI) synchronously and avoids races.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D18050889

fbshipit-source-id: 9364c820ea2b0358edf45f0e2b3e16a13d730a9c
2019-10-24 17:45:40 -07:00
Valentin Shergin b3cb27ee9f Fabric: Removing sync block dispatching from `RCTRuntimeExecutorFromBridge`
Summary:
The purpose of RCTRuntimeExecutorFromBridge is to create/implement RuntimeExecutor using some JS queue implemented as part of the Bridge. This diff changes the implementation of this method, specifically:
Removing dispatching a sync block. This causes a deadlock with TM sometimes and should not be generally required.
The implementation does not retain the Bridge anymore.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D17960236

fbshipit-source-id: 0ddea561a6884f066e483d6b0f41ddd1621df73c
2019-10-24 17:45:40 -07:00
Valentin Shergin 32b30074d3 Fabric: Introducing RCTSurfacePresenterBridgeAdapter
Summary:
Yes, this is a pretty big diff; because of the high interconnectedness of the things, I failed to split it apart.

This change does:
Introduces a new class RCTSurfacePresenterBridgeAdapter which decouples all Bridge-related functionality from RCTSurfacePresenter.
The new class allows "replacing" one instance of the bridge with another for a single RCTSurfacePresenter.

This change allows implementing unloading a bridge (e.g. during memory pressure warning) and suspending all RN surfaces with the future possibility of reloading a bridge and resuming surfaces.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D17960239

fbshipit-source-id: 7ae556ed91030f4c5ab187689ce6bd161fabde93
2019-10-24 17:45:40 -07:00
Valentin Shergin 4bdb702b9e Fabric: Generalizing `suspense` and `resume` operations in `RCTSurfacePresenter`
Summary:
We need this for better decoupling RCTSurfacePresenter from Bridge.

Changelog: [Internal] - Changes in RCTSurfacePresenter (Fabric)

Reviewed By: sammy-SC

Differential Revision: D17960237

fbshipit-source-id: e91cd04eab967745c6e5151187eb68ba108f3986
2019-10-24 17:45:39 -07:00
Mehdi Mulani 03acf57b76 Fix use of safeAreaInsets for old versions of iOS
Summary:
This would cause a crash on iOS 9.3 because this method does not exist on UIView on that platform. By wrapping it in an availability check, we provide some safety.

Changelog: [iOS] [Fixed] safeAreaInsets call would crash on older versions of iOS

Reviewed By: fkgozali

Differential Revision: D18118025

fbshipit-source-id: fb7e517b3bcb3e0ba11ae81d8bf8397abc227e04
2019-10-24 10:35:10 -07:00
Kevin Gozali 285d4742a9 iOS: optimize RCTUserInterfaceStyleDidChangeNotification handling
Summary:
* Fabric surface hosting view should emit the same event as RCTRootView
* Before emitting to JS, make sure to check if the color scheme really changed to avoid unnecessary re-render in JS

Changelog: [Internal]

Reviewed By: mdvacca, mmmulani

Differential Revision: D18100700

fbshipit-source-id: 451199beac07cdfb3833131ee429cc151391d8dd
2019-10-23 19:04:36 -07:00
Kevin Gozali 25d94ff34d iOS Allow disabling color scheme preference
Summary:
Some apps may need to disable the automatic dark mode color scheme assignment. This provides such kill switch.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D18088313

fbshipit-source-id: 75abf34e92f8a4a637daa26135adf85965cb9df5
2019-10-23 15:52:45 -07:00
Emily Janzer e7f6210d5d Don't attempt to connect to React devtools every 2s
Summary:
When testing out the NetworkOverlay, I noticed that we were creating a lot of WebSocket connections for localhost:8097. Rick found that this is because we're trying to connect to React devtools every 2 seconds: https://github.com/facebook/react/blob/master/packages/react-devtools-core/src/backend.js#L67 and it appears we create a new WebSocket every time.

Dan suggested that we use opening the dev menu as a trigger for attempting to connect to React devtools. This diff uses RCTNativeAppEventEmitter to emit an event from native when the dev menu/dialog is shown, and listening to that event in JS to attempt to connect to devtools.

I'm also making the change of passing in a websocket instead of just passing in the host + port; this way it will only attempt to connect once on each call to `connectToDevTools` (otherwise, we would attempt to reconnect every 2 seconds as soon as the dev menu is opened, and then the next time the menu is opened we'd so start that *again*, and so on - I could have it keep track of whether it's already connecting and avoid doing it again, but this is easier and should be sufficient, I think).

We should probably also update the suggested troubleshooting tips on the devtools page to reflect this change, so that people don't get confused.

Changelog: [General] [Fixed] Fix issue where we attempt to connect to React devtools every 2 seconds

Reviewed By: mmmulani

Differential Revision: D17919808

fbshipit-source-id: 4658d995c274574d22f2f54ea06d7f29ef2f54dc
2019-10-23 10:30:43 -07:00
Joe Loser ba18ee9b87 Replace folly::make_unique with std::make_unique (#26730)
Summary:
There is a mixed usage of `folly::make_unique` and `std::make_unique`. Soon, `folly::make_unique` may be removed (see [this PR](https://github.com/facebook/folly/pull/1150)). Since `react-native` only supports C++14-compilers and later, switch to always using `std::make_unique`.

## Changelog

[Internal] [Removed] - Replace folly::make_unique with std::make_unique
Pull Request resolved: https://github.com/facebook/react-native/pull/26730

Test Plan:
Running the existing test suite. No change in behavior is expected.

Joshua Gross: buck install -r fb4a, make sure MP Home and forced teardown works okay on android

Reviewed By: shergin

Differential Revision: D18062400

Pulled By: JoshuaGross

fbshipit-source-id: 978ca794c7e972db872a8dcc57c31bdec7451481
2019-10-22 12:21:41 -07:00
Moti Zilberman 468d1a2d2e Render collapsed frames in RedBox
Summary:
Renders frames in RedBox in a greyed-out style when their `collapse` field is set to `true`. This avoids outright hiding information in the stack trace while still drawing attention to frames that are likely to be more meaningful.

Changelog: [General] [Changed] - Render collapsed JavaScript frames in RedBox

Reviewed By: rickhanlonii

Differential Revision: D18039438

fbshipit-source-id: 527588f11c0bff495842be7036cd1293bab65eb9
2019-10-22 11:05:36 -07:00
Ramanpreet Nara d8fda74c24 Move RCTImage NativeModules back to RCTImage
Summary:
In D16805827, I moved `RCTImageLoader`, `RCTImageStoreManager`, and `RCTImageEditingManager` to `CoreModules`. This was necessary to turn `RCTImageLoader` into a TurboModule. However, after D17671288 landed, it's no longer necessary to have OSS NativeModules in `CoreModules`. Therefore, I'm moving these NativeModules back to `RCTImage`.

Changelog: [iOS][Fixed] Move RCTImage NativeModules back to RCTImage

Reviewed By: shergin

Differential Revision: D17921612

fbshipit-source-id: 8ae36d2dc8deaf704313cbe2479bfa011ebcbfbc
2019-10-21 17:15:32 -07:00
Ramanpreet Nara 2b5f4de7eb Make RCTTiming TurboModule-compatible
Summary: Changelog: [iOS][Added] Make RCTTiming TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D17891665

fbshipit-source-id: e0d36ccfb4f3f1d428668836a8b66698d51bdeaf
2019-10-16 19:00:26 -07:00
Emily Janzer f2f4d33a3a Remove unsupported flow types from OSS native module specs
Summary:
Some of our NativeModule type specs aren't compatible with our Android codegen and type safety checks - specifically, we don't support `$ReadOnly` in our type checks, and we don't support map types in the codegen. Removing these from a couple of the OSS type specs so we can enable codegen for these modules (eventually).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D17882093

fbshipit-source-id: 6e8669e4be775347199b2b5346bd8d40d7620886
2019-10-16 11:14:04 -07:00
Andres Suarez aee88b6843 Tidy up license headers [3/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952693

fbshipit-source-id: 8fcb8e58a2e04e7a3169f4d525bffc00835768e6
2019-10-16 10:06:34 -07:00
Andres Suarez 3b31e69e28 Tidy up license headers [2/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952694

fbshipit-source-id: 17c87de7ebb271fa2ac8d00af72a4d1addef8bd0
2019-10-16 10:06:34 -07:00
Andres Suarez 722feeb02b Tidy up license headers [1/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952695

fbshipit-source-id: 81aa607612ba1357ef7814ef20371335151afe7e
2019-10-16 10:06:33 -07:00
Samuel Susla 0d1b9b5397 Add MaskedView to LegacyViewManagerInterop white list
Summary:
For components to be used with LegacyViewManagerInterop they need to be added to a white list.
This makes it possible to test it out and assure proper functionality.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D17906107

fbshipit-source-id: 60ee99e6b973ba2d6fe804f3c99e492603d3cf8f
2019-10-16 04:26:44 -07:00
Samuel Susla 5327c3ed83 Forward subviews to Paper component from LegacyViewManagerInterop
Summary:
`RCTMaskedView` is simple enough to migrate manually to Fabric and I think we should eventually do it.
However this gives us opportunity to spot shortcomings of `LegacyViewManagerInterop` and address them.

Now `LegacyViewManagerInterop` forwards `mountChildComponent` and `unmountChildComponent` events to Paper component that it is wrapping.

Reviewed By: shergin

Differential Revision: D17905807

fbshipit-source-id: ad36c186d5c5a8ed164e412fa5fdf0042de46348
2019-10-16 04:26:43 -07:00
Andres Suarez e1cfeaddd4 Move non-license comments out of license header
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: cpojer

Differential Revision: D17749100

fbshipit-source-id: edca9c73a065e9fc311109cd6efeb1f75451a55a
2019-10-15 20:12:12 -07:00
Mehdi Mulani fc80a51457 Make RCTRedBox customizable
Summary:
Adds the ability to add extra buttons and renders them along with the other buttons.

Changelog: [iOS] [Added] - RCTRedBox ability to add extra buttons

Reviewed By: PeteTheHeat

Differential Revision: D17935352

fbshipit-source-id: f8fb28653e535cd2c098566afbc639eb5c196228
2019-10-15 20:09:39 -07:00
Mehdi Mulani ef3f80abc1 Refactor RCTRedBox button creation
Summary:
@public
A lot of this code was duplicated, so move it all into one method.
Later in this stack, I will make custom red box buttons which will need to reuse this method.

Changelog: [iOS] [Changed] - Refactor RCTRedBox button creation

Reviewed By: PeteTheHeat

Differential Revision: D17915485

fbshipit-source-id: ede649862556b057779e0267118799c63f0215b8
2019-10-15 20:09:39 -07:00
Janette Cheng 10cc834567 Use fbandroid_labels and fbobjc_labels in xplat targets
Summary:
`xplat` targets add different deps based on what platform the target is being built for.

for anything using `fb_xplat`, we can put all ios supermodules in `fbobjc_labels` and all android sms in `fbandroid_labels`

There's some weirdness with python targets like `thrift_gen` in  `/xplat/mobileconfig/tools/generator/gen-py/BUCK` that don't have platform-specific labels because the except_for list for `fbandroid` doesn't need the `fbsource//` prefix (see changes in `/ios/isolation/infra.mobileconfig.sm`)

Changelog: [Internal]

Reviewed By: shergin, joshleibsly

Differential Revision: D17884952

fbshipit-source-id: e245364cf515b75682990094d24f789d53b1f3f5
2019-10-15 19:32:27 -07:00
Peter Argany 79b573511b Fix RCTNullIfNil macro
Summary:
`RCTNullIfNil()` can return nil in certain scenarios.

Example, given:
`#define RCTNullIfNil(value) (value ?: (id)kCFNull)`
`RCTNullIfNil(nil == nil ? nil : @"lol")`
expanded out
`nil == nil ? nil : @"lol" ?: (id)kCFNull`

`?:` takes precedence, so reduced:
`nil == nil ? nil : @"lol"`
`nil`

Changelog: [iOS] [Fixed] Fixed longstanding bug where RCTNullIfNil() can return nil

Reviewed By: RSNara

Differential Revision: D17943530

fbshipit-source-id: 8c6e3dd2d86cbc8ff1fcbef732674835a312ef26
2019-10-15 18:02:27 -07:00
Valentin Shergin 101f864bcc Fabric: Fixed a crash in RCTImageResponseObserverProxy
Summary:
This fixes the crash, here is why:
When a block refers to `delegate_`, it  actually refers to `this->delegate_`, which means it no retaining happening (there is no way to retain C++ class). That causes a crash when the block overlive the class instance.
Making a local copy of `delegate_` enables proper ARC-powered retaining and prevents the crash.

Changelog: [iOS] [Fixed] - Fixed crash in RCTImageResponseObserverProxy (Fabric)

Reviewed By: sammy-SC

Differential Revision: D17923548

fbshipit-source-id: 71aff44647730a5cc1996928c164d3892884b455
2019-10-15 16:15:11 -07:00
Valentin Shergin dec80fe486 Fabric: Simplifying allocation/storing of RCTImageResponseObserverProxy
Summary: We don't need to have it as `std::unique_ptr`, we can simply store it by value.

Reviewed By: sammy-SC

Differential Revision: D17923551

fbshipit-source-id: e8222834a8dd8f84826e4e89067610cd0a7cac73
2019-10-15 16:15:11 -07:00
Valentin Shergin 01143859ff Fabric: Simplifying RCTImageResponseObserverProxy interface
Summary: There is no reason why RCTImageResponseObserverProxy accepts untyped pointer. This diff fixes that. The call sites now look much cleaner.

Reviewed By: sammy-SC

Differential Revision: D17923552

fbshipit-source-id: b08556e1164b00c9cf2676c0d9b1718ae60b2aca
2019-10-15 16:15:11 -07:00
Valentin Shergin 23564ab44d Fabric: Enforcing `RCTImageResponseDelegate` conformance
Summary: For `RCTSliderComponentView` the conformance to the protocol wasn't enforced. For `RCTImageComponentView` it was in .h file without a need to be exported.

Reviewed By: sammy-SC

Differential Revision: D17923550

fbshipit-source-id: d98b892d24d9079a7109dc7d881c5c5a175fe3bf
2019-10-15 16:15:10 -07:00
Valentin Shergin 14df0b2a78 Fabric: Using `wrapManagedObject` in `RCTImageManager` instead of manual casting
Summary: Hiding casting madness and complexity behind a helper function to avoid bugs and improve maintainability.

Reviewed By: sammy-SC

Differential Revision: D17923549

fbshipit-source-id: 105891d85b0412fa4a17d7ae8a9e156fc1b151fb
2019-10-15 16:15:10 -07:00
Ramanpreet Nara 2b62bd7695 Make RCTAsyncLocalStorage TurboModule-compatible
Summary:
**Note:** This was landed in D17724498 but reverted in D17855088. The revert had nothing to do with this NativeModule.

Changelog: [iOS][Added] Make RCTAsyncLocalStorage TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D17917841

fbshipit-source-id: 0f9dd5f592180d6512ca560007daa531a4da5b59
2019-10-15 09:16:56 -07:00
Ramanpreet Nara da6274ba76 Make RCTAlertManager TurboModule-compatible
Summary:
**Note:** This was landed in D17722913, but reverted in D17855088. The revert had nothing to do with this NativeModule.

Changelog: [iOS][Added] Make RCTAlertManager TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D17917827

fbshipit-source-id: d86ea2cddddd9535d656709296c74aebd6f45793
2019-10-15 09:16:56 -07:00
Samuel Susla be89e4d928 Fix tintColor in SegmentedControlIOS component
Summary:
iOS 13 introduced a new design for `UISegmentedControl` and new APIs to control this. `[UISegmentedControl tintColor]` is now ignored.

We try to maintain backwards compatibility so the appearance is as close as possible to iOS 12.

Changelog:
Fix `tintColor` on SegmentedControlIOS

Reviewed By: shergin

Differential Revision: D17905892

fbshipit-source-id: 964ac64c8543660929c43b427dce4f78094b1255
2019-10-15 08:13:37 -07:00
Valentin Shergin e7ef9921d3 Fabric: Fixing crash in RCTScrollViewComponentView (2nd attempt)
Summary:
Seems a ScrollView sometimes calls the delegate in own destructor; and seems that in some configurations the delegate is also already destroyed at this point. I am not sure if this a bug in UIKit or not, but seems the fix is easy, we just have to clear the ScrollView's delegate on the delegate's deallocation.
This issue is also looks similar:
https://stackoverflow.com/questions/18778691/crash-on-exc-breakpoint-scroll-view/19011871

Changelog: [iOS] [Fixed] - Fixed crash in RCTScrollViewComponentView

Reviewed By: sammy-SC

Differential Revision: D17924429

fbshipit-source-id: 5727bca9f028e28f76f60304c187ee39eb6e1856
2019-10-15 07:43:20 -07:00
Valentin Shergin beae6d6fa0 Revert D17456225: [RN] RCTRefreshControl was renamed to PullToRefreshView (for Paper)
Differential Revision:
D17456225

Original commit changeset: a8db99ddd507

fbshipit-source-id: 3186d76de13cccc21619702a1ad07842a4788b15
2019-10-15 07:11:53 -07:00
Samuel Susla ddbfe24c3b Add SegmentedControl to LegacyViewManagerInterop white list
Summary:
For components to be used with LegacyViewManagerInterop they need to be added to a white list.
This makes it possible to test it out and assure proper functionality.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D17905453

fbshipit-source-id: 4e8e53a1898b38b2c9f01e7fc9e3527bd7004ffb
2019-10-15 03:16:21 -07:00
Samuel Susla 53f003f233 Add ProgressView to LegacyViewManagerInterop white list
Summary:
For components to be used with LegacyViewManagerInterop they need to be added to a white list.
This makes it possible to test it out and assure proper functionality.

Reviewed By: shergin

Differential Revision: D17905413

fbshipit-source-id: f5ab523cca6227e99a7607ca1927005392b1ae36
2019-10-15 03:16:21 -07:00
Valentin Shergin 08d6cb19c4 RCTRefreshControl was renamed to PullToRefreshView (for Paper)
Summary:
The component RCTRefreshControl was renamed to PullToRefreshView (for Paper). Now only old Objective-C class names have the old name, which is okay.

Changelog: [Internal] [Changed] - The internal name of PullToRefresh component was changed from `RCTRefreshControl` to `PullToRefreshView` (No public API changes)

Reviewed By: rickhanlonii

Differential Revision: D17456225

fbshipit-source-id: a8db99ddd507377d8c98b26707a3b9fae483d20c
2019-10-14 20:49:48 -07:00
Sharon Gong baa66f63d8 Announce accessibility state changes happening in the background (#26624)
Summary:
Currently the react native framework doesn't handle the accessibility state changes of the focused item that happen not upon double tapping. Screen reader doesn't get notified when the state of the focused item changes in the background.
To fix this problem, post a layout change notification for every state changes on iOS.
On Android, send a click event whenever state "checked", "selected" or "disabled" changes. In the case that such states changes upon user's clicking, the duplicated click event will be skipped by Talkback.

## Changelog:
[General][Fixed] - Announce accessibility state changes happening in the background
Pull Request resolved: https://github.com/facebook/react-native/pull/26624

Test Plan: Add a nested checkbox example which state changes after a delay in the AccessibilityExample.

Differential Revision: D17903205

Pulled By: cpojer

fbshipit-source-id: 9245ee0b79936cf11b408b52d45c59ba3415b9f9
2019-10-14 00:28:34 -07:00
Samuel Susla ffc7ec992c Add support for ScrollView.onScroll animations
Summary: To enable onScroll animations with Fabric's scrollView on iOS, we dispatch onScroll event to Paper's eventDispatcher as well as to Fabric's one. One we have a proper NativeAnimationDriver in place, we will get rid of this.

Reviewed By: shergin

Differential Revision: D17814260

fbshipit-source-id: f04faf59cdfd4ea5cede513388e30500b4cb2ad5
2019-10-11 06:55:21 -07:00
Samuel Susla 4159e20146 Fix throttling in scroll view
Summary:
Setting minimal throttle to 1/60 causes dropped updates.

Let's take following example

Each frame is 16.666 MS.

Frame1: [________didScroll is called towards end of the frame_]

Frame2: [_didScroll is called towards beginning of the frame_________]

update from Frame 2 doesn't propagate because we set throttle to 16MS thinking that `onScroll` is called for each frame.

If Javascript specified value below 1/60 it is basically asking for every update.

Reviewed By: shergin, mdvacca

Differential Revision: D17829926

fbshipit-source-id: e7b07fd09581cd5053aa27a62cf6f6ddb2193783
2019-10-11 05:44:49 -07:00
Samuel Susla 1ba67fd9a6 Move RCTScrollEvent into separate file
Summary: Move RCTScrollEvent into separate file and export its header.

Reviewed By: shergin

Differential Revision: D17831709

fbshipit-source-id: f4ee4e09147ef5703b85a10238ddb6cdefdf05a5
2019-10-11 04:46:16 -07:00
Ashok Menon df96de78bb Back out D17720575 -- D17724498
Summary: This stack caused FB4A builds to start failing, complaining about `RCTImageApple`.

Reviewed By: RSNara

Differential Revision: D17855088

fbshipit-source-id: 21ecedc3725dde65fab20f414d07b32c3548447c
2019-10-10 09:41:33 -07:00
Valentin Shergin 38e36b7049 Storing RCTBridge weakly inside ContextContainer
Summary: Storing a Bridge introducing an retain cycle, so we need to store that weakly.

Reviewed By: sammy-SC

Differential Revision: D17773698

fbshipit-source-id: 824a83a6086f9ae6efb7c458d833931954c55643
2019-10-09 13:17:42 -07:00
Mehdi Mulani c30f895da5 Allow enabling RCTDevSettings outside of dev mode
Summary: This make RCTDevSettings configurable like RCTRedBox.

Reviewed By: RSNara

Differential Revision: D17798517

fbshipit-source-id: 3717e0aed27b2a6951b402641f589d472f45243e
2019-10-09 12:55:22 -07:00
Ramanpreet Nara 7eb7c84a09 Make RCTAsyncLocalStorage TurboModule-compatible
Summary: See title.

Reviewed By: PeteTheHeat

Differential Revision: D17724498

fbshipit-source-id: 738fdd1e4db3b435029b8300d426cca1242c1587
2019-10-09 12:34:00 -07:00
Ramanpreet Nara 60321a78ad Make RCTAlertManager TurboModule-compatible
Summary: See title.

Reviewed By: PeteTheHeat

Differential Revision: D17722913

fbshipit-source-id: cb78b9ea1bf497d27b19255e48809850e698ba0d
2019-10-09 12:34:00 -07:00
Ramanpreet Nara 3aa8a40659 Move RCTImage NativeModules back to RCTImage
Summary: In D16805827, I moved `RCTImageLoader`, `RCTImageStoreManager`, and `RCTImageEditingManager` to `CoreModules`. This was necessary to turn `RCTImageLoader` into a TurboModule. However, after D17671288 landed, it's no longer necessary to have OSS NativeModules in `CoreModules`. Therefore, I'm moving these NativeModules back to `RCTImage`.

Reviewed By: PeteTheHeat

Differential Revision: D17720575

fbshipit-source-id: 44b07cfa07cbb2b87254132810f86974edc7edab
2019-10-09 12:33:59 -07:00
Mehdi Mulani 2a3fa968b4 Revert D17793693: [RN] Add debug message to RCTShadowView when we insert a subview incorrectly
Differential Revision:
D17793693

Original commit changeset: 848ae658200e

fbshipit-source-id: e59299f596f95e2bea978b07cd7e8f1de345708a
2019-10-09 12:15:13 -07:00
Samuel Susla 1bf2f72abe Add support for commands
Summary: We need commands to work with `LegacyViewManagerInterop`. We will need to rethink this once Fabric has command-execution pipeline in place.

Reviewed By: shergin

Differential Revision: D17787294

fbshipit-source-id: a6b3dbfae41f04e7e7f5bafb1f7b4ad0de0eedc3
2019-10-08 09:05:16 -07:00
Samuel Susla 5dbd62c7ff Add support for events
Summary:
LegacyViewManagerInterop layer can now handle events as well.

We expose `eventInterceptor` from `NSComponentData`, that way we can hook into event dispatching that happens within `NSComponentData`.

Coordinator has a map of `UIView -> reactTag` which it uses to figure out to which component view to forward the event.

New `LegacyViewManagerInteropViewEventEmitter` exposes APIs to send `folly::dynamic` to javascript.

Reviewed By: shergin

Differential Revision: D17765834

fbshipit-source-id: 25e75e445b32c69ec9ab0189c4ab7fba5f8c7b5d
2019-10-08 09:05:15 -07:00
Mehdi Mulani 0a98be65e3 Try to lazily load RCTRedBox
Summary: I made a mistake earlier and somehow prevented RCTRedBox showing up. Not sure why this didn't prevent them from showing up in dev mode.

Reviewed By: RSNara

Differential Revision: D17798516

fbshipit-source-id: 48bf0523124ad3fd96d626281390bbafc62f3390
2019-10-08 07:38:17 -07:00
Ramanpreet Nara 021a63d4da Ensure internal builds don't use plugin stubs
Summary: We generate a stub for plugin system, so that TurboModules can work in OSS. Unless the `RN_DISABLE_OSS_PLUGIN_HEADER` define is seet, TurboModules will use the plugin stub. Therefore, for internal builds, we should set this define.

Reviewed By: fkgozali, mdvacca

Differential Revision: D17789993

fbshipit-source-id: a93735738513457236adb3064b80601053c95dd3
2019-10-07 14:55:39 -07:00
Mehdi Mulani 72c03900d2 Add debug message to RCTShadowView when we insert a subview incorrectly
Summary:
@public
This will provide a more useful error message and hopefully allow us to debug the issue further.

Reviewed By: JoshuaGross

Differential Revision: D17793693

fbshipit-source-id: 848ae658200ea5e3892d8a88888599c1c248c994
2019-10-07 13:37:53 -07:00
Rick Hanlon c71bbb0057 Report logs in dev to server on iOS
Summary:
This diff adds server side logging for all log levels in development (some levels sampled)

There are two new mobile analytic event pipelines (that pipe to scuba table)

- rn_dev_logs ([pigeon](https://our.intern.facebook.com/intern/marauder/event/?name=rn_dev_logs) [scuba](https://fburl.com/scuba/pqxl6mf5))
- rn_dev_logs_sampled ([pigeon](https://our.intern.facebook.com/intern/marauder/event/?name=rn_dev_logs_sampled) [scuba](https://fburl.com/scuba/oqz6b5x3))

Notes:
- All React Native logs from JS and Native on iOS go through this path to be printed to the console, so everything will be caputured even though native errors/warnings do not necessarily show a red/yellow box
- All errors and warnings are logged
- Log level info is sampled

Reviewed By: sammy-SC

Differential Revision: D17789494

fbshipit-source-id: dea6359237dbd91f267949f5185a0c79bb4083b8
2019-10-07 11:44:11 -07:00
Samuel Susla f580409919 Add command to set date on RCTDatePickerManager
Summary: We are moving away from setNativeProps, this adds necessary method on native to leverage commands API

Reviewed By: shergin

Differential Revision: D17787877

fbshipit-source-id: 8f06cdd85c96bce4ea9bb7a8cd5f6c1a1d68b20a
2019-10-07 10:36:37 -07:00
Samuel Susla 62cbdceedd Implement setNativeSelectedIndex command for Picker component
Summary:
This is required so we can switch to using commands instead of `setNativeProps`.
`setNativeProps` are not supported in Fabric, we are moving away from it.

Reviewed By: JoshuaGross

Differential Revision: D17764967

fbshipit-source-id: 16e54ebe1f0c58b80a6491db970a60c01fec8a15
2019-10-07 04:24:08 -07:00
Samuel Susla 07fd3125c8 Migrate MVP SafeAreaView to Fabric
Reviewed By: shergin

Differential Revision: D17736209

fbshipit-source-id: e70c309f2599cdcb8f234d96915546032b71d223
2019-10-04 07:07:36 -07:00
Adam Ernst a45e6a8b5f React Native supermodule
Summary: #nocancel

Reviewed By: fkgozali

Differential Revision: D17747685

fbshipit-source-id: 9bad072d3549959528612c2f0329799853d4b675
2019-10-03 15:43:38 -07:00
Ramanpreet Nara d7864d20d5 Mark plugin function definitions used
Summary: We need to mark the OSS plugin functions with `__attribute__((used))`, so that the compiler doesn't strip them out.

Reviewed By: fkgozali

Differential Revision: D17742818

fbshipit-source-id: df8055286cace850cea21bb6f09eb5ee6b587c0e
2019-10-03 13:06:06 -07:00
Samuel Susla e62a4c7988 Apply props to Paper component
Reviewed By: shergin

Differential Revision: D17710855

fbshipit-source-id: ab6864a22fd8df019b2619c2976876e176e07689
2019-10-03 08:37:29 -07:00
Samuel Susla 3f8221ddd9 Add coordinator class
Summary:
ComponentDescriptor owns a coordinator which is initialised with ViewManager that it represents.

Coordinator is passed to ComponentView through state and ComponentView asks the coordinator for view.

Later, ComponentView will ask coordinator to configure view with specified props.

Reviewed By: shergin

Differential Revision: D17670444

fbshipit-source-id: e920c5c4f033884c4b539ce711286f71c887d896
2019-10-03 08:37:29 -07:00
Samuel Susla 74608ee4ab Stage 1: printing props to screen
Summary:
# LegacyViewManagerInterop is born

LegacyViewManagerInterop is a component that should make it possible for legacy components to work in Fabric, new renderer.
This is just a first stage that prints keys of props to screen together with component name.

Reviewed By: shergin

Differential Revision: D17552827

fbshipit-source-id: c3e062f413727729e6a9b683c60f59f0292cc63b
2019-10-03 08:37:28 -07:00
Samuel Susla a261e6dfb2 Fix recycling of Switch
Reviewed By: shergin

Differential Revision: D17714863

fbshipit-source-id: 8a90a08328f007c782689b4e711d252bd2e22538
2019-10-03 03:59:47 -07:00
Samuel Susla eb08b428b6 Add setValue command to RCTSwitchManager
Reviewed By: shergin

Differential Revision: D17714133

fbshipit-source-id: ccb89be1b763678f44f1271e4d5882afd37ccf65
2019-10-03 03:59:47 -07:00
Mehdi Mulani 12d60c1049 iOS: Allow redbox to be toggled in debug builds
Summary: This adds the option to enable or disable the redbox.

Reviewed By: JoshuaGross

Differential Revision: D17720770

fbshipit-source-id: b9e9c948d53f7f284a48b6bd182dc2da47874d1c
2019-10-02 14:43:32 -07:00