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

2656 Коммитов

Автор SHA1 Сообщение Дата
cojo 97c414ec8d Fire timers in the background via NSTimer (#23674)
Summary:
This PR is a follow-up to #21211 by request of hramos to incorporate some additional crash fixes / synchronization edge cases found in our production testing.  What follows is largely a copy of the original PR description from #21211 - see that PR for original discussion thread as well as context on why this replacement PR was needed.

This PR is a minimalistic change to RCTTiming that causes it to switch exclusively to NSTimer (i.e., the 'sleep timer') in order to continue triggering timers when the app has moved to the background.

Many people have expressed a desire for background timer support on iOS. (See #1282, #167, and #16493). In our app — a podcast/audio player — we use background timers to ensure that we never lose track of the user's playback position, should the app crash or be terminated by the OS.

The RCTTimer module uses a RN-managed CADisplayLink if the next requested timer is less than a second away; otherwise, it switches to an NSTimer (which is refers to as a 'sleep timer' in source). The RN-managed CADisplayLink is always disabled when the app goes to the background (and thus cannot be used); however, the NSTimer will still issue its callbacks in the background.

This PR adds a flag to track whether the app is in the background, and if so, all timers are routed through NSTimer until the app returns to the foreground. vishnevskiy at Discord opened a similar PR (#16493) that implements a drop-in for CADisplayLink which falls back to NSTimer, but I decided to incorporate the background-NSTimer logic directly into RCTTimer, since NSTimer is already in use.

It's worth noting that the background NSTimer may not fire as often as requested — it may give the appearance of lagging depending upon your app's priority in the background. For our audio app, NSTimer fires exactly on schedule if there's an open AVAudioSession and audio is playing; if audio is not playing, it fires about half as often as requested, which is still adequate for networking polling and other tasks.

It's worth noting that background timers only function as long as an app is actually running in the background. Apple offers a variety of Background Modes (which can be toggled in the Capabilities section of the target inspector in Xcode), and the app will need to be legitimately using one of these modes in order for this change to provide any value — otherwise it will be terminated within a couple of seconds of moving to the background.

The good thing about this change is that for apps that do perform essential computation in support of their Background Mode, they can now use `setTimeout` and `setInterval` without problem — whereas in the past, neither would ever trigger their callback until the app returns to the foreground.
Pull Request resolved: https://github.com/facebook/react-native/pull/23674

Differential Revision: D14621326

Pulled By: shergin

fbshipit-source-id: c76e060ad2c662c140d7d2f4fb5aaa7094032515
2019-03-26 12:24:37 -07:00
zhongwuzw 946f1a6c87 Add lock for surface presenter observers (#24052)
Summary:
Add lock for observers when do enumeration.
cc. shergin .

[iOS] [Fixed] - Add lock for surface presenter observers
Pull Request resolved: https://github.com/facebook/react-native/pull/24052

Differential Revision: D14619029

Pulled By: shergin

fbshipit-source-id: b843ac0e4b106a572de75663840f2e5e5f126f31
2019-03-26 09:56:40 -07:00
Valentin Shergin af38a0cf87 Fabric: `Transform` type was moved to `graphics` module.
Summary:
We will use it inside `core` module, so we have to decouple it from `view`.
As part of this, I added some comments, changed `const Float &` to just `Float` and put the implementation into `.cpp` file.

Reviewed By: mdvacca

Differential Revision: D14593952

fbshipit-source-id: 80f7746f4fc5b95febc8df9f5a9c0386a6425c88
2019-03-25 12:04:53 -07:00
Dhaval Kapil 64f3a87c9d Refactor JSIExecutor to use runtimeInstaller for injecting the logger instance
Summary: This is based on the work done in D8686586. Removed the logger instance from JSIExecutor constructor and installed it into the runtimeInstaller at all call sites.

Reviewed By: mhorowitz

Differential Revision: D14444120

fbshipit-source-id: 0476fda4230c467573ea04102a12101bcdf36c53
2019-03-25 09:12:11 -07:00
Andrew Coates (REDMOND) 1b12e2caaa merge master 2019-03-23 16:38:05 -07:00
Ramanpreet Nara 8618a5824f Add support for argument conversion via RCTConvert
Summary:
With our current infra, we support automatic conversion of method arguments using `RCTConvert`.

```
RCT_EXPORT_METHOD(foo:(RCTSound*) sound)
{
  //...
}
```

```
interface RCTConvert (RCTSound)
+ (RCTSound *) RCTSound: (NSDictionary *) dict;
end

implementation RCTConvert (RCTSound)
+ (RCTSound *) RCTSound: (NSDictionary *) dict
{
  //...
}
end
```

```
export interface Spec extends TurboModule {
  +foo: (dict: Object) => void,
}
```

With this setup, when we call the foo method on the TurboModule in JS, we'd first convert `dict` from a JS Object to an `NSDictionary`. Then, because the `foo` method has an argument of type`RCTSound*`, and because `RCTConvert` has a method called `RCTSound`, before we invoke the `foo` NativeModule native method, we first convert the `NSDictionary` to `RCTSound` using `[RCTConvert RCTSound:obj]`. Essentially, if an argument type of a TurboModule method is neither a primitive type nor a struct (i.e: is an identifier), and it corresponds to a selector on `RCTConvert`, we call `[RCTConvert argumentType:obj]` to convert `obj` to the type `argumentType` before passing in `obj` as an argument to the NativeModule method call.

**Note:** I originally planned on using `NSMethodSignature` to get the argument types. Unfortunately, while the Objective C Runtime lets us know that the type is an identifier, it doesn't inform us which identifier it is. In other words, at runtime, we can't determine whether identifier represents `RCTSound *` or some other Objective C class. I figure this also the reason why the old code relies on the `RCT_EXPORT_METHOD` macros to implement this very same feature: https://git.io/fjJsC. It uses `NSMethodSignature` to switch on the argument type, and then uses the `RCTMethodInfo` struct to parse the argument type name, from which it constructs the RCTConvert selector.

One caveat of the current solution is that it won't work work unless we decorate our TurboModule methods with `RCT_EXPORT_METHOD`.

Reviewed By: fkgozali

Differential Revision: D14582661

fbshipit-source-id: 3c7dfb2059f031dba7495f12cbdf406b14f0b5b4
2019-03-22 16:23:40 -07:00
Rafi Ciesielczuk e2bf843d86 Introduce Module Setup Metric (#23859)
Summary:
The `RCTBridge` contains numerous definitions of notification names, which we can observe in order to get insights into the React Native performance.

The Android implementation is a little different, such that you can listen for any of the [following](https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java) marker constants, simply by including the following code:

```java
ReactMarker.addListener(new ReactMarker.MarkerListener() {
  Override
  public void logMarker(ReactMarkerConstants name, Nullable String tag, int instanceKey) {
    Log.d("ReactNativeEvent", "name: "+ name.name() + " tag: " + tag);
  }
});
```
This will allow you to perform the necessary processing, calculations as required.

 ---

This PR enables observing for the module setup event (`RCTDidSetupModuleNotification`) by including the respective module's name & setup time in milliseconds.

[iOS] [Added] - Gain insights on the module setup times by observing `RCTDidSetupModuleNotification`. The `userInfo` dictionary will contain the module name and setup time in milliseconds. These values can be extracted via `RCTDidSetupModuleNotificationModuleNameKey ` and `RCTDidSetupModuleNotificationSetupTimeKey`.
Pull Request resolved: https://github.com/facebook/react-native/pull/23859

Differential Revision: D14579066

Pulled By: PeteTheHeat

fbshipit-source-id: 52645127c3fc6aa5bd73e3bd471fccd79cb05c14
2019-03-22 10:43:00 -07:00
zhongwuzw 27e727968a Add copy for surface registry when return enumerator (#24056)
Summary:
To ensure all methods in surface registry thread safe, add copy to enumerator method.
cc. shergin .

[iOS] [Fixed] - Add copy for surface registry when return enumerator
Pull Request resolved: https://github.com/facebook/react-native/pull/24056

Differential Revision: D14575446

Pulled By: shergin

fbshipit-source-id: 6757f71e251381c4a38d13df4729e9494b3164d1
2019-03-21 23:37:18 -07:00
Lukas Kurucz 15619c22e5 Fix PerfMonitor appearance when reloading JS (#24073)
Summary:
Fix for this issue I rasied: https://github.com/facebook/react-native/issues/24024
When I toggle `Show Perf Monitor` and reload JS `CMD+R` the Perf Monitor will be hidden, but settings in dev menu will persist. So to fix this state and need to `Hide Perf Monitor` and `Show Perf Monitor` again to see it.

[iOS] [Fixed] - Show Perf Monitor, after reloading JS
Pull Request resolved: https://github.com/facebook/react-native/pull/24073

Differential Revision: D14560025

Pulled By: cpojer

fbshipit-source-id: cd5602bd6ee041b8b3e61d163d10bd8bc47237b9
2019-03-21 03:21:15 -07:00
Valentin Shergin 95b05c0d82 Revert D14425373: [react-native][PR] [iOS] Remove explicitly add png file extension when load local image
Differential Revision:
D14425373

Original commit changeset: 3cc06c9a3d68

fbshipit-source-id: eef2ee9a459c35dcb30e0c023eb24854529149be
2019-03-20 14:46:53 -07:00
Changnam Hong 5dd6908b25 Fix RCTJavaScriptLoader loadBundleAtURL error case (#23837)
Summary:
Change the function called when an error is returned from the completionHandler of the `RCTJavaScriptLoader(loadBundleAtURL:onProgress:onComplete:)`.

* AS-IS
    - `RCTLogError()`
    - This error method does not post any notification for users. So users cannot receive notification when `RCTJavaScriptLoader(loadBundleAtURL:onProgress:onComplete:)` complete with error.(i.e. bundleURL is is invalid but not nil, `http://1`, `http://localho:8081/index.bundle`)

* TO-BE
    - `handleError(error:)`
    -  Call this method will post notification for users when `completionHandler` fails with error.

[iOS] [Fixed] - Change the function called when an error is returned from the completionHandler of the `RCTJavaScriptLoader(loadBundleAtURL:onProgress:onComplete:)`.
Pull Request resolved: https://github.com/facebook/react-native/pull/23837

Differential Revision: D14538790

Pulled By: cpojer

fbshipit-source-id: da3306904c0d8113d204edfaa0f9e2a23793981a
2019-03-20 04:53:24 -07:00
zhongwuzw 7ae90408c9 Fixed surface presenter observer (#24048)
Summary:
We missed create observer array, let's add it.
cc. shergin .

[iOS] [Fixed] - Fixed surface presenter observer
Pull Request resolved: https://github.com/facebook/react-native/pull/24048

Differential Revision: D14537159

Pulled By: shergin

fbshipit-source-id: f57f685a09aa7c9692245d178b68e94d666ae2fb
2019-03-19 22:15:44 -07:00
zhongwuzw a98f342191 Reorder prepareForRecycle before adding recycle pool (#24025)
Summary:
Put `prepareForRecycle` to last before enqueue to recycle pool, ensure only call it when count lower than RCTComponentViewRegistryRecyclePoolMaxSize.

cc. shergin .

[General] [Changed] - Reorder prepareForRecycle before adding recycle pool
Pull Request resolved: https://github.com/facebook/react-native/pull/24025

Differential Revision: D14536843

Pulled By: shergin

fbshipit-source-id: 82a816e2c0afb5a6bb72637d7d55d6a4fda708af
2019-03-19 21:20:00 -07:00
Christopher Hogan d884baec86 iOS 0.58.6 merge building, linking, running 2019-03-19 14:09:38 -07:00
zhongwuzw e40a76715a Remove explicitly add png file extension when load local image (#23864)
Summary:
We need to remove adding png file extension when path has not extension. Two reasons:
1. `imageWithContentsOfFile` or other `UIKit` methods can load png image correctly, even if path has not `png` file extension.
2. Sometimes, people may have file that actually not have file extension, it's the designated behavior for user. Like #23844 .

CC. sahrens cpojer .

[iOS] [Fixed] - Remove explicitly add png file extension when load local image
Pull Request resolved: https://github.com/facebook/react-native/pull/23864

Reviewed By: shergin

Differential Revision: D14425373

Pulled By: hramos

fbshipit-source-id: 3cc06c9a3d68cadf652c1de742f3cce26258c874
2019-03-18 23:03:32 -07:00
zhongwuzw 8266f61935 Change invalid bridge log level from error to warn (#24005)
Summary:
I encountered invalid bridge error when I develop (reload high frequency) some times, and if it happened, I only can restart the app, because we would always show error invalid message if we trigger reload command. So I recommend Change invalid bridge log level from error to warn, I think it's enough.

cc. cpojer .

<img width="375" alt="892C97F4-E910-4E3B-935A-65C899916E6E" src="https://user-images.githubusercontent.com/5061845/54538344-0d32c600-49cf-11e9-818c-0e4cb5a0a518.png">

[iOS] [Fixed] - Change invalid bridge log level from error to warn
Pull Request resolved: https://github.com/facebook/react-native/pull/24005

Differential Revision: D14504820

Pulled By: cpojer

fbshipit-source-id: f24c4876fdb3e64183c09c5ddc598a8c87e405a7
2019-03-18 10:48:59 -07:00
ericlewis 97e6ea1371 Fabric: working podspecs & works in RNTester (#23803)
Summary:
This is the couple of hacks I used after I finished #23802 in order to get fabric working on RNTester. This is inspired from prior work by kmagiera.

The goal of this PR is to show others what I’m struggling with, and to eventually merge it sans hacks.

- Yarn Install
- Uncomment the commented out pods in RNTester's pod file
- Open RNTesterPods workspace
- Run App

- this is only for pods, the non-pod RNTester will no longer work until updated with fabric too.
- `SurfaceHostingView` & `SurfaceHostingProxyRootView` both try to start the surface immediately, this leads to a race condition due to the javascript not having loaded yet, the hack here is:
   1. Swizzle the `start` method on `RCTFabricSurface` to no-op when called.
   2. Add observer for `RCTJavaScriptDidLoadNotification`
   3. Call private method `_startAllSurfaces` on `_surfacePresenter` in AppDelegate when we receive `RCTJavaScriptDidLoadNotification`.

[General] [Added] - Use Fabric in RNTester
Pull Request resolved: https://github.com/facebook/react-native/pull/23803

Reviewed By: shergin, mdvacca

Differential Revision: D14450726

Pulled By: fkgozali

fbshipit-source-id: 8ae2d48634fecb60db539aaf0a2c89ba1f572c27
2019-03-15 23:59:22 -07:00
Joshua Gross 34499002f2 fbios BottomSheet implementation
Summary: Several things need to ironed out: 1) LocalState in Fabric C++, 2) setting dimensions of BottomSheet component to 0,0 for parent.

Reviewed By: shergin

Differential Revision: D14426167

fbshipit-source-id: 45a90a7971c87672872108a9e360926b4a6095f0
2019-03-15 14:37:39 -07:00
zhongwuzw 942bf4054d Fixed minuteInterval invalid in time mode (#23923)
Summary:
From https://github.com/facebook/react-native/pull/23861#issue-260337314
> changing "interval" example from "time-only" to "datetime" because there's a known bug that prevented the previous example from working

We need to ensure set minuteInterval after set datePickerMode, otherwise minuteInterval invalid in time mode.

cc. grabbou cpojer .

[iOS] [Fixed] - Fixed minuteInterval invalid in time mode
Pull Request resolved: https://github.com/facebook/react-native/pull/23923

Differential Revision: D14477549

Pulled By: cpojer

fbshipit-source-id: 2c612d488b6d592b1907e150df5e07fe83132829
2019-03-15 11:34:20 -07:00
Estevão Lucas 40de0495b9 - add more iOS flags into AccessibilityInfo (#23913)
Summary:
As a follow-up to this other PR #23839, it adds support for other, iOS only, flags into `AccessibilityInfo`.

It adds these other 4 methods:
* `isBoldTextEnabled()`
* `isGrayscaleEnabled()`
* `isInvertColorsEnabled()`
* `isReduceTransparencyEnabled()`

P.S: Android implementation for those methods just return `false` (with `Promise.resolve(false)`)

And the corresponding event listeners:
* `boldTextChanged`
* `grayscaleChanged`,
* `invertColorsChanged`,
* `reduceTransparencyChanged`
Pull Request resolved: https://github.com/facebook/react-native/pull/23913

Differential Revision: D14482214

Pulled By: cpojer

fbshipit-source-id: b97725fd12706957d4dad880a97e6b0993738272
2019-03-15 11:34:20 -07:00
zhongwuzw af7efff955 Move Bridge RCTSurfacePresenterStub category implementation to .m file (#23888)
Summary:
Move implementation out from header file. Because it may have potential linker issue.
CC. sahrens

<img width="716" alt="image" src="https://user-images.githubusercontent.com/5061845/54267283-ea11ac00-45b3-11e9-8d0e-9ff20db98b01.png">

[iOS] [Fixed] - Move Bridge RCTSurfacePresenterStub category implementation to .m file
Pull Request resolved: https://github.com/facebook/react-native/pull/23888

Differential Revision: D14477611

Pulled By: cpojer

fbshipit-source-id: 660f3c27806252fc8f47430582818d37d42fd365
2019-03-15 11:22:53 -07:00
Mike Grabowski 581711ca55 Do not run packager in Release mode (#23938)
Summary:
When running your project in "Release" mode, Metro will start automatically. This is not desired. See https://github.com/react-native-community/react-native-cli/issues/31 for details

[IOS] [FIXED] - Do not start Metro in Release mode
Pull Request resolved: https://github.com/facebook/react-native/pull/23938

Differential Revision: D14477595

Pulled By: cpojer

fbshipit-source-id: 05166537500fa95a59ae87f27154c9665b7ccfe8
2019-03-15 04:36:46 -07:00
Peter Argany d0d8c8b651 Fix a race condition in UIManager NativeID which cause snapshot tests to crash
Summary:
D14323747 broke SSTs. This PR optimized implementation of nativeID. Instead of searching entire tree to find a view, it uses a map to cache views which have nativeID set. The map uses keys with format <nativeID-rootViewTag>. Finding the rootViewTag causes a race condition, due to [this syncing code](https://fburl.com/93vqzlbg). The SST runner attempts to read the map to find a [SST view](https://fburl.com/8zadz024) before that view is added to the map.

My fix is to change the key format to simply <nativeID>. Product code should not duplicate nativeID since it is used to uniquely identify react managed views from native. I'll comment on PR with this fix.

Reviewed By: shergin, mmmulani

Differential Revision: D14416262

fbshipit-source-id: 3b707f2ff4049ac83ac8861e3cda435224d973d8
2019-03-14 22:08:33 -07:00
ericlewis fc94ade11c Move RCTTest & takeSnapshot to RNTester (#23721)
Summary:
Part of: #23313.

This moves the `RCTTest` lib from `Libraries/RCTTest` to `RNTester/RCTTest`. This also removes `takeSnapshot` from React Native, and implements it as a standalone module in RNTester called `ScreenshotManager`.

[General] [Removed] - RCTTest & ReactNative.takeSnapshot
Pull Request resolved: https://github.com/facebook/react-native/pull/23721

Differential Revision: D14434796

Pulled By: PeteTheHeat

fbshipit-source-id: d6e103a0ea0b6702701cdb5ce8449163ca4628ce
2019-03-14 11:24:21 -07:00
Tom Underhill 8e0d7f85d4
Fix macOS ActivityIndicator to color properly in different themes (#13)
* Fix macOS ActivityIndicator to color properly in different themes

* Removed prop setter override

* Add color setter to cause redisplay
2019-03-13 13:10:14 -07:00
zhongwuzw fc3225d0f1 Remove null file reference in Xcode project (#23883)
Summary:
So strange we have some null reference in Xcode, let's remove them.
CC. cpojer .

[iOS] [Fixed] - Remove null file reference in Xcode project
Pull Request resolved: https://github.com/facebook/react-native/pull/23883

Differential Revision: D14436828

Pulled By: cpojer

fbshipit-source-id: da6eb3b6a0941a9f91991403d1eef53da94a543a
2019-03-13 01:01:19 -07:00
zhongwuzw e3a3231e2f Add SurfacePresenterStub header to project header for tvOS (#23855)
Summary:
We need to add SurfacePresenterStub header to project header for tvOS.
Related 544d9fb10b
CC. sahrens .

[iOS] [Fixed] - Add SurfacePresenterStub header to project header for tvOS
Pull Request resolved: https://github.com/facebook/react-native/pull/23855

Differential Revision: D14436185

Pulled By: cpojer

fbshipit-source-id: b59369541e78967346fc9e9fa6a9685725834f39
2019-03-12 22:46:49 -07:00
ericlewis 01033d16ec Silence Xcode warning (#23880)
Summary:
Fixes a warning in React Xcode proj. Should be a trivial change.

[iOS] [Fixed] - uncaptured lambda warning
Pull Request resolved: https://github.com/facebook/react-native/pull/23880

Differential Revision: D14435848

Pulled By: cpojer

fbshipit-source-id: 83c126c7401ac32b769ff17172f4f4ae576bd771
2019-03-12 22:08:21 -07:00
Estevão Lucas 0090ab32c2 - Add support for "reduce motion" into AccessibilityInfo (#23839)
Summary:
This PR adds `isReduceMotionEnabled()` to `AccessibilityInfo` in other to add support for "reduce motion", exposing the Operational System's settings option. Additionally, it adds a new event, `reduceMotionChanged`, in order to listen for this flag's update.

With this feature, developers will be able to disable or reduce animations, _**something that will be required as soon as WCAG 2.1 draft got approved**._ See [WCAG 2.1 — 2.3.3 Animations from Interaction criteria](https://knowbility.org/blog/2018/WCAG21-233Animations/)

It's exposed by [`UIAccessibility`' isReduceMotionEnabled ](https://developer.apple.com/documentation/uikit/uiaccessibility/1615133-isreducemotionenabled
) on iOS and [Settings.Global.TRANSITION_ANIMATION_SCALE](https://developer.android.com/reference/android/provider/Settings.Global#TRANSITION_ANIMATION_SCALE) on Android.

Up until now, `AccessibilityInfo` only exposes screen reader flag. By adding this second accessibility option, it's a good opportunity to rename `fetch` method to an appropriate name, `isScreenReaderEnabled`, as well as rename `change` event to `screenReaderChanged`, which will make it clearer and more specific.

(In case it's approved, a follow-up PR could exposes [more iOS acessibility flags](https://developer.apple.com/documentation/uikit/uiaccessibility), such as `isShakeToUndoEnabled`, `isReduceTransparencyEnabled`, `isGrayscaleEnabled`, `isInvertColorsEnabled`)

(iOS code inspired by [phonegap-mobile-accessibility](https://github.com/phonegap/phonegap-mobile-accessibility). And Android by [Flutter](https://github.com/flutter/engine/blob/master/shell/platform/android/io/flutter/view/AccessibilityBridge.java
))
Pull Request resolved: https://github.com/facebook/react-native/pull/23839

Differential Revision: D14406227

Pulled By: hramos

fbshipit-source-id: adf43be84c488522bf1e29d862681220ad193883
2019-03-12 20:28:21 -07:00
ericlewis 8e490d4d87 Fabric: fix border memory leaks (#23815)
Summary:
This fixes a few memory leaks in fabrics handling of colors for borders, when using CGColorRef's we must be diligent about releasing the memory back.

[iOS] [Fixed] - Border style memory leaks
Pull Request resolved: https://github.com/facebook/react-native/pull/23815

Differential Revision: D14431250

Pulled By: shergin

fbshipit-source-id: dc663c633ae24809cb4841800d31a6ac6eeb8aa5
2019-03-12 20:13:28 -07:00
ericlewis 10d28421cf Fabric: fix startSurfaceWithSurfaceId typo (#23876)
Summary:
Fixes a trivial typo in `startSurfaceWithSurfaceId` method.

[iOS] [Fixed] - Typo in startSurfaceWithSurfaceId
Pull Request resolved: https://github.com/facebook/react-native/pull/23876

Differential Revision: D14435111

Pulled By: shergin

fbshipit-source-id: 252f60cc0eec6e355fcaf0f64cb987afd8d5ec72
2019-03-12 20:00:40 -07:00
Pavlos Vinieratos 629708beda Crash reporting heaven (#23691)
Summary:
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
I have used RN for a long time, and for all this time, crash reporting has been less great than native development crash reporting. At some point, companies like sentry, bugsnag and a bunch of others started supporting sourcemaps for js crashes in RN, which helped a lot.
But native crashes were (and still are) much harder to diagnose.

..Until now :D

I have make a repo of a sample RN app, included this PR in it, and some code and screenshots to help.
The repo is [here](https://github.com/pvinis/react-native-project-with-crash-heaven-pr).

I was trying to get good crash reports from native crashes in iOS for a looong time. I spoke with people in sentry, in bugsnag and more, and I could not get this solved. There was no clear way to get the **native** crashed to display correctly.
I made two repos here, one for [sentry](https://github.com/pvinis/SentryBadStack) and one for [bugsnag](https://github.com/pvinis/BugsnagBadStack), demonstrating the correct js handling and the bad native handling.

After all this, and talks with their support, twitter etc, I investigated further, on **why** this was happening. I thought there must be some reason that native crashes look bad in all the tools, and in the same way. Maybe it's not their fault, or up to them to fix it, or maybe they didn't have the experience to fix it.

In a test project I created, I checked what's up with the `RCTFatalException`, and I found out that the React Native code is catching the `NSException`s that come from any native modules of a RN app and converting it into an string and sending it to `RCTFatal` that created an `NSError` out of that string. Then it checks if the app has set a fatal error handler and if not, goes ahead and throws that `NSError`.

The problem here is that `NSException` has a bunch more info that the resulting `NSError` is missing or is altering. Turning the callstack into a string renders crash reporting tools useless as they are missing the original place the exception was thrown, symbols, return addresses etc. In both repos above it can be seen that both tools were thinking that the error happened somewhere in the `RCTFatal` function, and it did, since we create it there, losing all the previous useful info of the original exception. That leaves us with just a very long name including a callstack, but very hard to actually map this to the code and dsym.

I added a fatal exception handler, that mirrors the fatal error handler, as the error handler is used around React Native internal code.

Then I stopped making a string out of the original `NSException` and calling `RCTFatal`, and I simply throw the exception. This way no info is lost!

Finally, I added some code examples of native and js crashes and added a part in the `RNTester` app, so people can see how a js and a native error look like while debugging, as well as try to compile the app in release mode and see how the crash report would look like if they connect it to bugsnag or sentry or their tool of choice.

I have attached some images at the bottom of this PR, and you can find some in the 3 repos I linked above.

[iOS] [Fixed] - Changed the way iOS native module exceptions get handled. Instead of making them into an `NSError` and lose the context and callstack, we keep them as `NSException`s and propagate them.
[General] [Added] - Example code for native crashes in iOS and Android, with buttons on RNTester, so developers can see how these look when debugging, as well as the crash reports in release mode.
Pull Request resolved: https://github.com/facebook/react-native/pull/23691

Reviewed By: fkgozali

Differential Revision: D14276366

Pulled By: cpojer

fbshipit-source-id: b308d5608e1432d7676447347ae77c0721094e62
2019-03-12 19:41:51 -07:00
Héctor Ramos 0f7a278bbe Add RCTSurfacePresenterStub to tvOS target
Summary:
Changelog:

[iOS][Added] - Add RCTSurfacePresenterStub to tvOS target

Reviewed By: fkgozali

Differential Revision: D13498458

fbshipit-source-id: abad840ca1a087e1d2671549108cb05164b65200
2019-03-12 15:03:04 -07:00
Mike Grabowski 7c73f2bb5a [0.59.0] Bump version numbers 2019-03-12 13:42:02 +01:00
Christopher Hogan 27381d39db facebook 0.58.6 merge with conflicts (although some iOS files had conflicts removed) 2019-03-11 13:49:58 -07:00
Tom Duncalf f0bc491452 Remove duplicated Yoga compile sources to prevent "duplicate symbols" errors when linking using -force_load (#23823)
Summary:
This change fixes https://github.com/facebook/react-native/issues/23645.

The issue is that the `YGMarker.cpp`, `YGValue.cpp`, `YGConfig.cpp` and `log.cpp` files are already included in the Yoga compilation unit, so including these files in React's compile sources too results in "duplicate symbols" errors when loading React Native with `-force_load` (which behaves slightly differently to `-ObjC` - according to a colleague, "ObjC will scan through each object file in each library and force linking of any object file that contains Objective C code, while force_load will link every object file in a particular staticlib (regardless of whether or not the object file contains Objective C code)").

These changes seemed to be introduced by a few commits:
- D13819111 -> 43601f1a17
- D13439602 -> b5c66a3fbe
- D14123390-> e8f95dc7a1
- D7530369 -> 95f625e151

Perhaps we need to check with the original authors/any C++ experts to confirm if this fix is correct - it compiles for me but I'm not sure what the original intention of these changes was.

[iOS] [Fixed] - Remove duplicated Yoga compile sources to prevent "duplicate symbols" errors when linking using -force_load
Pull Request resolved: https://github.com/facebook/react-native/pull/23823

Reviewed By: davidaurelio

Differential Revision: D14387657

Pulled By: hramos

fbshipit-source-id: d85221b6dc1a0377662624f4201b27222aed8219
2019-03-11 21:22:37 +01:00
zhongwuzw 456a984722 Fix image wrong scale factor when load image from file system (#23446)
Summary:
Regression, fix image load from `~/Library` not respect scale factor.
Fixes #22383 , the bug comes from [Clean up some URL path handling](998197f444).

[iOS] [Fixed] - Fix image wrong scale factor when load image from file system
Pull Request resolved: https://github.com/facebook/react-native/pull/23446

Differential Revision: D14099614

Pulled By: cpojer

fbshipit-source-id: eb2267b195a05eb70cdc4671536a4c1d47fb03e2
2019-03-11 21:20:02 +01:00
Tom Duncalf cecd307708 Remove duplicated Yoga compile sources to prevent "duplicate symbols" errors when linking using -force_load (#23823)
Summary:
This change fixes https://github.com/facebook/react-native/issues/23645.

The issue is that the `YGMarker.cpp`, `YGValue.cpp`, `YGConfig.cpp` and `log.cpp` files are already included in the Yoga compilation unit, so including these files in React's compile sources too results in "duplicate symbols" errors when loading React Native with `-force_load` (which behaves slightly differently to `-ObjC` - according to a colleague, "ObjC will scan through each object file in each library and force linking of any object file that contains Objective C code, while force_load will link every object file in a particular staticlib (regardless of whether or not the object file contains Objective C code)").

These changes seemed to be introduced by a few commits:
- D13819111 -> 43601f1a17
- D13439602 -> b5c66a3fbe
- D14123390-> e8f95dc7a1
- D7530369 -> 95f625e151

Perhaps we need to check with the original authors/any C++ experts to confirm if this fix is correct - it compiles for me but I'm not sure what the original intention of these changes was.

[iOS] [Fixed] - Remove duplicated Yoga compile sources to prevent "duplicate symbols" errors when linking using -force_load
Pull Request resolved: https://github.com/facebook/react-native/pull/23823

Reviewed By: davidaurelio

Differential Revision: D14387657

Pulled By: hramos

fbshipit-source-id: d85221b6dc1a0377662624f4201b27222aed8219
2019-03-11 10:05:52 -07:00
Valentin Shergin 205171cab0 Fabric: Simpler view preallocation on iOS
Summary:
I measured the performance of UIMananger methods and found that `create` method spends a significant amount of time on preallocating views (around 10 ms on my device). Interestingly, this time was actually spent on dispatching operations on the main thread, not on performing those operations. That makes me think about think about the preallocation problem one more time.
(Here and later I discuss preemptive optimistic preallocation views on iOS, but the issues are more-less applicable for all platforms.)

BTW, what's view preallocation? – In React Native we believe that we can get significant TTI wins instantiating platform views ahead of time while JavaScript thread is busy doing reconciliation and the main one is idle.

So, seems the current approach has those downsides:
 * We spend too much time on dispatching only (jumping threads, creation Objective-C blocks, managing them in GCD, incrementing atomic refcountes inside `ShadowView` and so on). That's wasteful.
 * We don't have much information during preallocations that can help prepare something to save time in the future. We don't know the future size of the component, so we cannot e.g. pre-draw a border or even allocate memory for a future drawing.
 * We pre-allocate to much. At the moment of component creation, we don't know will this component be filtered out by view-flattening infra or not, so we always allocate a view for it. That's ~30% more views that we actually need.
 * We don't stop allocating (or dispatching instructions for that) after the recycle pool is already filled in. That's also wasteful.

Why is this so bad and how can we fix it properly?..

I thought about this problem for months. And I think the answer is trivial: We don't know the exact shape of the interface until we finish creating it, and there is no way to overcome this problem on the client side. In the ideal world, the server size (or hardcoded manifest somewhere) tells the renderer (at the moment where we started navigating to it) how many views of which type will some surface use.

And until our world is not so perfect, I think we can get a significant performance improvement doing simple preallocation of 100 regular views, 30 text views, and 30 image views during rendering the first React Native surface. So I hardcoded that.

Reviewed By: JoshuaGross

Differential Revision: D14333606

fbshipit-source-id: 96beeb58b546258de1b8fd58550e0ae412b78aa9
2019-03-08 10:27:05 -08:00
Spencer Ahrens 544d9fb10b Use surface observer for Animated
Summary:
Right now we rely on the Paper UIManager to update animated node graphs - this hooks us into `RCTSurfacePresenter` in the same way so we are no longer reliant on Paper. Should also help with complex ordering corner cases with pre vs. post operations and restoring defaults when nodes are removed. More info:

https://github.com/facebook/react-native/pull/11819/files

Note that we don't have a way to differentiate animation nodes related to fabric views vs. paper views, so if paper and fabric are both rendering updates simultaneously it's possible they could get processed by the wrong callback. That should be very rare, rarely cause problems even if it does happen, and won't be a problem at all in a post-Paper world.

Reviewed By: shergin

Differential Revision: D14336760

fbshipit-source-id: 1c6a72fa67d5fedbaefb21cd4d7e5d75484f4fae
2019-03-07 17:39:00 -08:00
Spencer Ahrens 3e40837a85 Fix animation delay
Summary:
We currently rely on the Paper UIManager calling `uiManagerWillPerformMounting` to flush the animated operations queue, which includes starting and stopping animations. This mostly works right now because Fabric always starts after Paper, but sometimes Paper doesn't fire `uiManagerWillPerformMounting` for a while, which can delay an animation starting.

To fix this, I force a flush of the queues on the UIThread whenever start or stop is called. This should be safe because the order of animation operations is still preserved, and start/stop are (almost?) always called in dedicated event handler loops, so any other updates like changing the way nodes are attached should already have been processed from a previous JS execution loop.

Reviewed By: JoshuaGross

Differential Revision: D14313502

fbshipit-source-id: 2a2b0c614fd1a591bd04b6b3fafcc09ff6c9d6e7
2019-03-07 17:39:00 -08:00
Rick Hanlon d48bd1759e Use codegen for Slider props + events
Summary: Use the codegen for the Slider component with the new `inferfaceOnly` option

Reviewed By: TheSavior

Differential Revision: D14295981

fbshipit-source-id: 0482572892fbcffada43c7c6fbf17e70546300b8
2019-03-05 11:53:56 -08:00
zhongwuzw b7b8836a7f Implement the nativeID functionality in a more efficient way (#23662)
Summary:
Implement TODO, implement the nativeID functionality in a more efficient way instead of searching the whole view tree.

[iOS] [Fixed] - Implement the nativeID functionality in a more efficient way
Pull Request resolved: https://github.com/facebook/react-native/pull/23662

Differential Revision: D14323747

Pulled By: shergin

fbshipit-source-id: 3d45dbf53ad2b6adb79b4331600d53b51ede76d4
2019-03-05 09:41:19 -08:00
aleclarson dc893756b8 Properly validate JS->native method calls (#23658)
Summary:
Between invalidating a bridge and suspending its JS thread, native modules may have their methods called.

Only warn when a native module has been invalidated, which happens right before its JS thread is suspended.

Avoid initializing a native module's instance if its bridge is invalidated.

/cc fkgozali f945212447 (commitcomment-32467567)

[iOS] [Fixed] - Properly validate JS->native method calls
Pull Request resolved: https://github.com/facebook/react-native/pull/23658

Differential Revision: D14287594

Pulled By: fkgozali

fbshipit-source-id: 89dd1906a0c55f3f48ba4ff220aac0cddf2eb822
2019-03-04 17:39:53 -08:00
zhongwuzw 17ae61e14c Fixed method invoke when both nullable and __unused exist (#23726)
Summary:
We have parse code to try to support exported method parameter annotated `__unused` and `nullable`, but actually, seems we don't support it entirely, for example, we parse `__unused` firstly, then we parse `nullable`, actually, this case not exist, because `nullable` macro must appear right after `(`, before `__unused`, so we can't parse success, leads to error signature and crash.

[iOS] [Fixed] - Fixed method invoke when both nullable and __unused exist
Pull Request resolved: https://github.com/facebook/react-native/pull/23726

Differential Revision: D14298563

Pulled By: cpojer

fbshipit-source-id: 934e1d384a5d67b7bbf117fd2dec51f50979c979
2019-03-03 20:45:06 -08:00
zhongwuzw 7025cce3f4 Fixed crash if event doesn't have body parameter (#23711)
Summary:
We need to check `body[@"target"]` wether equal to `nil`, if it is, return to prevent crash.

[iOS] [Fixed] - Fixed crash if event doesn't have body parameter
Pull Request resolved: https://github.com/facebook/react-native/pull/23711

Differential Revision: D14298543

Pulled By: cpojer

fbshipit-source-id: d5e8cd69438f323ae102e61618c0371a01bee347
2019-03-03 20:29:58 -08:00
zhongwuzw d8d42c7310 Added support of __nullable and __nonnull for module exported method signature (#23731)
Summary:
For the `NullabilityPostfix`, we can use `_Nullable` or `__nullable`. Please see https://developer.apple.com/swift/blog/?id=25 , and we also use it in our code.

[iOS] [Added] - Added support of __nullable and __nonnull for module exported method signature
Pull Request resolved: https://github.com/facebook/react-native/pull/23731

Differential Revision: D14298483

Pulled By: cpojer

fbshipit-source-id: 4dd3188f51be3808ea2b97ce19aa7a85ea1f4a9e
2019-03-03 20:06:21 -08:00
David Vacca 747d1f7029 Cleanup SchedulerDelegate interface
Summary: This diff removes the "isLayoutable" parameter from SchedulerDelegate.schedulerDidRequestPreliminaryViewAllocation. This now can be infered from the shadowView parameter

Reviewed By: shergin

Differential Revision: D14296481

fbshipit-source-id: b200504f9c2bef41f0a70257f1f5a274fbe97cbb
2019-03-03 15:51:32 -08:00
David Vacca 70447775f7 Update Props during pre-allocation avoiding re-updating the same props during mounting
Summary:
Update Props during pre-allocation avoiding re-updating the same props during mounting

MobileLab test showed an improvement of:
MARKETPLACE_YOU_TTI_SUCCESS: -3.34% = 58ms

Reviewed By: shergin

Differential Revision: D14252170

fbshipit-source-id: 1f4e9ad5dcecbc06651fa065135ffeed4892d984
2019-03-03 09:00:48 -08:00
Rick Hanlon 858efb222e Use Generated ActivityIndicatorView Schema
Summary:
We are now generating the native cpp files for ActivityIndicatorView via Buck.

Deleting the hand written files and switching over.

Reviewed By: TheSavior

Differential Revision: D14247446

fbshipit-source-id: 63a6df3254e4184de6c8abb9ea2c89654ad54398
2019-03-02 12:56:01 -08:00
Kevin Gozali 75f2da23c5 TM iOS: disable remote debugging toggle when TurboModule is active
Summary: TurboModule needs sync calls from JS to native, and that's not supported with the current Chrome debugger. Until we have proper solution, disable it to avoid confusion.

Reviewed By: PeteTheHeat

Differential Revision: D14286383

fbshipit-source-id: e93903bf8fdfc714960d0d58e3f3eb0442c811bd
2019-03-01 14:30:35 -08:00
REDMOND\acoates 5c0c3d4084 Initial commit of internal changes. 2019-03-01 10:09:07 -08:00
Mike Grabowski 7da8642849 [0.58.6] Bump version numbers 2019-02-28 16:57:28 +01:00
Mikael Sand 82c84c51e2 Don't reconnect inspector if connection refused (#22625)
Summary:
(Together with a pr to react-devtools) Fixes https://github.com/facebook/react-native/issues/21030

[iOS] [Fixed] - Fix infinite retry loop of inspector
Pull Request resolved: https://github.com/facebook/react-native/pull/22625

Differential Revision: D14169392

Pulled By: hramos

fbshipit-source-id: 2e301fd9d458598b62399fc61a9859ad29928483
2019-02-28 16:33:31 +01:00
Yedidya Feldblum fc91bccd53 Add assorted missing includes in xplat
Summary: Add assorted missing includes in `xplat` that would be exposed by future changes.

Reviewed By: ispeters, nlutsenko

Differential Revision: D14213660

fbshipit-source-id: 329f133784015fe20ee99feaec8ef05e117fe3a6
2019-02-28 00:52:48 -08:00
David Vacca b3790d283f Back out "[Fabric][C++][Android] update props during pre allocation of views"
Summary:
This is a back-out of D14214844, we noticed that this regressed TTI for Marketplace You screen running in Fabric

Original commit changeset: b81005f2bf49

Reviewed By: JoshuaGross

Differential Revision: D14247897

fbshipit-source-id: de0cea92b437b2fbcd075f0d6a0066156800e3f0
2019-02-28 00:04:09 -08:00
Mike Grabowski 9cb4d3f2c1 [0.59.0-rc.3] Bump version numbers 2019-02-27 22:21:55 +01:00
Mikael Sand f9097017de Don't reconnect inspector if connection refused (#22625)
Summary:
(Together with a pr to react-devtools) Fixes https://github.com/facebook/react-native/issues/21030

[iOS] [Fixed] - Fix infinite retry loop of inspector
Pull Request resolved: https://github.com/facebook/react-native/pull/22625

Differential Revision: D14169392

Pulled By: hramos

fbshipit-source-id: 2e301fd9d458598b62399fc61a9859ad29928483
2019-02-27 21:15:46 +01:00
Valentin Shergin 9207377058 Fabric: State-related mounting logic for iOS
Summary: The changes allows to get the State object on mounting layer and initiate the updates.

Reviewed By: mdvacca

Differential Revision: D14217185

fbshipit-source-id: 370644e06e350932e93c39adbe46544b071c28b3
2019-02-27 00:32:25 -08:00
zhongwuzw 06c6c7c673 Remove compatible system code for iOS8 and before (#23656)
Summary:
We already only support `iOS9+`, so we can remove all compatible codes now.

[iOS] [Fixed] - Remove compatible system code for iOS8 and before
Pull Request resolved: https://github.com/facebook/react-native/pull/23656

Differential Revision: D14224986

Pulled By: hramos

fbshipit-source-id: cac9ffe6788dd3eaf4f4f5f2b219f325ba78e85f
2019-02-26 07:58:52 -08:00
Valentin Shergin 9a64755a18 Fabric: `events` module was merged into `core` module
Summary: That's bummer that we have to do it, but it's actually reasonable. Files in `core` and `events` depend on each other creating circular dependencies and other similar hard problem.

Reviewed By: mdvacca

Differential Revision: D14195022

fbshipit-source-id: 96a44ae28631cc9ccd7d7de72a94526f9e0dd12a
2019-02-25 19:12:08 -08:00
David Vacca 19765c9b8c update props during pre allocation of views
Summary:
This diff changes the pre-allocation of Images update the props on the ImageViews during the creation of ShadowNodes instead of during rendering.

The purpose of this change is to optimize TTI.

Reviewed By: shergin

Differential Revision: D14214844

fbshipit-source-id: b81005f2bf494f62f421dc24846e1561e13b9a87
2019-02-25 17:21:24 -08:00
ericlewis 78b167c735 Call super if shouldDisableScrollInteraction false (#23647)
Summary:
Allow iOS to handle `touchesShouldCancelInContentView` on RCTScrollView if we aren't disabling the scroll interaction.

[iOS] [Changed] - RCTScrollView allows iOS to handle touchesShouldCancelInContentView
Pull Request resolved: https://github.com/facebook/react-native/pull/23647

Differential Revision: D14214248

Pulled By: hramos

fbshipit-source-id: 6e1bab3085aed6cabb93fb5dc988afe3911817e8
2019-02-25 14:35:17 -08:00
ericlewis 918620bdcb Fix xcode warnings (#23648)
Summary:
Fixes yet more Xcode warnings.

[iOS] [Fixed] - Xcode warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/23648

Differential Revision: D14214231

Pulled By: hramos

fbshipit-source-id: 050ab8519ca77941894b650b1c56bfcbe86e2c69
2019-02-25 14:30:39 -08:00
Spencer Ahrens ea54ceca13 basic useNativeDriver functionality
Summary:
Not super clean, but not terrible.

Unfortunately this still relies on the old Paper UIManager calling delegate methods to flush the operations queues. This will work for Marketplace You since Paper will be active, but we need to fix this, along with Animated Events which don't work at all yet.

Random aside: it seems like taps are less responsive in fabric vs. paper, at least on iOS. There is a sporadic delay between the touches event coming in nativly to the JS callback invoking the native module function to start the animation - this will need some debugging.

Reviewed By: shergin

Differential Revision: D14143331

fbshipit-source-id: 63a17eaafa1217d77a532a2716d9f886a96fae59
2019-02-25 12:25:34 -08:00
zhongwuzw d2ac9a0698 Fixed deprecated declarations warning (#23625)
Summary:
Fixed deprecated declarations warning.
cc cpojer .

[iOS] [Fixed] - Fixed deprecated declarations warning
Pull Request resolved: https://github.com/facebook/react-native/pull/23625

Differential Revision: D14205929

Pulled By: cpojer

fbshipit-source-id: 5e46f7f598ab1080b93923dcc25c98e1cd4362cd
2019-02-24 19:38:58 -08:00
zhongwuzw 81860c59c3 Remove compiler warning (#23588)
Summary:
Fixed compiler warning, after this, seems we have no warning for framework in debug mode.
<img width="1280" alt="image" src="https://user-images.githubusercontent.com/5061845/53224564-2d14e980-36b0-11e9-85f4-46304513b18d.png">

[iOS] [Fixed] - Remove compiler warning
Pull Request resolved: https://github.com/facebook/react-native/pull/23588

Differential Revision: D14181748

Pulled By: cpojer

fbshipit-source-id: 8b633e7cdb7b3b8029f4145a1155e540ac516191
2019-02-22 01:40:09 -08:00
Kevin Gozali 17082d92cf NativeModules iOS: downgrade duplicated module message to warning instead of error
Summary: [iOS] [Changed] - There seems to be a potential race condition during reloading that could cause "double registration" of modules. This should be mostly harmless, so downgrade to warning for the message instead of redboxing.

Reviewed By: cpojer

Differential Revision: D14179922

fbshipit-source-id: 5c16ac674f633a548353277d9f875544ed10ba9b
2019-02-21 20:10:30 -08:00
Ville Immonen 2321b3fd7f Split React.podspec into separate podspecs for each Xcode project (#23559)
Summary:
This PR implements the first part of [RFC0004: CocoaPods Support Improvements](353d44f649/proposals/0004-cocoapods-support-improvements.md), splitting the `React.podspec` into separate podspecs to more closely match the structure of Xcode projects.

The new structure aims to have one to one mapping between Xcode projects and podspecs. The only places where we differ from this mapping are:
* `React/React-DevSupport.podspec`: `DevSupport` is a part of `React.xcodeproj`, which corresponds to the `React-Core` pod. However, we can't include it in the `React-Core` pod because `DevSupport` depends on `React-RCTWebSocket`, which depends on `React-Core`. Pods may not have circular dependencies.
* The new pods under `ReactCommon/` don't have a corresponding `xcodeproj` because there are no `xcodproj` files in `ReactCommon/`. Those C++ modules are included in `React.xcodeproj`.

*Next steps (not in scope of this PR):*
- Start submitting the Podspecs to CocoaPods on a deploy (or turn the React Native repo into a spec repo): this is important in order to make the experience nicer for library consumers, so that it's not necessary to specify the local path of each Podspec in `Podfile`, you can just add `pod 'React', <version>`.
- Add `Podfile` to the default project template (I have a PR ready for this, but because of bugs related to subspecs, it's blocked on this PR)

[iOS] [Changed] - Split React.podspec into separate podspecs for each Xcode project
Pull Request resolved: https://github.com/facebook/react-native/pull/23559

Differential Revision: D14179326

Pulled By: cpojer

fbshipit-source-id: 397a9c30b6b5d24f86c790057c71f0d403f56c3d
2019-02-21 18:35:44 -08:00
Mikael Sand d9489c4e9c Don't reconnect inspector if connection refused (#22625)
Summary:
(Together with a pr to react-devtools) Fixes https://github.com/facebook/react-native/issues/21030

[iOS] [Fixed] - Fix infinite retry loop of inspector
Pull Request resolved: https://github.com/facebook/react-native/pull/22625

Differential Revision: D14169392

Pulled By: hramos

fbshipit-source-id: 2e301fd9d458598b62399fc61a9859ad29928483
2019-02-21 12:52:39 -08:00
Ville Immonen 0cffdaae30 Fix implicit conversion warning in RCTInspector.mm (#23577)
Summary:
Fixes Xcode warning: `Implicit conversion loses integer precision: 'NSInteger' (aka 'long') to 'int'`.

[iOS] [Fixed] - Fix implicit conversion warning in RCTInspector.mm
Pull Request resolved: https://github.com/facebook/react-native/pull/23577

Differential Revision: D14169498

Pulled By: hramos

fbshipit-source-id: c877a46b2b583c96bc977308ed28bdc0b0f2b517
2019-02-21 12:46:41 -08:00
Albert Martin bca85101cd fix: prevent exception when imageName is null (#20120)
Summary:
When an image source is parsed via `RCTImageFromLocalAssetURL` there seem to be certain situations in which `imageName` is empty from `RCTBundlePathForURL`. Any call to `UIImage imageNamed` with a an empty parameter will throw an exception:

```
CUICatalog: Invalid asset name supplied: '(null)'
```

In my case, the asset URL was pointing to an image in the application sandbox rather than the `NSBundle`. In this case `UIImage imageNamed` was throwing before the call to `NSData dataWithContentsOfURL` below could correctly resolve the image.

This change simply skips the call to `UIImage imageNamed` if no `imageName` value is set.
Pull Request resolved: https://github.com/facebook/react-native/pull/20120

Differential Revision: D14163101

Pulled By: cpojer

fbshipit-source-id: ceec95c02bf21b739962ef5618947a5726ba0473
2019-02-20 22:57:40 -08:00
Jacob Parker 30f13812ad Make JS loading progress use tabular numbers
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/20076

Differential Revision: D14162853

Pulled By: cpojer

fbshipit-source-id: a07b80319e23f8969887522b8761a560e8a3a98e
2019-02-20 22:14:23 -08:00
Luis Rivera fd96e2cb2c Feature: dev menu option to change packager location during runtime (#21970)
Summary:
Add an option to dev menu to change packager location on the fly on iOS (similar to Dev Settings in Android)
Pull Request resolved: https://github.com/facebook/react-native/pull/21970

Differential Revision: D14162776

Pulled By: cpojer

fbshipit-source-id: 3cca4f4fbd8c599bd5342ba1ae64905a03270d48
2019-02-20 22:07:11 -08:00
zhongwuzw 9c1c5a7455 Fix scrollview over bounds of content size (#23427)
Summary:
Fix scrollview `offset` out of content size in iOS, Android uses `scrollTo` and `smoothScrollTo` which not have this issue.

Fixes like #13594 #22768 #19970 .

[iOS] [Fixed] - Fixed scrollView offset out of content size.
Pull Request resolved: https://github.com/facebook/react-native/pull/23427

Differential Revision: D14162663

Pulled By: cpojer

fbshipit-source-id: a95371c8d703b6d5f604af0072f86c01c2018f4a
2019-02-20 21:32:51 -08:00
zhongwuzw 2ea4bcd001 Fixed ScrollView adjust inset behavior (#23555)
Summary:
Fixes #23500 , if user set prop `contentInsetAdjustmentBehavior="automatic"` of ScrollView, it not works when initial on the screen. We fixes it by filter valid offset, if offset is valid, just return.

[iOS] [Fixed] - Fixed ScrollView adjust inset behavior
Pull Request resolved: https://github.com/facebook/react-native/pull/23555

Differential Revision: D14161593

Pulled By: cpojer

fbshipit-source-id: 01434e55106ffde7f8e39f66dd5b0f02df9b38b1
2019-02-20 20:32:28 -08:00
Agustin Collazo 536045276c iOS downgrade invalid bridge warning (#23557)
Summary:
I downgrade the invalid bridge warning because I believe that it is a pain that every time that the JS gets refreshed this warnings are being thrown. If the project increase size and more and more NativeModules are added this warnings just spam the emulator or the device.

I understand the reason of validating if the bridge is valid. However in case of invalidness nothing is done, just the warning is thrown. Hence, the reason of downgrading it to improve the development process.

The error message still exist and it will be in the logs. But it will not spam the development screen

[iOS] [Changed] - Downgrade the Invalid bridge warning message to a log
Pull Request resolved: https://github.com/facebook/react-native/pull/23557

Differential Revision: D14161290

Pulled By: cpojer

fbshipit-source-id: e5608a9b2db5625309fd18d133fe69a9013043f3
2019-02-20 19:07:36 -08:00
Eric Lewis 468ae234a6 Fix xcode warnings (#23565)
Summary:
As part of #22609, this fixes yet more warnings.
- Adding more __unused to params.
- Refactors `isPackagerRunning` to use NSURLSession.
- Turns off suspicious comma warnings

[iOS] [Fixed] - Xcode Warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/23565

Differential Revision: D14161151

Pulled By: cpojer

fbshipit-source-id: 339874711eca718fc6151e84737ccc975225d736
2019-02-20 18:46:23 -08:00
Eric Lewis b0c69aba1d Allow compiler optimization (#23536)
Summary:
Fixes a warning thrown by Xcode & allow RVO to be performed.

[iOS] [Fixed] - Fix Xcode warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/23536

Reviewed By: JoshuaGross

Differential Revision: D14142973

Pulled By: hramos

fbshipit-source-id: e23050aed811127a3b4f73aa8a74472e4cc8e98c
2019-02-20 17:29:35 -08:00
Eric Lewis 19866aee3d Fix 50 xcode warnings (#23553)
Summary:
This PR reduces the number of warnings in React from 68 to 18. Mostly by marking unused variables. RNTester's warnings are more than halved.

[iOS] [Fixed] - Xcode warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/23553

Differential Revision: D14151339

Pulled By: hramos

fbshipit-source-id: 8255330bf910a69a4c03051d91d7b0de3fadf2d1
2019-02-20 10:17:26 -08:00
Skylar Peterson 5ff6b97d33 React scroll views should group accessibility children
Summary: If we don't group accessibility children, we can get into a state where the accessibility frame for our content lines up in such a way that VoiceOver doesn't know to scroll the scroll view, and instead jumps to the next piece of content (like the tab bar at the bottom)

Reviewed By: ikenwoo

Differential Revision: D14141532

fbshipit-source-id: 53b0971f494a39f0eba827e441a4cd9e08317663
2019-02-19 15:37:02 -08:00
David Vacca 6aa297a7f3 Fabric: Fixed crash when LayoutMetrics contained NaN values
Summary:
CALayer will crash if we pass NaN or Inf values.

It's unclear how to detect this case on cross-platform manner holistically, so we have to do it on the mounting layer as well.
NaN/Inf is a kinda valid result of some math operations. Even if we can (and should) detect (and report early) incorrect (NaN and Inf) values which come from JavaScript side, we sometimes cannot backtrace the sources of a calculation that produced an incorrect/useless result.

Besides that, I will investigate why the crash is actually happening, so we might need to fix something in layout engine. But, it general, we cannot capture all errors like that, so we need to have it here anyway.

Reviewed By: JoshuaGross, mmmulani

Differential Revision: D14126058

fbshipit-source-id: 807e5a223bdef48af9a3b7210803863431e8c507
2019-02-19 13:03:15 -08:00
Héctor Ramos 2c25e34060 Use new yearless copyright header format
Summary: Use the new copyright header format used elsewhere in the React Native repository.

Reviewed By: shergin

Differential Revision: D14091706

fbshipit-source-id: b27b8e6bcdf2f3d9402886dbc6b68c305150b7d5
2019-02-19 10:35:12 -08:00
David Aurelio e8f95dc7a1 Make logging private
Summary:
@public

Makes logging implementation internal to Yoga.

Breaking changes: removed  `YGLog` and `YGLogWithConfig`.

The upcoming changes to the JNI layer (removal of weak global refs for each node) requires adding additional parameters to the logging functions that will only be available when calculating layout.

Reviewed By: SidharthGuglani

Differential Revision: D14123390

fbshipit-source-id: 468e4a240c190342868ffbb5f8beb92324cdfdd6
2019-02-19 09:58:26 -08:00
Mike Grabowski 41577ec70e [0.58.5] Bump version numbers 2019-02-19 15:20:21 +01:00
Mike Grabowski ee2bf1c4a2 Revert "[0.58.5] Bump version numbers"
This reverts commit 9d9069674a.
2019-02-19 11:43:31 +01:00
Mike Grabowski 40603bc9c4 [0.59.0-rc.2] Bump version numbers 2019-02-18 18:04:25 +01:00
Mike Grabowski 9d9069674a [0.58.5] Bump version numbers 2019-02-18 17:24:06 +01:00
Kevin Gozali 2f33b50f4f Don't attempt to load RCTDevLoadingView lazily
Summary:
There's a very old issue with reload logic: invalidation and resetting up of the bridge could be racing. In this case, we hit a redbox when:
* Chrome debugger is enabled in previous app run, then we launch the app again
* The bridge starts, then immediately reloads itself to connect to Chrome
* On the 2nd setup, the logic to update the green loading bar, with the % indicator for loading off metro, failed to find the DevLoadingView module instance because the bridge is in the middle of invalidating

See https://github.com/facebook/react-native/issues/23235

To test:
Using react-native init from github, do the steps in https://github.com/facebook/react-native/issues/23235, no more redbox. Note that the loading indicator % won't be proper still, but at least it doesn't crash/redbox.

Reviewed By: JoshuaGross

Differential Revision: D14110814

fbshipit-source-id: 835061e50acc6968bffbcc2ddfbe8da79a100df9
2019-02-18 14:50:35 +01:00
Kevin Gozali 0af31ce77c Don't attempt to load RCTDevLoadingView lazily
Summary:
There's a very old issue with reload logic: invalidation and resetting up of the bridge could be racing. In this case, we hit a redbox when:
* Chrome debugger is enabled in previous app run, then we launch the app again
* The bridge starts, then immediately reloads itself to connect to Chrome
* On the 2nd setup, the logic to update the green loading bar, with the % indicator for loading off metro, failed to find the DevLoadingView module instance because the bridge is in the middle of invalidating

See https://github.com/facebook/react-native/issues/23235

To test:
Using react-native init from github, do the steps in https://github.com/facebook/react-native/issues/23235, no more redbox. Note that the loading indicator % won't be proper still, but at least it doesn't crash/redbox.

Reviewed By: JoshuaGross

Differential Revision: D14110814

fbshipit-source-id: 835061e50acc6968bffbcc2ddfbe8da79a100df9
2019-02-18 14:50:20 +01:00
Tyrone Trevorrow 805e4fe2e0 Fix duplicate symbols linker error in xcodeproj (#23284)
Summary:
When using building React Native using the `.xcodeproj` (either via linked projects in Xcode, or precompiling React Native, which is what we do), you'll get a duplicate symbol error:

```
duplicate symbol __ZN8facebook5react10IInspectorD0Ev ...
```

And a few more.

This is because the `InspectorInterfaces.cpp` file is included in _both_ the `React` target _and_ the `jsinspector` target, and since the `jsinspector` target gets linked into the `React` target, this means the symbols from `InspectorInterfaces.cpp` end up in `libReact.a` twice.

<img width="187" alt="screen shot 2019-02-04 at 11 43 39 am" src="https://user-images.githubusercontent.com/819705/52189088-93190880-288a-11e9-8411-b44b59e8e461.png">

This PR removes `InspectorInterfaces.cpp` from the `React` target, as I believe was the original intent.

Since this bug is in the `xcodeproj` it only affects builds that use that, so CocoaPods and Buck users are unaffected.

[iOS][Fixed] - Fix potential linker issues when using xcode project
Pull Request resolved: https://github.com/facebook/react-native/pull/23284

Differential Revision: D13941777

Pulled By: cpojer

fbshipit-source-id: 8a3ffb4fc916ff6570bbff8794b4515b48055667
2019-02-18 14:44:58 +01:00
zhongwuzw f95876ba8c Remove android initialAppState fallback check (#23487)
Summary:
1. We expose the `initialAppState` for Android in #19935, so we can remove the fallback check for Android.
2. Rename `RCTCurrentAppBackgroundState` to `RCTCurrentAppState`, it's a private file function, so it's safe to rename, `RCTCurrentAppState` is more suitable because we actually get app state, not app background state.

[Android] [Enhancement] - Remove android `initialAppState` fallback check.
Pull Request resolved: https://github.com/facebook/react-native/pull/23487

Differential Revision: D14121293

Pulled By: cpojer

fbshipit-source-id: fec196cef2969fe6f6f1571f4ebcafcec26266a1
2019-02-17 15:32:13 -08:00
zhongwuzw a6fde5d846 Apply latest shadow view workflow description (#23485)
Summary:
Apply latest shadow view workflow description

[iOS] [Fixed] - Apply latest shadow view workflow description
Pull Request resolved: https://github.com/facebook/react-native/pull/23485

Differential Revision: D14121276

Pulled By: cpojer

fbshipit-source-id: 128158a560dddd6dbb7213368410c3f36818b5fb
2019-02-17 15:08:16 -08:00
Kevin Gozali 24894ac795 FBiOS TM: make sure to lazily load view managers
Summary: The hacks we added for lazy viewmanagers don't really apply to TurboModule lookup system, so let's enable lazy lookup as needed only if TurboModule is enabled.

Reviewed By: PeteTheHeat

Differential Revision: D14116548

fbshipit-source-id: 701e963ef0593cd890198725f8cb6d0d29434cd9
2019-02-15 20:14:59 -08:00
Peter Argany cd778873f0 Remove custom border logic from RCTView
Summary:
Context: https://fb.workplace.com/groups/735885229793428/permalink/2329819300400005/

A large number of RN SSTs (https://fburl.com/screenshot_tests/itlks3mn) stopped working last week. Turns out I silently broke them with D13981728.

The issue is that SSTs were being run with `RCTRunningInTestEnvironment == false`. When D13981728 changed that, borders began drawing from a different code path (this diff). Somehow, using the graphics context to draw borders breaks  https://fburl.com/pcce4y0h in SSTs.

Going forward, it doesn't make any sense to me why borders should be drawn any differently when testing.

Reviewed By: sahrens

Differential Revision: D14109654

fbshipit-source-id: b8a5c01b923c93c32a8fa8954a850070f55764bc
2019-02-15 15:31:47 -08:00
Kevin Gozali a9dd828c68 Don't attempt to load RCTDevLoadingView lazily
Summary:
There's a very old issue with reload logic: invalidation and resetting up of the bridge could be racing. In this case, we hit a redbox when:
* Chrome debugger is enabled in previous app run, then we launch the app again
* The bridge starts, then immediately reloads itself to connect to Chrome
* On the 2nd setup, the logic to update the green loading bar, with the % indicator for loading off metro, failed to find the DevLoadingView module instance because the bridge is in the middle of invalidating

See https://github.com/facebook/react-native/issues/23235

To test:
Using react-native init from github, do the steps in https://github.com/facebook/react-native/issues/23235, no more redbox. Note that the loading indicator % won't be proper still, but at least it doesn't crash/redbox.

Reviewed By: JoshuaGross

Differential Revision: D14110814

fbshipit-source-id: 835061e50acc6968bffbcc2ddfbe8da79a100df9
2019-02-15 13:31:51 -08:00
zhongwuzw cbf65f2cf4 Enable edge antialiasing only for transforms with perspective (#19360)
Summary:
Enable edge antialiasing only for transforms with perspective

[iOS] [Added] - RCTViewManager: Enable edge antialiasing only for transforms with perspective.

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

Reviewed By: cpojer

Differential Revision: D14088290

Pulled By: hramos

fbshipit-source-id: 2113c7a29efce5ca9990e2a79c69fc70bdf8a041
2019-02-15 10:09:07 -08:00
Mujtaba Alboori 65cfb9a47d iOS support keyboardType ASCIICapableNumberPad (#20597)
Summary:
React native is missing a keyboard type for iOS so I included support for it. So it can be used in react native app
https://developer.apple.com/documentation/uikit/uikeyboardtype/uikeyboardtypeasciicapablenumberpad

Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
Pull Request resolved: https://github.com/facebook/react-native/pull/20597

Differential Revision: D14103498

Pulled By: cpojer

fbshipit-source-id: b0aa17f3e527734c6e90eadc73c96db4dd002698
2019-02-15 08:44:03 -08:00
zhongwuzw da023c5873 No force layout of superview and contentSize recalculation if intrinsicContentSize not changed
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/20664

Differential Revision: D14103326

Pulled By: cpojer

fbshipit-source-id: 9346f12827843960178fbeef646bdb4c2cbd71ce
2019-02-15 08:35:41 -08:00
Mike Grabowski 1768655971 [0.59.0-rc.1] Bump version numbers 2019-02-15 16:38:54 +01:00
Mike Grabowski 560a484fc6 Revert "[0.59.0-rc.1] Bump version numbers"
This reverts commit 199de26f42.
2019-02-15 15:36:00 +01:00
Rostislav Simonik 95d399bc82 Add fix for refresh control state's race condition. (#21763)
Summary:
Fixes #21762
Pull Request resolved: https://github.com/facebook/react-native/pull/21763

Differential Revision: D14064621

Pulled By: cpojer

fbshipit-source-id: 63010248a46cb49ed17ed89d7c55945aa7b22973
2019-02-15 02:50:06 -08:00
zhongwuzw e5fbd39450 Fix image wrong scale factor when load image from file system (#23446)
Summary:
Regression, fix image load from `~/Library` not respect scale factor.
Fixes #22383 , the bug comes from [Clean up some URL path handling](998197f444).

[iOS] [Fixed] - Fix image wrong scale factor when load image from file system
Pull Request resolved: https://github.com/facebook/react-native/pull/23446

Differential Revision: D14099614

Pulled By: cpojer

fbshipit-source-id: eb2267b195a05eb70cdc4671536a4c1d47fb03e2
2019-02-15 02:43:04 -08:00
Peter Ammon 0d7faf6f73 Introduce prepareJavaScript jsi API
Summary:
This adds a new jsi API prepareJavaScript. This accepts the same
parameters as evaluateJavaScript() but does not evaluate anything; instead
it returns a new object PreparedJavaScript which can itself be evaluated,
via the new API evaluatePreparedJavaScript().

There is a new empty class PreparedJavaScript which may be subclassed by
each Runtime variant to store its particular prepared form.

Reviewed By: mhorowitz

Differential Revision: D10491585

fbshipit-source-id: 702b9e23f2ff03d71a8ab17efb7e154b16dd8e87
2019-02-15 01:52:00 -08:00
Takeru Chuganji 6082431c5d Leak mutex to avoid a crashing issue (#22607)
Summary:
Try to solve https://github.com/facebook/react-native/issues/13588
ref: https://github.com/facebook/componentkit/pull/906
Pull Request resolved: https://github.com/facebook/react-native/pull/22607

Differential Revision: D14084056

Pulled By: shergin

fbshipit-source-id: 585aef758e1a215e825ae12914c5011d790a69b0
2019-02-14 14:53:20 -08:00
Mike Grabowski 199de26f42 [0.59.0-rc.1] Bump version numbers 2019-02-14 10:12:20 +01:00
Valentin Shergin 13d87e9ad2 Fabric: Fixed object ownership problem in ImageManager
Summary:
Sometimes, when we deal with ImageRequest and ImageResponseObserverCoordinator we subscribe for status (or access the coordinator) without owning an ImageRequest. In those cases, we have to retain the coordinator explicitly.
For those cases, ImageRequest now exposes `ImageResponseObserverCoordinator` as a `std::shared_ptr`.

Eg, concretely in the code, `completionBlock` and `progressBlock` copied a raw pointer to the observer inside which can lead to a crash when ImageRequest is being deallocated before we received an image data.

Reviewed By: JoshuaGross

Differential Revision: D14072079

fbshipit-source-id: e10120bc05bf685e288f7b3d69092714dcd91d43
2019-02-14 00:43:03 -08:00
Hoa Dinh b655e7555b Fixed build on Xcode 10.2 - availability guard
Summary:
https://our.intern.facebook.com/intern/sandcastle/job/18014398585083744

```
xplat/js/react-native-github/React/Views/ScrollView/RCTScrollViewManager.m:38:20: warning: 'UIScrollViewContentInsetAdjustmentBehavior' is only available on iOS 11.0 or newer [-Wunguarded-availability-new]
```

Reviewed By: mattrobmattrob

Differential Revision: D14076127

fbshipit-source-id: 4050131c4f5211757383069567a2cf5382979735
2019-02-13 17:19:42 -08:00
Håvard Fossli cf5f25472d Add support for needsOffscreenAlphaCompositing on iOS (#19052)
Summary:
Currently on iOS in UIKit and in RN all views are by default set to `allowsGroupOpacity=true`. Any view that has all of the following
- `allowsGroupOpacity` set to true
- opacity greater than 0.0 and less than 1.0
- have any subviews

will be rendered off screen (on CPU). [See this link for more details](https://stackoverflow.com/questions/13158796/what-triggers-offscreen-rendering-blending-and-layoutsubviews-in-ios/13649143#13649143).  Which means performance will be decreased and may affect the user experience. Therefore it makes sense to allow the developers to override this property.

This pull request allows for changing `allowsGroupOpacity` via `needsOffscreenAlphaCompositing`. Android already supports this. This is not a new name or variable. See https://facebook.github.io/react-native/docs/view.html#needsoffscreenalphacompositing.
Pull Request resolved: https://github.com/facebook/react-native/pull/19052

Differential Revision: D14071300

Pulled By: hramos

fbshipit-source-id: 004278801a19463ebf9da6f8855f02ed27926025
2019-02-13 16:43:20 -08:00
Valentin Shergin 9101ebdfbb Fabric: More clang-format
Summary: Apparently, I haven't modify all files in D14018903. Here is the last (I hope) chunk.

Reviewed By: JoshuaGross

Differential Revision: D14058288

fbshipit-source-id: b21950cdd1aa9aa55b0c72fac0f8b44e4a7d131c
2019-02-13 15:25:00 -08:00
Héctor Ramos 5a314690f2 [0.59.0-rc.0] Bump version numbers 2019-02-13 12:14:47 -08:00
Héctor Ramos 2bc055a227 Revert "[0.59.0-rc.0] Bump version numbers"
This reverts commit af6de4e8c8.
2019-02-13 12:13:49 -08:00
Héctor Ramos af6de4e8c8 [0.59.0-rc.0] Bump version numbers 2019-02-13 12:03:09 -08:00
Héctor Ramos cef5ad6964 Revert "[0.59.0-rc.0] Bump version numbers"
This reverts commit 517c165dae.
2019-02-13 11:52:49 -08:00
Mike Grabowski 517c165dae [0.59.0-rc.0] Bump version numbers 2019-02-13 20:15:31 +01:00
Mike Grabowski 8b75677fdb Revert "[0.59.0-rc.0] Bump version numbers"
This reverts commit d47aa28ef7.
2019-02-13 20:15:00 +01:00
Mike Grabowski d47aa28ef7 [0.59.0-rc.0] Bump version numbers 2019-02-13 18:04:43 +01:00
Mike Grabowski a962cb659f Revert "[0.59.0-rc.0] Bump version numbers"
This reverts commit d059e74704.
2019-02-13 17:10:19 +01:00
Mike Grabowski d059e74704 [0.59.0-rc.0] Bump version numbers 2019-02-13 16:47:58 +01:00
Mike Grabowski 9f96606d32 Revert "[0.59.0-rc.0] Bump version numbers"
This reverts commit 69e5c2ddc1.
2019-02-13 16:47:27 +01:00
Mike Grabowski 69e5c2ddc1 [0.59.0-rc.0] Bump version numbers 2019-02-13 16:37:12 +01:00
zhongwuzw 7a6fe0cda0 Fix triangle views on iOS (#23402)
Summary:
Fixes #22824 #21945 , the bug comes from #21208 , it was to fix #11897. Now Let's constrain edge adjust only when view has corners.

[iOS] [Fixed] - Fix triangle views on iOS
Pull Request resolved: https://github.com/facebook/react-native/pull/23402

Differential Revision: D14059192

Pulled By: hramos

fbshipit-source-id: be613bf056d3cc484f281f7ea3d08f251971700a
2019-02-12 16:54:20 -08:00
Valentin Shergin 1a26f97eb0 Clang-format for all files in Fabric folder
Summary:
Trivial.
If you have troubles with rebasing on top of this revision, run this on your diff:
$ find */*.h */*.mm */*.cpp */*.m -exec clang-format -style=file -i {} \;

Reviewed By: JoshuaGross

Differential Revision: D14018903

fbshipit-source-id: fd0ce2da0e11954e683385402738c701045e727c
2019-02-11 13:07:09 -08:00
Valentin Shergin 64d6ea8b0d Moving ObjC specific clang-format rules to the common config
Summary: I found that clang-format config file allows to specify rules on a per-language basis, so I moved Objective-C specific rules to the unified config. Now we have only one clang-format file. Yay!

Reviewed By: JoshuaGross

Differential Revision: D14018902

fbshipit-source-id: 45c1e185b8f2b8151ea202b3d9a68a3886597198
2019-02-11 13:07:09 -08:00
Valentin Shergin bf58ba96f4 Fabric: Stop preallocation views on the main thread
Summary:
There is no reason to allocate views ahead of time on the main thread.

There is a chance that this view will not be mounted and we are not saving any time because it's a sequential process anyway (because we are doing it on the main thread). Moreover, the switching context can only slowdown JS execution.

Reviewed By: JoshuaGross

Differential Revision: D14019433

fbshipit-source-id: 83ac05a91e4b70cb382a55d6687752480984404e
2019-02-11 12:52:46 -08:00
Peter Argany 0bde29e197 Consider SSTs in Platform.isTesting
Summary:
A common util from RN to gate on testing code is `Platform.isTesting()`

Unfortunately, this util does not account for ServerSnapshotTests, since they don't use apple's XCTest infra.

Reviewed By: sahrens

Differential Revision: D13981728

fbshipit-source-id: bf902a04f5d7fcb98a06816f5c2c9b082e7d14b8
2019-02-07 11:07:17 -08:00
Joshua Gross 3cca9e76c5 Partially implemented view recycling for Slider with note to improve
Summary: Recycling and dealloc were not implemented at all before for Slider, so I've taken a first stab at it. It's a little more complex than I initially thought, due to things I don't 100% understand about UISlider as well as Fabric, so I've left a TODO note to fix this at some point. We should be aware that view recycling doesn't appear to be working the way I would expect currently though.

Reviewed By: shergin

Differential Revision: D13965475

fbshipit-source-id: fd18a219cead770b63b514fdc868e23214e735b7
2019-02-06 11:51:32 -08:00
Joshua Gross 550a14c216 ImageResponseObserverCoordinator does not need to be shared_ptr
Summary: Don't use shared_ptr in this case, it's not needed.

Reviewed By: shergin

Differential Revision: D13965413

fbshipit-source-id: ec98c13f53c7d558a0cb68cea0f97568dd202cd8
2019-02-06 11:51:32 -08:00
Mike Grabowski de9019295d [0.58.4] Bump version numbers 2019-02-06 17:45:47 +01:00
Mike Grabowski 6436157b85 Revert "[0.58.4] Bump version numbers"
This reverts commit 6c839455ba.
2019-02-06 17:44:54 +01:00
Joshua Gross b6318acbab Support image props for Slider component, feature parity with pre-Fabric Slider
Summary: The biggest change is that (1) the image proxy/observer code from the Image component has been generalized, (2) the four image props for the Slider component are fully supported, (3) a handful of props that were ignored or buggy on iOS now perform as expected.

Reviewed By: shergin

Differential Revision: D13954892

fbshipit-source-id: bec8ad3407c39a1cb186d9541a73b509dccc92ce
2019-02-05 17:31:40 -08:00
Ramanpreet Nara f37093319b Start using getConstants
Summary:
TurboModules depend on a getConstants method. Existing ObjectiveC modules do not have this method. Therefore, I moved the contents of `constantsToExport` to `getConstants` and then had `constantsToExports` call `getConstants`.

facebook
Since all NativeModules will eventually need to be migrated to the TurboModule system, I didn't restrict this to just the NativeModules in Marketplace.

```
const fs = require('fs');

if (process.argv.length < 3) {
    throw new Error('Expected a file containing a list of native modules as the third param');
}

function read(filename) {
    return fs.readFileSync(filename, 'utf8');
}

const nativeModuleFilenames = read(process.argv[2]).split('\n').filter(Boolean);

nativeModuleFilenames.forEach((fileName) => {
    if (fileName.endsWith('.h')) {
        return;
    }

    const absPath = `${process.env.HOME}/${fileName}`;
    const fileSource = read(absPath);

    if (/(\n|^)-\s*\((.+)\)getConstants/.test(fileSource)) {
        return;
    }

    const constantsToExportRegex = /(\n|^)-\s*\((.+)\)constantsToExport/;
    const result = constantsToExportRegex.exec(fileSource);

    if (result == null) {
        throw new Error(`Didn't find a constantsToExport function inside NativeModule ${fileName}`);
    }

    const returnType = result[2];

    const newFileSource = fileSource.replace(
        constantsToExportRegex,
        '$1- ($2)constantsToExport\n' +
        '{\n' +
        `  return ${returnType.includes('ModuleConstants') ? '($2)' : ''}[self getConstants];\n` +
        '}\n' +
        '\n' +
        '- ($2)getConstants'
    );

    fs.writeFileSync(absPath, newFileSource);
});
```

```
> xbgs -l ')constantsToExport'
```

Reviewed By: fkgozali

Differential Revision: D13951197

fbshipit-source-id: 394a319d42aff466c56a3d748e17c335307a8f47
2019-02-04 17:46:56 -08:00
David Vacca 7f27888878 Add performance counters for Fabric
Summary:
This diff adds performance loggers for Fabric in Android to be able to compare current version or RN with Fabric

This is the summary of Points and Annotations:

- **UIManager_CommitStart**: time that React starts the commit (react tree is ready to start rendering in native)
- **UIManager_LayoutTime**: this is the time it takes to calculate layout in yoga
- **UIManager_FabricFinishTransactionTime**: Time it takes transform "C++ mutationInstructions" into "Java MountItems" and cross boundaries from C++ to Java (including serialization of data) (THIS IS ONLY FABRIC)
- **UIManager_DispatchViewUpdates**: time right before RN moves the mount operations to the Queue that is going to be processed in the next tick UI thread
- **UIManager_BatchRunStart**: time right before the mountItems are going to be process in the UI Thread
- **UIManager_BatchedExecutionTime**: time it took to run batched mountItems (usually layout and prop updates on views)
- **UIManager_NonBatchedExecutionTime**: time it took to run non-batched mountItems (usually creation of views)

Reviewed By: fkgozali

Differential Revision: D13838337

fbshipit-source-id: 0a707619829e7d95ce94d9305ff434d1224afc46
2019-02-04 17:27:30 -08:00
Mike Grabowski 6c839455ba [0.58.4] Bump version numbers 2019-02-04 17:52:41 +01:00
Tyrone Trevorrow 9f72e6a5d0 Fix duplicate symbols linker error in xcodeproj (#23284)
Summary:
When using building React Native using the `.xcodeproj` (either via linked projects in Xcode, or precompiling React Native, which is what we do), you'll get a duplicate symbol error:

```
duplicate symbol __ZN8facebook5react10IInspectorD0Ev ...
```

And a few more.

This is because the `InspectorInterfaces.cpp` file is included in _both_ the `React` target _and_ the `jsinspector` target, and since the `jsinspector` target gets linked into the `React` target, this means the symbols from `InspectorInterfaces.cpp` end up in `libReact.a` twice.

<img width="187" alt="screen shot 2019-02-04 at 11 43 39 am" src="https://user-images.githubusercontent.com/819705/52189088-93190880-288a-11e9-8411-b44b59e8e461.png">

This PR removes `InspectorInterfaces.cpp` from the `React` target, as I believe was the original intent.

Since this bug is in the `xcodeproj` it only affects builds that use that, so CocoaPods and Buck users are unaffected.

[iOS][Fixed] - Fix potential linker issues when using xcode project
Pull Request resolved: https://github.com/facebook/react-native/pull/23284

Differential Revision: D13941777

Pulled By: cpojer

fbshipit-source-id: 8a3ffb4fc916ff6570bbff8794b4515b48055667
2019-02-04 07:56:14 -08:00
nossbigg 05f35c296d Expose isLocalUserInfoKey to keyboard event notifications (#23245)
Summary:
Given two apps loaded side-by-side and when a `Keyboard` event is triggered, there is no way to ascertain which app triggered the keyboard event. This ambiguity can arise in slide over/split view scenarios.

This pull request exposes the `isLocalUserInfoKey` property of the native `UIKeyboard` iOS events to the `Keyboard` event listener; this property will return `true` for the app that triggered the keyboard event.

(Also, I threw in a couple of Keyboard.js tests just for fun 😅)

[iOS][Added] - Expose isLocalUserInfoKey to keyboard event notifications

1. Load two apps side-by-side, with the app on the left side subscribing to the keyboard events (and logging out the events as they happen)
1. Trigger a keyboard to appear with the left app. The logged keyboard event will contain the `isEventFromThisApp` property which will be true.
1. Dismiss the keyboard
1. Trigger a keyboard to appear with the right app. The left app will still log the keyboard event, but the event's `isEventFromThisApp` property will be false (because the left app didn't trigger the keyboard event)
Pull Request resolved: https://github.com/facebook/react-native/pull/23245

Differential Revision: D13928612

Pulled By: hramos

fbshipit-source-id: 6d74d2565e2af62328485fd9da86f15f9e2ccfab
2019-02-01 14:32:19 -08:00
zhongwuzw e4364faa3c Fixes alert view block first responder (#23240)
Summary:
Fixes #23076 , the reason is `blur()` is managed by `UIManager`, `UIManager` maintains all operations and execute them each `batchDidComplete`, which means every time `JS` finish callback native , but `Alert` module would call directly, this mess up the order of method call, for example like below, even `this.$input.blur()` is called before `Alert.alert()`, but in native side, `Alert.alert()` is called before `this.$input.blur()`.

```
        <TextInput style={{ borderWidth: 1 }} ref={$input => this.$input = $input} />
        <Button title="Show Alert" onPress={() => {
          // // `blur` works if using without `Alert`
          this.$input && this.$input.blur()
          // // `blur` is not working
          Alert.alert('show alert', 'desc', [
            { text: 'cancel', style: 'cancel' },
            { text: 'show', onPress: () => {
            }},
          ])
        }} />
```

[iOS] [Fixed] - Fixes alert view block first responder

After fix, example like below, `blur` can works.
```
import * as React from 'react';
import { TextInput, View, Alert, Button } from 'react-native';

export default class App extends React.Component {
  render() {
    return (
      <View style={{ flex: 1, justifyContent: 'center' }}>
        <TextInput style={{ borderWidth: 1 }} ref={$input => this.$input = $input} />
        <Button title="Show Alert" onPress={() => {
          this.$input && this.$input.blur()
          Alert.alert('show alert', 'desc', [
            { text: 'cancel', style: 'cancel' },
            { text: 'show', onPress: () => {
            }},
          ])
        }} />
      </View>
    );
  }
}
```
Pull Request resolved: https://github.com/facebook/react-native/pull/23240

Differential Revision: D13915920

Pulled By: cpojer

fbshipit-source-id: fe1916fcb5913e2b8128d045a6364c5e3d39c516
2019-02-01 03:51:24 -08:00
Ramanpreet Nara 0ceefb40d5 Enable module lookup in TurboModules
Summary:
NativeModules are instantiated by the bridge. If they choose, they can capture the bridge instance that instantiated them. From within the NativeModule, the bridge can then be used to lookup other NativeModules. TurboModules have no way to do such a lookup.

Both NativeModules and TurboModules need to be able to query for one another. Therefore, we have four cases:
1. NativeModule accesses NativeModule.
2. NativeModule accesses TurboModule.
3. TurboModule accesses NativeModule.
4. TurboModule accesses TurboModule.

In summary, this solution extends the bridge to support querying TurboModules. It also introduces a `RCTTurboModuleLookupDelegate` protocol, which, implemented by `RCTTurboModuleManager`, supports querying TurboModules:
```
protocol RCTTurboModuleLookupDelegate <NSObject>
- (id)moduleForName:(NSString *)moduleName;
- (id)moduleForName:(NSString *)moduleName warnOnLookupFailure:(BOOL)warnOnLookupFailure;
- (BOOL)moduleIsInitialized:(NSString *)moduleName
end
```

If TurboModules want to query other TurboModules, then they need to implement this protocol and synthesize `turboModuleLookupDelegate`:

```
protocol RCTTurboModuleWithLookupCapabilities
property (nonatomic, weak) id<RCTTurboModuleLookupDelegate> turboModuleLookupDelegate;
end
```

NativeModules will continue to use `RCTBridge` to access other NativeModules. Nothing needs to change.

When we attach the bridge to `RCTTurboModuleManager`, we also attach `RCTTurboModuleManager` to the bridge as a `RCTTurboModuleLookupDelegate`. This allows the bridge to query TurboModules, which enables our NativeModules to transparently (i.e: without any NativeModule code modification) query TurboModules.

In an ideal world, all modules would be TurboModules. Until then, we're going to require that TurboModules use the bridge to query for NativeModules or TurboModules.

`RCTTurboModuleManager` keeps a map of all TurboModules that we instantiated. We simply search in this map and return the TurboModule.

This setup allows us to switch NativeModules to TurboModules without compromising their ability to use the bridge to search for other NativeModules (and TurboModules). When we write new TurboModules, we can have them use `RCTTurboModuleLookupDelegate` to do access other TurboModules. Eventually, after we migrate all NativeModules to TurboModules, we can migrate all old callsites to use `RCTTurboModuleLookupDelegate`.

Reviewed By: fkgozali

Differential Revision: D13553186

fbshipit-source-id: 4d0488eef081332c8b70782e1337eccf10717dae
2019-01-31 11:35:05 -08:00
Ram N 02697291ff Remove TabbarIOS from OSS
Reviewed By: fkgozali

Differential Revision: D13858496

fbshipit-source-id: ba9dd9912f4abcbeb3326f412ec91be9bee9cfd3
2019-01-30 23:41:40 -08:00
Kevin Gozali 8a50bc3ab3 iOS: Make each module implement getTurboModuleWithJsInvoker: instead of having centralized provider
Summary:
For better modularity, each module conforming to RCTTurboModule should provide a getter for the specific TurboModule instance for itself. This is a bit more extra work for devs, but simplify tooling and allow better modularity vs having a central function that provides the correct instance based on name.

Note: Android may or may not follow this new pattern -- TBD.

Reviewed By: RSNara

Differential Revision: D13882073

fbshipit-source-id: 6d5f82af67278c39c43c4f7970995690d4a82a98
2019-01-30 17:32:16 -08:00
Kevin Gozali 4c69ccd0fb Revert D13860038: [react-native][PR] Add ability to control scroll animation duration for Android
Differential Revision:
D13860038

Original commit changeset: f06751d063a3

fbshipit-source-id: 5d89137aed0d549004e790068c1e4998ebccdaf1
2019-01-29 18:00:54 -08:00
David Aurelio f1a3137b41 Add `MarkerSection`
Summary:
@public

Adds a class for triggering markers.

This calls `startMarker()` on construction, and `endMarker()` on destruction, thus being usable like a "scope guard": the object is instantiated, and automatically destroyed when going out of scope.

Reviewed By: SidharthGuglani

Differential Revision: D13817589

fbshipit-source-id: fd88884af970c1c0933d9ca6843f3f8f5d28b9e6
2019-01-29 11:41:36 -08:00
Elliott Sprehn 27b4d21564 Always write the manifest in multiRemove (#18613)
Summary:
RCTAsyncLocalStorage did not write the manifest after removing a value that was larger than RCTInlineValueThreshold. This meant that the values would still be on disk as null in the manifest.json, and if the app didn't do anything to make the manifest get written out again the null values would persist in the AsyncStorage and be returned by getAllKeys. We need to always write out the manifest.json even if the value is in the overflow storage files.

Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

Fixes #9196.

Not sure where the tests are for this?

none.

[IOS] [BUGFIX] [AsyncStorage] - Correctly remove keys of large values from AsyncStorage.

tadeuzagallo nicklockwood dannycochran
Pull Request resolved: https://github.com/facebook/react-native/pull/18613

Differential Revision: D13860820

Pulled By: cpojer

fbshipit-source-id: ced1cd40273140335cd9b1f29fc1c1881ab8cebd
2019-01-29 09:15:30 -08:00
Teddy Martin 7b8235a95a Expose AsyncLocalStorage get/set methods (#18454)
Summary:
Currently, if an app uses AsyncStorage on the JS side, there is no public interface to access stored data from the native side.

In our app, written in Swift, I have written a [helper](https://gist.github.com/ejmartin504/d501abe55c28450a0e52ac39aee7b0e6) that pulls out the data. I accomplished this by reverse-engineering the code in RCTAsyncLocalStorage.m. It would have been far easier had this code been exposed to native.

I made this change locally and tested out getting the data from Swift code. This worked like a charm:

```swift
let storage = RCTAsyncLocalStorage()
let cacheKey = "test"
storage.methodQueue?.async {
    self.storage.multiGet([cacheKey]) { values in
        print(values)
    }
}
```

[IOS ][ENHANCEMENT ][RCTAsyncLocalStorage.h] - Expose AsyncLocalStorage get/set methods to native code.

<!--
  **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

    CATEGORY
  [----------]      TYPE
  [ CLI      ] [-------------]    LOCATION
  [ DOCS     ] [ BREAKING    ] [-------------]
  [ GENERAL  ] [ BUGFIX      ] [ {Component} ]
  [ INTERNAL ] [ ENHANCEMENT ] [ {Filename}  ]
  [ IOS      ] [ FEATURE     ] [ {Directory} ]   |-----------|
  [ ANDROID  ] [ MINOR       ] [ {Framework} ] - | {Message} |
  [----------] [-------------] [-------------]   |-----------|

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Pull Request resolved: https://github.com/facebook/react-native/pull/18454

Differential Revision: D13860333

Pulled By: cpojer

fbshipit-source-id: b33ee5bf1ec65c8291bfcb76b0d6f0df39376a7e
2019-01-29 08:54:16 -08:00
Michał Osadnik 7e8b810499 Add ability to control scroll animation duration for Android (#22884)
Summary:
Motivation:
----------
This is one of the more sought after feature requests for RN:
react-native.canny.io/feature-requests/p/add-speed-attribute-to-scrollto

This PR adds the support to add a "duration" whenever using "scrollTo" or "scrollToEnd" with
a scrollView. Currently this only exists for Android as the iOS implementation will be somewhat more involved.

This PR is also backwards compatible and does not yet deprecate the "animated" boolean. It may not make sense to ever deprecate "animated", as it could be the flag that is used when devs want the system default duration (which is 250ms for Android). I'm not sure what it is for iOS. It would simplify things to remove "animated", though.
Pull Request resolved: https://github.com/facebook/react-native/pull/22884

Differential Revision: D13860038

Pulled By: cpojer

fbshipit-source-id: f06751d063a33d7046241c95348b6abbb327d36f
2019-01-29 07:18:09 -08:00
David Aurelio 43601f1a17 Add function to set marker callbacks
Summary:
@public

Adds a function to allow to configure markers. The function is declared in `YGMarker.h`

Reviewed By: SidharthGuglani

Differential Revision: D13819111

fbshipit-source-id: f9158b3d4e5727da4e151c84b523c7c7e8158620
2019-01-29 03:51:37 -08:00
Joshua Gross 6418e30e90 Small changes to get Profile build working
Summary: Small changes to get Profile build working. Compiler errors or immediate crashes occur without these lines, when running a profile build on device.

Reviewed By: fkgozali

Differential Revision: D13823136

fbshipit-source-id: a1777d5337d8bd78ef3eb11bbeeb7e23c383ab83
2019-01-28 14:36:30 -08:00
Mike Grabowski adf1274955 [0.58.3] Bump version numbers 2019-01-28 19:22:29 +01:00
Mike Grabowski 6084cf1401 [0.58.2] Bump version numbers 2019-01-28 17:08:24 +01:00
Mike Grabowski 9d19ab0c0c Bring missing changes to 0.58-stable branch
This reverts commit b864e7e63e.
2019-01-28 14:56:57 +01:00
Joshua Gross b905548a3b Fabric: Replace ImageLoader promise implementation with observer model
Summary: Folly promises/futures have been replaced by an observer model which keeps track of loading state. This resolves at least one crash that I can no longer repro and simplifies the code a bit (IMO).

Reviewed By: shergin

Differential Revision: D13743393

fbshipit-source-id: 2b650841525db98b2f67add85f2097f24259c6cf
2019-01-25 09:24:09 -08:00
Mike Grabowski a289b7efb0 [0.58.1] Bump version numbers 2019-01-25 16:32:43 +01:00
Pavlos Vinieratos 61ca119650 Replace deprecated `stringByReplacingPercentEscapesUsingEncoding:` with `stringByAddingPercentEncodingWithAllowedCharacters:` (#19792)
Summary:
Replace some NSString deprecated methods.
motivation for these prs is less warnings reported on xcode everytime we compile a rn app.

N/A

[INTERNAL] [DEPRECATIONS] [NSString] - Replace NSString deprecation methods.
Pull Request resolved: https://github.com/facebook/react-native/pull/19792

Differential Revision: D8515136

Pulled By: cpojer

fbshipit-source-id: 4379ef4e229ef201685b87e54ac859ba3d30a833
2019-01-25 05:25:39 -08:00
Mike Grabowski 57ad19758d [0.58.0] Bump version numbers 2019-01-24 21:01:54 +01:00
Joshua Gross 62395d09eb Fabric: Add Fabric-compatible Slider component to iOS (ObjC code)
Summary: Objective-C side of the Fabric-compatible slider component for iOS.

Reviewed By: mdvacca

Differential Revision: D13745263

fbshipit-source-id: 647631d6fc86f81a5d4f735c507636ed9c468093
2019-01-22 17:03:08 -08:00
Hagen Hübel 5ebe84c704 Removed method call to RCTRootView::setReactPreferredFocusedView as ... (#21596)
Summary:
…it doesn't exist (#21593)

Fixes #21593

RCTTVView.m contains a method called `setHasTVPreferredFocus`, where the following function call breaks the build:

      [(RCTRootView *)rootview setReactPreferredFocusedView:self];

`setReactPreferredFocusedView` was formerly part of **RCTRootViewInternal.h** but was removed sometime.
Pull Request resolved: https://github.com/facebook/react-native/pull/21596

Differential Revision: D13761925

Pulled By: cpojer

fbshipit-source-id: be536786d7a8209f3a97b039e17d68d0aa653a0d
2019-01-22 07:33:44 -08:00
zhongwuzw d55558e138 Fix isBatchActive of RCTCxxBridge (#22785)
Summary:
Seems we lost handler of `isBatchActive` from [RCTBatchedBridge a86171a](a86171a482/React/Base/RCTBatchedBridge.m) to [RCTCxxBridge 5bc7e39](b774820dc2 (diff-a2a67635fffd7b690d14dc17ae563a71)).

Changelog:
----------

[iOS] [fixed] - Fix isBatchActive of RCTCxxBridge
Pull Request resolved: https://github.com/facebook/react-native/pull/22785

Reviewed By: mhorowitz

Differential Revision: D13731897

Pulled By: cpojer

fbshipit-source-id: 8d6b85bcea8fe8997a93b4e1ac8b8007422ca20e
2019-01-21 00:28:48 -08:00
Mike Grabowski 60b3942389 [0.58.0-rc.3] Bump version numbers 2019-01-17 16:02:13 +01:00
Mike Grabowski 9151e0d400 Revert "[0.58.0-rc.3] Bump version numbers"
This reverts commit 22af50ad95.
2019-01-17 16:02:05 +01:00
Mike Grabowski 22af50ad95 [0.58.0-rc.3] Bump version numbers 2019-01-17 15:40:47 +01:00
Valentin Shergin 8f9ca2b9a0 Fabric: Even more systraces
Summary: Trivial.

Reviewed By: mdvacca

Differential Revision: D13664395

fbshipit-source-id: 3de5d65d6fcf8b68bce2636fc91492defdbe8405
2019-01-16 20:22:39 -08:00
Jeff Held c93edb5ffd Apply thumbTintColor to Sliders on iOS (#22177)
Summary:
Applies the `thumbTintColor` prop to Sliders on iOS (which has been supported since iOS 5.0). Updates other documentation so that it is not labeled as Android-only, including the RNTester app
Pull Request resolved: https://github.com/facebook/react-native/pull/22177

Differential Revision: D13695554

Pulled By: hramos

fbshipit-source-id: 250f6574b193a37b3cd237bcf42612c3e91bf813
2019-01-16 15:13:43 -08:00
David Vacca b421b5f4bd Open source Fabric android
Summary: This diff open sources Fabric Android implementation and it extracts ComponentDescriptorFactory into a function that can be "injected" per application

Reviewed By: shergin

Differential Revision: D13616172

fbshipit-source-id: 7b7a6461216740b5a1ad5ebbead9e37de4570221
2019-01-16 12:38:22 -08:00
Alexey Lang 27d8824b4b Make JSCExecutorFactory accessible from outside
Summary: I need this to set up QPL hooks in Instagram on iOS (see D13668326).

Reviewed By: mhorowitz

Differential Revision: D13668327

fbshipit-source-id: ee17d29ec0bbf4ef74736b1d7a095f955c0a7cc1
2019-01-16 10:47:44 -08:00
Francisco Javier Trujillo Mata a93db4915b Removing warning for Pointer is missing a nullability type specifier … (#17872)
Summary:
Xcode 9 has compiler settings that are more strict. This can occur if someone updates there project to use the default settings.

This patch declares the default type instead of allowing the compiler to determine it. Instead of () we now say (void) in a block call.

Motivation
It was just trying to get my project totally empty of warnings, and it has no side effects. If there are side effects, then we should fix the type and not go with empty to represent void.

Test Plan
Update project settings in Xcode. This code doesn't have any known side effects since the compiler assumes the type is void when not declared.

Release Notes
[DOCS] - Fixed potential compiler build issue on Xcode 9 after updating settings in project.
Pull Request resolved: https://github.com/facebook/react-native/pull/17872

Differential Revision: D6981435

Pulled By: hramos

fbshipit-source-id: 508ecea0f8874dc16a25f1dee6255481b309f8c2
2019-01-16 09:50:48 -08:00
Monte Thakkar dbdb509f26 Updated RedBox screen (#22242)
Summary:
[Re: RedBox screen is a bit scary - Discussions and Proposals](https://github.com/react-native-community/discussions-and-proposals/issues/42)

Per hramos:
> The RedScreen was inspired by Ruby on Rails's error screen

> I do see the RedBox screen could be made less jarring while still successfully displaying all the information we need.

Hence jamonholmgren came up with the idea that only the header & footer of the RedBox screen could be red. This makes the content a bit more readable as well as makes the screen a little less intimidating.

Also frantic made the suggestion that since the bottom buttons are not as important, they don't need to stand out. Hence only the header of the RedBox screen which displays the error is made red.

Screenshots:
----------

<div style="flex-direction: row">
<img width="325" alt="orginal" src="https://user-images.githubusercontent.com/7840686/48322916-b4958b80-e5de-11e8-9276-33378d1b41c5.png">
<img width="320" alt="redbox_v2_ios" src="https://user-images.githubusercontent.com/7840686/48665300-cce32b80-ea60-11e8-8e8f-88f74bad30ca.png">

</div>

<div style="flex-direction: row">
<img width="300" alt="original_android" src="https://user-images.githubusercontent.com/7840686/48322958-d5f67780-e5de-11e8-891c-1b20bd00e67b.png">
<img width="300" alt="redbox_v2_android" src="https://user-images.githubusercontent.com/7840686/48665312-f13f0800-ea60-11e8-9fb6-47e03c809789.png">

</div>
Pull Request resolved: https://github.com/facebook/react-native/pull/22242

Reviewed By: hramos

Differential Revision: D13564287

Pulled By: cpojer

fbshipit-source-id: fcb6ba5e20d863f4b957d20f3787f5b7a365bfdb
2019-01-16 16:43:37 +01:00
Eli White db5528ffa9 Use Generated Switch Schema
Summary: We are now generating the native cpp files for Switch via Buck. Deleting the hand written files and switching over.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D13666672

fbshipit-source-id: 72cf6f6af9374511f2742f8f0d996fa52e1bff5b
2019-01-15 18:10:34 -08:00
Karl Sander 9ed36b77e9 Fix for #22891: change type for iOS accessiblityActions from NSString to NSArray<NSString*> (#22892)
Summary:
The bug is described in #22891.

It's possible this might not be the right fix, since the original type comes from the commit introducing the feature (36ad813899). But after making this change custom VoiceOver actions work in my real project and my reduced test project.

Changelog:
----------

[iOS] [Fixed] - Fix supplying an array of custom VoiceOver actions via accessibilityActions prop
Pull Request resolved: https://github.com/facebook/react-native/pull/22892

Differential Revision: D13682727

Pulled By: hramos

fbshipit-source-id: a165af4ba78d2dbeca5bffbf60beb9ba50498f8d
2019-01-15 17:01:49 -08:00
Wojciech Tyczynski 3654b9edb2 Differentiate swipe and tap events (#22916)
Summary:
Motivation:
----------

As developers want to handle multiple actions on Siri Remote input when using TVEventHandler, it is crucial to differentiate 'swap' and 'tap' events.

Changelog:
----------

[tvOS] [Changed] - 'up', 'down', 'left' and 'right' events are now connected with tapping on edges of remote. New events 'swipeUp', 'swipeDown', 'swipeLeft' and 'swipeRight' added to detect swipes.
Pull Request resolved: https://github.com/facebook/react-native/pull/22916

Differential Revision: D13682705

Pulled By: hramos

fbshipit-source-id: 233ad1cecc04ca4ced75cd00e7fcb65d224ed3ca
2019-01-15 16:29:38 -08:00
Monte Thakkar 7fbccdea22 Updated RedBox screen (#22242)
Summary:
[Re: RedBox screen is a bit scary - Discussions and Proposals](https://github.com/react-native-community/discussions-and-proposals/issues/42)

Per hramos:
> The RedScreen was inspired by Ruby on Rails's error screen

> I do see the RedBox screen could be made less jarring while still successfully displaying all the information we need.

Hence jamonholmgren came up with the idea that only the header & footer of the RedBox screen could be red. This makes the content a bit more readable as well as makes the screen a little less intimidating.

Also frantic made the suggestion that since the bottom buttons are not as important, they don't need to stand out. Hence only the header of the RedBox screen which displays the error is made red.

Screenshots:
----------

<div style="flex-direction: row">
<img width="325" alt="orginal" src="https://user-images.githubusercontent.com/7840686/48322916-b4958b80-e5de-11e8-9276-33378d1b41c5.png">
<img width="320" alt="redbox_v2_ios" src="https://user-images.githubusercontent.com/7840686/48665300-cce32b80-ea60-11e8-8e8f-88f74bad30ca.png">

</div>

<div style="flex-direction: row">
<img width="300" alt="original_android" src="https://user-images.githubusercontent.com/7840686/48322958-d5f67780-e5de-11e8-891c-1b20bd00e67b.png">
<img width="300" alt="redbox_v2_android" src="https://user-images.githubusercontent.com/7840686/48665312-f13f0800-ea60-11e8-9fb6-47e03c809789.png">

</div>
Pull Request resolved: https://github.com/facebook/react-native/pull/22242

Reviewed By: hramos

Differential Revision: D13564287

Pulled By: cpojer

fbshipit-source-id: fcb6ba5e20d863f4b957d20f3787f5b7a365bfdb
2019-01-15 06:29:49 -08:00
Alexander Nikiforov 19d04a312b iOS: Clear `Linking.getInitialURL` during bridge reload (#22659)
Summary:
On iOS platform, RN retains launchOptions dictionary after bridge reload which can lead to unexpected consequences to a developer. The app will receive the same value for `Linking.getInitialURL` during initial launch and during bridge reload. Here's an example from our application. We use deeplinks via custom URL scheme so a user can open the app via link. Also, we reload the bridge when a user signs out. So if a user opens the app via URL, logs out, and a second user logs into the app, the app will behave as though the second user launched the app via the same deeplink. Because reload destroys the JS engine, there's nowhere for our app to remember that it already handled the deeplink activation.

On iOS Linking.getInitialURL() gets URL from the _launchOptions dictionary, so by setting it to nil we prevent retention of initialURL after reload.

This change makes iOS's behavior consistent with Android's. On Android, the launch URL is stored on the `Intent` and reloading the app involves creating a new `Intent`. Consequently, the launch URL is dropped as desired during the reload process.
Pull Request resolved: https://github.com/facebook/react-native/pull/22659

Differential Revision: D13564251

Pulled By: cpojer

fbshipit-source-id: 4c6d81f1775eb3c41b100582436f1c0f1ee6dc36
2019-01-15 02:10:08 -08:00
Luna Wei b5e6ae0fc4 Unify native props
Summary: Unify native props for Switch

Reviewed By: TheSavior, mdvacca

Differential Revision: D13563403

fbshipit-source-id: d219febf197bd024d1ef2acda9f42e40bdf39532
2019-01-07 15:39:21 -08:00
Mike Grabowski d25e304bcc [0.58.0-rc.2] Bump version numbers 2019-01-03 23:19:14 +01:00
Kevin Gozali 608670ebed iOS: guard against bad RCTModuleData instance
Summary: In some rare race condition (usually involving network request handling vs bridge shutting down), there may be bad access to an RCTModuleData that may have been de-allocated. To prevent crashes, let's guard the access and return nil appropriately.

Reviewed By: yungsters

Differential Revision: D13548755

fbshipit-source-id: b97326524cd9ca70a13d15098a1eaadfc7f1a6a8
2018-12-26 11:11:12 -08:00
Spencer Ahrens 34ea65e3d9 tighter ContextContainer semantics
Summary:
shergin mentioned that he'd like to move away from RTTI a bit and use explicit key strings for context container instances rather than relying on the `typeid`, so this does this.

We also fatal with a useful error message if we get a collision, rather than failing silently.

Reviewed By: shergin

Differential Revision: D13384308

fbshipit-source-id: 0b06d7555b082be89e8f130c23e94be99749a7a3
2018-12-21 18:00:36 -08:00
Spencer Ahrens a3b348eacb clean up surface register / start
Summary:
`RCTSurfaceHostingProxyRootView` surfaces are still automatically started right after the initialization to match `RCTRootView` interface, but `RCTSurfaceHostingView` must be started explicitly now. Also fixed some internal stuff so start and register are clear and distinct.

Background / initial motivation:

One tricky bit - we render the template as part of init`ing the rootView, so we don't know what the surfaceId will be before hand to register the UITemplate. Two possible solutions:

1) Require start be called explicitly after initializing the rootView, and setup the context in between.
2) Do something like "setUITemplateConfigForNextSurface" before creating the rootView, and have some hook when the surfaceId is assigned that associates the surfaceId with that "next" UITemplate stuff before.

(1) seems a lot cleaner, but it requires ever user of rootView to explicitly call start on it - how do you feel about that? Seems like we could also use that start call to decide if the initial render should be synchronous or not? start vs. startSync?

Reviewed By: mdvacca

Differential Revision: D13372914

fbshipit-source-id: 6db297870610e6c231f8a78c0dd74d584cb64910
2018-12-21 18:00:35 -08:00
Spencer Ahrens 089dba3842 expose contextContainer as application API
Summary: We need a way for different apps to inject dependencies or additional functionality into Fabric - ReactNativeConfig might be a special case, but I think this could clean up it's integration nicely, and I'm using this for a uitemplate cache system so we can use CompactDisk or other storage systems for caching depending on the app.

Reviewed By: mdvacca

Differential Revision: D13407287

fbshipit-source-id: 45481908434e6235850aa4d2d6b2bfb936a23be7
2018-12-21 18:00:35 -08:00
Mike Grabowski be40199f13 §Revert "[0.58.0-rc.2] Bump version numbers"
This reverts commit 6ae2ebfcab.
2018-12-19 14:00:56 +01:00
Alex Dvornikov 97eb53d14f Update RCTFormatError to support segment ids
Reviewed By: PeteTheHeat

Differential Revision: D13507444

fbshipit-source-id: ed55ce4cfa26f54db87a753867b6cf710936ba5a
2018-12-18 16:23:39 -08:00
Valentin Shergin 1bd66d9aa9 RCTSurface: Calling `start` is now required to start the Surface
Summary:
So, it does not start itself automatically right after instantiation.
(Classic RCTSurface still kinda start itself automatically but only because start/stop concept is not implemented for this yet.)

Reviewed By: sahrens

Differential Revision: D13461294

fbshipit-source-id: 05430688f69a0d9bf75d03e6d25f02ccd5d3176a
2018-12-18 12:57:38 -08:00
Mike Grabowski 6ae2ebfcab [0.58.0-rc.2] Bump version numbers 2018-12-18 19:35:57 +01:00
Mike Grabowski 7c04c09923 Revert "[0.58.0-rc.2] Bump version numbers"
This reverts commit 8c3111af31.
2018-12-18 19:32:08 +01:00
David Aurelio ac94e54f5a Switch storage in `YGStyle` to `CompactValue`
Summary:
@public

Switches the storage in `facebook::yoga::detail::Values` from `YGValue` to `facebook::yoga::detail::CompactValue`.
This cuts heap size for arrays of values in half.

Reviewed By: SidharthGuglani

Differential Revision: D13465586

fbshipit-source-id: 49a4d6d29a73bdd44843b1f3c57bf746050c94d6
2018-12-18 08:15:09 -08:00
Mike Grabowski 8c3111af31 [0.58.0-rc.2] Bump version numbers 2018-12-18 14:48:35 +01:00
Zack Sheppard e7a52675cb Extend reason message for `RCTFatalException` (#22532)
Summary:
Fixes #22530

As described in the issue, the previous behavior for the `RCTFatal` macro was to truncate the `reason` on the resulting `NSException` to 75 characters. This would ensure the reason would fit on a single line, but resulted in issues debugging errors that occurred in the wild, as many crash logging tools (like Sentry) discard the `name` value of the exception and use the `reason` as their primary identifier. At 75 characters, useful information like the location of the error would usually be truncated.

- [x] This extends the truncation threshold to 175 characters, which should be short enough to prevent full-screen-takeover length errors, but long enough to provide useful context to the error.
- [x] This adds a `userInfo` value to the resulting `NSException`. It copies over the `userInfo` from the `NSError` passed to the macro, and adds an "untruncated message" value that contains the untruncated version of the `NSException`'s reason.

[iOS] [Changed] - RCTFatalExceptions now include more information in their reason and a userInfo.

<!--

  CATEGORY may be:

  - [General]
  - [iOS]
  - [Android]

  TYPE may be:

  - [Added] for new features.
  - [Changed] for changes in existing functionality.
  - [Deprecated] for soon-to-be removed features.
  - [Removed] for now removed features.
  - [Fixed] for any bug fixes.
  - [Security] in case of vulnerabilities.

  For more detail, see https://keepachangelog.com/en/1.0.0/#how

  MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.

  EXAMPLES:

  [General] [Added] - Add snapToOffsets prop to ScrollView component
  [General] [Fixed] - Fix various issues in snapToInterval on ScrollView component
  [iOS] [Fixed] - Fix crash in RCTImagePicker

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

Differential Revision: D13373469

Pulled By: cpojer

fbshipit-source-id: ac140d14ce76e1664869437c2c178bdd65ab6e0e
2018-12-17 19:53:16 +01:00
Kevin Gozali 54a6e1ad38 Surface: fixed up surface stage value check
Summary: Some logic to check for surface stage should've done bitwise `&` operation instead of equality check, because we do bitwise `|` whenever we "set stage".

Reviewed By: shergin

Differential Revision: D13459156

fbshipit-source-id: 94e2f5279fb1a31060beb7d6195953b25ce603c9
2018-12-13 16:52:30 -08:00
David Aurelio a56b67fa9b Inline `YGFloatOptional` completely
Summary:
@public
`YGFLoatOptional` only contains trivial functionality. Make it header-only.

Reviewed By: SidharthGuglani

Differential Revision: D13439609

fbshipit-source-id: 3f3c6c3a15e05ac55da2af30eb629f786ecb90a9
2018-12-13 07:16:45 -08:00
David Aurelio b5c66a3fbe Move out `YGValue`
Summary:
@public

Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.

Also fixes the incorrect definition of NAN.

Reviewed By: SidharthGuglani

Differential Revision: D13439602

fbshipit-source-id: 68eef2c391b6c9810f3c995b86fff7204ebe6511
2018-12-13 07:16:45 -08:00
Birkir Rafn Guðjónsson ba9c208cdf Support additional UIBarStyle's in RCTConvert (#20102)
Summary:
Adds two additional UIBarStyles to RCTConvert

- [x] UIBarStyleBlackOpaque
- [x] UIBarStyleBlackTranslucent

Does not affect any tests or current usage of this conversion.
Pull Request resolved: https://github.com/facebook/react-native/pull/20102

Differential Revision: D13421942

Pulled By: hramos

fbshipit-source-id: 1e609eca0fdea2b56b9f6ac87e759c661bdee12b
2018-12-11 17:43:24 -08:00
Kevin Gozali 2918679479 iOS: ignore extra modules during bridge start up if it's marked for TurboModule
Summary: Currently, bridge delegate can provide extra modules during bridge start up path. For TurboModules, we don't need this mechanism (if we need eager init, it will be done in a different way). So, let's ignore modules marked as RCTTurboModule if they are supplied as "extra native modules".

Reviewed By: axe-fb

Differential Revision: D13383710

fbshipit-source-id: c88d32739be9f66e0daf07ef5465ea6457f8d1c6
2018-12-11 00:00:56 -08:00
David Aurelio 90f582ffb9 Back out Stack D13119110..D13236159
Summary: backout, causes failures

Reviewed By: adityasharat

Differential Revision: D13376210

fbshipit-source-id: 1fa8823f2dce601c47738f34ddb2674288197e79
2018-12-07 13:01:28 -08:00
Zack Sheppard 2831d9ef61 Extend reason message for `RCTFatalException` (#22532)
Summary:
Fixes #22530

As described in the issue, the previous behavior for the `RCTFatal` macro was to truncate the `reason` on the resulting `NSException` to 75 characters. This would ensure the reason would fit on a single line, but resulted in issues debugging errors that occurred in the wild, as many crash logging tools (like Sentry) discard the `name` value of the exception and use the `reason` as their primary identifier. At 75 characters, useful information like the location of the error would usually be truncated.

- [x] This extends the truncation threshold to 175 characters, which should be short enough to prevent full-screen-takeover length errors, but long enough to provide useful context to the error.
- [x] This adds a `userInfo` value to the resulting `NSException`. It copies over the `userInfo` from the `NSError` passed to the macro, and adds an "untruncated message" value that contains the untruncated version of the `NSException`'s reason.

[iOS] [Changed] - RCTFatalExceptions now include more information in their reason and a userInfo.

<!--

  CATEGORY may be:

  - [General]
  - [iOS]
  - [Android]

  TYPE may be:

  - [Added] for new features.
  - [Changed] for changes in existing functionality.
  - [Deprecated] for soon-to-be removed features.
  - [Removed] for now removed features.
  - [Fixed] for any bug fixes.
  - [Security] in case of vulnerabilities.

  For more detail, see https://keepachangelog.com/en/1.0.0/#how

  MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.

  EXAMPLES:

  [General] [Added] - Add snapToOffsets prop to ScrollView component
  [General] [Fixed] - Fix various issues in snapToInterval on ScrollView component
  [iOS] [Fixed] - Fix crash in RCTImagePicker

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

Differential Revision: D13373469

Pulled By: cpojer

fbshipit-source-id: ac140d14ce76e1664869437c2c178bdd65ab6e0e
2018-12-06 20:22:25 -08:00
Doug Russell ee7c702308 Accessibility Escape
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/22047

Differential Revision: D13146179

Pulled By: cpojer

fbshipit-source-id: b8a089114a5deafee47dd482e484d413c8c39137
2018-12-06 19:44:21 -08:00
David Aurelio ceb6602422 Inline `YGFloatOptional` completely
Summary:
@public
`YGFLoatOptional` only contains trivial functionality. Make it header-only.

Reviewed By: SidharthGuglani

Differential Revision: D13209151

fbshipit-source-id: 3ecca015fa0ac6644ae694b44bc53d840fbc5635
2018-12-06 07:38:43 -08:00
David Aurelio c37826a933 Move out `YGValue`
Summary:
@public

Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.

Also fixes the incorrect definition of NAN.

Reviewed By: SidharthGuglani

Differential Revision: D13172444

fbshipit-source-id: 4250dbcf8fe15ec3ecdee3913360a73bab633ce3
2018-12-06 07:38:43 -08:00
Mike Grabowski c0bf7a128c [0.58.0-rc.1] Bump version numbers 2018-12-06 09:39:36 +01:00
Kevin Gozali 3b6f229eb9 xplat: added ReactNativeConfig to access runtime specific config values
Summary: Each app may provide different impl for its runtime specific behaviors, then Fabric and other new infra can share the same config instance to configure stuffs.

Reviewed By: sahrens

Differential Revision: D13290319

fbshipit-source-id: 30e3eeedc6ff6ef250ed233b27e38cb7c1062b55
2018-12-05 15:03:27 -08:00
ifsnow c45d290b07 Fixed for supporting mediaPlaybackRequiresUserAction under iOS 10. (#22208)
Summary:
There is a problem that the `mediaPlaybackRequiresUserAction` property does not work in WKWebView(`useWebKit`) under iOS 10.

I fully know you are currently working to migrate the core's WebView to the standalone `react-native-webview` project. This has already been submitted to PR in `react-native-webview` and will be merged soon. I hope this fix applies to `react-native` before your migration is done.
Pull Request resolved: https://github.com/facebook/react-native/pull/22208

Differential Revision: D13334868

Pulled By: cpojer

fbshipit-source-id: f2a811a477054155ed5fe62ab31e4d63f70e7848
2018-12-04 20:46:42 -08:00
Marc Horowitz 99c370959a Don't create the JSCRuntime until createJSExecutor() is called.
Summary:
This avoids an intermittent reentrancy bug in JSC on iOS 11
(https://bugs.webkit.org/show_bug.cgi?id=186827).  It also makes the
code more consistent with android.

Reviewed By: amnn

Differential Revision: D13313265

fbshipit-source-id: f42476b2f660e127ecfc9c72584554817eea1010
2018-12-04 12:01:59 -08:00
Valentin Shergin f6566c77b1 Summary:
Calling -[UIScrollView setContentOffset] with NaN values can cause a crash. That's not clear why exactly the computation returns NaN sometime, but the implemented sanitizing should help to detect this problem during development (and this also prevents the app from crashing).

See attached task for more details.

Reviewed By: fkgozali

Differential Revision: D13242729

fbshipit-source-id: 747bf1b42e02597e9f1300eee24547563ab29b27
2018-12-04 15:37:25 +01:00