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

18197 Коммитов

Автор SHA1 Сообщение Дата
Samuel Susla 0d6c427517 Fix crash in ScrollView.scrollEventThrottle
Summary: Fix crash when casting `scrollEventThrottle`. `scrollEventThrottle` is passed as double from javascript.

Reviewed By: shergin

Differential Revision: D17626401

fbshipit-source-id: 0707a5a440fe7887e316054b455ba972a9291a18
2019-09-30 03:55:59 -07:00
Oleksandr Melnykov 07fe994e26 Fix Slider height in Fabric
Summary: This diff fixes the height of the Slider component in Fabric on Android. Note that the layout is still broken (no padding and the seek bar is misaligned, but it's another issue).

Reviewed By: JoshuaGross

Differential Revision: D17629798

fbshipit-source-id: af8cae909279dc92ee1c80b9be2f5c578972eafc
2019-09-30 03:51:59 -07:00
masaaki1915 231d2f95cd fix typo in comment about package (#26638)
Summary:
This PR only fixes a typo in `ModuleHolder.java`.

## Changelog

[Internal] [Fixed] - Fix typo in comment about package
Pull Request resolved: https://github.com/facebook/react-native/pull/26638

Differential Revision: D17661204

Pulled By: cpojer

fbshipit-source-id: 77ab92b7bfff300961e0a32183188a6e57e99b3d
2019-09-29 20:49:51 -07:00
Valentin Shergin e9f72978d1 Fabric: ComponentDescriptorProviderRequest, a way to register a component on demand
Summary: This diff implements the core functionality of "reactive component registration". With a new API now we have a public API that allows registering a component by request on-demand. That can be helpful in some environments where loading of all components is undesirable or impossible due to generic app design constrains.

Reviewed By: mdvacca

Differential Revision: D17211914

fbshipit-source-id: 5a957a4f6541420d70952856599b827ceec63e3b
2019-09-29 20:06:37 -07:00
Valentin Shergin c5cc27f1e9 Fabric: Introducing ComponentDescriptor::Flavor
Summary:
Currently, the same ComponentDescriptor class cannot be registered as a responder for components with different names. However, we have marginal cases where we really need it. The examples are `UnimplementedView` or possible universal interop with the classic RN or any other UI framework.

This change adds a special optional argument to ComponentDescript constructor that allows implementing this functionality.

Reviewed By: fkgozali

Differential Revision: D17211915

fbshipit-source-id: 18f59e09fe06b875a8e8975b7b2ab423489238bb
2019-09-29 20:06:37 -07:00
Valentin Shergin df229590b2 Fabric: Adding missing `noexcept` operator to functions in raw props parsing infra
Summary:
This part of the codebase is very perf sensitive and designed to work without exceptions enabled.
Most of the method was `noexcept` all the time, but some of those missing that by mistake.

Reviewed By: sammy-SC

Differential Revision: D17629426

fbshipit-source-id: b311e4b7eff8e2b7cf29518288480d3a812dda44
2019-09-29 20:04:15 -07:00
Marc Mulcahy c7aa6dc827 Add onSlidingComplete callbacks when sliders adjusted via a11y (#26600)
Summary:
When sliders are adjusted via accessibility, no onSlidingComplete callback is
generated. This causes problems for components which perform behavior in this
callback, and means that such components don't behave properly when adjusted via
accessibility. For example, if an app hosting a volume control slider only commits the volume change to the hardware on onSlidingComplete, it is impossible for a screen reader user to ever actually adjust the volume.

Ensure that sliders call the onSlidingComplete callback after adjusted via
accessibility.

## Changelog

[General] [Fix] - Add onSlidingComplete callbacks when sliders adjusted via a11y.

[CATEGORY] [TYPE] - Message
Pull Request resolved: https://github.com/facebook/react-native/pull/26600

Test Plan: Prior to this change, using the RNTester slider example with a screen reader, the onSlidingComplete callback tests never shows any callbacks when the slider is adjusted. With this change applied, the callback test will show a number of callbacks corresponding to the number of times the slider was adjusted via the screen reader.

Differential Revision: D17661157

Pulled By: cpojer

fbshipit-source-id: a6eedef099c6c1b571b290c329059ac9b69b53dd
2019-09-29 19:45:06 -07:00
Vojtech Novak 113c4e229c improve error message in NativeModuleRegistryBuilder.java (#26467)
Summary:
## Motivation

I have seen a spike in users reporting this error. Unfortunately I did not receive any repros that would confirm this, but my hypothesis is that they ran into situation when `new XYZPackage()` was present in `getPackages()` method and then the CLI kicked in with autolinking and they were left with this incomplete error.

someone more knowledgeable of autolinking should review this.
Pull Request resolved: https://github.com/facebook/react-native/pull/26467

Differential Revision: D17661242

Pulled By: cpojer

fbshipit-source-id: 63dfcd85a0d41d85a0dd52f84ab16cb7ceb64ba2
2019-09-29 19:42:08 -07:00
Roshan Gautam 9caf99162d Fixes button partially showing when parent view height is 0 (#26435)
Summary:
When the parent view that wraps a button has height 0, the button is still shown partially because of the padding given for text inside Button component for iOS. Here is the issue raised for that:
https://github.com/facebook/react-native/issues/26421

Probably, we should not hard code these values, rather provide a way to provide custom style ? This is my first PR so not making big change. :D

## Changelog

[iOS] [Fixed] - Give margin instead of padding to text in Button component
Pull Request resolved: https://github.com/facebook/react-native/pull/26435

Test Plan:
When using this block of code,
```
<View style={{height:0}}>
    <Button title="There is an issue"></Button>
</View>
```
Before:
<img width="284" alt="image" src="https://user-images.githubusercontent.com/5866078/64905271-6c129700-d6f5-11e9-86c1-c301eb8123f3.png">

After:
<img width="283" alt="image" src="https://user-images.githubusercontent.com/5866078/64905284-8cdaec80-d6f5-11e9-9589-28d8d01c8ba1.png">

Differential Revision: D17661181

Pulled By: cpojer

fbshipit-source-id: 62b04123d9edb4d760bd54d96ae0615c1ccff7ab
2019-09-29 19:35:17 -07:00
Petter Hesselberg 4b9350061f Petterh/support parcelable array args (#26379)
Summary:
`ReactRootView.startReactApplication` takes a `Bundle` argument called `initialProperties`. This is translated to a `ReadableMap` via `Arguments.fromBundle`. If the bundle contains an array of bundles, this gets translated by `Arguments.fromArray`.

If the bundle was passed from one activity to another via intent extras, however, there is a problem. After the bundle has been marshaled and unmarshaled, the array of `Bundle`s come out the other end as an arrap of `Parcelable`s, although each array element remains a `Bundle`. This results in an "Unknown array type" exception.

This PR fixes this by adding support for `Parcelable` arrays &ndash; provided they contain only members of type `Bundle`.

## Changelog

[Android] [Fixed] - Don't throw "Unknown array type" exception when passing serialized bundle arrays in ReactRootView.startReactApplication's initialProperties parameter
Pull Request resolved: https://github.com/facebook/react-native/pull/26379

Test Plan: Added test class `ArgumentsTest`. The test method `testFromMarshaledBundle` fails when used on the old version of `Arguments`.

Differential Revision: D17661203

Pulled By: cpojer

fbshipit-source-id: 63612d78f49bdf9cc53f6f21ae883dba6cebce84
2019-09-29 19:22:22 -07:00
Pablo Espinosa e1d89fbd9d Added Warning message Linking API with Phones in iOS Simulator (#26607)
Summary:
This PR, tries to fix the problem at https://github.com/facebook/react-native/issues/26554

## Changelog
iOS Fixed - Now it will show a warning when trying to use it inside a simulator, instead of throwing a red screen error.

## Notes
Docs PR opened as well at: https://github.com/facebook/react-native-website/pull/1295
<img width="418" alt="image" src="https://user-images.githubusercontent.com/12865914/65734976-532ebc00-e0cd-11e9-8e8c-2b4a5a7b8aea.png">
Pull Request resolved: https://github.com/facebook/react-native/pull/26607

Differential Revision: D17661091

Pulled By: cpojer

fbshipit-source-id: 3d660f25546374adfa3436e2954c9c27750039b7
2019-09-29 19:01:13 -07:00
Daniel Andersson 9e7e178a2d Make it possible for a Runtime to provide its own JSON parsing
Summary: Make it possible for a Runtime implementation to provide its own JSON parsing, by making the method on Value call through Runtime, which now has the default implementation.

Reviewed By: tmikov

Differential Revision: D17637395

fbshipit-source-id: b8997f7d1721a7790326417f3abfa86c875923c9
2019-09-29 18:55:53 -07:00
Miguel Alatzar 0a282c42b4 Include transform in OUTER_PROPS (#26611)
Summary:
Without `transform` in `OUTER_PROPS`, the refresh control component would not include `transform: {scaleY: -1}` in its style and so pulling down, rather than up, on a scroll view would trigger a refresh.

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

## Changelog
[Android] [Fixed] - Fixed issue with refresh control not working properly on an inverted ScrollView
Pull Request resolved: https://github.com/facebook/react-native/pull/26611

Test Plan: Updated unit test in splitLayoutProps-test.js.

Differential Revision: D17661079

Pulled By: cpojer

fbshipit-source-id: 747da27b11c3ca59b7f639f393ae5ac137f5490a
2019-09-29 18:49:45 -07:00
vasilich 9a2bc71064 Export props type for TextInput component (#26622)
Summary:
Fix for issue https://github.com/facebook/react-native/issues/26263

## Changelog

[JavaScript] [Fixed] - Added an export for TextInput props type
Pull Request resolved: https://github.com/facebook/react-native/pull/26622

Test Plan: This PR does not change user interface

Differential Revision: D17661069

Pulled By: cpojer

fbshipit-source-id: 7a8e0159de9dc9e775eae349d0f1e743155e56db
2019-09-29 18:39:20 -07:00
Frieder Bluemle d98ff02433 Fix template whitespace error (#26631)
Summary:
Very small update here. 0fcaca8e26 accidentally introduced a whitespace error (trailing whitespace) in an iOS test file - This whitespace error is now propagated into all new projects generated by `react-native init`. This fixes it.

## Changelog

[iOS] [Fixed] - Template whitespace error
Pull Request resolved: https://github.com/facebook/react-native/pull/26631

Test Plan: N/A

Differential Revision: D17661040

Pulled By: cpojer

fbshipit-source-id: 1858d2fe238d139894738187ec73f1e27e306294
2019-09-29 18:03:35 -07:00
Dulmandakh 8c099b5f53 add ACCESS_BACKGROUND_LOCATION to PermissionsAndroid (#26562)
Summary:
This PR adds ACCESS_BACKGROUND_LOCATION to PermissionsAndroid. Fixes https://github.com/facebook/react-native/issues/26541

## Changelog

[Android] [Changed] - add ACCESS_BACKGROUND_LOCATION to PermissionsAndroid
Pull Request resolved: https://github.com/facebook/react-native/pull/26562

Test Plan:
```javascript
PermissionsAndroid.ACCESS_BACKGROUND_LOCATION === 'android.permission.ACCESS_BACKGROUND_LOCATION'
```

Differential Revision: D17660062

Pulled By: cpojer

fbshipit-source-id: 3133504c6065ffb2f46e4dff14d2d662348e0987
2019-09-29 17:45:27 -07:00
Valentin Shergin ba8b6a77a6 Fabric: Checking an EventEmitter before calling in RCTModalHostViewComponentView
Summary: We need to check if `_eventEmitter` is not nullptr before each call on it.

Reviewed By: sammy-SC

Differential Revision: D17531070

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

Reviewed By: sammy-SC

Differential Revision: D17531071

fbshipit-source-id: 373ae5270199f3a9099bda8c34b06737446858f1
2019-09-28 15:10:26 -07:00
Ramanpreet Nara 42dcfab2a9 Stop requiring TurboModuleManager JSIModule on CatalystInstance cleanup
Summary:
In `CatalystInstanceImpl.destroy()`, we require the TurboModuleManager using the [following lines](https://fburl.com/diffusion/a4y6wbft):

```
final JSIModule turboModuleManager =
    ReactFeatureFlags.useTurboModules
        ? mJSIModuleRegistry.getModule(JSIModuleType.TurboModuleManager)
        : null;
```

For some strange reason, even though `ReactFeatureFlags.useTurboModules` is true, the TurboModuleManager isn't registered with mJSIModuleRegistry. I spent some time looking through the code, but I couldn't figure out why. These lines actually aren't necessary, so it's possible to fix the issue by simply working around it, which is what this diff does. We shouldn't have been double requiring the TurboModuleManager anyways, since `CatalystInstance.java` has a method to set the TurboModuleManager, which we call in `ReactInstanceManager.createReactContext`.

## Alternative approach
I could push this diff to the next cut, and instead land a diff that adds debug information to the native crash. At the cost of a week, it may help us figure out why we're seeing the crash. Thoughts? cc fkgozali

Reviewed By: fkgozali

Differential Revision: D17636604

fbshipit-source-id: ecfff593dc6eb4ec4d5e331348b308bc7ab37966
2019-09-27 18:20:28 -07:00
Kevin Gozali 1452954c4c TM: Add mutex to access LongLivedObjectCollection - making it thread safe
Summary:
There are cases where the CallbackWrapper instances were added from different thread, potentially crashing the inner std::unordered_set<> we're using to keep the wrappers alive for extended time.

To avoid it, let's just use std::mutex.

Reviewed By: shergin

Differential Revision: D17631233

fbshipit-source-id: e8f98004e45a68be31f8f0cda118fb67dcb06d45
2019-09-27 13:44:49 -07:00
Marek Cirkos de17cdecd8 Migrate platform imports to platform_defs.bzl
Summary:
This is easiest migration of imports that ONLY import platform symbols, so can be simply renamed
Generated by running in xplat:
```
$ REGEX="(load\(\"fbsource\/\/tools\/build_defs\:default_platform_defs\.bzl\")((, \"ANDROID\")*(, \"APPLE\")*(, \"CXX\")*(, \"IOS\")*(, \"MACOSX\")*(, \"WINDOWS\")*)\)"
$ REPLACEMENT="load(\"fbsource//tools/build_defs:platform_defs.bzl\"\2)"

$ cd xplat
$ ../fbcode/experimental/codemod2/codemod.py --filename "BUCK" "${REGEX}" "${REPLACEMENT}"
$ ../fbcode/experimental/codemod2/codemod.py --extension "bzl" "${REGEX}" "${REPLACEMENT}"
$ arc lint -a
```

Reviewed By: mzlee

Differential Revision: D17602152

fbshipit-source-id: 905f7c3c5ef27596e4c0f85dd2a0ad6b57753182
2019-09-27 09:54:58 -07:00
Luna Wei 06d3031281 Native changes for ImageLoader native module
Summary:
Split changes from D17587836
Native changes for ImageLoader native module

Reviewed By: TheSavior

Differential Revision: D17607364

fbshipit-source-id: 451e24d4cf3c982b64bd6196addacef4cb967d1b
2019-09-26 17:37:38 -07:00
Sidharth Guglani 8583d85de1 Add boolean flag to decide whether to use fbjni or jni
Summary:
Adds a flag useVanillaJNI in YogaConfig to determine whether to use FbJNI or JNI.
Currently default is set to false.

We will experiment based on this flag once all code have been migrated.

Reviewed By: Andrey-Mishanin

Differential Revision: D17601703

fbshipit-source-id: 377a5bd2a6f8a7584e84932e87fa7044d8165efd
2019-09-26 17:32:32 -07:00
Sidharth Guglani 34b71e4fb4 Add separate classes to implement JNI methods suing vanilla JNI
Summary:
This diffs adds a separate file YGJNIVanilla.cpp to add jni methods which uses vanilla JNI instead of FBJNI.
In this diff only one method has been added to setup the experiment boolean setup.

At the end of this diff stack , we will be able to experiment between fbjni and vanilla jni in yoga and finally get rid of fbjni which saves us around 300Kb per architecture in yoga binary size.

Reviewed By: Andrey-Mishanin

Differential Revision: D17601591

fbshipit-source-id: a88520c625bd8b5d9ffcf8ab5f02fc71dc800081
2019-09-26 17:32:32 -07:00
Rajdeep Kaur d21f695edf Limit size of video uploaded from camera roll in android
Summary: Details in Task T53266042. AMA users are trying to upload video data of more than 300 MB which is causing spikes of server_err in the web tier. So i added check to retrive videos that have size < 100 MB.

Reviewed By: furdei

Differential Revision: D17544308

fbshipit-source-id: 5a1d1329b6b12656f1617bb8775e303c96d529cb
2019-09-26 09:47:17 -07:00
Ramanpreet Nara 5e68a98c3d Make TurboModuleProviderFunctionType not depend on TurboModuleManager instance
Summary:
## Description
The C++ lambda that JS invokes to create TurboModules uses `TurboModuleManager`. It is possible for this lambda to outlive the `TurboModuleManager` instance because we delete `TurboModuleManager` on the JS Thread before we schedule the deletion of `CatalystInstanceImpl` object on a neutral third-party background thread. `CatalystInstanceImpl` owns the JS VM instance that owns the C++ lambda.

## [CatalystInstanceImpl.java](https://fburl.com/diffusion/vt4pwjwa)
```
public void destroy() {
  // ...

  getReactQueueConfiguration()
    .getJSQueueThread()
    .runOnQueue(
        new Runnable() {
          Override
          public void run() {
            // We need to destroy the TurboModuleManager on the JS Thread
            if (turboModuleManager != null) {
              turboModuleManager.onCatalystInstanceDestroy();
            }

            getReactQueueConfiguration()
                .getUIQueueThread()
                .runOnQueue(
                    new Runnable() {
                      Override
                      public void run() {
                        // AsyncTask.execute must be executed from the UI Thread
                        AsyncTask.execute(
                            new Runnable() {
                              Override
                              public void run() {
                                // Kill non-UI threads from neutral third party
                                // potentially expensive, so don't run on UI thread

                                // contextHolder is used as a lock to guard against
                                // other users of the JS VM having the VM destroyed
                                // underneath them, so notify them before we reset
                                // Native
                                mJavaScriptContextHolder.clear();

                                mHybridData.resetNative();
                                getReactQueueConfiguration().destroy();
                                Log.d(
                                    ReactConstants.TAG,
                                    "CatalystInstanceImpl.destroy() end");
                                ReactMarker.logMarker(
                                    ReactMarkerConstants.DESTROY_CATALYST_INSTANCE_END);
                              }
                            });
                      }
                    });
          }
        });
    }
  });

  // ...
}
```

The JS thread is also terminated in the neutral third-party thread. Therefore, it should be possible for JS to request a `TurboModule` after `TurboModuleManager` has been destroyed (i.e: JS can try to access memory that was freed). This is why I think we're getting a segfault in T54298358.

## Fix
The fix was to wrap all the member variables of TurboModuleManager we use in `TurboModuleProviderFunctionType` in weak references. This way, we can make sure that the memory is valid before using it.

Reviewed By: fkgozali

Differential Revision: D17539761

fbshipit-source-id: fe527383458a019a4cb9107ec5c3ddd6295ae41c
2019-09-26 09:34:41 -07:00
Eli White a2aa008b33 Remove unused flow suppressions
Summary: I'm trying to clean up core files and finding suppressions that aren't needed. Bulk removing them.

Reviewed By: cpojer

Differential Revision: D17586683

fbshipit-source-id: fc289bd70b0c928b49a75015ecb5aebe8ab4f1da
2019-09-26 08:16:24 -07:00
Eli White c0029be953 Update ReactNativeTypes from PR to React
Summary:
I upstreamed the changes to this file from previous commits to React in this (unlanded) PR: https://github.com/facebook/react/pull/16898#issuecomment-535248721

I had to make some additional changes to be able to make Flow pass there. Bringing those changes back to FBSource as well. Having this change made here will make the next sync easier as we won't have to deal with conflicts then.

Changelog:
[Internal]

Reviewed By: cpojer

Differential Revision: D17586781

fbshipit-source-id: 4be8376d0af4fb5d63410afaaf5bb0005d992981
2019-09-26 08:16:24 -07:00
Eli White 79e08f3c15 Add Flowtests for HostComponent
Summary:
`HostComponent` is built specifically to differentiate from `ReactNative.NativeComponent`. These tests should ensure that is the case, and help it stay that way.

I also expect these tests to be duplicated to DefinitelyTyped to help the team working on the TypeScript types ensure they have things modeled correctly.

Reviewed By: cpojer

Differential Revision: D17580120

fbshipit-source-id: c14eb18507cbee1b308beeff0092607e18706171
2019-09-26 08:16:23 -07:00
Eli White bcc58bce02 Strengthen flowtype of measureLayout
Summary:
MeasureLayout requires either a reactTag or a ref to a host component. Now that we have a type for Host Components we can be more differentiating here.

Also, because Object is treated as `any` in flow, the type was allowing the return from findNodeHandle or a ref itself be passed, even though both of those are nullable.

This change explicitly requires checking for null before calling the function which is consistent with the behavior of the implementation of measureLayout.

Changelog:
[Changed] Flowtype for measureLayout now disallows null as reactTag

Reviewed By: cpojer

Differential Revision: D17579300

fbshipit-source-id: af062fcd9dfc40eab42e5c5452af2ff653d0888e
2019-09-26 08:16:23 -07:00
Han Lin Yap babf67f11c Upgrade all dependencies in package.json template (#26563)
Summary:
Upgrade all dependencies in package.json template

## Changelog

[General] [Changed] - Upgrade to latest dependencies in package.json template
Pull Request resolved: https://github.com/facebook/react-native/pull/26563

Differential Revision: D17589559

Pulled By: cpojer

fbshipit-source-id: edbc9da11a850e01d00e77d9e689d9278a05f6fd
2019-09-25 22:03:45 -07:00
Andrea Cimitan 8d8c3d4e1e Also listen to NFC actions for linking url events (#26553)
Summary:
This PR solves bug https://github.com/facebook/react-native/issues/26552 for Android. Allows an app to receive url events through Linking from NFC tags

## Changelog
[Android] [Fixed] - This branch checks also for `ACTION_NDEF_DISCOVERED` intent matches to send the url events
Pull Request resolved: https://github.com/facebook/react-native/pull/26553

Test Plan: Tested the code multiple times with both NFC tags and normal links

Differential Revision: D17589654

Pulled By: cpojer

fbshipit-source-id: 55e854e765a84da5e22ec2cc51d0fe0972254175
2019-09-25 18:44:43 -07:00
Mats Byrkjeland 46090b0e56 Make RelativeImageStub regex match images in scoped packages (#26567)
Summary:
I am importing an image from a scoped package and I expected this to be recognized by the `module.name_mapper` and treated as a `RelativeImageStub`. But since there's an `@` in the path, the string does not match the regex pattern as it is defined today. Therefore I added the possibility of a `@` in the start of the path to the regex pattern.

Example import not recognized by the name_mapper today:
```
import NicePicture from 'example-pkg/assets/nice-picture.png'
```

## Changelog

[General] [Fixed] - Make RelativeImageStub regex match images in scoped packages
Pull Request resolved: https://github.com/facebook/react-native/pull/26567

Test Plan:
* I have run `yarn flow` in the `react-native` project
* I tested that it resolves my issue with images in scoped packages in my own app's repo

Differential Revision: D17589473

Pulled By: cpojer

fbshipit-source-id: d0c18f2b36456fd974012a0605f3d9ceff0ad744
2019-09-25 18:27:27 -07:00
Ilia Burdukovski 81a6b6ed3c fix build with hermes on windows (#26556)
Summary:
On the Windows platform, with hermes-engine enabled, the assembly crashes with an error:
![image](https://user-images.githubusercontent.com/8634793/65568495-ab11d980-df8c-11e9-83a0-2a2d26447860.png)
The problem lies in calling hermes command without the leading arguments `"cmd", "/c"` ([react.gradle, line: 152](e028ac7af2/react.gradle (L152)) )

## Changelog

[General] [Fixed] - Added a platform check and running commandLine with the corresponding arguments
Pull Request resolved: https://github.com/facebook/react-native/pull/26556

Test Plan:
Under Windows, enable hermes-engine in _build.gradle_ and run the `gradlew assembleRelease` or `gradlew bundleRelease` command
Also check assembly on other available platforms

Differential Revision: D17587023

Pulled By: cpojer

fbshipit-source-id: bab10213b23fac5ab6a46ac4929759dcd43e39c2
2019-09-25 17:51:48 -07:00
Juan Tejada f0bcfbe9be Upgrade eslint-plugin-relay to 1.3.12
Summary:
Bump eslint-plugin-relay version to 1.3.12 on fbsource
`js1 upgrade dependency --package eslint-plugin-relay@1.3.12`

Reviewed By: kassens

Differential Revision: D17581310

fbshipit-source-id: 6285843dd2f92c6cdd4f0fe0bc2ac7f5c78dbff2
2019-09-25 16:00:05 -07:00
Peter Argany a6a6dbe05c Split up createTimer into two methods, createTimer and createTimerForNextFrame
Summary:
This diff adds nuance to timer creation.  Imagine the following bit of JS:

```
    setTimeout(() => {
      console.log("Timeout")
    }, 0);
    setImmediate(() => {
      setNine("Immediate");
    });
```

In classic RN, `setTimeout` will be called async by the bridge, immediate is implemented in JS, so the ordering of logs will be:

1. Immediate
2. Timeout

In bridgeless RN `setTimeout` is called sync, so the ordering of the logs is:

1. Timeout
2. Immediate

In order to preserve ordering, this diff adds a timer creation method which doesn't immediately invoke it, but waits one frame to do so.

This PR does the same thing for android, and explains the reasoning for preserving behaviour (some products may rely on this behaviour) f054928124

Reviewed By: ejanzer

Differential Revision: D17535639

fbshipit-source-id: 3f734c420a6a95be2ee10e8d6ac48adc79ef1c96
2019-09-25 15:31:26 -07:00
Logan Daniels 1bfd15ccb6 Re-land stack of D17563110: codemod xplat/js
Summary:
The stack of D17563110 was reverted because it triggered a failing OTA job that wasn't caught at land time.

Fixing the issue by reverting the change to `Route.js` and re-landing the rest of the diff.

Differential Revision: D17564219

fbshipit-source-id: 166b50a163ce8ae226de224882a98c40652e29ac
2019-09-25 14:47:02 -07:00
Eli White 5876052615 Make setting useNativeDriver required. Add runtime warning if not specified
Summary:
We found that many callsites existed that could be using the native driver, but weren't. In order to help people use it when appropriate and eventually switch the default, we are requiring that useNativeDriver is explicit, even when set to false.

This change adds a runtime warning if useNativeDriver is not specified, hopefully giving some light feedback to remember to use the native driver when you can. Without it being explicit it is very easy to forget setting this.

Reviewed By: JoshuaGross

Differential Revision: D17575918

fbshipit-source-id: e54612d87177e1821692b7de20fe673df0e890d2
2019-09-25 13:36:27 -07:00
Eli White 62acf6e26a Update codegen test fixtures to use HostComponent
Summary:
Changelog:
[Internal] Update codegen test fixtures to use HostComponent

Reviewed By: JoshuaGross

Differential Revision: D17573955

fbshipit-source-id: bae3ab44c5d300d4b9297fcb243e49667776f9bc
2019-09-25 13:16:04 -07:00
Eli White a446a38aaa Add HostComponent to the public API of React Native
Summary:
In React Native there are three types of "Native" components.

```
createReactClass with NativeMethodsMixin
```
```
class MyComponent extends ReactNative.NativeComponent
```
```
requireNativeComponent('RCTView')
```

The implementation for how to handle all three of these exists in the React Native Renderer. Refs attached to components created via these methods provide a set of functions such as
```
.measure
.measureInWindow
.measureLayout
.setNativeProps
```

These methods have been used for our core components in the repo to provide a consistent API. Many of the APIs in React Native require a `reactTag` to a host component. This is acquired by calling `findNodeHandle` with any component. `findNodeHandle` works with the first two approaches.

For a lot of our new Fabric APIs, we will require passing a ref to a HostComponent directly instead of relying on `findNodeHandle` to tunnel through the component tree as that behavior isn't safe with React concurrent mode.

The goal of this change is to enable us to differentiate between components created with `requireNativeComponent` and the other types. This will be needed to be able to safely type the new APIs.

For existing components that should support being a host component but need to use some JS behavior in a wrapper, they should use `forwardRef`. The majority of React Native's core components were migrated to use `forwardRef` last year. Components that can't use forwardRef will need to have a method like `getNativeRef()` to get access to the underlying host component ref.

Reviewed By: rickhanlonii

Differential Revision: D17563615

fbshipit-source-id: b9e6042805517d502770fcba37301c2c5b6452b6
2019-09-25 11:44:38 -07:00
Eli White 0676ebf79a Migrate NativeComponentType from codegenNativeComponent to HostComponent #2
Summary:
We need to migrate to HostComponent instead of the exported type from codegenNativeComponent which is the same type

Changelog:
[Internal] Migrate NativeComponentType from codegenNativeComponent to HostComponent

Reviewed By: rickhanlonii

Differential Revision: D17563307

fbshipit-source-id: 01c8fea8c67b33bed42ae28ffb8c132be87b9a7a
2019-09-25 11:44:38 -07:00
Eli White 1b4eaeb184 Migrate NativeComponentType from codegenNativeComponent to HostComponent #1
Summary:
We need to migrate to HostComponent, this is the first batch.

Changelog:
[Internal] Migrate NativeComponentType from codegenNativeComponent to HostComponent

Reviewed By: rickhanlonii

Differential Revision: D17562879

fbshipit-source-id: ce1993b64a79cede3598c89ddff0dadf07fde92f
2019-09-25 11:44:38 -07:00
Logan Daniels 89e3f70eab Upgrade nullthrows to ^1.1.1
Reviewed By: TheSavior

Differential Revision: D17552725

fbshipit-source-id: 535faeb8d9ca2b901c5342a48ccba7fc26aebd4f
2019-09-25 10:16:00 -07:00
Eli White 69c38e5a63 Introduce flow type to differentiate between HostComponent, NativeMethodsMixin, and NativeComponent
Summary:
In React Native there are three types of "Native" components.

```
createReactClass with NativeMethodsMixin
```
```
class MyComponent extends ReactNative.NativeComponent
```
```
requireNativeComponent('RCTView')
```

The implementation for how to handle all three of these exists in the React Native Renderer. Refs attached to components created via these methods provide a set of functions such as
```
.measure
.measureInWindow
.measureLayout
.setNativeProps
```

These methods have been used for our core components in the repo to provide a consistent API. Many of the APIs in React Native require a `reactTag` to a host component. This is acquired by calling `findNodeHandle` with any component. `findNodeHandle` works with the first two approaches.

For a lot of our new Fabric APIs, we will require passing a ref to a HostComponent directly instead of relying on `findNodeHandle` to tunnel through the component tree as that behavior isn't safe with React concurrent mode.

The goal of this change is to enable us to differentiate between components created with `requireNativeComponent` and the other types. This will be needed to be able to safely type the new APIs.

For existing components that should support being a host component but need to use some JS behavior in a wrapper, they should use `forwardRef`. The majority of React Native's core components were migrated to use `forwardRef` last year. Components that can't use forwardRef will need to have a method like `getNativeRef()` to get access to the underlying host component ref.

Note, we will need follow up changes as well as changes to the React Renderer in the React repo to fully utilize this new type.

Changelog:
[Internal] Flow type to differentiate between HostComponent and NativeMethodsMixin and NativeComponent

Reviewed By: jbrown215

Differential Revision: D17551089

fbshipit-source-id: 7a30b4bb4323156c0b2465ca41fcd05f4315becf
2019-09-25 10:12:38 -07:00
Uts Sikder 94e8ccf9c0 BREAKING: rm YogaNode parameter from YogaLogger#log
Summary:
In D17439957, I noted that YogaLogger#log throws a NoMethodFoundException when called from C++ b/c C++ and Java's signatures of that method don't match. C++ uses YogaNodeJNIBase for the first param, Java uses YogaNode. Both my attempts to fix this failed.

Attempt #1 - Make Java use YogaNodeJNIBase. This doesn't work because the :java-interface target includes YogaLogger but not YogaNodeJNIBase. Moving YogaLogger to the impl target doesn't work either b/c other files in :java-interface reference YogaLogger.

Attempt #2 - Make C++ use YogaNode. This doesn't work b/c we try to call the log method with objects of fbjni type YogaNodeJNIBase. This would be fine in Java since YogaNodeJNIBase extends YogaNode. But fbjni's typing isn't advanced enough to know this, so the Yoga C++ fails to compile.

At this point, I was wondering what the value of having this param in the log function at all was. None of the implementations in our codebase use it today. It might be easier to just remove it all together. This also removes a bug with YGNodePrint where we pass a null layout context that eventually causes a SIG_ABRT when we use it to try to find a YogaNode to pass to this function. (https://fburl.com/diffusion/ssw9h8lv).

Reviewed By: amir-shalem

Differential Revision: D17470379

fbshipit-source-id: 8fc2d95505971a52af2399a9fbb60b63f27f0ec2
2019-09-25 09:12:43 -07:00
Eli White e028ac7af2 Fix ref and component return types
Summary:
These types aren't robust to changes in the React component type. When we refactor requireNativeComponent these will error. This change is forwards compatible.

Changelog:
[Internal] Improve internal type in DrawerLayoutAndroid

Reviewed By: JoshuaGross

Differential Revision: D17561194

fbshipit-source-id: 470289449b4d5b3148692f1945fb720e1e3972eb
2019-09-24 18:51:46 -07:00
Eli White 419722bd07 Flow type vendor/core/merge.js
Summary:
This is used by Image.android.js and needs to be flow typed to be able to have confidence in the requireNativeComponent type change

Changelog:
[Internal] Flow type vendor/core/merge.js

Reviewed By: JoshuaGross

Differential Revision: D17561195

fbshipit-source-id: 2639f2628e15b2dd5469bb2ebfe935a444025a21
2019-09-24 18:51:45 -07:00
Joshua Gross fb90f64d9c Collect more information on Debug T48643168
Summary:
It's possible that this crashes because the callback is non-null/non-undefined but isn't a function; if so, I would like to collect that information.

 These changes have already been made in the React repo.

Reviewed By: TheSavior

Differential Revision: D17559022

fbshipit-source-id: a0538d533c3c482d27eef0ed3c8c980e2bc8e817
2019-09-24 18:35:13 -07:00
Joshua Gross c16b219456 Revert D17518337: [flow][types-first] Export types so codemod can use them
Differential Revision:
D17518337

Original commit changeset: 253bf0fb4955

fbshipit-source-id: 4bd08c1061f6759f08f1186f5bd5a2c207c96315
2019-09-24 17:21:30 -07:00
Mehdi Mulani 2fbe956aac Make NSData usage in RCTNetworkTask threadsafe
Summary:
@public
We're seeing crashes from multiple threads trying to call `[NSData appendData:]` at the same time. Usually the RCTURLRequestHandlers implementation avoids this but if you're using a background queue, it is pretty easy to reach this case.
Adding a lock to accessors of `_data` should prevent this.

Reviewed By: shergin

Differential Revision: D17552136

fbshipit-source-id: 3384d36221d0ada8cda638ad8e79e1bf3862f93f
2019-09-24 12:41:05 -07:00