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

17990 Коммитов

Автор SHA1 Сообщение Дата
Rick Hanlon 588ece23a0 Add fixture for array<array<object>>
Summary:
This diff adds a fixture for supporting arrays of arrays of objects, eventually parsable as:

`$ReadOnlyArray<$ReadOnlyArray<$ReadOnly<{|foo: string|}>>`

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D16936233

fbshipit-source-id: 14143522d82ad7d42e81605bb701890ca2731bed
2019-09-06 06:04:17 -07:00
Rick Hanlon 91d59eb20b Add RawValue support for arrays of arrays
Summary: Adds support for dynamic value that are `std::vector<std::vector<RawValue>>`

Reviewed By: shergin, mdvacca

Differential Revision: D16936932

fbshipit-source-id: fc8d087f9705af9da56ccc1bd9a0537b2bfeb50d
2019-09-06 06:04:17 -07:00
Rick Hanlon c232b5ae3b Add e2e tests for int enums
Summary: This diff adds e2e tests for int enums

Reviewed By: JoshuaGross

Differential Revision: D17161728

fbshipit-source-id: 25003d9472d1df53931e9df8d42d5a68e9d11632
2019-09-06 05:33:08 -07:00
Rick Hanlon 6874bade43 Add parser support for number unions as Int32 enums
Summary:
## Overview

This diff adds flow parser support for number unions as Int32Enums

The following will be supported as an Int32 enum:

```
interval?: WithDefault<0 | 15 | 30 | 60, 0>,
```

