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

3542 Коммитов

Автор SHA1 Сообщение Дата
Moti Zilberman a05e9f8e09 Android: Sort modules by ID when serializing delta bundle
Summary:
Fixes redbox/yellowbox symbolication when the Java delta client is enabled. Previously the modules would get concatenated in a nondeterministic order (owing to Metro's parallelism) which differed from their order in the source map, where they're explicitly sorted by module ID.

This diff changes the data structure holding modules in memory from a `LinkedHashMap` (which iterates in insertion order) to a `TreeMap` (which iterates in key order).

NOTE: Similar to this change in the Chrome debugger's delta client: https://github.com/react-native-community/cli/pull/279

Reviewed By: dcaspi

Differential Revision: D15301927

fbshipit-source-id: 27bdecfb3d6963aa358e4d542c8b7663fd9eb437
2019-05-14 10:24:57 -07:00
wojteg1337 e4aff423ac fix: set js delta bundle default value to false (#24848)
Summary:
When running Android app for the first time, the packager is requesting delta bundles from metro instead of a bundle (in dev settings delta bundles are disabled by default and marked as experimental). UI of dev settings is not consistent with the current state, to turn off delta bundles you have to enable them and then disable.

[Android] [Fixed] - Disable delta bundles on the first app run
Pull Request resolved: https://github.com/facebook/react-native/pull/24848

Differential Revision: D15334059

Pulled By: cpojer

fbshipit-source-id: 384a8abba64c54db3656a4d5d0e24acc825870c8
2019-05-14 04:20:14 -07:00
James Ide cd9adda651 Migrate "androidTest" JS from Haste to path-based requires (#24813)
Summary:
The files in `ReactAndroid/src/androidTest/js` use Haste names; this commit migrates them to use path-based imports. This helps us move RN towards standard path-based requires. All the requires in `androidTest` have been rewritten to use relative requires.

[General] [Changed] - Migrate "androidTest" JS from Haste to path-based requires
Pull Request resolved: https://github.com/facebook/react-native/pull/24813

Differential Revision: D15318108

Pulled By: cpojer

fbshipit-source-id: dddc68f992b8dea48afb01fd4481bd5b846231ca
2019-05-14 03:21:24 -07:00
Emily Janzer c75f062a77 Change JSCallInvoker to be an abstract class
Summary: The existing implementation of JSCallInvoker holds a reference to Instance (aka the bridge). This diff makes JSCallInvoker an abstract base class that's extended by BridgeJSCallInvoker, which is what's returned by CatalystInstance to initialize TurboModules. This will allow us to add another class that derives from JSCallInvoker that doesn't rely on the bridge.

Reviewed By: shergin

Differential Revision: D15252375

fbshipit-source-id: 75eee2ca149235a63e2a2cd8cdd361b163d1d1ab
2019-05-13 12:04:33 -07:00
Luna Wei 0d7a0dc997 Add log to view that is being dropped
Summary:
We are getting errors where views are being dropped twice.
This is following from logic that viewManagers are only removed from `mTagsToViewManagers` from `dropView`.

This log will hopefully identify if we are getting improper operations because we shouldn't be re-using tags

Reviewed By: mdvacca

Differential Revision: D15152869

fbshipit-source-id: 914ee9c1772fa066adefde0753075ecba6377a0c
2019-05-13 11:00:55 -07:00
David Vacca 1b4678105b Ensures constraintSurfaceLayout is executed before 'JS run application' starts
Summary:
This diff ensures the method scheduler.constraintSurfaceLayout is executed before the JS run application start.
This is necessary to properly set the pointScaleFactor for the Root before running JS.

This is a workaround to fix a bug when the pointScaleFactor changes over time for the rootShadowNode. The bug is easily reproducible when rendering the "fabric" indicator on Fabric screens. During the first render of a Fabric screen this method was called before "JS run application" starts, and the Fabric indicator was render correctly.
Beacuse of timing of measure APIS, the second time a Fabric screen is rendered the method is called after the "JS run application process started", as a consecuence the Fabric indicator is not rendered correctlly (the pointScaleFactor is incorrectly assigned into the layout metrics of the Fabric indicator text).

We still need to analyze why the pointScaleFactor is not correctly assigned when it is set after the "JS run application process started", but this will be part of another diff.

Reviewed By: shergin

Differential Revision: D15303554

fbshipit-source-id: 7d985cefee20fd40dbe04166c1a1358b3f3ddc85
2019-05-10 16:32:01 -07:00
Valentin Shergin 184073813e Fabric: Making `YogaStylableProps.yogaStyle` protected
Summary: `YogaStylableProps.yogaStyle` is designed to be consumed by Yoga only. Making it `protected` allows us to avoid confusion and misuse of this props.

Reviewed By: JoshuaGross

Differential Revision: D15296474

fbshipit-source-id: cf9e416afee99fb426d72765557b34d303a63dbe
2019-05-10 15:34:25 -07:00
Kudo Chien 310cc38a5a Fix PickerAndroid will reset selected value during items update. (#24793)
Summary:
Fixes #13351

Two root causes:
1. Android Spinner will reset selection to undefined after setAdapter()
   which will trigger onValueChange().
   The behavior is not expected for RN.
   And the solution is to setSelection() explicitly

2. In original implementation, it setups `items` immediately,
   but delays the `selected` setup after update transaction.
   There will be some race condition and incosistency
   if update `items` only.
   The fix will do the setup all after update transaction.

[Android] [Fixed] - Fix #13351 PickerAndroid will reset selected value during items update.
Pull Request resolved: https://github.com/facebook/react-native/pull/24793

Differential Revision: D15293516

Pulled By: cpojer

fbshipit-source-id: 5a99a60015c7e1b2968252cdc0b2661d52a15b9d
2019-05-10 02:01:14 -07:00
Maciej Srokowski ebeb893b50 Fix Android Camera Roll crash on mime type guessing (#24780)
Summary:
Fixes this issue:
https://github.com/facebook/react-native/issues/24468
It was incorrectly closed by a fix on react-native-community CameraRoll implementation. CameraRoll in react-native still crashes when finding a file with # sign

[Android] [Fix] - Fix Android Camera Roll crash on mime type guessing
Pull Request resolved: https://github.com/facebook/react-native/pull/24780

Reviewed By: mdvacca

Differential Revision: D15281062

Pulled By: lunaleaps

fbshipit-source-id: ca3364c8478d9bfc9a0a6657b531ffb384145d8c
2019-05-09 18:40:59 -07:00
Emily Janzer d5b27fc0a8 Allow creating ThemedReactContext without a CatalystInstance
Summary: In the future we're planning to decouple ThemedReactContext from the bridge (CatalystInstance). For now, we just need to be able to create a ThemedReactContext with a ReactContext that has no Catalyst instance.

Reviewed By: mdvacca

Differential Revision: D15246442

fbshipit-source-id: 99ebda6521f4df72969011ea0e6ea41b046875c8
2019-05-09 17:47:18 -07:00
Emily Janzer db40c28728 Move message queue initialization in ReactContext into its own method
Summary: Refactoring ReactContext to move message queue initialization into its own function that can be called independently of initializeWithInstance. This allows you to create a ReactContext with message queue threads without a CatalystInstance.

Reviewed By: mdvacca

Differential Revision: D15246287

fbshipit-source-id: 4b8c53e68112af7eded47d8c31311500cc296dfe
2019-05-09 15:49:18 -07:00
Emily Janzer 078f14c5d2 Require passing in JSCallInvokerHolder to TurboModuleManager
Summary: Right now TurboModuleManager gets the JSCallInvokerHolder from the bridge in its constructor; this diff changes the constructor to make the JSCallInvokerHolder a required argument so that TurboModuleManager doesn't directly depend on the bridge.

Reviewed By: axe-fb, RSNara

Differential Revision: D15227184

fbshipit-source-id: b16e6abaa727587986a132d0e124163acdf55408
2019-05-09 11:28:30 -07:00
David Aurelio 7d44113bee **breaking:** remove `YGNodeGetInstanceCount`
Summary:
@public

`YGNodeGetInstanceCount` was only ever meant for tests, and caused data races in multi-threaded environments.

It was completely replaced with event-based counting for tests.

Here we remove public API around the counter, and the counter itself.

Reviewed By: SidharthGuglani

Differential Revision: D15174857

fbshipit-source-id: 228e85da565bac9e8485121e956a2e41910b11c8
2019-05-09 04:22:42 -07:00
Joshua Gross d7447fadeb Core React/Litho support and Java codegen
Summary:
Core React/Litho support and Java codegen. View updating still in progress.

Generated ViewManager code:

```
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Autogenerated by ComponentsReactNativeSupportProcessor
package com.facebook.catalyst.samples.componentsembedding;

import com.facebook.litho.Component;
import com.facebook.litho.ComponentContext;
import com.facebook.litho.reactnative.ComponentsShadowNode;
import com.facebook.litho.reactnative.ComponentsViewManager;
import com.facebook.litho.reactnative.ReactLithoView;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.ThemedReactContext;
import java.util.HashMap;
import java.util.Map;

ReactModule(
    name = "SampleComponent"
)
public class GeneratedSampleComponentViewManager extends ComponentsViewManager {
  Override
  public String getName() {
    return "SampleComponent";
  }

  Override
  public ReactLithoView createViewInstanceWithProps(ThemedReactContext context,
      ReactStylesDiffMap props) {
    Map<String, Object> propsMap;
    if (props != null && props.toMap() != null) {
      propsMap = props.toMap();
    } else {
      // Non-Fabric will always follow this path, initial props are never provided;
      return ReactLithoView.create(context, null, null);
    }
    Component component = createComponentInstanceWithPropsMap(new ComponentContext(context), propsMap);
    return ReactLithoView.create(context, component, propsMap);
  }

  Override
  public Component createComponentInstanceWithPropsMap(ComponentContext context,
      Map<String, Object> propsMap) {
    SampleComponent.Builder componentBuilder = SampleComponent.create(context);
    setComponentBuilderPropsWithMap(componentBuilder, propsMap);
    return componentBuilder.build();
  }

  Override
  public void updateProperties(ReactLithoView view, ReactStylesDiffMap props) {
    super.updateProperties(view, props);
    Map<String, Object> propsMap = props.toMap();
    Map<String, Object> oldProps = view.getProps();
    if (oldProps == null) {
      // Non-Fabric RN will always terminate here; we do not store props, nor do we need to.;
      // Prop updating happens incrementally in non-Fabric RN.;
      return;
    }
    Map<String, Object> mergedProps = new HashMap<>(oldProps);
    mergedProps.putAll(propsMap);
    SampleComponent.Builder componentBuilder = SampleComponent.create(new ComponentContext(view.getComponentContext()));
    setComponentBuilderPropsWithMap(componentBuilder, mergedProps);
    view.setProps(mergedProps);
    view.setComponent(componentBuilder.build());
  }

  private void setComponentBuilderPropsWithMap(SampleComponent.Builder componentBuilder,
      Map<String, Object> propsMap) {
    if (propsMap != null && propsMap.containsKey("title")) {
      componentBuilder.title((((String)propsMap.getOrDefault("title", null))));
    }
    if (propsMap != null && propsMap.containsKey("imageUri")) {
      componentBuilder.imageUri(android.net.Uri.parse(((String)propsMap.getOrDefault("imageUri", null))));
    }
  }

  Override
  public GeneratedSampleComponentShadowNode createShadowNodeInstance(ReactApplicationContext context) {
    return new GeneratedSampleComponentShadowNode();
  }

  Override
  public Class<? extends ComponentsShadowNode> getShadowNodeClass() {
    return GeneratedSampleComponentShadowNode.class;
  }

  Override
  public void updateState(ReactLithoView view, StateWrapper stateWrapper) {
    view.setStateWrapper(stateWrapper);
  }
}
```

Reviewed By: shergin

Differential Revision: D14846423

fbshipit-source-id: 4eeeb991f7e32c0cec5e9307d6175b81c8fd034e
2019-05-08 14:53:51 -07:00
Ramanpreet Nara f2618fd81b Fix OSS Android build (#24764)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/24764

The `test_android` CI build was failing:

```
./scripts/circleci/buck_fetch.sh
+ buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
Not using buckd because watchman isn't installed.
Picked up _JAVA_OPTIONS: -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
PARSING BUCK FILES: FINISHED IN 1.1s
No build file at ReactAndroid/src/main/libraries/fbjni/BUCK when resolving target //ReactAndroid/src/main/libraries/fbjni:java.

This error happened while trying to get dependency '//ReactAndroid/src/main/libraries/fbjni:java' of target '//ReactAndroid/src/main/java/com/facebook/react/turbomodule/core:jscallinvokerholder'
Exited with code 1
```

The problem was that I was using `react_native_dep("libraries/fbjni:java")` to access JNI classes like `HybridData`. In open source this target translates to the path `//ReactAndroid/src/main/libraries/fbjni`, which doesn't exist. Instead, the actual classes are available at the path `//ReactAndroid/src/main/java/com/facebook/jni`. Therefore, I changed the target to `react_native_dep("java/com/facebook/jni:jni")`. This is exactly how the bridge (i.e: `//ReactAndroid/src/main/java/com/facebook/react/bridge:bridge`) accesses JNI clases.

Reviewed By: hramos

Differential Revision: D15261218

fbshipit-source-id: 659a5627389bbca3603db7de347618cd400d4ffc
2019-05-08 12:28:26 -07:00
Alan Kenyon 09f17a4e29 AccessibilityInfo.announceForAccessibility (#24746)
Summary:
AccessibilityInfo.announceForAccessibility is currently only available on iOS. I've added the Android specific implementation, updated RNTester, and the documentation.

[Android] [Added] - Added AccessibilityInfo.announceForAccessibility for Android
[General] [Added] - RNTester example for AccessibilityInfo.announceForAccessibility
Pull Request resolved: https://github.com/facebook/react-native/pull/24746

Differential Revision: D15258054

Pulled By: cpojer

fbshipit-source-id: 3e057a5c32b28e30ea2ee74a18854b012cd2dbfd
2019-05-08 03:58:13 -07:00
Dulmandakh fd6386a07e custom fonts support The Android Way (#24595)
Summary:
In https://github.com/facebook/react-native/pull/23865, RN introduced support for custom fonts the Android Way. But it introduced performance regression because it'll lookup for a font using getIdentifier() every time fontFamily changed. This PR fixes regression by requiring custom fonts to be listed in **fonts** array, and populating **mTypeCache** at first use using the list.

[Android] [Changed] - Require custom fonts to list in **fonts** array. Fixes performance regression.
Pull Request resolved: https://github.com/facebook/react-native/pull/24595

Reviewed By: mdvacca

Differential Revision: D15184590

Pulled By: fkgozali

fbshipit-source-id: e3feb2396609583ebc95101130186a1f5af931da
2019-05-07 18:44:10 -07:00
Piotr Trocki a5c57b4ed4 onKeyPress is not fired on Android when entering an Emoji (#24717)
Summary:
Resolve #24690

This is very simple unicode detecting. Should I improve this solution creating StringsUtils for detecting unicodes in whole react-native project ?

[Android][Fixed] onKeyPress method is calling, when user type emoji
Pull Request resolved: https://github.com/facebook/react-native/pull/24717

Differential Revision: D15238388

Pulled By: cpojer

fbshipit-source-id: 038b1040e1c44fd6f9401a3988a782f5778e1209
2019-05-07 04:25:14 -07:00
Marc Mulcahy 70e2ab2ec9 Update Android view state when accessibility states are changed. (#24678)
Summary:
In #24095, we removed the code that changes the underlying Android view's enabled state to false when "disabled" is included in the accessibility states, which seems correct. The Android view's state shouldn't mirror the accessibility state, it should be the other way round-- the accessibility state should represent the state of the view.

It seems that the existing test is brokenly setting the disabled state in the Javascript object, and then querying the Android view's enabled state to confirm the change. If the Button implementation is actually the culprit, then IMHO, the correct fix would be to have the Button implementation manipulate the Android View's enabled state, not the accessibilityStates code.

[android] [fix] - Fix internal test case around disabled state of buttons
Pull Request resolved: https://github.com/facebook/react-native/pull/24678

Differential Revision: D15237590

Pulled By: cpojer

fbshipit-source-id: d7ebefbcba9d4d9425da4285175302e4b6435df7
2019-05-07 03:23:38 -07:00
Eileen Zhang bfd06958f4 Revert D14817741: Move message queue initialization in ReactContext into its own method
Differential Revision:
D14817741

Original commit changeset: f314a526c653

fbshipit-source-id: 9925e6473a261f47582c8db5cc7e9d77836cdbb5
2019-05-06 19:14:21 -07:00
Eileen Zhang 15f17d3c05 Revert D15194220: [Venice] Allow creating ThemedReactContext without CatalystInstance
Differential Revision:
D15194220

Original commit changeset: 64689cbe79c8

fbshipit-source-id: 346009e3ee00286b095f26c78abffc73efea21dd
2019-05-06 19:14:21 -07:00
Emily Janzer 6cf784fae7 Allow creating ThemedReactContext without CatalystInstance
Summary: I'm not sure if this is a good idea. Right now FabricUIManager creates a ThemedReactContext in addRootView() using the RAC you pass in. If you pass in an RAC without a Catalyst instance, this will throw; this diff makes it so it'll throw the next time you try to actually try to access the CatalystInstance, instead. I don't know if we're really relying on this right now, but we need to be able to create a ThemedReactContext without a CatalystInstance for Venice (for now, until we actually go through and get rid of TRC's dependency on the CatalystInstance entirely - but that'll be a lot more work)

Reviewed By: mdvacca

Differential Revision: D15194220

fbshipit-source-id: 64689cbe79c84ae33fe16e3dc396e3c69ec8e20f
2019-05-06 15:51:13 -07:00
Emily Janzer c6b4eb7dcf Move message queue initialization in ReactContext into its own method
Summary: Refactoring ReactContext to move message queue initialization into its own function that can be called independently of initializeWithInstance. This allows you to create a ReactContext with message queue threads without a CatalystInstance.

Reviewed By: mdvacca

Differential Revision: D14817741

fbshipit-source-id: f314a526c6534792714e5ba55dd873f1728c6b9f
2019-05-06 15:51:13 -07:00
Luna Wei 5f027ec64d Rearrange order of manageChildren
Summary:
[General] [Fix] - Reorder operations of native view hierarchy

When we update the native view hierarchy in `manageChildren` we:
1. iterate through all views we plan to remove and remove them from the native hierarchy
2. iterate through all views we plan to add and add them to the native hierarchy
3. iterate through all views we plan to delete and delete them (remove them from memory)

This covers these cases:
a. A view is moved from one place to another -- handled by steps 1 & 2
b. A view is added -- handled by step 2
c. A view is deleted -- handled by step 1 & 3

> Note the difference between remove and delete

Everything above sounds fine! But...

The important bit:
**A view that is going to be deleted asynchronously (by a layout animation) is NOT removed in step 1. It is removed and deleted all in step 3.** See: https://fburl.com/ryxp626i

If the reader may recall we solved a similar problem in D14529038 where we introduced the `pendingIndicesToDelete` data structure to keep track of views that were marked for deletion but had not yet been deleted. An example of an order of operations that we would've solved with D14529038 is:

* we "delete" the view asynchronously (view A) in one operation
* we add a view B that shares a parent with view A in subsequent operation
* view A finally calls its callback after the animation is complete and removes itself from the native view hierarchy

A case that D14529038 would not fix:
1. we add a view B in one operation
2. we delete a view A in the same operation asynchronously because it's in a layout animation
3. ... etc.

What we must remember is that the index we use to add view B in step 1 is based on the indices assuming that all deletions are synchronous as this [comment notes](https://fburl.com/j9uillje): removals (both deletions and moveFroms) use the indices of the current order of the views and are assumed independent of each other. Whereas additions are indexed on the updated order (after deletions!)

This diff re-arranges the order in how we act upon the operations to update the native view hierarchy -- similar to how UIImplementation does its operations on the shadow tree here: https://fburl.com/j9uillje

By doing the removals and deletions first, we know that the addAt indices will be correct because either the view is removed from the native view hierarchy or `pendingIndicesToDelete` should be tracking an async delete already so the addAt index will be normalized

Reviewed By: mdvacca

Differential Revision: D15112664

fbshipit-source-id: 85d4b21211ac802183ca2f0fd28fc4437d312100
2019-05-06 08:35:40 -07:00
David Vacca 57074143ac Eager initialize more Fabric classes
Summary:
This diff forces the eager initialization of some additional classes into FabricJSIModuleProvider.loadClasses().
This is a "hack" that will be removed in the near future

Reviewed By: JoshuaGross

Differential Revision: D15208977

fbshipit-source-id: 2e2c7856839b6c6888452800ef6da7f269e46735
2019-05-03 17:23:53 -07:00
Joshua Gross ff1de68e67 Java objects should own C++ State
Summary: When passing StateWrapper objects across the JNI, we were not ensuring that the Java objects would own the C++ state. This was initially done because I assumed that in Java, State would either be used immediately or discarded, so this wouldn't be unsafe. As it turns out, it makes sense in some cases to store the StateWrapper in Java and use it later, potentially even in other threads, so we need to make sure we maintain ownership of the C++ object from the Java object.

Reviewed By: shergin

Differential Revision: D15206194

fbshipit-source-id: a437d921ba00b194cf08bad80666bd99baf11d52
2019-05-03 15:51:19 -07:00
Valentin Shergin 0f2a09d1f6 Fabric: MountingCoordinator - the new way to ensure ordering of mount transaction
Summary:
TBD.
This thing fixes flickering during appearing of Fabric screens on iOS.

Reviewed By: mdvacca

Differential Revision: D15116079

fbshipit-source-id: 95ed0ba94667cad67fe4317025128d01b34f69c5
2019-05-03 15:11:35 -07:00
Valentin Shergin 4803cab8c4 Fabric: MountingTelemetry and refinments in TimeUtils
Summary: This diff implements encapsulating all time metrics in a single class for better extensibility and readability.

Reviewed By: JoshuaGross

Differential Revision: D15179835

fbshipit-source-id: 62bdf94435a0d37a87ad9bad613cc8e38043a235
2019-05-03 15:11:34 -07:00
Ramanpreet Nara d77adcadbe Fix OSS build
Summary:
`CatalystInstanceImpl.cpp` now depends on `JSCallInvoker` and `JavaJSCallInvokerHolder`. Therefore, we need to correctly adjust the OSS builds to include these dependencies into the `libreactnativejni.so` file.

I made `ReactCommon/turbomodule/jscallinvoker` a static library `libjscallinvoker.a`. I then made `ReactAndroid/src/main/jni/react/jni`'s `libreactnativejni.so` depend on that static library. Also, because the Android NDK build system doesn't support header namespaces, I had to use the filesystem to simulate them. This is why all the `.cpp` and `.h` files for `JSCallInvoker` were moved to a `jsireact` folder.

Reviewed By: mdvacca

Differential Revision: D15194821

fbshipit-source-id: 0cee682e41db53d0619f56ad017d5882f6d554aa
2019-05-03 13:31:20 -07:00
Ramanpreet Nara cba205b82c Introduce TurboModuleManagerDelegate
Summary:
`TurboModuleManagerDelegate` is an abstract base class with the following API:

```
  public TurboModule getModule(String name, ReactApplicationContext reactApplicationContext);
  public CxxModuleWrapper getLegacyCxxModule(String name, ReactApplicationContext reactApplicationContext);
```

```
  std::shared_ptr<TurboModule> getTurboModule(std::string name, jni::global_ref<JTurboModule> turboModule, std::shared_ptr<JSCallInvoker> jsInvoker) override;
  std::shared_ptr<TurboModule> getTurboModule(std::string name, std::shared_ptr<JSCallInvoker> jsInvoker) override;
```

On the C++ side, when asked to provide a TurboModule with name `name`:

1. First, is this a CxxModule? If so:
    1. Create the CxxModule and return
2. Otherwise:
    1. Somehow get a Java instance of the TurboModule
    2. If this Java object represents a CxxModule, like `FbReactLibSodiumModule`:
        1. Grab the C++ part of this object, and wrap it in a `TurboCxxModule.cpp` and return.
    3. Otherwise:
        1. Wrap the Java object in a C++ HostObject and return.

This pseudocode demonstrates how we'd use `TurboModuleManagerDelegate` to implement `__turboModuleProxy`.
```
__turboModuleProxy(name, jsCallInvoker):
  let cxxModule = TurboModuleManagerDelegate::getTurboModule(name, jsCallInvoker)
  if (!cxxModule) {
    return cxxModule;
  }

  // JNI Call that forwards to TurboModuleManagerDelegate.getLegacyCxxModule
  let javaCxxModule : CxxModuleWrapper = TurboModuleManager.getLegacyCxxModule(name)

  if (!javaCxxModule) {
    return std::shared_ptr<react::TurboCxxModule>(javaCxxModule.getModule())
  }

  // JNI Call that forwards to TurboModuleManagerDelegate.getModule
  let javaModule : TurboModule = TurboModuleManager.getModule(name)

  if (!javaCxxModule) {
    return TurboModuleManagerDelegate::getTurboModule(name, javaModule, jsCallInvoker)
  }

  return null
```

Reviewed By: mdvacca

Differential Revision: D15111335

fbshipit-source-id: c7b0aeda0e4565e3a2729e7f9604775782b6f893
2019-05-03 13:31:20 -07:00
Ramanpreet Nara ef4955fefe Make async calls work
Summary:
JSCallInvoker requires a `std::weak_ptr<Instance>` to create. In our C++, `CatalystInstance` is responsible for creating this `Instance` object. This `CatalystInstance` C++ initialization is separate from the `TurboModuleManager` C++ initialization. Therefore, in this diff, I made `CatalystInstance` responsible for creating the `JSCallInvoker`. It then exposes the `JSCallInvoker` using a hybrid class called `JSCallInvokerHolder`, which contains a `std::shared_ptr<JSCallInvoker>` member variable. Using `CatalystInstance.getJSCallInvokerHolder()` in TurboModuleManager.java, we get a handle to this hybrid container. Then, we pass it this hybrid object to `TurboModuleManager::initHybrid`, which retrieves the `std::shared_ptr<JSCallInvoker>` from the `JavaJSCallInvokerHandler`.

There were a few cyclic dependencies, so I had to break down the buck targets:
- `CatalystInstanceImpl.java` depends on `JSCallInvokerHolderImpl.java`, and `TurboModuleManager.java` depends on classes that are packaged with `CatalystInstanceImpl.java`. So, I had to put `JSCallInvokerHolderImpl.java` in its own buck target.
- `CatalystInstance.cpp` depends on `JavaJSCallInvokerHolder.cpp`, and `TurboModuleManager.cpp` depends on classes that are build with `CatalystInstance.cpp`. So, I had to put `JavaJSCallInvokerHolder.cpp` in its own buck target. To make things simpler, I also moved `JSCallInvoker.{cpp,h}` files into the same buck target as `JavaJSCallInvokerHolder.{cpp,h}`.

I think these steps should be enough to create the TurboModuleManager without needing a bridge:
1. Make `JSCallInvoker` an abstract base class.
2. On Android, create another derived class of `JSCallInvoker` that doesn't depend on Instance.
3. Create `JavaJSCallInvokerHolder` using an instance of this new class somewhere in C++.
4. Pass this instance of `JavaJSCallInvokerHolder` to Java and use it to create/instatiate `TurboModuleManager`.

Regarding steps 1 and 2, we can also make JSCallInvoker accept a lambda.

Reviewed By: mdvacca

Differential Revision: D15055511

fbshipit-source-id: 0ad72a86599819ec35d421dbee7e140959a26ab6
2019-05-03 13:31:20 -07:00
Joshua Gross 4a1d532674 Convert FabricUIManager.measure params to floats
Summary: Convert FabricUIManager.measure params to floats. Currently we convert parameters to ints across the JNI boundary, and then back to floats several times in Java. This is unnecessary and actually makes measurements trickier. The new implementation uses floats across the JNI boundary and uses Float.POSITIVE_INFINITY to represent unconstrained values, which is consistent with Fabric C++ as well.

Reviewed By: shergin, mdvacca

Differential Revision: D15176108

fbshipit-source-id: cf849b3773007637f059279460163872f300a4aa
2019-05-03 12:36:28 -07:00
Marc Horowitz 4900077e83 Add libfolly_futures target
Summary: This new target provides dependencies for using folly futures

Reviewed By: willholen

Differential Revision: D15018282

fbshipit-source-id: c38ad4775102b9f0c10b3a52c5a18f00aa398322
2019-05-01 18:44:26 -07:00
Marc Horowitz 709baabb62 add to inputs in buildReactNdkLib so gradle will rebuild on more changes
Summary: This make iteration work better without needing to clean as much

Reviewed By: willholen

Differential Revision: D15018285

fbshipit-source-id: 034f5529e2e51711aeaa75360ad10bb1f85c7fb8
2019-05-01 18:44:26 -07:00
Marc Horowitz 7486c77ab5 make prepareGlog idempotent
Summary:
The path to copy log_severity.h could refer to the
destination, which would result in an empty file being copied on some
rebuilds.

Reviewed By: willholen

Differential Revision: D15018283

fbshipit-source-id: 0081526a9686de8c74753738c165753de6dda18d
2019-05-01 18:44:26 -07:00
Tim Wang 88dbb4558c Use class canonical name for PARTIAL_WAKE_LOCK tag (#24673)
Summary:
When acquiring the `PARTIAL_WAKE_LOCK`, Android requires a tag to identify the source, normally the class name. This tag will show on dumpsys call and Google Play developer console.

`getSimpleName` will work fine as long as not enable ProGuard, in my case, it transformed the class name to just `"c"`, and I take my half day to find where the `c` comes from.

`getCanonicalName` will add the package path, which is more friendly for developers.

Later we can even let the developer choose the tag name, but this will require API break changes.

[Android] [Changed] - Use class canonical name for PARTIAL_WAKE_LOCK tag
Pull Request resolved: https://github.com/facebook/react-native/pull/24673

Differential Revision: D15164306

Pulled By: cpojer

fbshipit-source-id: fd65f9e5250c180b0053940b17877fe36af5d48b
2019-05-01 02:53:54 -07:00
David Vacca b3a07685f2 Add debug information in Mounting Manager
Summary: Easy diff that adds debug information in Mounting Manager

Reviewed By: JoshuaGross

Differential Revision: D15076577

fbshipit-source-id: 183c87c929ea7a99f0667956c33012d7dfdb246e
2019-04-30 15:05:02 -07:00
David Vacca abbeac9bb3 Refactor mapping of ComponentNames in FabricUIManager
Summary: The map of sComponentNames ONLY contains the names of components that are different between JS and Android. This diff adds a method to unify the way we use this map.

Reviewed By: shergin

Differential Revision: D15076549

fbshipit-source-id: 9df750dca305e55cb44037bc63f3ebb6476c8b81
2019-04-30 15:05:02 -07:00
David Vacca 532afbde6e Add support for Modal in Android
Summary: This diff implements Modal for Android in Fabric

Reviewed By: JoshuaGross

Differential Revision: D15069863

fbshipit-source-id: 4171c9590a4a7a1f4f80cf9b08ea9a9e94b9097a
2019-04-30 15:05:01 -07:00
Michał Pierzchała 49d26eb0c4 cleanup RedBox message and stack output (#24662)
Summary:
Cleanup RedBox messages and stack traces. This PR consists of 2 changes (I'm good with splitting them up if you'd like):

- [general] filter out some of the internal callsites from the symbolicated stack (I thought about using monospace font for title with code frame, but it looks weird)
- [ios][android] strip ANSI characters (coming from colored Babel code frame) from the error message

I think it's ok to strip it inside native handlers so we can still have a colorful code frame in the terminal output.

**JS Code frame:**

|before|after|
|--|--|
|<img width="400" alt="Screenshot 2019-04-30 at 12 32 05" src="https://user-images.githubusercontent.com/5106466/56956590-ef678d80-6b44-11e9-9019-6801f050ab0d.png">|<img width="400" alt="Screenshot 2019-04-30 at 12 52 43" src="https://user-images.githubusercontent.com/5106466/56957302-f42d4100-6b46-11e9-869b-ea9c7ce5b90f.png">|

|before|after|
|--|--|
|![image](https://user-images.githubusercontent.com/5106466/56959472-c8618980-6b4d-11e9-84be-6261d8375f4a.png)|![image](https://user-images.githubusercontent.com/5106466/56959463-bc75c780-6b4d-11e9-9d8b-25ffe46c87cf.png)|

**Filtered stack traces:**

|before|after|
|--|--|
|<img width="50%" alt="Screenshot 2019-04-30 at 12 27 21" src="https://user-images.githubusercontent.com/5106466/56956641-0908d500-6b45-11e9-8cdc-8c2a34a071e5.png"><img width="50%" alt="Screenshot 2019-04-30 at 12 27 28" src="https://user-images.githubusercontent.com/5106466/56956642-0908d500-6b45-11e9-921c-fabfb8515cc0.png">|<img width="100%" alt="Screenshot 2019-04-30 at 12 26 55" src="https://user-images.githubusercontent.com/5106466/56956650-0efeb600-6b45-11e9-9f5f-f10dd69580d1.png">|

There's still a lot of places that are hard to read, but I think this is a good start towards more readable errors.

cc cpojer

[General][Changed] - Cleanup RedBox message and stack output
Pull Request resolved: https://github.com/facebook/react-native/pull/24662

Differential Revision: D15147571

Pulled By: cpojer

fbshipit-source-id: 1de4e521af988fa7fc709b6accd0ddd984388e72
2019-04-30 07:35:14 -07:00
David Vacca 61d2f1e6be Display wrong view hierarchy in Test exceptions
Summary: Trivial diff that adds extra logging information on Exceptions that are thrown by the FabricViewTest

Reviewed By: shergin

Differential Revision: D14817899

fbshipit-source-id: 32e1d1fcd1292715dfcf2750d3f14c668927c8b8
2019-04-30 01:48:25 -07:00
David Vacca f98880b1a3 - Fix mounting of views when a re-order happen caused by changes in viewflattening
Summary:
This diff fixes a bug that is reproducible when a view is reordered in a different level of hierarchy in the react tree.
Even if this is not supported by react, this can still happen because of viewFlattening.

Reviewed By: shergin

Differential Revision: D14817452

fbshipit-source-id: 13425b0e6a280affe681e80b4a6daa17ee56251a
2019-04-30 01:48:25 -07:00
David Vacca 81d0f9a690 Ensure proper Synchronization on ReactChoreographer
Summary: This diff refactors the way we synchronize in ReactChoreographer using a lock object

Reviewed By: ejanzer

Differential Revision: D14913056

fbshipit-source-id: e86c4395d5d3c3fd5b7330b72c14920b536f74ce
2019-04-29 18:12:01 -07:00
Emiel Mols 6f6696fa63 ReactAndroid: JS errors during bundle load were reported as UnknownCppException (#24648)
Summary:
This fixes a regression on Android introduced by f3e5cce where JS errors thrown during bundle load were lost (shown only as UnknownCppException). It is especially tough to debug (custom) bundling errors without seeing the javascript error.

Root cause hypothesis: since switching to clang, `JSError`s thrown in ReactCommon's `JSCRuntime::checkException` were never matched as `std::exception` in ReactAndroid's `convertCppExceptionToJavaException` due to these missing flags.

I'm a bit shy on low-level details concerning how C++ rtti works exactly around catching exceptions thrown in other libraries. All I can say that with this change, a `bundle.android.js` that only contains `throw new Error("wtf");` now nicely outputs a message and stack trace in the logcat. Before (and since DanielZlotin's switch to clang) it just outputted:

```
2019-04-29 12:17:59.365 1162-1306/com.rntest E/unknown:ReactNative: Exception in native call
    com.facebook.jni.UnknownCppException: Unknown
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loop(Looper.java:214)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
        at java.lang.Thread.run(Thread.java:764)
```

[Android] [Fixed] - JS errors during bundle load were reported as UnknownCppException.
Pull Request resolved: https://github.com/facebook/react-native/pull/24648

Differential Revision: D15123525

Pulled By: mdvacca

fbshipit-source-id: 74b5ce9ebae38d172446b6e31739d795c601947b
2019-04-29 09:51:15 -07:00
Guilherme Iscaro 20b09e4c45 The ART '<Surface>' becomes invisible in Android (#22624)
Summary:
Hello Everyone, this series of commits helps to fix problems related to ART on Android. The main problem in here is that the ART components would disappear if the user turns off the screen and then turn it on again.  It's important to note that this behaviour only occurs after Android N (7.1 or higher).
Pull Request resolved: https://github.com/facebook/react-native/pull/22624

Differential Revision: D15122573

Pulled By: cpojer

fbshipit-source-id: e7fb8b9280b4c52562e3d0c1a89759d4d31cd53d
2019-04-29 09:30:56 -07:00
Janic Duplessis 9fba85569c Fix crash when borderXColor is null on Android (#24640)
Summary:
On android when borderXColor is null it causes the app to crash with:

```
04-28 17:44:18.021 20114 20213 E unknown:ReactNative: com.facebook.react.bridge.NoSuchKeyException: borderBottomColor
04-28 17:44:18.021 20114 20213 E unknown:ReactNative: 	at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:111)
04-28 17:44:18.021 20114 20213 E unknown:ReactNative: 	at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:115)
04-28 17:44:18.021 20114 20213 E unknown:ReactNative: 	at com.facebook.react.bridge.ReadableNativeMap.getInt(ReadableNativeMap.java:158)
04-28 17:44:18.021 20114 20213 E unknown:ReactNative: 	at com.facebook.react.uimanager.ViewProps.isLayoutOnly(ViewProps.java:246)
04-28 17:44:18.021 20114 20213 E unknown:ReactNative: 	at com.facebook.react.uimanager.NativeViewHierarchyOptimizer.isLayoutOnlyAndCollapsable(NativeViewHierarchyOptimizer.java:482)
```

Basically it is missing a `isNull` check on the props map before trying to access the value.

Fixes #22727

[Android] [Fixed] - Fix a crash when borderXColor is null
Pull Request resolved: https://github.com/facebook/react-native/pull/24640

Differential Revision: D15120182

Pulled By: cpojer

fbshipit-source-id: bc41da572f04d8abf733b5a4e94a74a0f40acda1
2019-04-29 03:31:03 -07:00
Dulmandakh bb6f316c87 Gradle KTS (#24631)
Summary:
Convert root Gradle script to Kotlin DSL, and cleanup. Currently, there is not much benefit or advantage over Groovy scripts, except IDE support and it'll cache compiled KTS scripts on first run.

[Android] [Changed] - Convert root Gradle script to Kotlin DSL, and cleanup.
Pull Request resolved: https://github.com/facebook/react-native/pull/24631

Differential Revision: D15120190

Pulled By: cpojer

fbshipit-source-id: 86691db5c7746e71bb243ebc263c1a3075ee9a9e
2019-04-29 02:41:05 -07:00
Dulmandakh 30348f7899 bump android gradle plugin to 3.4.0 (#24463)
Summary:
This PR bumps Android Gradle Plugin to 3.4.0, which enables R8 shrinker by default and improves build performance significantly.

Disabled R8 for ReactAndroid because it'll strip out AndroidX and other libraries bundled in ReactAndroid.

[Android] [Changed] - bump Android Gradle plugin to 3.4.0
Pull Request resolved: https://github.com/facebook/react-native/pull/24463

Differential Revision: D15107117

Pulled By: hramos

fbshipit-source-id: 35a03dc9955e889c9399faeaf9a862e0fc044fc4
2019-04-27 09:43:19 -07:00
Kevin Gozali 4b4c8d4d02 android: renamed strings.xml to strings_unlocalized.xml
Summary: 9079beda9b wasn't enough to blacklist the strings.xml files from FB infra. So this is a better workaround. According to https://developer.android.com/guide/topics/resources/string-resource the .xml file names doesn't really matter, so this shouldn't break the ability to get the string resource in code, like `R.strings.foo`.

Reviewed By: yungsters

Differential Revision: D15103303

fbshipit-source-id: 6d5174a8dc9598930670d35434e1494f9eaea059
2019-04-26 15:34:09 -07:00
Dulmandakh 243070afe2 DialogModule supports only FragmentActivity (#23365)
Summary:
Now RN has only ReactActivity which extends AppCompatActivity, subclass of FragmentActivity, therefore no need to check if activity is FragmentActivity or not. This PR changes DialogModule to work only with FragmentActivity.

Also DialogFragment from Android is deprecated in API 28, and recommends to use DialogFragment from Support Library. Excerpt from DialogFragment documentation.

> **This class was deprecated in API level 28.**
> Use the Support Library DialogFragment for consistent behavior across all devices and access to Lifecycle.

**BREAKING CHANGE**: Brown field apps must extend FragmentActivity or its subclasses.

[Android] [Changed] - DialogModule supports only FragmentActivity
Pull Request resolved: https://github.com/facebook/react-native/pull/23365

Differential Revision: D14021986

Pulled By: cpojer

fbshipit-source-id: b0ede60ef19cec48111a12701659a8bc1f66c331
2019-04-26 02:46:24 -07:00
Build Service b46eda78a9 translation auto-update for i18n/fb4a.config.json on master
fbshipit-source-id: eaad91325c24d3e763910c46f95aa279fffea3a0
2019-04-25 22:41:19 -07:00
Build Service de29553818 translation auto-update for i18n/expresswifi.config.json on master
fbshipit-source-id: 88df8402fa6a64d18f6b73f357effbac23e0b6e4
2019-04-25 22:41:19 -07:00
Build Service 8eac1b3a4e translation auto-update for i18n/creatorapp.config.json on master
fbshipit-source-id: 71a74ed00df788b08533767924af7b772b327d4d
2019-04-25 22:41:18 -07:00
Build Service 86c2706d85 translation auto-update for i18n/bishop.config.json on master
fbshipit-source-id: 6ac2bf6d98f5af1e4ab0f99988224f92b9817ef2
2019-04-25 22:41:18 -07:00
Build Service 4585e3bd8e translation auto-update for i18n/analyticsapp.config.json on master
fbshipit-source-id: 7e418e80bdebe43a4c003a13629eaef3f1f97fab
2019-04-25 22:41:18 -07:00
Build Service 0db8226392 translation auto-update for i18n/adsmanager.config.json on master
fbshipit-source-id: b7f3a877004704368bb3e0e54dae2e7e50d3649c
2019-04-25 22:41:18 -07:00
Kevin Gozali 9079beda9b OSS: Marked strings.xml as non-translatable and removed irrelevant translations
Summary: These strings shouldn't be translated by FB system because each app has its own set of languages and/or translation outputs. We're keeping just values/strings.xml in the repo.

Reviewed By: cpojer

Differential Revision: D15087192

fbshipit-source-id: c4b6112f6dd010d317060ac6640b34e4b725c695
2019-04-25 16:29:23 -07:00
Kevin Gozali eb40b09bfd Back out "[react-native][PR] add support for native/downloadable fonts"
Summary: Original commit changeset: 67ba3148fb4b

Reviewed By: cpojer

Differential Revision: D15071309

fbshipit-source-id: 8ea6b40ae7cedd8aec1463373ccd219212fce0f5
2019-04-25 11:15:08 -07:00
Build Service 5592744825 translation auto-update for i18n/pages-manager.config.json on master
fbshipit-source-id: 0ddad3606613fe285bf10116d697096c7ab9779c
2019-04-25 10:59:50 -07:00
Build Service 27d2506dc7 translation auto-update for i18n/onavo-spaceship.config.json on master
fbshipit-source-id: 872f5a198325f4bb9c64d1af565738c293127c1d
2019-04-25 10:59:50 -07:00
Build Service 7a786ab1f0 translation auto-update for i18n/instagram.config.json on master
fbshipit-source-id: b349b15e647805ff824c97a4e9f650d52da73c22
2019-04-25 10:59:49 -07:00
Build Service b56e183f9e translation auto-update for i18n/instagram-igtv.config.json on master
fbshipit-source-id: 05869242c5d4df4bfff5556b234213508f1bc839
2019-04-25 10:59:49 -07:00
Build Service 8ddd37c56d translation auto-update for i18n/fb4a.config.json on master
fbshipit-source-id: 19ed7b34aff5385594696e66d925d40c766f9c00
2019-04-25 10:59:49 -07:00
Build Service 79bde6a48a translation auto-update for i18n/expresswifi.config.json on master
fbshipit-source-id: 302ee057295da87390d8606e0be81177d2c7ab29
2019-04-25 10:59:48 -07:00
Build Service 86462bfc84 translation auto-update for i18n/creatorapp.config.json on master
fbshipit-source-id: e003d25cc264e405700dae029ab07a56c4b7c508
2019-04-25 10:59:48 -07:00
Build Service 5628ac6447 translation auto-update for i18n/bishop.config.json on master
fbshipit-source-id: e83ff7061c7a6106cc4174b1512f9ae928a708b3
2019-04-25 10:59:48 -07:00
Build Service 28c18fcef5 translation auto-update for i18n/analyticsapp.config.json on master
fbshipit-source-id: 545d7d3d211996f2e600d92cddeac96c3c976378
2019-04-25 10:59:48 -07:00
Build Service ef4c9867d8 translation auto-update for i18n/adsmanager.config.json on master
fbshipit-source-id: 7f0c41e577c55458961e863c33ecd0f01a41b633
2019-04-25 10:59:47 -07:00
Marc Mulcahy 1aeac1c625 Additional Accessibility Roles and States (#24095)
Summary:
Assistive technologies use the accessibility role of a component to tell the disabled user what the component is, and provide hints about how to use it. Many important roles do not have analog AccessibilityTraits on iOS. This PR adds many critical roles, such as editabletext, checkbox, menu, and switch to name a few.

Accessibility states are used to convey the current state of a component. This PR adds several critical states such as checked, unchecked, on and off.

[general] [change] - Adds critical accessibility roles and states.
Pull Request resolved: https://github.com/facebook/react-native/pull/24095

Differential Revision: D15079245

Pulled By: cpojer

fbshipit-source-id: 941b30eb8f5d565597e5ea3a04687d9809cbe372
2019-04-25 06:13:07 -07:00
Thorben Primke 954f715b25 Adds Logic To Catch MissingWebViewPackageException (#24533)
Summary:
We are seeing crash reports that the webview is missing. In this case
it should fail gracefully so that a missing webview does not block
from using an app built with React Native.

The contains could also be changed to check for "webview" in general
to catch all webview related exception. It's currently checking on
for the specific string that I'm seeing in our app's crashreporting tool.

<img width="1507" alt="Screen Shot 2019-04-19 at 11 26 19 AM" src="https://user-images.githubusercontent.com/741767/56438307-5e1c2f80-6297-11e9-970b-a5095d18e9d7.png">

<img width="935" alt="Screen Shot 2019-04-19 at 11 32 58 AM" src="https://user-images.githubusercontent.com/741767/56438213-fa920200-6296-11e9-8008-5eb344eca8a8.png">

[Android] [Fixed] - The ReactCookieJarContainer/ForwardingCookieHandler now handles the missing WebView  gracefully.
Pull Request resolved: https://github.com/facebook/react-native/pull/24533

Differential Revision: D15062824

Pulled By: cpojer

fbshipit-source-id: 80805a47494f0d924b7ee029ce8ca0504eaeee57
2019-04-24 06:58:15 -07:00
Christoph Nakazawa 8d3e16831a Revert "improve RTL (#24069)" (#24580)
Summary:
This reverts commit b3c74967ca.

Fixes #24267

[Android] [Fixed] - Invalid text alignment for RTL fonts.
Pull Request resolved: https://github.com/facebook/react-native/pull/24580

Differential Revision: D15061667

Pulled By: cpojer

fbshipit-source-id: 6d02c9e938f1f8630ba691f57bdf79fd57db3bb2
2019-04-24 03:45:41 -07:00
David Aurelio 54af7fc645 `YGStyle`: wrap all fields into accessors
Summary:
@public

In order to encapsulate property access on `YGStyle`, as a first measure we wrap all fields with accessors.

This will e.g. enable dynamic property storage and instrumentation in the future.

All accessors have a `const` version that allows direct access via `const&`. For mutation, bit fields are wrapped with a custom reference object.

This style allows for the least amount of changes in client code. Property access simply needs appended parens, eg `style.direction` becomes `style.direction`.

Reviewed By: shergin

Differential Revision: D14999096

fbshipit-source-id: fbf29f7ddab520513d4618f5e70094c4f6330b30
2019-04-23 08:12:35 -07:00
Pavel Rotek 67be81968e Fix smooth scrolling on old devices (SDK >=16) (#24545)
Summary:
React Native Environment Info:
    System:
      OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
      CPU: (4) x64 Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz
      Memory: 1.12 GB / 15.55 GB
      Shell: 4.4.19 - /bin/bash
    Binaries:
      Node: 8.10.0 - /usr/bin/node
      Yarn: 1.13.0 - /usr/local/bin/yarn
      npm: 3.5.2 - /usr/bin/npm
    SDKs:
      Android SDK:
        API Levels: 16, 19, 22, 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 23.0.3, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.3, 27.0.3, 28.0.2, 28.0.3
        System Images: android-16 | Google APIs Intel x86 Atom, android-19 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
    npmPackages:
      react: 16.8.6 => 16.8.6
      react-native: git+https://github.com/facebook/react-native.git#v0.59.5 => 0.59.5
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

The workaround implemented in https://github.com/facebook/react-native/pull/21117 tries to fix
https://issuetracker.google.com/issues/112385925 scroll direction (according to the latest comments, the scroll direction problem has been reverted in security patches so not sure if the workaround is still valid).

But... proposed solution in fling method is using signum which leads to zero computedVelocityY in case of zero mOnScrollDispatchHelper.getYFlingVelocity() on old devices(Samsung s4 mini) even when real velocityY is non zero

```
final int correctedVelocityY = (int)(Math.abs(velocityY) * Math.signum(mOnScrollDispatchHelper.getYFlingVelocity()));
```

Proposed solution is to take signum from original velocityY in case of zero
```
float signum = Math.signum(mOnScrollDispatchHelper.getYFlingVelocity());
if (signum == 0) {
  signum = Math.signum(velocityY);
}
final int correctedVelocityY = (int)(Math.abs(velocityY) * signum);
```

The symptoms are the same as described in issue https://github.com/facebook/react-native/issues/22925, but proposed workaround doesn't work.

[Android][fixed] - Fix smooth scrolling on old devices (SDK >=16)
Pull Request resolved: https://github.com/facebook/react-native/pull/24545

Differential Revision: D15044834

Pulled By: cpojer

fbshipit-source-id: 3f523eb1a438df774e22387aecded433b9031ab9
2019-04-23 03:45:17 -07:00
Kudo Chien 040502b5d9 Fix jsc-android not found if building from source (#24547)
Summary:
If an app [builds from RN source](https://facebook.github.io/react-native/docs/building-from-source), there was an error for jsc-android not found.
It is a side effect of my previous [JSC as node dependency change](8e375850de)
For building from RN source case, the jsc-android is located at `/path/to/app/node_modules/jsc-android`.
Original gradle task will try to find it at `/path/to/app/node_modules/react-native/ReactAndroid/../node_modules/jsc-android`, as ReactAndroid project path was being override inside node_modules.
The change fixes the building from source case.

N/A
This change does not need to publish into changelog, as it is a master branch building fix.
Pull Request resolved: https://github.com/facebook/react-native/pull/24547

Differential Revision: D15044703

Pulled By: cpojer

fbshipit-source-id: a7d824b1a14064d46c4a2ec9ea28255179174c83
2019-04-23 02:27:44 -07:00
Dulmandakh ebed815fb5 fix CI instrumentation tests (#24561)
Summary:
It seems that **react_native_dep("android_res/com/facebook/catalyst/appcompat:appcompat")** is no longer used. fixes https://github.com/facebook/react-native/issues/24537

[Android] [Changed] - fix CI instrumentation tests
Pull Request resolved: https://github.com/facebook/react-native/pull/24561

Differential Revision: D15043343

Pulled By: hramos

fbshipit-source-id: 8dd657758e57c6c384850bf2d6c26535e1fdc42b
2019-04-22 23:20:14 -07:00
Will Holen 7442437d07 Remove unnecessary shared library dependency from libreactnativejni
Summary:
libreactnativejni does not need to link against libjsc directly:
that library is only needed by libjscexecutor.

Reviewed By: mhorowitz

Differential Revision: D15017942

fbshipit-source-id: fb545c9127221dab28434321fe9c116fe72f7507
2019-04-22 12:14:35 -07:00
Valentin Shergin af0daaf583 Fabric: Introducing MountingTransaction
Summary:
`MountingTransaction` encapsulates all artifacts of `ShadowTree` commit, particularly list of mutations and meta-data.
We will rely on this heavily in the coming diffs.

Reviewed By: JoshuaGross

Differential Revision: D15021795

fbshipit-source-id: 811da7afd7b929a34a81aa66566193d46bbc34f8
2019-04-20 10:53:16 -07:00
Emily Janzer f81d77c102 Change ViewManager.measure() to use Context instead of ReactContext
Summary: It seems like ReactContext isn't actually needed in measure functions. Changing the signature of ViewManager.measure() to take a Context instead.

Reviewed By: lunaleaps

Differential Revision: D14940330

fbshipit-source-id: b29987fd1d7f9c191a5f26138151082ca61cb351
2019-04-18 10:10:38 -07:00
Estevão Lucas e76a7df5b5 - Add DevSetting native module (making it cross-platform) (#24441)
Summary:
React Native has a `NativeModule` to manipulate programmatically the dev menu options (live reload, hot reload, remote debugging, etc), called [`DevSettings`](https://github.com/facebook/react-native/blob/master/React/Modules/RCTDevSettings.mm#L120). However this module is only available for iOS.

This PR brings the same `DevSettings` for Android, making it a cross-platform NativeModule.

Motivation: Right now if your app needs to programmatically reload RN, one option is to install [`react-native-restart`](https://www.npmjs.com/package/react-native-restart). It's a tiny dependency, but it's annoying to have to install it, while the code to do so is inside RN codebase. According to NPM, react-native-restart has ~12k weekly downloads, shows it's a recurring feature for many apps (my case).

Thus making `NativeModules.DevSettings` is a small increment in the codebase, just exposing the dev menu methods, to improve the Development Experience

[Android] [Added] - Add DevSetting native module (making it cross-platform)

With expection of `setIsShakeToShowDevMenuEnabled`, the following methods will be available for both platforms:
* reload
* setHotLoadingEnabled
* setIsDebuggingRemotely
* setIsShakeToShowDevMenuEnabled
* setLiveReloadEnabled
* setProfilingEnabled
* toggleElementInspector
Pull Request resolved: https://github.com/facebook/react-native/pull/24441

Differential Revision: D14932751

Pulled By: cpojer

fbshipit-source-id: 465e6a89c3beb5fd1ea22e80ea02e9438f596a09
2019-04-17 11:00:17 -07:00
Sam Mathias Weggersen 01bcde3ed8 Keyboard accessibility improvements (#24359)
Summary:
In order to meet our accessibility requirements we need to have full support for keyboard navigation. The Touchable components works with press/tap with a finger, but doesn't respond to 'enter' when using a keyboard. Navigation works fine. This PR adds an onClick listener to touchable views that have the onPress prop defined.

[Android] [Added] - Add View.OnClickListener to Touchable components when onPress is defined
Pull Request resolved: https://github.com/facebook/react-native/pull/24359

Differential Revision: D14971230

Pulled By: cpojer

fbshipit-source-id: ca5559ca1308ee6c338532a00dcea4d00fa57f42
2019-04-17 09:55:24 -07:00
Rick Ratmansky 44fe9904ac Removing more unused libraries from the repo
Summary: This is removing packages and libraries from the repo.  Any modified buck files simply change the redirect targets to something more appropriate (no logic actually changed)

Differential Revision: D14950721

fbshipit-source-id: 6c14f827b76ca1dbaf83dcb983930f362c6a27d4
2019-04-16 11:32:43 -07:00
Valentin Shergin 184cfd5594 Fabric: Bunch of small changes in ContextContainer
Summary:
So, changes:
* Correctness checks only in debug mode (codesize win?);
* `registerInstance` marked as const (because it's thread safe);
* ContextContainer::Shared also enforces constness;
* Using faster better::map;
* Using shared/RW mutex instead of regular one;
* SharedContextContainer got removed.

Reviewed By: sahrens

Differential Revision: D14920284

fbshipit-source-id: f0f8d970e7fae79a1abe3bc32827db9fd2d17e13
2019-04-16 07:35:07 -07:00
David Aurelio cdf3343dd0 Code formatting: allow short inline methods on one line
Summary:
@public

This allows short methods defined in class declarations to occupy a single line.
The change makes class declarations more readable.

Reviewed By: SidharthGuglani

Differential Revision: D14950012

fbshipit-source-id: 1321949475184181c6cceb86613f730e430763e2
2019-04-16 07:14:12 -07:00
Taylor123 faaa92bb04 disable momentum scrolling for horizontal ScrollView (#24045)
Summary:
Would like feedback from the community as this may not be the best solution for all

I would like to restrict (or paginate) the fling of a horizontal ScrollView when `snapToInterval` is set. This is not currently possible with `pagingEnabled`, since the pagination works only when items are the entire width of the ScrollView.

This implementation simply restricts the predicted `targetOffset` found from the `x` velocity and replaces it with the offset when the pan gesture ended.

To get pagination working, I may paginate based on the interval by calculating the offset delta from the beginning of the gesture to current offset and restricting the scrolling behavior to the `snapToInterval`. If this is preferred, I can update this PR or make a new one, but wanted to start a discussion since it seems like there are many in the community that would like this feature  #21302 .

[General] [Added] - add prop `disableIntervalMomentum` to disable the predictive scrolling behavior of horizontal ScrollViews
Pull Request resolved: https://github.com/facebook/react-native/pull/24045

Differential Revision: D14939754

Pulled By: sahrens

fbshipit-source-id: 26be19c47dfb8eed4d7e6035df53a77451e23081
2019-04-15 14:40:44 -07:00
Alston Lin e28b6f314a Fixed bug with Android's CameraRoll module where saveToPhotos crashed devices on a very small subset of devices
Summary:
For a small subset of Android devices, the following line of code caused the device to crash

```
output.transferFrom(input, 0, Long.MAX_VALUE);
```

According to the [Java docs](https://docs.oracle.com/javase/1.5.0/docs/api/java/nio/channels/FileChannel.html), this is what the function does.

> Transfers bytes into this channel's file from the given readable byte channel.
An attempt is made to read up to count bytes from the source channel and write them to this channel's file starting at the given position. An invocation of this method may or may not transfer all of the requested bytes; whether or not it does so depends upon the natures and states of the channels. Fewer than the requested number of bytes will be transferred if the source channel has fewer than count bytes remaining, or if the source channel is non-blocking and has fewer than count bytes immediately available in its input buffer.

Hence, using `Long.MAX_VALUE` seemed to be the standard way to transfer all bytes from one channel to the other.

However, it appeared that for some reason on a subset of old Android devices, the device tries to allocate `count` bytes of memory before transferring the bytes. Obviously, this caused a crash because no device has that much memory. This was fixed transferring bytes using a 1MB buffer.

Differential Revision: D14921778

fbshipit-source-id: 7fa46e10c656e23ae7d5679c72b278188f09ad0a
2019-04-15 12:38:30 -07:00
Estevão Lucas f70e58f355 - remove accessibilityComponentType and accessibilityTraits props (a11y) (#24344)
Summary:
Closes: https://github.com/facebook/react-native/issues/24016

React Native 0.57 introduced cross-platform `accessibilityRole` and `accessibilityStates` props in order to replace `accessibilityComponentType` (for android) and `accessibilityTraits` (for iOS). With #24095 `accessibilityRole` and `accessibilityStates` will increase, receiving more options, which seems to be a good moment to remove deprecated props.

Remove deprecated `accessibilityComponentType` and `accessibilityTraits` props.

[General] [Removed] - Remove accessibilityComponentType and accessibilityTraits props
Pull Request resolved: https://github.com/facebook/react-native/pull/24344

Reviewed By: rickhanlonii

Differential Revision: D14842214

Pulled By: cpojer

fbshipit-source-id: 279945e503d8a23bfee7a49d42f5db490c5f6069
2019-04-15 10:53:50 -07:00
Joshua Gross bbd925cdd1 MountingManager can create views with props in one step instead of two
Summary: Create views with props in one call instead of two. Backwards-compatible.

Reviewed By: shergin

Differential Revision: D14846424

fbshipit-source-id: cb53225579089f7e51d4e9d1fc9fc2e331a994c1
2019-04-15 01:46:04 -07:00
Valentin Shergin 792585fd48 Fabric: ContextContainer was moved to `utils` module
Summary: That allows avoiding circular deps and unnecessary deps on uimanager module.

Reviewed By: PeteTheHeat

Differential Revision: D14917227

fbshipit-source-id: fe7962ee528aa659d8bd23e3e46627722551d995
2019-04-12 15:14:48 -07:00
Kevin Gozali e3d3b2cab9 Fabric Android: added ReactUnimplementedView impl
Summary: Similar to iOS, here we provide the basic impl of unimplemented view.

Reviewed By: mdvacca

Differential Revision: D14895706

fbshipit-source-id: 9053edfb2175b370d9070b6921794dbcafa1f37a
2019-04-11 14:23:13 -07:00
Dulmandakh 9b80560715 fix surface BUCK, and CI (#24404)
Summary:
Fix surface BUCK, and make Android CI green.

[Android] [Changed] - fix surface BUCK, and make CI green.
Pull Request resolved: https://github.com/facebook/react-native/pull/24404

Differential Revision: D14888049

Pulled By: cpojer

fbshipit-source-id: b0e0440c3e22ff8f90f0ff99f9fcb6fed3689725
2019-04-11 04:32:50 -07:00
Mike Diarmid c953e0b431 JSStackTrace -> Ensure lineNumber exists before consuming (#24399)
Summary:
Fixes https://github.com/facebook/react-native/issues/24382

[ANDROID] [INTERNAL] - Fixed a `NoSuchKeyException` when parsing JS stack frames without line numbers.
Pull Request resolved: https://github.com/facebook/react-native/pull/24399

Differential Revision: D14890746

Pulled By: cpojer

fbshipit-source-id: cea3653076484ad624084c370439f8a39c303083
2019-04-11 03:15:28 -07:00
Vojtech Novak 3b1760d1d1 improve dev mode and HMR interop (#24377)
Summary:
Motivation is following - I'm sure many people encountered this because it has been like this for a long time.

1 . you're developing something on android, HMR and dev mode is enabled
2 . you go to dev settings, you disable dev mode because you want to see how something behaves
3 . you reload the app because that's what is required for the change to take effect
4 . you wait for the bundle to be compiled and served, and when that is done, you get an error message about HMR not being a registered callable module - because HMR is not available when `__DEV__ === false` (todo screenshot)

this fixes the described case by checking if HMR is enabled and dev mode disabled when reloading (step 3) and disables HMR in that case.

this also fixes the case when dev mode is disabled and without knowing it, you try to enable HRM (will enable both dev hmr and dev mode).

[Android] [Changed] - improve developer experience around Dev mode and HMR interop
Pull Request resolved: https://github.com/facebook/react-native/pull/24377

Differential Revision: D14890695

Pulled By: cpojer

fbshipit-source-id: 95b6ff4131c6d05a32aadd09a9d5ed11f602122c
2019-04-11 02:41:28 -07:00
David Vacca 261cda92de Temporarly ignore exception when running animations
Summary: Running animations sometimes fail in Android. we are ignoring those failures temporarly

Reviewed By: fkgozali

Differential Revision: D14884510

fbshipit-source-id: 66d6113e12b1bd67e8bcc564943b423825b4cea6
2019-04-10 17:31:32 -07:00
David Vacca ebbc4f6cc4 Adding debug information in Mounting Manager
Summary: This diff adds extra debug information in the mounting manager

Reviewed By: shergin

Differential Revision: D14817456

fbshipit-source-id: 5619c94eb76cdc20f5d7767f1aa4263e63f8d021
2019-04-10 16:18:21 -07:00
David Vacca 40590348ea Recycle only views created by RN
Summary: This diff ensure that only views created by RN are taken into consideration for recycling.

Reviewed By: fkgozali

Differential Revision: D14874678

fbshipit-source-id: ea7dd5a0f29f6acf0dce8573fc77b012395476bd
2019-04-10 14:13:42 -07:00
Dulmandakh f01c4e2a14 add support for native/downloadable fonts (#23865)
Summary:
Android API 26 and Android Support Library 26 added support for font resource type and native/downloadable fonts. It allows apps to easily download fonts from online providers, but also use of various font weights other than normal and bold, like medium. So it deprecated APIs for asset fonts, and should be removed in the future.

Advantages:
- Just copy font files in res/font and use it specifying filename (without extension) in fontFamily
- Define custom font-family using XML file (in res/font) and font files, it may have many weights and styles. See PR for example.
- Define configuration to download fonts from online font providers, and use it.

See https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml and https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts

[Android] [Changed] - add support for custom/downloadable fonts
Pull Request resolved: https://github.com/facebook/react-native/pull/23865

Differential Revision: D14506542

Pulled By: hramos

fbshipit-source-id: 67ba3148fb4b548cdbc779213cf6c1b2c3baffd2
2019-04-10 13:53:25 -07:00
Sebastian McKenzie d338a60cbe Remove copyToClipBoardMiddleware
Summary:
This diff removes the copyToClipBoardMiddleware. This was exposing the /copy-to-clipboard endpoint that allowed unauthenticated access to writing to a developers clipboard.

This was only used in a single place, the Android red box dialog, so I've removed it from there.

Reviewed By: cpojer

Differential Revision: D14790813

fbshipit-source-id: 80e044eefd9658b8c5885643cdadf7947c00d34a
2019-04-10 13:40:01 -07:00
Luna Wei 135ba492fb Detach dependency on RRV for Instance Manager
Summary: Remove dependency on ReactRootView in ReactInstanceManager by creating a rough interface (ReactRoot) so that either a Surface or ReactRootView can be attached to ReactInstanceManager.

Reviewed By: ejanzer, mdvacca

Differential Revision: D14158890

fbshipit-source-id: b7ab4654b1e0ef8343230a3c15023653a7f23a4b
2019-04-10 13:13:16 -07:00
Пётр Потапов a05b409b38 Fix: specific border radius corner causes visual bug on other corners (#24390)
Summary:
Fixes #22511

I understand the motivation of adding extraRadiusForOutline to corner radius: without it there can be an empty space between border and view's background color.

So I add simple check: if corner radius is more than zero we still add extraRadiusForOutline. And if not, we don't add it to prevent all the corners to become slightly curved.

[GENERAL] [Fixed] -  fix of Android's bug that causes all the corners to become slightly curved if only specific corners' radius should be more than zero.
Pull Request resolved: https://github.com/facebook/react-native/pull/24390

Differential Revision: D14870476

Pulled By: cpojer

fbshipit-source-id: df40fc584a2f8badc499413cb3c4e4d96b9e18cf
2019-04-10 06:44:20 -07:00
David Vacca db8e3f7744 Fix Lint warnings
Summary: Trivial reorder on buck dependencies and import in ComponentRegistry.cpp

Reviewed By: shergin

Differential Revision: D14779320

fbshipit-source-id: df4111d4ecfb04d67c7170f0800a745656100fb4
2019-04-09 20:22:40 -07:00
Will Holen 094f221a0c Move JSI source files into a separate directory
Summary: This will simplify updating the JSI API from upstream in the future.

Reviewed By: mhorowitz

Differential Revision: D14762674

fbshipit-source-id: fa4a86f08425943e301da4ef3df9893ebaa1493e
2019-04-09 11:44:32 -07:00
David Aurelio 2d8ad076fe JNI: set language level to C++11
Summary:
@public

compiler flags were pushed to C++14, but we don’t currently have any code that requires it. Setting to `-std=c++11` in order to fix the OSS build.

Reviewed By: SidharthGuglani

Differential Revision: D14833737

fbshipit-source-id: df2cd7da8c7124e89863c90d7b77bcf86c495618
2019-04-09 03:11:47 -07:00
Spencer Ahrens 8ec13c306c Fix tests with JavaOnlyMap
Summary: Need to force the double thing in more places.

Reviewed By: cpojer

Differential Revision: D14835792

fbshipit-source-id: fb7a5435675b322d5fbbe9858e08804e9abe65db
2019-04-08 23:07:35 -07:00
Emily Janzer 8e70e374f6 Export JNativeRunnable from react/jni
Summary: Adding JNativeRunnable to exported headers in react/jni/BUCK so I can use it outside of CatalystInstance.

Reviewed By: axe-fb

Differential Revision: D14817655

fbshipit-source-id: 15aa794e50f273778da337956c887c235a5aec3d
2019-04-08 14:40:34 -07:00
landon e5d975b5c7 ignore dropView method when view is null (#24347)
Summary:
In #20288, we solved `com.facebook.react.uimanager.NativeViewHierarchyManager.dropView (NativeViewHierarchyManager.java:536)` by adding codes that prevent to run method on `view` object when `view.getId()` is null.

But if `view` is null, `view.getId()` can make error about NullPointerException. So, I think `dropView` method  needs to check if `view` is null.

If you need more information, Please read #24346.

[Android] [Fixed] - Ignore dropView method when view is null.
Pull Request resolved: https://github.com/facebook/react-native/pull/24347

Differential Revision: D14833822

Pulled By: cpojer

fbshipit-source-id: 88b6a05090ea8e8d6737c1f10b40e93649fab151
2019-04-08 12:44:48 -07:00
Joshua Gross e34761ff25 Android plumbing for State and LocalData update mount items
Summary: Android plumbing for State and LocalData update mount items. See other commits in stack for usage

Reviewed By: mdvacca

Differential Revision: D14663522

fbshipit-source-id: 5604a6a9af292805e9ce46c68e5ce7472eef0218
2019-04-06 00:52:43 -07:00
Emily Janzer 7944d47a63 Back out "[react-native][PR] Android - Add a ReactFragment"
Summary: Original commit changeset: b50b708cde45

Reviewed By: mdvacca

Differential Revision: D14792438

fbshipit-source-id: c5e0b5f7663fe70110f73ae94a6fa99388f87ae3
2019-04-04 18:43:01 -07:00
Kudo Chien 8e375850de Use node package dependency to manage JSC version (#24276)
Summary:
In origin approach, we packed libjsc.so inside react-native.aar and it is difficult for user to choose different JSC variants. E.g., [the Intl supported version](https://github.com/react-native-community/jsc-android-buildscripts#international-variant).

This change list allows application to determine JSC versions or variants by npm/yarn package.

There is a |useIntlJsc| flag in build.gradle, it will use the same JSC version but with Intl support.

`yarn add jsc-android@canary`

[Android] [Changed] - Allow application to select different JSC variants

**MIGRATION**
Note that there are some changes in build.gradle.
Existing application needs to change their android/build.gradle and android/app/build.gradle.
Hopefully, the rn-diff-purge should handle the case well.
Pull Request resolved: https://github.com/facebook/react-native/pull/24276

Differential Revision: D14752359

Pulled By: cpojer

fbshipit-source-id: a4bfb135ad8e328f404a2d1a062412f40ebf4622
2019-04-04 14:22:14 -07:00
YuTeh Shen 84a1cacfa5 Fix crash if set text and set selection at the same time. (#22723)
Summary:
Since text and selection has dependency, handle text selection in
updateExtraData as well.

The root cause is due to setText is handled on extra data update but setSelection is handled on set property. And extra data update will be handled after all properties are handled. Since selection and text has dependency, move selection to extra data update as well.

Changelog:
----------
[Android] [Fixed] - Fix crash when set text and selection on textinput at the same time
Pull Request resolved: https://github.com/facebook/react-native/pull/22723

Differential Revision: D14783791

Pulled By: cpojer

fbshipit-source-id: a4065f3e151d23f4813d76e91d68362cfd4daaf4
2019-04-04 14:08:37 -07:00
Pieter De Baets d9a82221a4 Back out "[react-native] Remove experimental gating for LayoutAnimation on Android"
Summary: We've identified a couple of remaining issues that need to be re-tested before we can ship this more broadly.

Reviewed By: fred2028

Differential Revision: D14775730

fbshipit-source-id: 22402149066c5fbe72c36fcf7f547d63feaf5241
2019-04-04 09:47:12 -07:00
John Shelley 691f2f9d02 Android - Add a ReactFragment (#12199)
Summary:
React Native on Android has currently been focused and targeted at using an [Activity](https://developer.android.com/reference/android/app/Activity.html) for its main form of instantiation.

While this has probably worked for most companies and developers, you lose some of the modularity of a more cohesive application when working in a "brown-field" project that is currently native. This hurts more companies that are looking to adopt React Native and slowly implement it in a fully native application.

A lot of developers follow Android's guidelines of using Fragments in their projects, even if it is a debated subject in the Android community, and this addition will allow others to embrace React Native more freely. (I even assume it could help with managing navigation state in applications that contain a decent amount of Native code and would be appreciated in those projects. Such as sharing the Toolbar, TabBar, ViewPager, etc in Native Android)

Even with this addition, a developer will still need to host the fragment in an activity, but now that activity can contain native logic like a Drawer, Tabs, ViewPager, etc.

**Test plan (required)**
* We have been using this class at Hudl for over a couple of months and have found it valuable.
* If the community agrees on the addition, I can add documentation to the Android sections to include notes about the potential of this Fragment.
* If the community agrees on the addition, I can update one or more of the examples in the `/Examples` folder and make use of the Fragment, or even create a new example that uses a native layout manager like Drawer, Tabs, Viewpager, etc)

Make sure tests pass on both Travis and Circle CI.

_To Note:_
* There is also talk of using React Native inside Android Fragment's without any legit documentation, this could help remedy some of that with more documentation included in this PR https://facebook.github.io/react-native/releases/0.26/docs/embedded-app-android.html#sharing-a-reactinstance-across-multiple-activities-fragments-in-your-app
* Others have also requested something similar and have a half-baked solution as well http://stackoverflow.com/questions/35221447/react-native-inside-a-fragment

[ANDROID][FEATURE][ReactAndroid/src/main/java/com/facebook/react/ReactFragment.java] - Adds support for Android's Fragment system. This allows for a more hybrid application.
<!--
Help reviewers and the release process by writing your own release notes

**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 ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - 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/12199

Differential Revision: D14590665

Pulled By: mdvacca

fbshipit-source-id: b50b708cde458f9634e0c14b3952fa32f9d82048
2019-04-04 00:23:28 -07:00
Christoph Nakazawa e62cfc0f72 Fix crash in RCTText in open source RNTester
Summary: See https://github.com/facebook/react-native/issues/24288

Reviewed By: sahrens

Differential Revision: D14765625

fbshipit-source-id: f7275f3735691e1f0c87e682f6dd675e5ba5a7c0
2019-04-03 18:55:36 -07:00
David Vacca da44010b59 Implement AxialGradientView in Fabric Android
Summary: This diff integreates AxialGradientView in Fabric Android

Reviewed By: shergin

Differential Revision: D14631690

fbshipit-source-id: 54785466ab4cd7251c6667c8dc12d69d9d194832
2019-04-03 17:57:24 -07:00
David Vacca 2777c6572a Pre-allocate Fabric views even when React is running in the UI Thread
Summary: Before D14297477, the pre-allocation of views was ONLY necessary when react was running in the JS Thread, this is because the batch of mount items used to contain mount items for creation of views. After D14297477, views are only created during pre-allocation, that means that pre-allocation of views need to be trated the same way independently the thread where it is running.

Reviewed By: shergin

Differential Revision: D14714933

fbshipit-source-id: 7bd19cd33b624a5b0daaafabb476bb06707eea17
2019-04-03 17:31:37 -07:00
Kevin Gozali 1e2e07da2c TM Android: fixed up JSCallInvoker creation
Summary: A previous commit changed the signature of the Instance (the arg to JSCallInvoker) to be a weak ref, so this callsite needs updating.

Reviewed By: mmmulani

Differential Revision: D14757188

fbshipit-source-id: 1a8663e56a42b26c6202881c57a7caafa71da2ab
2019-04-03 13:23:51 -07:00
Aditya Sharat 99ec3dc845 Add YogaNode.cloneWithoutChildren
Summary: Adding flat clone method back to YogaNode for reconciliation.

Reviewed By: davidaurelio

Differential Revision: D14683019

fbshipit-source-id: 08ed2ffbb16052cb11aa464f67a7ba9a64297985
2019-04-03 12:43:05 -07:00
Dulmandakh 6a26cb4bea bump fresco to 1.13 (#24274)
Summary:
Bump Fresco to 1.13, which uses libc++ and many improvements.

[Android] [Changed] - Bump Fresco to 1.13
Pull Request resolved: https://github.com/facebook/react-native/pull/24274

Differential Revision: D14750275

Pulled By: cpojer

fbshipit-source-id: 3c040fccd4cb484e31d9c6e849ec285666f140c7
2019-04-03 10:45:34 -07:00
David Aurelio b015b99fce Move `YGSetUsedCachedEntries` to internal header
Summary:
@public

In order to get out of pre-releases again, we move `YGSetUsedCachedEntries` from `Yoga.h` to `Yoga-internal.h`.
This way, it’s obvious that the function is not public, and we can remove it from future versions without breaking semver contracts.

Reviewed By: SidharthGuglani

Differential Revision: D14726029

fbshipit-source-id: 8d7e747e843bf5c4b5e1d4cfbfa37ca9d240dffb
2019-04-03 08:45:39 -07:00
Nurzhan Bakibayev f00d1b8518 Change default Inspector Proxy port to 8081
Summary: Change default Inspector Proxy port to 8081

Reviewed By: cwdick

Differential Revision: D14745974

fbshipit-source-id: f4b3b158f55c6f5f1b3d9cc2528c5ddb59774a8b
2019-04-03 08:39:08 -07:00
Rick Ratmansky 7f6ab5068c Removing unused and very old versions of the support library resources
Summary: TSIA

Differential Revision: D14727969

fbshipit-source-id: 1c73534dea7225f2d952ef0f20ea602894d78f04
2019-04-03 07:58:40 -07:00
Pieter De Baets 9895d01137 Remove experimental gating for LayoutAnimation on Android
Reviewed By: sahrens

Differential Revision: D14658087

fbshipit-source-id: 378ef4a5c5336d428b5045772d094a297b2767c7
2019-04-03 04:42:15 -07:00
Pieter De Baets f571c62ddf Implement completion callback for LayoutAnimation on Android
Summary: All animations are scheduled by the UIManager while it processes a batch of changes, so we can just wait to see what the longest animation is and cancel+reschedule the callback.

Reviewed By: mdvacca

Differential Revision: D14656733

fbshipit-source-id: 4cbbb7e741219cd43f511f2ce750c53c30e2b2ca
2019-04-03 04:42:14 -07:00
Pieter De Baets a333c2b202 Remove legacy AnimationManagerModule
Summary: This code was shipped as part of the initial open-source release but was never used.

Reviewed By: sahrens

Differential Revision: D14649389

fbshipit-source-id: 0c068ca69b91d275008f4a7af77a23a4f1470c18
2019-04-03 04:42:14 -07:00
Luna Wei d9711e2693 Log uri for guessContentTypeFromName exceptions
Summary: Add additional logging around the exception to figure out what kind of uris are causing the exception for `getContentTypeForFileName`

Reviewed By: PeteTheHeat

Differential Revision: D14715917

fbshipit-source-id: 46299d2ff3f1f06991d7800784a025a85815ae8c
2019-04-02 18:38:39 -07:00
Emily Janzer 15b2f994ce Guard against content view being null in onOverScrolled
Summary:
It seems that the content view can sometimes be null when onOverScrolled is called (presumably when the scrollview gets unmounted while it's in the middle of scrolling?).

Changelog: [Android][fixed] - Guard against content view being null in onOverScrolled.

Reviewed By: mdvacca

Differential Revision: D14737534

fbshipit-source-id: e88ec6f585e50517b734a8809fc3843c0b22df10
2019-04-02 18:15:42 -07:00
Christoph Nakazawa 1ca9a95537 Move WebView Android files to FB internal
Summary: This moves the Java files to FB internal and updates all the buck files

Reviewed By: TheSavior

Differential Revision: D14622521

fbshipit-source-id: a8d293e9f9e08868cca3ed2986a08d0db16dec15
2019-04-02 11:19:47 -07:00
Sunny Luo 556aa93ed7 Prevent crash when setting underlineColorAndroid (#24183)
Summary:
Try to prevent the crash described in https://github.com/facebook/react-native/issues/17530

There seems to be a bug in `Drawable.mutate()` in some devices/android os versions even after you check the constant state. This error is hard to reproduce and to fix, so just try to catch the exception to prevent crash.

[Android][Fixed] Prevent random crash when setting underlineColorAndroid
Pull Request resolved: https://github.com/facebook/react-native/pull/24183

Differential Revision: D14710484

Pulled By: cpojer

fbshipit-source-id: 3af20a5cb0ecd40839beaf85118c0f5aa6905414
2019-04-02 09:41:16 -07:00
Adam Comella a2285b1790 Android: Enable views to be nested within <Text> (#23195)
Summary:
Potential breaking change: The signature of ReactShadowNode's onBeforeLayout method was changed
  - Before: public void onBeforeLayout()
  - After:  public void onBeforeLayout(NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer)

Implements same feature as this iOS PR: https://github.com/facebook/react-native/pull/7304

Previously, only Text and Image could be nested within Text. Now, any view can be nested within Text. One restriction of this feature is that developers must give inline views a width and a height via the style prop.

Previously, inline Images were supported via FrescoBasedReactTextInlineImageSpan. To get support for nesting views within Text, we create one special kind of span per inline view. This span is called TextInlineViewPlaceholderSpan. It is the same size as the inline view. Its job is just to occupy space -- it doesn't render any visual. After the text is rendered, we query the Android Layout object associated with the TextView to find out where it has positioned each TextInlineViewPlaceholderSpan. We then position the views to be at those locations.

One tricky aspect of the implementation is that the Text component needs to be able to render native children (the inline views) but the Android TextView cannot have children. This is solved by having the native parent of the ReactTextView also host the inline views. Implementation-wise, this was accomplished by extending the NativeViewHierarchyOptimizer to handle this case. The optimizer now handles these cases:
  - Node is not in the native tree. An ancestor must host its children.
  - Node is in the native tree and it can host its own children.
  - (new) Node is in the native tree but it cannot host its own children. An ancestor must host both this node and its children.

I added the `onInlineViewLayout` event which is useful for writing tests for verifying that the inline views are positioned properly.

Limitation: Clipping
----------

If Text's height/width is small such that an inline view doesn't completely fit, the inline view may still be fully visible due to hoisting (the inline view isn't actually parented to the Text which has the limited size. It is parented to an ancestor which may have a different clipping rectangle.). Prior to this change, layout-only views had a similar limitation.
Pull Request resolved: https://github.com/facebook/react-native/pull/23195

Differential Revision: D14014668

Pulled By: shergin

fbshipit-source-id: d46130f3d19cc83ac7ddf423adcc9e23988245d3
2019-04-01 19:55:23 -07:00
Héctor Ramos 2a80a42d40 Revert D14423742: Use of TraceCompat
Summary:
D14423742 introduced a regression on OSS test_android due to androidx.core.os not being available. I spent some time investigating a fix forward this morning, with no success. Reverting.

Changelog:

[Android] [Changed] - Revert 92f019c666

Reviewed By: cpojer

Differential Revision: D14668728

fbshipit-source-id: c7542992805551dc4302626e1536759794efaa82
2019-04-01 13:09:07 -07:00
Gábor Siffel 9ddef77b1d Add the ability to customize webview response to client cert requests
Summary:
Add the ability to set a custom handler on ReactWebViewManager to handle client certificate challenges during TLS authentication.

[Android][Added] - Public method setCustomClientCertRequestHandler to the native com.facebook.react.views.webview.ReactWebViewManager, that allows using a custom response for client certificate challenges.

Reviewed By: mjhu

Differential Revision: D14609697

fbshipit-source-id: 567c95458af638d1f8233fc3ca0d9cefc061c2bf
2019-04-01 11:16:54 -07:00
Valentin Shergin 3e4a8e35fe Fabric `ShadowTree` (and co) was moved to `mounting` module
Summary: Because it's kinda more logical and we will rely on this in comming diffs.

Reviewed By: mdvacca

Differential Revision: D14587124

fbshipit-source-id: 94ae9410b4ffeffd0fcb4da4a0518f0bb0d2ba63
2019-04-01 10:50:50 -07:00
Sidharth Guglani 11e93cdc1f added flag for useBatchingForLayoutOutputs experiment
Summary:
Using a config flag to switch between different implementations of transferring layout outputs
- YogaNodeJNI uses multiple access of java fields to pass all properties like width, height, margin etc...
- YogaNodeJNIBatching uses a float array to pass all the data in one java field access

Reviewed By: davidaurelio

Differential Revision: D14378301

fbshipit-source-id: 0da5b28e6a67ad8fd60eb7efe622d9b2deaf177f
2019-04-01 06:16:36 -07:00
Sidharth Guglani 9bbca7c531 Added implementation for YogaNodeJNIBatching and logic for passing array from c++ to java
Summary: This diff adds the logic to transfer layout outputs using a float array

Reviewed By: davidaurelio

Differential Revision: D14368120

fbshipit-source-id: d1f22283bcea051d15657f42c15b90edaa0a8a7a
2019-04-01 06:16:36 -07:00
Sidharth Guglani 5ad752079c added test for reset method in YogaNodeJNI to verify all layout outputs are reset properly
Summary: This diff adds a test for reset method in YogaNodeJNI to verify all layout outputs are reset properly

Reviewed By: davidaurelio

Differential Revision: D14643926

fbshipit-source-id: fffbcd07ccb6d2df83fc0bf187d992ef194f3bd0
2019-04-01 06:16:36 -07:00
Sidharth Guglani c378be490f moved all the properties used for layout outputs to YogaNodeJNI
Summary:
Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14642995

fbshipit-source-id: 5d0bc7fa18c1985be7e216d7351f5eab2e03861d
2019-04-01 06:16:35 -07:00
Ram N 0b62ff0b94 Move Android code for Geolocation out
Reviewed By: cpojer

Differential Revision: D14692916

fbshipit-source-id: 6bcfda8aa8c7d22dce36828dae9f57068815ce20
2019-03-31 22:52:36 -07:00
David Vacca 02562e51bd Disable view pooling
Summary:
Temporarily disable View Pooling in Fabric

Naming of classes will change in the near future

Reviewed By: JoshuaGross

Differential Revision: D14685009

fbshipit-source-id: 83573dd09af0202a67d0d0aa11e37c1660c3991f
2019-03-30 23:20:26 -07:00
Christoph Nakazawa 8b895ca710 Back out "[react-native][PR][Microsoft] This change fixes currently broken ReactContext listeners mechanism."
Summary: Original commit changeset: d506e5035a7f

Reviewed By: JoshuaGross

Differential Revision: D14689559

fbshipit-source-id: 9a8c8be0d2b7b9dd9be1ec038d7c3b356a5e3adf
2019-03-29 14:51:57 -07:00
Christoph Nakazawa d2981af68f Back out "[react-native][PR] There is a small gap in the SynchronizedWeakHashSet implementation. T?"
Summary: Original commit changeset: 2998bffb06e2

Reviewed By: JoshuaGross

Differential Revision: D14689422

fbshipit-source-id: 2638bed8005859cc95972ba5f78a9e9cace878ef
2019-03-29 14:51:57 -07:00
Kevin Gozali a47746b851 TM Android: temporarily disable callback support to unbreak build
Summary: With the recent change, JSCallInvoker now expects `Instance` to be passed in, not just the `MessageQueueThread`. There needs to be more plumbing to get the instance of `Instance` from the Java side, but this commit is just to unbreak the build temporarily.

Reviewed By: JoshuaGross

Differential Revision: D14687622

fbshipit-source-id: 42e0173ee8336fc5660fe8188a1e1f8517611521
2019-03-29 12:33:33 -07:00
David Vacca 5d0d50cc44 Fix scrolling of Android Horizontal Scroll View
Summary:
This diff fixes the scrolling of Android Horizontal Scroll View, the root cause was that Binding was mounting a ScrollView instead of an AndroidHorizontalScrollView component.
This will be automatically fixed when all the View components are autogenerated.

Reviewed By: shergin

Differential Revision: D14594622

fbshipit-source-id: 7c477ca167188ea9c473f61145461d3cf1696e17
2019-03-29 00:43:32 -07:00
David Vacca ed0085ca1b Refactor mapping of FabricComponentNames
Summary: Simple diff that refactors the usage of the sComponentNames to not require components to be part of the mapping when the name in JS is the same as the name in Native side.

Reviewed By: shergin

Differential Revision: D14594659

fbshipit-source-id: d1948b27e04686fefbf9b6e2b06d4f9317b97062
2019-03-29 00:43:31 -07:00
David Vacca 0c17992485 Add logs in mounting layer
Summary: Adds debug logging in FabricUIManager and the mounting layer of Fabric.

Reviewed By: shergin

Differential Revision: D14594521

fbshipit-source-id: a5c0ee39e1bac8a340849ca3e044694cbee5427e
2019-03-29 00:43:31 -07:00
David Vacca 58c16e63a4 Expose collapsable as React Prop in LayoutShadowNode
Summary: This diff exposes the collapsable prop as part of LayoutShadowNode, fixing the bug of the collapsable prop being filtered by JS in Fabric

Reviewed By: shergin

Differential Revision: D14594522

fbshipit-source-id: a892ba8228e76f11232acc6fe5c8d75e991d8fc6
2019-03-29 00:43:31 -07:00
Christoph Nakazawa 6345fcf12b Remove WebView from public RN interface
Summary:
This diff removes the `WebView` export from React Native. Internally, we are requiring `WebView` directly now and externally people will have to use the community maintained module. This diff does not yet move the WebView files from the repo, this will happen in a follow-up.

Note that I had to remove a test for Cookies that displayed data in a WebView. I don't think there is an easy way to retain this (debugging) information that likely very few people ever take a look at so I think it is fine.

Reviewed By: TheSavior

Differential Revision: D14613077

fbshipit-source-id: b1d412f970d09d7d70ecac2c23e62cfdd09d7c8e
2019-03-28 17:37:05 -07:00
Gábor Siffel 81fcaa151d Add the ability to customize the http client in networking native module
Summary:
Add the ability to build on top of the OkHttpClient.Builder by defining a lambda that gets called on network requests

[Android][Added] - Public method `setCustomClientBuilder` to the native `com.facebook.react.modules.network.NetworkingModule`, that allows customizing the OkHttpClient per-request for greater control over HTTP requests.

Reviewed By: hramos

Differential Revision: D14288613

fbshipit-source-id: 34df0ff3e18eeea1d565ccfcf97408379900120b
2019-03-27 21:50:56 -07:00
Ioannis Kokkinidis f149426c83 Enforced thread safety on UIImplementation methods that mutate the shadowNodeRegistry (#20025)
Summary:
Fixes: #17178

[ANDROID] [Fixes] - UIImplementation: Now enforcing atomic mutation of the shadowNodeRegistry
Pull Request resolved: https://github.com/facebook/react-native/pull/20025

Differential Revision: D14652876

Pulled By: shergin

fbshipit-source-id: 7b20bad4cb43d3e6f09e2037e3c60a217a91d273
2019-03-27 14:43:12 -07:00
Dulmandakh 92f019c666 use TraceCompat (#23780)
Summary:
I was working to use more Android Support Library in RN core, but wasn't able to finish it. So this PR is for only Systrace and TraceCompat only.

[Android] [Changed] - Use TraceCompat in Systrace
Pull Request resolved: https://github.com/facebook/react-native/pull/23780

Differential Revision: D14423742

Pulled By: hramos

fbshipit-source-id: e3c3e2dfd95eac3d2484313f9be69df1c85904cf
2019-03-27 12:07:37 -07:00
Alexander Vasyuk f330056420 Revert D14368107: [yoga] moved all the properties used for layout outputs to YogaNodeJNI
Differential Revision:
D14368107

Original commit changeset: 75ca330c1e7f

fbshipit-source-id: 9a9f5140bf8b1563c9ba85b3fe5f93fc6d8fdf41
2019-03-26 20:21:32 -07:00
Alexander Vasyuk ac22913121 Revert D14368114: [yoga] removing unused const int
Differential Revision:
D14368114

Original commit changeset: f63b978813a0

fbshipit-source-id: 86a517b1483b0635f283702602712c42c3d51e20
2019-03-26 20:21:32 -07:00
Christoph Nakazawa 95c7db90b8 Back out "[react-native][PR] Support Interpolation of strings when using native driver in Animated, fix Expected node to be marked as "native", optimize AnimatedNode creation and connections"
Summary: Original commit changeset: 82a948a95419

Reviewed By: TheSavior

Differential Revision: D14631845

fbshipit-source-id: f20d8150bccf50ea85388761e2f31ca4f97ae158
2019-03-26 17:13:11 -07:00
Kyle Pinkham b1251d067a Implement data detection for android Text elements (#19216)
Summary:
We want the ability to use Linkify on android text elements. This only adds this property to Text and not TextInput since there are some functional differences with how the types could be used between iOS and android - iOS allows one or many types while Linkify restricted us to providing only one option (using the masks).

Performance is affected ONLY FOR TEXT ELEMENTS USING THIS FEATURE since Linkify is searching for patterns.
Pull Request resolved: https://github.com/facebook/react-native/pull/19216

Differential Revision: D14621883

Pulled By: cpojer

fbshipit-source-id: cb692021d314140b9a92b29e23384afd7fd1b09e
2019-03-26 12:31:30 -07:00
David Vacca 2a336f2b11 Fix NoSuchElementException in ReactChoreographerDispatcher.doFrame
Summary: This diff fixes a NoSuchElementException that was being thrown at ReactChoreographerDispatcher.doFrame(). The root cause was a lack of syncronization in removeFrameCallback().

Reviewed By: shergin

Differential Revision: D14619386

fbshipit-source-id: 80bc9e44866218d2a8703b3186f6958c145f260b
2019-03-26 10:38:42 -07:00
Luna Wei 20b4879dfd - LayoutAnimations cause invalid view operations
Summary:
[Android] [Fixed] - LayoutAnimations cause invalid view operations

The dating team has found a consistent repro where following an order of steps will get you the following exception:

https://lookaside.facebook.com/intern/pixelcloudnew/asset/?id=2113362972287761

The exception is due to the fact that the following operation
 `delete child tag 17 from parent tag 481 which is located at index 2`
cannot be performed because parent tag 481 only has 2 children.. and they also happen to not have the tag 17 as a child. Somehow the operations and the tree they act upon are out of sync.

RN receives operations from React via the native module `UIManagerModule`. The operations use tags (an identifier for a view) and indices to determine what view is updated. These operations (grouped together as a batch) are then passed to the UI thread where we perform them on the platform views.

LayoutAnimations are implemented per batch in RN. When LayoutAnimations are on, qualified view updates are animated. Because the delete operation is animated, RN doesn't remove the view from the platform view hierarchy immediately but asynchronously -- after the animation is complete. This is problematic for other view operations that rely on an index on where to insert or delete a view because during the creation of those operations, it was assumed all prior operations were performed synchronously.

This is what was occurring in the repro and there were silent view errors occurring before the exception was thrown.

This diff proposes a solution to track all pending delete operations across operations.
We introduce a map that is keyed on view tags and has a value of a sparse array that represents child index -> count of views that are pending deletion.
`{11: [0=1], 481: [2=1]}` where this would be interpreted as for index 0 under view tag 11, there is one async view deletion that has not completed and under tag 481 there is one async view deletion at index 2.

We use the map to adjust indices on add / delete operations. We also update the count when the deletion animation is complete and remove the tag from the map when it is deleted.

Regarding worst case sizing of the map => O(# of platform views rendered)

Reviewed By: mdvacca

Differential Revision: D14529038

fbshipit-source-id: 86d8982845e25a2b23d6d89ce27852fd77dbb060
2019-03-26 10:33:08 -07:00
Mikael Sand 5e4a5892b9 Support Interpolation of strings when using native driver in Animated, fix Expected node to be marked as "native", optimize AnimatedNode creation and connections (#18187)
Summary:
Allow interpolation of strings with useNativeDriver. This allows animating much more of react-native-svg. This PR adds support for native animation of lengths with units, path data, colors etc. Plus, fixing the redundantly created nodes and (and thus, previously incorrect) connection of native animated nodes, improving performance.

Docs will need to change, specifying that string interpolation works with the native driver as well.

[GENERAL] [Added] Add support for native driven string interpolation in Animated
[GENERAL] Fix exception: Expected node to be marked as "native"
[GENERAL] Fix connection of AnimatedNodes and creation of redundant AnimatedNodes
Pull Request resolved: https://github.com/facebook/react-native/pull/18187

Differential Revision: D14597147

Pulled By: cpojer

fbshipit-source-id: 82a948a95419236be7931a8cc4ff72f41e477e9c
2019-03-26 09:33:25 -07:00
Sidharth Guglani 81a702b426 removing unused const int
Summary: Removed unused const int

Reviewed By: davidaurelio

Differential Revision: D14368114

fbshipit-source-id: f63b978813a01a37710fac299dc7ec9aff610844
2019-03-26 08:50:33 -07:00
Sidharth Guglani d5a8f4d600 moved all the properties used for layout outputs to YogaNodeJNI
Summary:
Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14368107

fbshipit-source-id: 75ca330c1e7f07adc0ab8e7a5927d93977088918
2019-03-26 07:36:58 -07:00
Spencer Ahrens d9eae2a809 fix setNativeProps crash
Summary:
setNativeProps ends up calling UIManager.updateView which fails to find the view tag in the Paper UIManager and crashes.

This diff simply checks if the tag is managed by fabric, and calls `fabricUIManager.synchronouslyUpdateViewOnUIThread` if it is.

Not the ideal fix, but it generally works (js-driven animations work as well as in Paper) and it's better than crashing or not working at all.

Reviewed By: JoshuaGross

Differential Revision: D14414523

fbshipit-source-id: 0acd404f55094f8ce8eda39cb87ab58c727fb068
2019-03-25 12:24:46 -07:00
Spencer Ahrens 45b9b656cc factor out common native obj switch code
Summary: No reason to duplicate it.

Reviewed By: mdvacca

Differential Revision: D14488262

fbshipit-source-id: b5ce23ea591abc3e9bc07ee48cc756322cae220c
2019-03-25 12:12:11 -07:00
Spencer Ahrens a062b34493 same cleanup but for ReadableNativeArray
Summary: Removes useArrayNativeAccessor and everything needed to support it, similar to D14486283

Reviewed By: mdvacca

Differential Revision: D14487244

fbshipit-source-id: 7cfa91f7cf322c648c82be5951f3622cd6468961
2019-03-25 12:12:11 -07:00
Spencer Ahrens b257e06bc6 remove useMapNativeAccessor stuff
Summary:
This was quite a rabit hole of remove deps -> delete dead code -> repeat.

Waaay simpler now with less duplicate lookups, redundant type verification, and extra function calls.

Reviewed By: mdvacca

Differential Revision: D14486283

fbshipit-source-id: 035db30181755d046a1ae99760468b954b2449df
2019-03-25 12:12:10 -07:00
Spencer Ahrens a46fba5dd3 use DynamicFromObject to avoid maps
Summary:
Changes our property access pattern to iterate through props once and pass the Object value directly rather than looking the value up in the map with the key.

Note some ViewManagers methods (especially yoga related ones on shadow nodes) expect a `Dyanamic`, so this diff also creates Dynamic's only when needed by the hand-written code, and introduces a new `DynamicWithObject` to create them that simply wraps the underlying object (as opposed to `DynamicWithMap` which wraps the map and does a lookup any time the `Dynamic` is accessed.

Reviewed By: mdvacca

Differential Revision: D14453300

fbshipit-source-id: df98567b6eff1e6b7c611f179eb11e413fb94e5d
2019-03-25 12:12:10 -07:00
David Vacca b943db418f Fix IllegalStateException when tapping next on Android Keyboard
Summary: This diff fixes an IllegalStateException that is thrown when the user click is on a edit text and tap 'Next' on the keyboard to focus on the next view, but the next view is hidden.

Reviewed By: lunaleaps, mmmulani

Differential Revision: D14598410

fbshipit-source-id: 2999cc468ed24bedff163eedcfaec50f6ee005d6
2019-03-25 10:17:39 -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
Sidharth Guglani 526b40bfe3 fixed @Nullable missing infer errors
Summary: Fixed Nullable lint errors

Reviewed By: davidaurelio

Differential Revision: D14383930

fbshipit-source-id: 0847e19c50a0b8d4039199045b74aa86c96ac096
2019-03-25 06:36:15 -07:00
David Vacca d53200a4c3 ReactTTRCRenderFlag component in Fabric android
Summary: This diff migrates ReactTTRCRenderFlag component to Fabric android

Reviewed By: fkgozali

Differential Revision: D14591212

fbshipit-source-id: c10de2ab4a77af985853da6d3fe7a7c6a1bc7a1e
2019-03-23 22:53:23 -07:00
Yuan Du a3296ff40f Revert D14572430: [Fabric][Android] ReactTTRCRenderFlag component in Fabric android
Differential Revision:
D14572430

Original commit changeset: 0e7c6cb5520b

fbshipit-source-id: 2cde5c9316c055c3836aab656a06c508f3e468af
2019-03-23 13:08:20 -07:00
David Vacca 819c584c46 ReactTTRCRenderFlag component in Fabric android
Summary: This diff migrates ReactTTRCRenderFlag component to Fabric android

Reviewed By: shergin

Differential Revision: D14572430

fbshipit-source-id: 0e7c6cb5520be44221939b0e711269b84f4657dc
2019-03-23 12:10:00 -07:00
David Vacca bd7df8bdaa Remove BatchedExecutionTime from Fabric metrics
Summary: This diff removes BatchedExecutionTime from the metrics that are measured in Fabric. This does not add much value and it is not easy to compare against current version of RN

Reviewed By: shergin

Differential Revision: D14541976

fbshipit-source-id: c488e0951815306a978dd7a4246ec8a16d663218
2019-03-23 00:38:57 -07:00
David Aurelio f9a344c4dc Switch style getters to JNI fast calls
Summary:
@public

After changing native methods to return `long` rather than `YogaValue`, we switch them to JNI fast calls, as there is no more interaction with the Java GC.

Reviewed By: pasqualeanatriello

Differential Revision: D14576815

fbshipit-source-id: b5a33caef7343ba1de3d9634a50dc82ab3148cc7
2019-03-22 10:35:49 -07:00
David Aurelio 672a101ee3 Create `YogaValue` instances in Java, not C++
Summary:
@public

Passing primitive data via JNI is more efficient than passing objects.

Here, we avoid creating `YogaValue` (Java) instances via JNI, and rather pass a `long` back to Java. The instance is then created by extracting the necessary bytes on the Java side.

Reviewed By: foghina

Differential Revision: D14576755

fbshipit-source-id: 22d09ad50c3ac6c49b0a797a0dad639ea4829df9
2019-03-22 10:35:49 -07:00
David Aurelio cef6bb1f72 Move native methods to a single class
Summary:
@public

Moving all native methods in a single class provides the benefit of not having to load native bindings eagerly when just creating config objects in the startup paths, or setting Java-only values on them.
Loading native bindings triggers additional class loads (`YogaConfig` / `YogaNode`), and can lead to problems in multi-dex scenarions.

Reviewed By: pasqualeanatriello

Differential Revision: D14560658

fbshipit-source-id: 14e31e3c3b560675b5a752a38ae75ab80a565ea1
2019-03-22 09:44:29 -07:00
Sergei Dryganets aad4dbbbfe OkHttp is more strict than other http libraries. (#21231)
Summary:
It crashes with IllegalStateException in case you pass a wrong URL.
It crashes if it meets unexpected symbols in the header name and value,
while standard says it is not recommended to use those symbols not that
they are prohibited.

The headers handing is a special use case as a client might have an auth token in the header. In this case, we want to get 401 error response
from the server to find out that token is wrong. In case of the onerror
client will continue to retry with an existing token.

[ANDROID][Fixed] - Networking: Passing invalid URL not crashes the app instead onerror callback of HttpClient is called. Invalid symbols are stripped from the headers to allow HTTP query to fail with 401 error code in case of the broken token.

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

Reviewed By: axe-fb

Differential Revision: D10222129

Pulled By: hramos

fbshipit-source-id: b23340692d0fb059a90e338fa85ad4d9612275f2
2019-03-21 11:22:55 -07:00
David Aurelio 3c2300f4fe Fix license headers
Summary:
@public

Yoga's Java license headers were not in the correct format.

Reviewed By: muraziz

Differential Revision: D14541087

fbshipit-source-id: 5b3cff398875bd59dadeaddbb43020700ef027e2
2019-03-21 04:57:11 -07:00
Dulmandakh b3c74967ca improve RTL (#24069)
Summary:
Google recommends to use Gravity.START and Gravity.END instead of Gravity.LEFT and Gravity.RIGHT to support RTL better.

[Android] [Changed] - Improve RTL support
Pull Request resolved: https://github.com/facebook/react-native/pull/24069

Differential Revision: D14541569

Pulled By: cpojer

fbshipit-source-id: 5c104d8bd666e1270d5410216c7f2efa6152692a
2019-03-20 11:40:37 -07:00
Sidharth Guglani 000bf3d936 created a new class YogaNodeJNI which extends YogaNodeJNIBase and using YogaNodeJNi for new object creation
Summary:
Added a child class of YogaNodeJNIBase which will be used to separate layout outputs transfer logic.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14368098

fbshipit-source-id: e0f10fb61cd09ee47cf9ce41fb400f4cfb3dd795
2019-03-20 09:07:49 -07:00
David Aurelio 5c91595d63 JNI: Simplify node context
Summary:
@public
Contexts of nodes only hold a bit mask after we got rid of weak JNI refs.
We can simply store that data in a pointer-sized unsigned int.

Here, we replace all context heap allocations with usage of the node context (`void *`) as bitmask. We also add a couple of utility operators in order to keep the code comprehensible.

Reviewed By: fabiomassimo

Differential Revision: D14425742

fbshipit-source-id: f32c2184a1f09268c39dbb8cd09ac96517339674
2019-03-20 08:46:24 -07:00
Sidharth Guglani 80743eb7b1 renamed YogaNodeJNI to YogaNodeJNIBase
Summary:
Renamed class from YogaNodeJNI to YogaNodeJNIBase.
This change set is for adding experiment for layout outputs batching using a float array where we will have two separate classes which will override how layout outputs are transferred to java YogaNode object.

We needed two separate classes because having everything in one class was causing memory issues as both the individual fields for width, height etc. and float array for batching needs to be present in code.

Reviewed By: davidaurelio

Differential Revision: D14368069

fbshipit-source-id: 0e98e28c8c7a9788345ccb92b2cd0f2cd4a53525
2019-03-20 07:54:03 -07:00
Héctor Ramos c2f5b676ff Refactor autofillHints API 26+ runtime check
Summary: Refactor the fix from d4aa1e7a52 into something that follows the same convention used in 36957dcedd

Reviewed By: mdvacca

Differential Revision: D14485427

fbshipit-source-id: e6118284fcffa4b43c8392c94991764a07094403
2019-03-18 22:55:42 -07:00
Sergei Dryganets 62d340910a There is a small gap in the SynchronizedWeakHashSet implementation. T… (#24015)
Summary:
There is a small gap in the SynchronizedWeakHashSet implementation - the containsKey method of the WeakHashMap is modifying hence calling it during the iteration might cause ConcurrentModificationException. Added a command DO_IF_CONTAINS to safely handle this case.

[Android] [Bugfix] - Should fix a ConcurrentModificationException in onResume.
Pull Request resolved: https://github.com/facebook/react-native/pull/24015

Reviewed By: mdvacca

Differential Revision: D14507342

Pulled By: fkgozali

fbshipit-source-id: 2998bffb06e2cbacd8df1780964355842b1cc4a0
2019-03-18 14:24:25 -07:00
Dulmandakh f49f1812ed land androidx in gradle (#24014)
Summary:
Use AndroidX in ReactAndroid/build.gradle, and remove androidx dependency from template and RNTester app because it's already exposed/exported from ReactAndroid.

[Android] [Changed] - Land AndroidX in gradle
Pull Request resolved: https://github.com/facebook/react-native/pull/24014

Differential Revision: D14508774

Pulled By: mdvacca

fbshipit-source-id: c96b97876571a5a7f2b400dd29188cfdf1f84a4c
2019-03-18 13:37:17 -07:00
Alston Lin d6b2f78ad4 Added support for saving http and https URIs in the React Native CameraRoll module
Summary:
Currently, the behavior of saving in the `CameraRoll` module varies depending on the platform.

On iOS, remote URIs are supported and will save a remote image to the local storage. However, on Android it can only be used for local images, making this function much less useful.

This change allows the Android version of the `CameraRoll` module to have the same behavior, at least for http and https scheme URIs, which will probably cover the vast majority of the use cases.

Reviewed By: sahrens

Differential Revision: D14483943

fbshipit-source-id: e63ca786240e6657c8c8e0292be9fb08efa40ef1
2019-03-18 13:03:28 -07:00
Dulmandakh 75af15ede4 use Conscrypt as security provider if available (#23984)
Summary:
This PR adds support to use Conscrypt as Security Provider if available runtime. Consscrypt supports TLS 1.2 on Android 4.x and TLS 1.3 on all Android versions. Fixes issues (ex https://github.com/facebook/react-native/issues/23151) with HTTPS connections on Android 4.x.

Just add below to your project build.gradle and it'll use it.

```gradle
implementation('org.conscrypt:conscrypt-android:2.0.0')
```

[Android] [Changed] - Add TLS 1.3 support to all Android versions using Conscrypt.
Pull Request resolved: https://github.com/facebook/react-native/pull/23984

Differential Revision: D14506000

Pulled By: cpojer

fbshipit-source-id: 58bf18f7203d20519fb4451bae83f01e2f020a44
2019-03-18 12:01:35 -07:00
Ryan Elliott eec2495a96 Resolve issue #23816, updated with recent merges (#23961)
Summary:
This fixes #23816, which states that `getSize()` does not function correctly on Android. The original PR for this is now outdated as there have been merges into master that would create merge conflicts.

[Android] [Fixed] - Added correct handling for `getSize()` to avoid warnings being thrown.import
Pull Request resolved: https://github.com/facebook/react-native/pull/23961

Differential Revision: D14505183

Pulled By: cpojer

fbshipit-source-id: 3d8976fd518de0903d7736a8cbd8371987eb1b2d
2019-03-18 11:16:20 -07:00
Estevão Lucas fa426cf05f - Add openSettings method to Linking module (#23965)
Summary:
This will create a cross-platform and safe way to programmatically open the app's settings into the iOS /Android Settings app.

Right now it's possible to open the app's settings, but _**only for iOS**_ via `Linking.openURL("app-settings:")`

To do the same for Android, you need to either create NodeModule or install a dependency such as [react-native-open-settings](https://github.com/lunarmayor/react-native-open-settings).

Why this new method is useful: since Android 6, app permissions work similar to iOS. It's granular and it's requested in the app runtime.

https://developer.android.com/guide/topics/permissions/overview#runtime_requests_android_60_and_higher

> If the device is running Android 6.0 (API level 23) or higher, and the app's targetSdkVersion is 23 or higher, the user isn't notified of any app permissions at install time. Your app must ask the user to grant the dangerous permissions at runtime. When your app requests permission, the user sees a system dialog telling the user which permission group your app is trying to access. The dialog includes a Deny and Allow button.

Thus, if the user checks the **"Never ask again box"** and taps **"Deny"**, for some specific permission, the only way to change the permission is going to the Android Setting app.

And that's where this new method becomes useful. It'll allow our apps to programmatically send the the user to  settings app.

Also, `openSettings()` doesn't receive a parameter to redirect to specific subsections of the Settings app because there's no public API to do it on iOS ([there's a way to have, via private API, but it causes the app to get rejected.](https://github.com/mauron85/cordova-plugin-background-geolocation/issues/394))

Create `Linking.openSettings()` for iOS and Android;

[General] [add ] - Add openSetting method to Linking module
Pull Request resolved: https://github.com/facebook/react-native/pull/23965

Differential Revision: D14502910

Pulled By: cpojer

fbshipit-source-id: d27d62282b9df499845c78d983d3b6936c36ea39
2019-03-18 08:06:12 -07:00
Max Komarychev cc3f9a7538 Fix native implementation of `Animated.modulo` (#23973)
Summary:
fixes #23875
[ios,android][fixes] incorrect behavior of `Animated.modulo`

Use the same formula as used in js: `mod(a,m)=>(a % m + m) % m` (https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedModulo.js#L35)

Native implementation of `Animated.modulo` was different from what was used in javascript, more details available here: https://github.com/facebook/react-native/issues/23875

[iOS] [Fixed] incorrect behavior of Animated.modulo
[Android] [Fixed] incorrect behavior of Animated.modulo
Pull Request resolved: https://github.com/facebook/react-native/pull/23973

Differential Revision: D14502697

Pulled By: cpojer

fbshipit-source-id: befef2b99ae758f98459caaadc8ebdbbd547e69a
2019-03-18 07:40:56 -07:00
David Vacca 8d5ac8de76 Migration of RN-Android OSS tests to Android X
Summary:
This diff migrates RN to AndroidX.
As part of this diff I disabled few tests in RNAndroid OSS that will be re-enabled this week. As part of the refactor of BUCK files in OSS

Reviewed By: shergin

Differential Revision: D14200097

fbshipit-source-id: 932fcae251d1553e672acd67ecd0e703dcb364aa
2019-03-17 08:13:30 -07:00
Dulmandakh d6ee448e15 fix switch trackColor on Android. fixes #23962 (#23977)
Summary:
fixes #23962, where trackColor is reset when value changed. This PR will set trackColor corresponding trackColor every-time value changes.

[Android] [Changed] - Fix Switch trackColor
Pull Request resolved: https://github.com/facebook/react-native/pull/23977

Differential Revision: D14495206

Pulled By: hramos

fbshipit-source-id: d712f540cd3f8359d6e85f79c12732689870a112
2019-03-16 07:33:14 -07:00
Yedidya Feldblum 508daf2c21 Upgrade mobile BUCK and .bzl files to use C++14
Summary:
Upgrade mobile `BUCK` and `.bzl` files to use C++14.

Let's see what happens.

Reviewed By: mzlee

Differential Revision: D14223329

fbshipit-source-id: ff642ca017103d9415c4d7f5beaf5ded07ef7ff1
2019-03-16 02:25:33 -07:00
Peter Argany 845189c17d Turn off Metro JS Deltas by default for Android
Summary: JS Deltas have been killing productivity of RN engineers lately. There's been several posts and questions asked that end in "Turn off JS Deltas". Disabling them until we can make them more stable.

Reviewed By: fkgozali

Differential Revision: D14491774

fbshipit-source-id: 29b1c8e5e72369882c2890e3b6347ecd2fe4bed1
2019-03-15 17:33:36 -07:00
Héctor Ramos d4aa1e7a52 Do not use autofill methods on Android APIs older than Oreo (26)
Summary:
Autofill Hints were added in [Android API 26](https://developer.android.com/reference/android/view/View.html#setAutofillHints(java.lang.String...)). Without this runtime check, pre-26 devices will crash.

[Android][Fixed] - Fixes crash on pre-26 Android devices when setting text content type

Reviewed By: lunaleaps

Differential Revision: D14479468

fbshipit-source-id: 238c1efd6aea682a93ecb45e1123aaed6bdcd9e3
2019-03-15 11:57:37 -07:00
Peter van der Zee dcd4e90d9a Bump Prettier to 1.16.4
Summary:
@public
This bumps Prettier to v1.16.4
Only format source files were updated.

Reviewed By: mjesun

Differential Revision: D14454893

fbshipit-source-id: 72f9872fe764a79dbf0d9fab9bebb1456b039f2f
2019-03-14 07:00:27 -07:00
Eric Schlanger 6cc5137a07 Exclude logging functionality outside debug builds
Summary: Don't compile in YGNodePrint in production builds

Reviewed By: davidaurelio

Differential Revision: D14258269

fbshipit-source-id: 15b5e94d241a752fea74a45263aa343265071451
2019-03-13 07:39:16 -07:00
Sidharth Guglani 7e9e6c1ce5 moved together the java object fields which are set always
Summary:
Moved all layout outputs fields which are set always on yoga node java object.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14355025

fbshipit-source-id: 371d9c49fcb631efa8a79b62f8051ba5a17c232c
2019-03-13 07:02:31 -07:00
Sidharth Guglani d31cc696fb change BOrder constant to 4 to set correct field bits
Summary: These constants are used for setting bit fields so they should be in power of 2

Reviewed By: davidaurelio

Differential Revision: D14384999

fbshipit-source-id: fa1f6994c874aff7a039ca98d5947cba317fa749
2019-03-13 03:23:17 -07:00
Andrew Schenk 25d397651e adds type checking to Animated toValue and iterations key values to m… (#23812)
Summary:
…ake sure Android does not crash from bad params when using useNativeDriver

Android apps crash when using Animated useNativeDriver: true and the toValue is not a number.  See issue here with test case.  [Issue](https://github.com/facebook/react-native/issues/23810)

[Android] [fixed] - Fix crash when using Animated with useNativeDriver and a non Number toValue
Pull Request resolved: https://github.com/facebook/react-native/pull/23812

Differential Revision: D14436113

Pulled By: cpojer

fbshipit-source-id: 89fb3180c08cc5ffb817b3984dacda0a80b4f703
2019-03-12 22:54:22 -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
Sébastiaan Versteeg c991e1c4cc Add Image.getSizeWithHeaders (#18850)
Summary:
This adds new functionality to the `Image` component by allowing you to retrieve the width and height of an image just like you'd do with [`Image.getSize`](https://facebook.github.io/react-native/docs/image.html#getsize) but _with_ the ability to provide headers to your request.

Why would you need this you ask? Well, imagine that you have an image that you're loading into your `Image` component that is protected and you get access by using a token in a header (or something similar). That would work. However, getting the dimensions isn't possible since you can't provide those same headers.
This is something that is bothering me when using a third-party library (https://github.com/archriss/react-native-image-gallery) and instead of implementing this just for that single library I imagined that it would be useful for anyone else that needs to get the image dimensions before displaying it.

[Android] [Added] - Added Image.getSizeWithHeaders
[iOS] [Added] - Added Image.getSizeWithHeaders
Pull Request resolved: https://github.com/facebook/react-native/pull/18850

Differential Revision: D14434599

Pulled By: cpojer

fbshipit-source-id: 56d5e58889ddf7ddc12d5f6f7d9dc6921fa17884
2019-03-12 19:20:31 -07:00
David Aurelio 015b5ddc2e Remove configuration for avoiding JNI refs
Summary:
@public

Removes the configuration field to avoid weak JNI refs. It is no longer used.

Reviewed By: marco-cova

Differential Revision: D14424594

fbshipit-source-id: f0877022615a11ac5079354e0977c6893b7d58d7
2019-03-12 13:15:18 -07:00
David Aurelio 85b3454678 No more weak JNI refs!
Summary:
@public

Completely removes the usage of weak JNI refs.

This is great, because node allocation and deallocation no longer go through a VM-global lock to access the weak reference table.
This is also great, because we can no longer overflow that ref table.
Performance is comparable to weak refs.

Reviewed By: marco-cova

Differential Revision: D14423068

fbshipit-source-id: 62003d2d6fd971e91460a26fb3477046f26e2ba5
2019-03-12 13:15:18 -07:00
Emily Janzer 0b266458ea Change EventBeatManager and AsyncEventBeat to use RuntimeExecutor
Summary:
Right now we have a raw pointer to the js runtime in Java and we pass that to EventBeatManager's constructor; this diff adds a setter for the runtime ptr and removes it from the member initializer list, so that you can set it later from cpp instead.

Q: Should I just rewrite this to use RuntimeExecutor instead?

Reviewed By: shergin

Differential Revision: D14318893

fbshipit-source-id: 1221dd5959927967bad870f15c901c15e5455874
2019-03-12 11:06:52 -07:00
David Vacca 726d001210 Cleanup TextLayoutManager
Summary: Easy cleanup of commented code in TextLayoutManager, I kept the TODOs to complete the code in the future

Reviewed By: shergin

Differential Revision: D14372356

fbshipit-source-id: ff87f9b09e9f40ed021256f463e39299467b3e0e
2019-03-11 19:24:06 -07:00
David Vacca 36957dcedd Disable ImportantForAutofill when using Android API level < 26
Summary: Disable ImportantForAutofill when using Android API level < 26

Reviewed By: wcheng86

Differential Revision: D14400085

fbshipit-source-id: db8f94d38ed6b3f6559a13abb8752f08a3d0dab2
2019-03-11 18:49:07 -07:00
Luna Wei cba75cf12d EditText turn off hardware acc. for Oreo
Summary:
Research into this error led us to this: https://issuetracker.google.com/issues/67102093

which refers to a very similar stack trace as our error:
* Both errors have a bad access in `android.text.DynamicLayout.getBlockIndex` due to a negative array index
* The report mentions it only affecting Oreo devices, this aligns with our [LogView](https://our.intern.facebook.com/intern/logview/details/facebook_android_crashes/80ce327664e6696ef03f951a9268ac29/?trace_key=cc916846a500b6efb5c68ae1a2e6b5c3) where ~99% of affected device os versions are Oreo.

As a workaround mentioned in discussion, this diff turns off hardware acceleration for Oreo devices in `ReactEditText`

Reviewed By: mdvacca

Differential Revision: D14291369

fbshipit-source-id: 797d3123bcb240abd2401ca0d7d3a5a3ef8e22e3
2019-03-05 14:39:34 -08:00
Rick Ratmansky f43f48fce1 Fixing robolectric tests by not skipping androidx instrumentation
Summary:
androidx files were not being instrumented properly which meant we would have exceptions thrown by powermock

Robolectric Instrumentation config was changed by hand, the remainder is a codemod using abgs + xargs + sed

Differential Revision: D14323745

fbshipit-source-id: 56aa97dad5d7197f4eb0ba1fdd80b1583bcad6ac
2019-03-05 14:33:42 -08:00
Sunny Luo d2153fc58d Text: Implement textAlign justify for android O+ (#22477)
Summary:
Add textAlign justify for android O+(api level >=26)
Resolves https://github.com/facebook/react-native/issues/22475

<img src="https://user-images.githubusercontent.com/615282/49341207-35e3b980-f685-11e8-91ab-dbc19c1ee4d0.gif" width="400" />

Changelog:
----------
[Android] [Added] - Implement textAlign justify for android O+
Pull Request resolved: https://github.com/facebook/react-native/pull/22477

Differential Revision: D13512004

Pulled By: cpojer

fbshipit-source-id: e20f4976bfd957a5faeae0bbed2ff27c03023bb1
2019-03-05 00:35:08 -08:00
David Aurelio b9a7880434 Fix problems with GCC < v8
Summary:
@public

GCC up until v7 flags our way of reading edges in `YGNodeSetStyleInputs` as unused variables. I managed to work around that by rearranging the casts a bit.

Reviewed By: SidharthGuglani

Differential Revision: D14299439

fbshipit-source-id: eec0266185504d1b790b9ef574bd4a83c0059d3a
2019-03-04 02:37:34 -08:00
David Aurelio fb329fbf86 Encapsulate all used java classes
Summary:
@public

Moves all Java classes used from C++ to their own header + implementation file. In `YGJNI.cpp`, we only call methods on these objects deriving from `jni::JavaClass`.

This is only a bit of cleanup, no functional change.

Reviewed By: SidharthGuglani

Differential Revision: D14261043

fbshipit-source-id: 2db1d81cb7f56a4cdc24b182b2166e1d7e24ba3c
2019-03-04 01:30:49 -08:00
David Vacca d451c03284 Remove createMountItem code
Summary:
Now that pre-allocation of views update props, we can just force the execution of "pre-allocation" instead of "create" mount item.

This diff removes the methods that were used by view creation

This way we reduce the amount of mountItems that are created during commit phase.
This should improve TTI (I'm running a MobileLab)

Reviewed By: shergin

Differential Revision: D14297477

fbshipit-source-id: a100bab798467e9f0fa9773e0206ba1ded472298
2019-03-03 15:51:32 -08:00
David Vacca 7720613bda Add systraces for pre-mountItems executed during commit
Summary:
Now that pre-allocation of views update props, we can just force the execution of "pre-allocation" instead of "create" mount item.

This diff adds systraces to the execution of pre-mountItems during commit

This should reduce the amount of mountItems that are created during commit phase.
This should improve TTI (I'm running a MobileLab)

Reviewed By: shergin

Differential Revision: D14297478

fbshipit-source-id: d8e515d34cf6edacce53c0903f74a08029259f6f
2019-03-03 15:51:32 -08:00
David Vacca 861e406097 Force execution of all pre-allocation of views before execution of mount items
Summary:
Now that pre-allocation of views update props, we can just force the execution of "pre-allocation" instead of "create" mount item.

This should reduce the amount of mountItems that are created during commit phase.
This should improve TTI (I'm running a MobileLab)

Reviewed By: shergin

Differential Revision: D14297476

fbshipit-source-id: 3ade662848ed836dc3221abe78611bb4a2b94e00
2019-03-03 15:51:32 -08:00
David Vacca ca6e1793ed Cleanup android log
Summary:
Cleaning up <android/log.h> from includes
We use LOG
```
LOG(INFO) << "message";
```
to log

Reviewed By: shergin

Differential Revision: D14297264

fbshipit-source-id: 1a9a760a092b6947cca7d7d59b66c574b3e41ad8
2019-03-03 15:51:32 -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
David Vacca 95c414cfbf Introduce "updateProps" field InsertMutation
Summary: This diff introduces the concept of "updateProps" as part of InsertMutation and it changes the diffing algorithm to populate this field.

Reviewed By: shergin

Differential Revision: D14289608

fbshipit-source-id: 642f00d03d294a12ea7fa7482c72e701b756f3d4
2019-03-03 09:00:47 -08:00
David Vacca f6ba52bf1e Enable update of props during preallocation for all views
Summary:
Before only the props of Images components were being applied during the pre-allocation phase.
Now that we have a limit of time that pre-allocations will be executed we can update props for any component

Reviewed By: shergin

Differential Revision: D14252171

fbshipit-source-id: afea4b71a32b7ae2c184b0cdce97f778bc3a47d2
2019-03-03 09:00:47 -08:00
David Vacca ed8573f957 Implement limit to execute pre-mount operations
Summary: This diff implements a limit on the execution of pre-allocation of views, taking into consideration the time it is left on the frame, with a maximum of 8 ms / frame

Reviewed By: shergin

Differential Revision: D14252172

fbshipit-source-id: 1780a489122a8bc476d6ec7c92b45fdc58993e1d
2019-03-03 09:00:47 -08:00
David Vacca aa69e51096 Preallocate Image 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.

This was originally landed in D14214844 and then backed out in D14247897

Reviewed By: shergin

Differential Revision: D14286232

fbshipit-source-id: 8437f57f9473eb22ef98d80531b4020ee5fbb9ae
2019-03-03 09:00:47 -08:00
David Aurelio f41cb21c3d clean up config context
Summary: `YGConfigContext` was using `global_ref` instances for the config, leading to the config object never being freed. Since we no longer need it after getting rid of cloning, we can make the context a pointer to a `global_ref` to the logger.

Reviewed By: SidharthGuglani

Differential Revision: D14258571

fbshipit-source-id: cce632499839a680eef00a3854f61ab74ae2a87a
2019-03-01 05:45:05 -08:00
Luna Wei bc06d1cc9c Use a surface switch
Summary: Flesh out how surface will be used with a flag in ReactRootView

Reviewed By: mdvacca

Differential Revision: D14112897

fbshipit-source-id: adf6078048dbf83452d3523f0530a4d6dca7b3e8
2019-02-28 17:30:13 -08:00
Sidharth Guglani 87a6ebda2a Setting flags for margin, padding, position and border
Summary:
We set flags to true when setting margin, padding, border, position individually
Doing the same for batching API

Reviewed By: davidaurelio

Differential Revision: D14207550

fbshipit-source-id: ddfdcd5056bea0dd76bd6762f47e90370e26c9e1
2019-02-28 12:55:39 -08:00
Sidharth Guglani 754011c144 Added getters for flexWrap and flex style inputs in java bindings
Summary: Added getters fro flexWrap an flex style input properties in java bindings

Reviewed By: davidaurelio

Differential Revision: D14207517

fbshipit-source-id: e8d2ad17b5edbdf02e69011c6d95a4de076bd366
2019-02-28 12:55:39 -08:00
Sidharth Guglani 30dd48e0f6 JNI batching API using float array
Summary:
Added a new API `YGNodeSetLayoutStyleInputs` to pass layout style inputs from java to native code.
All the style inputs are passed in a float array in [key1, key2, value2, key3, value3a, value3b .....] format over JNI layer.
There are three types of style inputs
- do not need any value to be passed along with them like WidthAuto, HeightAuto
- need one value to be passed like Width, Height
- need two values to be passed like Margin, Padding (edge value and actual margin, padding value)

Reviewed By: davidaurelio

Differential Revision: D14166948

fbshipit-source-id: 4bea64d6a429959c3962c87e337914dcd99199fd
2019-02-28 12:55:39 -08:00
Sidharth Guglani 6c7649503a added mEdgeSetFlags inside YogaNodeContext and using it YGJNI in getters/setters of margin, padding, border
Summary:
We have now create a yoga node context which consists of weak reference to java yoga node object and flag which tells us whether margin, padding , border are set or not.

This flag was initially in java layer and we have moved this to native layer as it will help us with enabling the bacthing API for setting style inputs.

Reviewed By: davidaurelio

Differential Revision: D14243378

fbshipit-source-id: fed935ef18c1abf2b07e5d69d9ca79ced51699f2
2019-02-28 12:55:39 -08:00
Sidharth Guglani 5a9d944e57 not setting flags when setting margin, padding, border and position on yoga node
Summary: We are now not setting flags when we set style inputs margin, padding, border and position on yoga node.

Reviewed By: davidaurelio

Differential Revision: D14224000

fbshipit-source-id: deef4c1ab1a60fbc4909183bc2aa59fa23939d43
2019-02-28 12:55:39 -08:00
Peter Argany f2d20d2904 Set Platform.isTesting true when running Server Snapshot Tests
Summary:
`Platform.isTesting` returns false when running SSTs. This diff changes that to true.

See https://our.intern.facebook.com/intern/qa/9690/how-to-detect-when-running-as-sst for inspiration.

I fixed this for iOS in D13981728.

Reviewed By: cpojer

Differential Revision: D14244606

fbshipit-source-id: ed95b772cc4206cf7c835aed7415aa5fc5fbdf7d
2019-02-28 12:50:30 -08: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
Vishwesh Jainkuniya 60c0a60c50 Fix: mostRecentEventCount is not updated. (#17990)
Summary:
<!--
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.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

Update it's value as it changes on the JS thread, so that updated value is used (f7f5dc6649/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java (L243)) whenever setSelection(int start, int end) is called (f7f5dc6649/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java (L315)).
Pull Request resolved: https://github.com/facebook/react-native/pull/17990

Differential Revision: D14255969

Pulled By: mdvacca

fbshipit-source-id: 555d6752eabca5c31c1762955a56f99cc1828546
2019-02-27 22:18:55 -08:00
David Aurelio 537ed61d94 Breaking remove `YogaNode#clone`
Summary:
@public

The cloning features of YogaNode don’t seem to be used. Let’s remove them.

Reviewed By: SidharthGuglani

Differential Revision: D14165624

fbshipit-source-id: 5b710964a4abf1b35f3bcc25b143ffc719a03cec
2019-02-27 05:03:12 -08:00
Joshua Gross 3c1114eea7 Enable Slider component
Summary:
Enable Slider component in Fabric on Android.

{F151706188}

Reviewed By: mdvacca

Differential Revision: D14220147

fbshipit-source-id: 10b29112e950c8de98cba995839780c4f4e8d3b6
2019-02-26 14:40:58 -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
Luna Wei 4cf70306b9 Use cached react tag versus id on view
Summary: Due to the way (initial) surface implementation plays with ReactRootView (RRV), the react tag from the UIManagerModule is now set on the surface container view rather than on RRV as it was historically done. RRV still caches the react tag but just doesn't use it as an id on the view so `RRV.getViewId()` no longer equals `RRV.getReactTag()`.

Reviewed By: mdvacca

Differential Revision: D14110104

fbshipit-source-id: 6dbcc41c85fd7a6c32c7250f68f4a84bed4e075a
2019-02-25 17:25:42 -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
David Vacca 4859b1a126 Remove unused variables
Summary: Trivial diff to remove unused variables

Reviewed By: fkgozali

Differential Revision: D14214843

fbshipit-source-id: ace624bafce12c9ee6ce02051d684e581e78fe2c
2019-02-25 17:21:24 -08:00
Sergei Dryganets 972f39985a This change fixes currently broken ReactContext listeners mechanism. (#22318)
Summary:
This mechanism is heavily abused inside of the react-native and inside of the various native modules.
The main problem is that people don't remove their listeners and as result, we have memory leaks.

Some modules like UIManager, NativeAnimatedModule have resources holding Activity context. Those modules are held through a pretty long chain of dependencies.

In order to allow GC to collect those listeners, I replaced the CopyOnWriteSet by WeakHashMap and synchronized access. It is not such a big deal in terms of performance as those listeners are not called/modified too frequently but this prevents hard to debug memory leaks.

Changelog:
----------
Help reviewers and the release process by writing your own changelog entry. When the change doesn't impact React Native developers, it may be ommitted from the changelog for brevity. See below for an example.

[Android] [Fixed] - ReactContext - lifecycle listeners don't cause the leaks even if not removed.

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

Reviewed By: mdvacca

Differential Revision: D13106915

Pulled By: hramos

fbshipit-source-id: d506e5035a7f7bea1b57a6308fb5d9b5fcb277a7
2019-02-25 08:06:22 -08:00
yukai1 b2d3052de7 ModalHostView's child view can not fill screen (#18615)
Summary:
Signed-off-by: yukai <yk3372@gmail.com>

In some Android device such as Samsung S8, the ModalHostView's child view can't fill the screen.
before:
![before](https://user-images.githubusercontent.com/1514899/38024961-3e756f8e-32b9-11e8-9555-50a7cf778288.jpeg)
The JS ModalHostView can't fill the bottom, the area is device's navigation bar.

In class ModalHostShadowNode, follow code calculate is error:
`Point modalSize = ModalHostHelper.getModalHostSize(getThemedContext());`
This way not care the device's navigation bar, so the height is smaller than real.
For Samsung S8, real height is 2220 and modalSize.y is 2076.
Pull Request resolved: https://github.com/facebook/react-native/pull/18615

Differential Revision: D14206830

Pulled By: cpojer

fbshipit-source-id: abe35ce1ab253aa1472d2c798543b515218be445
2019-02-25 01:18:42 -08:00
August Lilleaas a8449c14ac Allow ReactActivityDelegate subclass to overrride mainComponentName (#19814)
Summary:
Currently, the final field mMainComponentName is used. This field is
initialized in the constructor of ReactActivityDelegate, and the
ReactActivityDelegate itself is initialized in the constructor of
ReactActivity. This means that the only way you can pass a main
component name to ReactActivityDelegate, is when your ReactActivity
subclass is constructed. At this point in the lifecycle of an
activity, the getIntent() value that the activity was initialized by
returns null, making it impossible to set the mainComponentName
dynamically based on data passed to the activity via an intent.

The mMainComponentName final field is also only used in onCreate of
the delegate, so it's not actually needed by the ReactActivityDelegate
at construction time. So the above limitation is not fundamental, it's
just a side effect of the API design.

By allowing subclasses of ReactActivityDelegate to implement a
getMainComponentName method, the subclass then has full control of how
to initialize the value. So an implementation of getMainComponentName
could be:

    public String getMainComponentName() {
        return getIntent().getStringExtra("reactMainComponentName");
    }

This commit doesn't remove anything and only adds a new method, so it
should be fully backwards compatible.

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.

<!--
  Required: Write your motivation here.
  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/19814

Differential Revision: D14206644

Pulled By: cpojer

fbshipit-source-id: 8532560f944362fe0cce263a7f9a503df8ae539f
2019-02-25 00:40:11 -08:00
Wei Yang b9d3743cda add talkback navigation support for links and header (#22447)
Summary:
1. add role description for heading
2. add talkback navigation support for link and header

Fixes #22440
Pull Request resolved: https://github.com/facebook/react-native/pull/22447

Differential Revision: D14205822

Pulled By: cpojer

fbshipit-source-id: 86bfc3bfc851f3544b1962012abaf8d1a357a9d2
2019-02-24 19:25:51 -08:00
David Vacca 2e42cc7652 optimize calls to updateRootLayoutSpecs
Summary: This diff changes the onMeasure method of the RootView to optimize the amount of times we call updateRootLayoutSpecs in Fabric

Reviewed By: shergin

Differential Revision: D14198155

fbshipit-source-id: ff2deee04540899c25d4e38b0bd93333f74c6ace
2019-02-24 11:58:47 -08:00
David Vacca daccb54353 Add new performance metric in Fabric
Summary: This diff adds a new metric in Fabric to measure time it takes to Fabric finish transaction in CPP

Reviewed By: shergin

Differential Revision: D14198153

fbshipit-source-id: 987d1db1ae669906192060cc9b9e077901da6787
2019-02-24 11:58:47 -08:00
David Vacca 10679a97c3 Temporarily remove optimization of updateRootLayoutSpecs
Summary: revert D14142305

Reviewed By: shergin

Differential Revision: D14198154

fbshipit-source-id: 2f2b2b6e0c0d64b71dc720b3d934c348600e0367
2019-02-24 11:58:47 -08:00
Dulmandakh 0b4f74176c add nullable annotations to some ViewManager methods (#23610)
Summary:
Add nullable annotations to BaseViewManager and ViewManager methods. This will improve Kotlin developer experience and help Android Studio to offer better autocomplete.

[Android] [Changed] - add nullable annotations to BaseViewManager and ViewManager methods. Might break ViewManagers in Kotlin.
Pull Request resolved: https://github.com/facebook/react-native/pull/23610

Differential Revision: D14198630

Pulled By: mdvacca

fbshipit-source-id: c596c88254e1d02f0af233a466f685200fac8917
2019-02-23 10:07:31 -08:00
Nate Hunzaker 0d5aebbd9a Use existing character set in POST body when possible (#23603)
Summary:
This commit fixes a bug introduced in a previous attempt (https://github.com/facebook/react-native/pull/23580) to address an issue where okhttp appended `charset=utf-8` to the Content-Type header when otherwise not specified.

In that commit, I converted all characters to UTF-8, however it should instead use an existing encoding when possible.

Related issues:
https://github.com/facebook/react-native/issues/8237#issuecomment-466304854

[Android][fixed] - Respect existing character set when specified in fetch() POST request
Pull Request resolved: https://github.com/facebook/react-native/pull/23603

Differential Revision: D14191750

Pulled By: hramos

fbshipit-source-id: 11c1bfd98ccd33cd8e54ea426285b7d2ce9c2d7c
2019-02-22 16:20:49 -08:00
Chris Sarbora c1349b5960 Rename makeCriticalNativeMethod to discourage over-use
Summary: "Critical" or "Fast" JNI methods are enticing by their name, but carry dangers that are not trivially visible.

Reviewed By: davidaurelio

Differential Revision: D14184560

fbshipit-source-id: 89ec70f53bb2cb89ff568d8b1fe222ede86c9824
2019-02-22 14:29:45 -08:00
David Vacca 8928358108 optimize updateRootLayoutSpecs to not call setContraints if they did not change
Summary: This diff avoids calling mBinding.setConstraints when the measurespecs haven't changed

Reviewed By: shergin

Differential Revision: D14142305

fbshipit-source-id: 6770c97dcf0fb23c605a90fb6c3311d2fb771d11
2019-02-22 13:51:30 -08:00
David Vacca 1aa279d78b Force updateRootLayoutSpecs to run synchronously
Summary: This diff makes updateRootLayoutSpecs to run synchronously on any thread instead of schedulling this to run in the JS thread

Reviewed By: shergin

Differential Revision: D14142306

fbshipit-source-id: 746f9c51f13e6d987fd9bca35a7c502cc8622f7b
2019-02-22 13:51:30 -08:00
David Vacca eae89d829f Add logging for BatchMountItem
Summary: trivial diff to add logging in BatchMountItem

Reviewed By: JoshuaGross

Differential Revision: D14142307

fbshipit-source-id: 39ca5dd00a0beed9e6a7baf5434d82f9d26381c4
2019-02-22 13:51:29 -08:00
David Vacca cda8171af3 Fix IllegalArgumentException when creating CookieManager
Summary:
This prevents this https://bugs.chromium.org/p/chromium/issues/detail?id=559720 to crash the app.
When using this fix the webView will not function correctly

More details about the bug https://bugs.chromium.org/p/chromium/issues/detail?id=559720

Reviewed By: fkgozali

Differential Revision: D14181851

fbshipit-source-id: 5a8c149df82a7373fe8b5b32006f034868532485
2019-02-22 11:27:16 -08:00
David Aurelio c3522a017d Don't call `jni_YGNodeFree` as fast native method
Summary:
@public

If `jni_YGNodeFree` is called while GC is running, the weak reference table lock is held by the GC, leading to deadlock.

Here, we revert the method to being a regular native method, solving that problem.

Reviewed By: SidharthGuglani

Differential Revision: D14184220

fbshipit-source-id: 2882fa10586617cea2df99550a7dd8885376d11e
2019-02-22 09:00:39 -08:00