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

2874 Коммитов

Автор SHA1 Сообщение Дата
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