## Number type issues
We assume that all number enums are ints (so far there's not been a valid use case for unions of floats).

If we think there would be a use case for float unions we would need to update this to something like:

```
// Int32
intervalInt?: WithDefault<Int32Enum<0 | 15 | 30 | 60>, 0>,

// Float
intervalInt?: WithDefault<FloatEnum<0.0 | 15.1 | 30.2 | 60.3>, 0.0>,
```

My recommendation is that we default number unions to ints and if a use case arises later for floats, we would add the Float support as:

```
// Int32
intervalInt?: WithDefault<0 | 15 | 30 | 60, 0>,

// Float
intervalInt?: WithDefault<FloatEnum<0.0 | 15.1 | 30.2 | 60.3>, 0.0>,
```

Reviewed By: JoshuaGross

Differential Revision: D17161701

fbshipit-source-id: 4b016eee45bf28bf505afd14a6c1aeea6ca8c04f
2019-09-06 05:33:08 -07:00
Rick Hanlon e352edebeb Add support for int enum object properties
Summary: This diff adds more advanced support for Int32 enums by allowing them as object properties in props

Reviewed By: JoshuaGross

Differential Revision: D17161656

fbshipit-source-id: d4377d95961554c83b60ed929f6279291c2d1104
2019-09-06 05:33:07 -07:00
Rick Hanlon f4c6868fc2 Add basic support for Int32Enum in generators
Summary: This diff adds basic (non-object) support for generating Int32 enums

Reviewed By: JoshuaGross

Differential Revision: D17161643

fbshipit-source-id: d91fe70e6086930629c505fb1dab1f6b8555c936
2019-09-06 05:33:07 -07:00
Rick Hanlon c58106344e Update unrelated Int32Enum snapshots
Summary: This diff adds the snapshots for the new Int32 fixture and renames the ENUM_ fixture to STRING_ENUM

Reviewed By: JoshuaGross

Differential Revision: D17158033

fbshipit-source-id: 405b1da5ede16410434a9097ef256f99e4115533
2019-09-06 05:33:07 -07:00
Rick Hanlon e906c6f78f Add Int32EnumTypeAnnotation to codegen schema
Summary:
Adds schema to allow for Int32Enums in the codegen.

All of the non-schema updates here are flow fixes, the code there is implemented in the next diffs

Reviewed By: JoshuaGross

Differential Revision: D17158026

fbshipit-source-id: b5a6871225771c3c97a43a901d5f8e51c44f35c8
2019-09-06 05:33:07 -07:00
Christoph Nakazawa 90a8e3012c Remove live reloading option from RN iOS
Summary: See previous diff in this stack

Reviewed By: motiz88

Differential Revision: D17156649

fbshipit-source-id: 12bdba248481258b9c6ca001472a41ca19fb4b6f
2019-09-06 03:48:49 -07:00
Christoph Nakazawa 478df155e7 Remove "Reload on JS change" from RN Android
Summary: This feature is not necessary any longer with Fast Refresh enabled by default.

Reviewed By: gaearon

Differential Revision: D17156607

fbshipit-source-id: 2396a86d192c6b5d90cbed9cefbf13367dd6b699
2019-09-06 03:48:49 -07:00
Frieder Bluemle b1c954b1f1 Update Gradle wrapper to 5.6.2 (#26349)
Summary:
Gradle wrapper `5.6.2`

Supersedes and closes https://github.com/facebook/react-native/issues/26227

## Changelog

[Android] [Changed] - Gradle wrapper 5.6.2
Pull Request resolved: https://github.com/facebook/react-native/pull/26349

Test Plan: Builds successfully (just like the current `master` branch, **only** after either reverting 4763000554 **or** cherry-picking 7f238785ec898560c276d1d37b4c88b7018c245b from https://github.com/facebook/react-native/issues/26314)

Differential Revision: D17224299

Pulled By: mdvacca

fbshipit-source-id: cbd1b3d5d686e284fdc8e3f6faaeaa93654b301d
2019-09-06 00:25:53 -07:00
Petter Hesselberg 60e00d9d96 Ensure SoLoader is initialized before attempting to load jscexecutor … (#26343)
Summary:
This change fixes the issue "[ReactInstanceManagerBuilder.build fails unless SoLoader.init has been called](https://github.com/facebook/react-native/issues/26342)" on Android.

The `ReactInstanceManager` constructor calls `initializeSoLoaderIfNecessary`, so the intent is clearly that things should work without an explicit call to `SoLoader.init` on the part of the application.

However, with the introduction of Hermes, we have `ReactInstanceManagerBuilder.getDefaultJSExecutorFactory`,  which gets called before the `ReactInstanceManager` constructor. It attempts this:

    SoLoader.loadLibrary("jscexecutor");

This fails with the following stack trace:

     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebook.react.uiapp/com.facebook.react.uiapp.RNTesterActivity}: java.lang.RuntimeException: SoLoader.init() not yet called
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6944)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
     Caused by: java.lang.RuntimeException: SoLoader.init() not yet called
        at com.facebook.soloader.SoLoader.assertInitialized(SoLoader.java:781)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:505)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
        at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:291)
        at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:266)
        at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:86)
        at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:38)
        at com.facebook.react.ReactDelegate.loadApp(ReactDelegate.java:103)
        at com.facebook.react.ReactActivityDelegate.loadApp(ReactActivityDelegate.java:83)
        at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:78)
        at com.facebook.react.uiapp.RNTesterActivity$RNTesterActivityDelegate.onCreate(RNTesterActivity.java:40)
        at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:44)
        at android.app.Activity.performCreate(Activity.java:7183)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6944) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 

## Changelog

[Android] [Fixed] - Don't crash ReactInstanceManagerBuilder.build even if SoLoader has not been explicitly initialized
Pull Request resolved: https://github.com/facebook/react-native/pull/26343

Test Plan:
To demonstrate the defect, remove the call to `SoLoader.init` from `RNTester.onCreate` and run the app.

To demonstrate the fix, apply this PR, which does in fact also remove the call to `SoLoader.init`

Differential Revision: D17223701

Pulled By: mdvacca

fbshipit-source-id: c508ab52bd3fefe8a946ebab7b2906a5d8c21e0f
2019-09-06 00:16:59 -07:00
Will Holen fa6add7d4b Page reloads through execution context
Summary:
This ressurects D14994945 and fixes the following extra issues:
1. Source map not being accounted for after reloads
2. Breakpoints being resent before Hermes is ready for them
3. Connection being dropped when reloading at inopportune times

This hopefully fixes the issue of having to close and re-open the debugger if
it's attached when reloading.

Reviewed By: sahrens

Differential Revision: D17100911

fbshipit-source-id: df988e7bb532170f5add47b9e49cd7c8ddf67b43
2019-09-05 16:30:04 -07:00
Ram N 0a5c43fcc3 Enable Flipper on RNTester (iOS)
Summary:
By enabling Flipper on RNTester, we can ensure that Flipper continues to work with ReactNative.
Note that Flipper is disabled when RNTester is built with `USE_FRAMEWORKS=1 pod install`

Reviewed By: PeteTheHeat

Differential Revision: D6976784

fbshipit-source-id: 4e16a47949d7ed6400e0b8ccd640be0754203c69
2019-09-05 16:08:16 -07:00
Joshua Gross 0cc4306d6c Support Gratuitous Animation Example on Android
Summary:
It doesn't work super smoothly, but I don't think we should hide it. The ultimate goal is to get it working well in Fabric.

Changelog:
[Internal]

Reviewed By: shergin

Differential Revision: D17201209

fbshipit-source-id: 2d2f447e10173462d98ff01ed58f3cb94da77513
2019-09-05 13:27:03 -07:00
Valentin Shergin 862bd2fa2a Fabric: Fixing small nit in `ParagraphComponentDescriptor`
Summary: Trivial. `measureCache_` is unique pointer here. It cannot be `nullptr`.

Reviewed By: JoshuaGross

Differential Revision: D17200950

fbshipit-source-id: dc267eb6545a10322cc2f02690f90c6a50366f0e
2019-09-05 08:06:09 -07:00
Valentin Shergin 50c318fb04 Fabric: Killing a concept of `getDefaultComponentRegistryFactory`
Summary: We used this mechanism at the very early stages of Fabric. Now we do component registration differently.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D17200952

fbshipit-source-id: 16ff9d6569714a24e2a8d58dc6e60ad4d7bc1e16
2019-09-05 08:06:09 -07:00
Joshua Gross e6b11e0953 AndroidTextInput: remove enum todos from flow typing
Summary: It looks like codegen supports string enums as long as defaults are provided. Uncommenting the enums and removing TODOs.

Reviewed By: rickhanlonii

Differential Revision: D17196139

fbshipit-source-id: a076b1a25eb38b23cfd53fd92e8c42f121d08d6b
2019-09-04 23:20:15 -07:00
Valentin Shergin 10fe41cc8c Fabric: Exposing `findShadowNodeByTag_DEPRECATED` to JavaScript
Summary: This allows to implement `findNodeHandle` in Fabric world (temporary).

Reviewed By: zackargyle, JoshuaGross, mdvacca

Differential Revision: D17175953

fbshipit-source-id: c88bd1c58608450812799d4ecb4a6bf2c027c5f3
2019-09-04 23:16:56 -07:00
Valentin Shergin 79ef5f9b0f Fabric: `UIManager::findShadowNodeByTag_DEPRECATED`
Summary: The mehtod implements the core functionality of finding a shadow node by given tag.

Reviewed By: zackargyle, JoshuaGross, mdvacca

Differential Revision: D17175955

fbshipit-source-id: 5cfbb80b2d4e54a33ca9c20a21988df4de54c800
2019-09-04 23:16:56 -07:00
Valentin Shergin b42fdae3e7 Fabric: `ShadowTreeRegistry::enumerate`, the way to iterate over registered shadow trees
Summary: The new methods provides a way to iterate over all registered shadow trees.

Reviewed By: zackargyle, JoshuaGross, mdvacca

Differential Revision: D17175954

fbshipit-source-id: e4e6ee5a0e0a4e4e36b99d546f8724b99559c8c2
2019-09-04 23:16:56 -07:00
Dulmandakh Sukhbaatar a2f513e83e remove android support annotations (#26320)
Summary:
Remove Android Support Library annotations dependency since we migrated to AndroidX.

## Changelog

[Android] [Changed] - remove android support annotations
Pull Request resolved: https://github.com/facebook/react-native/pull/26320

Test Plan: ./scripts/circleci/buck_fetch.sh script completes without error.

Differential Revision: D17179995

Pulled By: TheSavior

fbshipit-source-id: c0c5f5847c9e0a67d4859ca84600796cfdd7eca4
2019-09-04 22:30:23 -07:00
Rick Hanlon 69020a8e87 Add back accessibilityStates until next release
Reviewed By: fkgozali

Differential Revision: D17196525

fbshipit-source-id: 56445ea34b3f0d55ac05e17034a969e3bfea0150
2019-09-04 20:14:26 -07:00
Zihan Chen (MSFT) d63c46de7e Fix flow test case input in react-native-codegen package that has syntax errors. (#26316)
Summary:
Fix flow test case input in react-native-codegen package that has syntax errors.
Missing ";" after export type,
Missing ";" or "," after interface/object type member signature,
Missing ":" in method signature,
etc

## Changelog

[General] [Fixed] - Fix flow test case input in react-native-codegen package
Pull Request resolved: https://github.com/facebook/react-native/pull/26316

Test Plan: Parsed files using flow parser, but some test cases are intended to have syntax error, in this case I fixed unexpected ones.

Reviewed By: rickhanlonii

Differential Revision: D17194969

Pulled By: osdnk

fbshipit-source-id: 262d0af4d9e7e74f7ba3eb30c4fd9753c08f3bf7
2019-09-04 17:23:26 -07:00
Héctor Ramos a31c76fbd3 nit: Fix RNTester gradle command (#26140)
Summary:
The README.md was slightly out of date.
## Changelog

[Android] [Fixed] - Fixed RNTester instructions
Pull Request resolved: https://github.com/facebook/react-native/pull/26140

Test Plan: Ran `./gradlew :RNTester:android:app:installJscDebug` to build and install RNTester on my device.

Differential Revision: D17178074

Pulled By: mdvacca

fbshipit-source-id: 677f91833170af54eeb1f0b5431dd94eae7668ac
2019-09-04 14:41:41 -07:00
Frieder Bluemle 14375101ae Fix RNTester Lint errors (#26279)
Summary:
Trying to build the Android RNTester app using Gradle fails with the following error:

```
  Errors found:

  [...]/RNTester/android/app/src/main/AndroidManifest.xml:2: Error: Hardware feature android.hardware.touchscreen not explicitly marked as optional  [ImpliedTouchscreenHardware]
  <manifest
   ~~~~~~~~
  [...]/RNTester/android/app/src/main/AndroidManifest.xml:2: Error: Expecting <uses-feature android:name="android.software.leanback" android:required="false" /> tag. [MissingLeanbackSupport]
  <manifest
   ~~~~~~~~
```

This PR adds the two missing `uses-feature` tags to AndroidManifest of RNTester.

## Changelog

[Android] [Fixed] - Fix RNTester Lint errors
Pull Request resolved: https://github.com/facebook/react-native/pull/26279

Test Plan: After adding the tags, the build is successful again.

Differential Revision: D17177952

Pulled By: mdvacca

fbshipit-source-id: c81dce9c6642fc8551f3d0eeb84c984ed06b18e3
2019-09-04 14:33:50 -07:00
Oleg Lokhvitsky d69387dac8 Sanitize float value before calling setCameraDistance
Summary: Fixes the crash when calling setCameraDistance with NaN on Android Q.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D17170045

fbshipit-source-id: 386f969e70c56bca6ae5b8ffead62453ebb72857
2019-09-04 14:07:01 -07:00
Oleksandr Melnykov bf01dfbc97 Reset sMatrixDecompositionContext before applying transformations
Summary: Recover accidentally removed call to `sMatrixDecompositionContext.reset()` added in https://github.com/facebook/react-native/pull/25438.

Reviewed By: mdvacca

Differential Revision: D17136023

fbshipit-source-id: 01d351729b427a01a04e3a260f72c12da7b8d03a
2019-09-04 09:47:56 -07:00
Kevin Gozali 67fe9b29e8 iOS Appearance: default to light
Summary:
For iOS < 13, default to "light" appearance, just like in Android (instead of `nil`).

This fixes the following redbox:

{F205818545}

Reviewed By: cpojer

Differential Revision: D17147970

fbshipit-source-id: b2adccd349a0a0ff7668c2f30e93164d23c3eea6
2019-09-04 09:16:32 -07:00
Kevin Gozali 241091d527 TM iOS: Disable in test environment
Summary:
For now, disable TM completely in test environment, like RNTester integration/unit tests. See details in T53341772

This also fixes the failure discussed in https://github.com/facebook/react-native/pull/26151

Reviewed By: PeteTheHeat

Differential Revision: D17147915

fbshipit-source-id: 1c48ebb9c3b81fc08bc33606dcc38c29297d6010
2019-09-04 09:16:32 -07:00
Oleksandr Melnykov 7715d18e6e Migrate FbReactTTRCStepRenderFlagManager to JS codegen
Summary: This diff migrates `FbReactTTRCStepRenderFlagManager` to use the generated `TTRCStepRenderFlagManagerDelegate` for setting its properties. A bit more work was required to migrate this view manager since it doesn't extend `BaseViewManager`, so I had to add an adapter which made it possible to pass an instance of `FbReactTTRCStepRenderFlagManager` to `TTRCStepRenderFlagManagerDelegate`.

Reviewed By: mdvacca

Differential Revision: D16984172

fbshipit-source-id: 7bf8c1342435c4e615eb9e7ca711f53c63ed3438
2019-09-04 07:04:08 -07:00
Oleksandr Melnykov d38afb4a9d Use interface instead of abstract class to reference view manager in generated delegate
Summary:
Our JS codegen assumes that all Android view managers extend `BaseViewManager` which allows generated delegates to set base view props using `BaseViewManagerDelegate`, see and example of the generated delegate for `FbReactTTRCStepRenderFlagManager`:
```
public class TTRCStepRenderFlagManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & TTRCStepRenderFlagManagerInterface<T>>{
  public TTRCStepRenderFlagManagerDelegate(U viewManager) {
    super(viewManager);
  }
  Override
  public void setProperty(T view, String propName, Nullable Object value) {
    switch (propName) {
      case "traceId":
        mViewManager.setTraceId(view, value == null ? null : (String) value);
        break;
      case "stepName":
        mViewManager.setStepName(view, value == null ? null : (String) value);
        break;
      default:
        super.setProperty(view, propName, value);
    }
  }
}
```
The problem is that `FbReactTTRCStepRenderFlagManager` doesn't extend `BaseViewManager`, but `ViewManager`, which means that we cannot use it with the generated delegate. We cannot use  `ViewManager` instead of `BaseViewManager` in our JS codegen either, otherwise we will not be able to set base view props.

This diff makes it possible for delegates generated by JS to be used by Android view managers that do not extend `BaseViewManager`. By having a `BaseViewManagerInterface` we will be able to introduce a no-op base view manager implementation and wrap our original view manager in it so that we can pass as a constructor parameter to `BaseViewManagerDelegate`.

See an example of this approach for `FbReactTTRCStepRenderFlagManager`:

```
public class FbReactTTRCStepRenderFlagManager extends ViewManager<FbReactTTRCStepRenderFlag, ReactShadowNodeImpl> implements TTRCStepRenderFlagManagerInterface<FbReactTTRCStepRenderFlag> {

    private final ViewManagerDelegate<FbReactTTRCStepRenderFlag> mDelegate;

    public FbReactTTRCStepRenderFlagManager() {
        mDelegate = new TTRCStepRenderFlagManagerDelegate<>(new ViewManagerWrapper(this));
    }
    ...

    private static class ViewManagerWrapper extends BaseViewManagerAdapter<FbReactTTRCStepRenderFlag> implements TTRCStepRenderFlagManagerInterface<FbReactTTRCStepRenderFlag> {

        private final TTRCStepRenderFlagManagerInterface<FbReactTTRCStepRenderFlag> mViewManager;

        private FbReactTTRCStepRenderFlagManagerAdapter(TTRCStepRenderFlagManagerInterface<FbReactTTRCStepRenderFlag> viewManager) {
          mViewManager = viewManager;
        }

        Override
        public void setTraceId(FbReactTTRCStepRenderFlag view, Nullable String traceId) {
          mViewManager.setTraceId(view, traceId);
        }

        Override
        public void setStepName(FbReactTTRCStepRenderFlag view, Nullable String stepName) {
          mViewManager.setStepName(view, stepName);
        }
    }
}
```

Reviewed By: mdvacca

Differential Revision: D16984121

fbshipit-source-id: ea2761dda68a96ff3ba6ac64153bc4e56e396774
2019-09-04 07:04:08 -07:00
David Vacca 1ee811c951 Revert D17170140: [Fabric][JS] Use SoundManager in Pressability and Touchable
Differential Revision:
D17170140

Original commit changeset: 33a8ca508ec3

fbshipit-source-id: ec7dbded4caf3e9efd61e0c3370c894e8a9c054d
2019-09-04 06:43:18 -07:00
Ashok Menon e6d5f2e80d Make sure requests are sent in sequential order on iOS.
Summary:
blairv recently brought an issue with heap snapshots to our attention:  When
captured from iOS, the viewer would quite regularly hang forever instead of
capturing the snapshot.

Further investigation showed that it was because the message that Hermes sends
to indicate that it had finished sending chunks of the heap snapshot was
arriving to chrome before the last chunk of the snapshot.  This caused Chrome
to believe the snapshot was malformed.

I confirmed that:

 - Sends from the Hermes Inspector were occurring in the correct order.
 - The WebSocket protocol, being built on top of TCP, also preserves order.
 - The Inspector Proxy in Metro was preserving the order of requests it was
   given, but the responses were already in the wrong order when they reached
   it.

This left the code that Hermes' Inspector calls into to send its messages.  On
iOS, the logic to send the request is run on the global dispatch queue which
can and does schedule jobs concurrently with each other.  Because the messages
containing heap snapshot chunks are much larger than the "Ok" message used to
indicate the end of the snapshot, the earlier chunk message would often lose
the race with the later "Ok" message.

There was already a serial background queue used by the websocket server to
schedule the actual sending of the message.  I re-use it in this diff to
process the message as well.

The architecture of the [same code in Android](https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorPackagerConnection.java?commit=64c8954ec7be555509437db6944b9a71a350e87c&lines=283) initially seems to be broken in
the same way, but it is not, because AsyncTask does not run tasks concurrently
any more because Google found it exposed too many concurrency bugs to do so.

pakoito, it seems like you might be somewhat familiar with what's going on
here.  Let me know if what I've done is sensible.

Reviewed By: pakoito

Differential Revision: D17106960

fbshipit-source-id: af85ff1753324340bb55fc63048e8bd424c8a983
2019-09-04 05:37:29 -07:00
Joshua Gross 15b38958b0 Log soft exceptions but don't crash when viewState is missing for commands or view deletion
Summary:
We probably don't always need to crash in these cases.

This should replace all prod/dev crashes with logged SoftExceptions.

Note that this is currently only used for Fabric.

Changelog:
[Internal]

Reviewed By: mdvacca

Differential Revision: D17170459

fbshipit-source-id: 70757ae88deb8c893b36971d879174e25a194fb9
2019-09-03 21:45:49 -07:00
David Vacca de2572ce12 Use SoundManager in Pressability and Touchable
Summary:
This diff replaces the usage of UIManagerModule.playTouchSound() in Pressability and Touchable for the SoundManager.playTouchSound()

Previously landed and unladed: D16543433

Reviewed By: rickhanlonii, JoshuaGross

Differential Revision: D17170140

fbshipit-source-id: 33a8ca508ec31f034c76fb0ac4107150d43c608b
2019-09-03 18:56:17 -07:00
Kudo Chien 962d9c9c1a Fix compile error for native debug build (#26248)
Summary:
Fix Android gradle build error for native debug build.
`NATIVE_BUILD_TYPE=Debug ./gradlew :ReactAndroid:installArchives`
The root cause is `folly::Future<bool>` not declared.
As we don't include true folly::Future implementation in OSS build but to use a forward declaration,
the fix is pretty much like to original declaration as `folly::Future<folly::Unit>`.

## Changelog

[Android] [Fixed] - Fix compile error for native debug build
This change could be ignored from changelog which is only for internal development.
Pull Request resolved: https://github.com/facebook/react-native/pull/26248

Test Plan: Makes sure `NATIVE_BUILD_TYPE=Debug ./gradlew :ReactAndroid:installArchives` build without errors.

Differential Revision: D17169696

Pulled By: mdvacca

fbshipit-source-id: 42e8b84b7ee0d1bd99d913702df98bc030965f63
2019-09-03 18:27:55 -07:00
Logan Daniels f0cc7fb666 Add type annotations to render method of react components
Summary:
This is part of enabling types-first mode in xplat/js ([context](https://fb.workplace.com/groups/rn.engineering/permalink/2293015867694617/)).

This diff adds `React.Node` as the return type of the `render` method of react components.

Differential Revision: D17137432

fbshipit-source-id: 415e902d87b6be5c26e4a0af3884a43a89c9be78
2019-09-03 17:36:32 -07:00
Ram N 24de443bac Add Fresco Image Plugin
Reviewed By: mdvacca

Differential Revision: D15751118

fbshipit-source-id: 75a8b65b276968462f8e3e3cff6d8f95fd62e8cd
2019-09-03 16:59:33 -07:00
Valentin Shergin 86d3bd7476 Fabric: Fixing "No suitable image loader" redbox on hot-reload
Summary:
This diff fixes a redbox happens on every single hot-reload practically saying that ImageLoader is misconfigured. The issue happened because after reloading Fabric used the previous obsolete instance of `ImageLoader` created and stored inside old (and already destroyed) instance of Bridge. The fix is simple: We update all dependencies after the Bridge was reloaded.

See https://fb.workplace.com/groups/rn.support/permalink/2677343372314261/ for more details.

Reviewed By: mdvacca

Differential Revision: D17173702

fbshipit-source-id: 5ff0c418feae10ede9b76c184cd24ad06ee008b7
2019-09-03 16:49:54 -07:00
Ram N 70274f4e91 Add code to enable Flipper in React Native iOS Template
Reviewed By: rickhanlonii

Differential Revision: D6997542

fbshipit-source-id: c8f7280b52febabb0a987df5dffadf957dadd1fb
2019-09-03 16:33:11 -07:00
Ram N 755ad3b33a Move ReactNativeFlipper class to template
Reviewed By: mdvacca

Differential Revision: D6101369

fbshipit-source-id: e1ae8f57136dd568b7c14fa873a50bb490d73808
2019-09-03 16:28:24 -07:00
Ram N 4bda2dbbfc Documentation Fix for the way to run RNTester Android
Summary: `installDebug` is no longer working, `installJscDebug` is the right command. ALso removed Genymotion recommendation.

Reviewed By: mdvacca

Differential Revision: D13912729

fbshipit-source-id: 1ed5eccc8460c48ee417efbd360f42783010d376
2019-09-03 16:20:00 -07:00
Mehdi Mulani b070f05926 Remove guard around isHotLoadingAvailable
Summary:
@public
With this guard removed, the functionality is the same in RCT_DEV and non-RCT_DEV builds because RCTDevSettings will return NO (or not exist) in non-RCT_DEV builds, so this code will not be run.

Pros to this approach:
- Hot loading can be enabled in a non-RCT_DEV build

Cons:
- all builds now have this extra block of code, even if it won't be run

If the cons are too strong, I can move this code into a new RCT_DEFINE that inherits from RCT_DEV. (but notably, can be overridden)

Reviewed By: shergin

Differential Revision: D17118516

fbshipit-source-id: cc6c01cca6b2450c35274eccc939c9a2123e6b93
2019-09-03 15:54:11 -07:00
Mehdi Mulani d2cb52beee Allow RCTDevMenu to be enabled separately from RCT_DEV flag
Summary:
@public
RCTDevMenu and RCTDevSettings are used to display the dev menu you see when you shake the device.
With this change in build flags, it's possible to build them into a production version of the app without pulling in all the RCT_DEV logic.

Reviewed By: shergin

Differential Revision: D17116992

fbshipit-source-id: 71458c49affe5bb94c52c9d8bb0f793b16d35828
2019-09-03 15:54:11 -07:00
Ramanpreet Nara 55276a9b10 Fix codegen output
Summary:
It looks like the codegen output for OSS NativeModule specs was modified in D17152891. In this diff, I run `js1 build oss-native-modules-specs -p ios` to unbreak stable.

build-break

Differential Revision:
D17171834
Ninja: master broken

fbshipit-source-id: 3eb14e555030dc3cd50ae6f9f946c75710c0f141
2019-09-03 15:04:51 -07:00
Ramanpreet Nara 7756114250 Print stacktraces of exceptions thrown when creating NativeModules
Summary:
## Summary
When an exception is raised by Java in a synchronous call from JS to Java, the Java portion of the stack trace is simply ignored when the exception is forwarded to JS. This problem doesn't exist for async calls. I did some digging to figure out why this works with async calls, but not sync calls, to get to the bottom of T52585087.

In T52585087, `TurboModuleRegistry.get<Spec>('I18nAssets')` fails because of a `NullPointerException` in Java. However, since there's no stack trace associated with the `NullPointerException`, it's hard to diagnose the problem.

## Asynchronous calls
ReactNative's NativeModules thread is a background thread on which we schedule asynchronous NativeModule method invocations. We spawn our background threads in Java using the [`MessageQueueThreadImpl`](https://fburl.com/diffusion/u0vdm5k3). Each thread is associated with a queue on which you can schedule some work. These `MessageQueueThread`s have a [C++ API](https://fburl.com/diffusion/596740d8) that we can use to schedule some work from C++.

NativeModule method invocations in JS produce a C++/Java boundry, because our JS executes C++, which executes the Java NativeModule method. But since the method is asynchronous, instead of invoking it immediately, we wrap it in a C++ lambda and use the C++ API of `MessageQueueThread` to schedule it to be invoked later. Therefore, when it actually invokes, we'll get Java invoking C++, which invokes Java.

When the NativeModule method (implemented in Java) throws an exception, fbjni will convert that exception into a `jni::JniException` and start unwinding the C++ stack. Eventually, this exception will reach the outermost Java/C++ boundry. Typically, at this point, the program would crash, but because we used fbjni to register all our native functions, our `jni::JniException` will automatically be converted into a regular Java exception. This exception will be caught by MessageQueueThreadHandler [here](https://fburl.com/diffusion/c4thoca7), and handled using our ExceptionHandler NativeModule.

## Synchronous calls
In synchronous execution, JS uses a `JSI::HostObject` to call the Java method directly. If the Java method throws an error, because we're using fbjni, that Java exception will be converted to a `jni::JniException` object, which will contain the stack tract of the Java object. However, from what I could gather, Hermes doesn't know about `jni::JniException`. So, simply ignore the stack trace associated with the Java exception, understanding only the exception message. Hence, all synchronous calls into Java only display the JS stack trace. What we really want is to build an platform-agnostic abstraction that understands `jni::JniException` (and whatever its analogue is in iOS, if any) and use that to bridge between Native and JS.

## Temporary Solution
We know that when NativeModules are created, we do a synchronous call from JS to C++ to Java. This synchronous call happens when you do a property access on the `NativeModules` object. Therefore, at the very least, to get to the bottom of T52585087, we could log all exceptions that are thrown whenever a NativeModule is created. This should help us get to the bottom of T52585087.

Reviewed By: mdvacca

Differential Revision: D17126667

fbshipit-source-id: a6fb27aaea094b9559939ddcc260d3a2c6e71492
2019-09-03 13:58:52 -07:00
Valentin Shergin d89d7809b0 Fabric: Devirtualizing `ShadowNode::getComponentName/Handle()`
Summary:
We don't need to have those methods virtual anymore.
Nowadays we have a pointer to a `ComponentDescriptor` in `ShadowNode`, it's simpler to get that value from there.
That's also more code-size friendly because we now can remove those methods from a template.

Reviewed By: sammy-SC

Differential Revision: D17142173

fbshipit-source-id: 9f54fbe6c1ebad3ed49843ed75a01ca5ee48c34f
2019-09-03 12:24:27 -07:00
Valentin Shergin a4221e9f68 Fabric: Removed obsolete type definition in EventEmitter
Summary: We merge `events` module into `core` long time ago, so we don't need this anymore.

Reviewed By: mdvacca

Differential Revision: D17142174

fbshipit-source-id: 6e63f7f22dc3d65ed2f9cc3bd4f4776404dfe788
2019-09-03 12:24:27 -07:00
Ram N 49f59a6b9e Handle empty string returned from NativeAppearance.getColorScheme()
Reviewed By: PeteTheHeat

Differential Revision: D17151675

fbshipit-source-id: 39b9a32271cd45b82faa5e0248d589ef1ed9f4c9
2019-09-03 12:11:15 -07:00