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

15496 Коммитов

Автор SHA1 Сообщение Дата
Sam Goldman 2c7895706d @allow-large-files Deploy Flow v0.90 to xplat/js
Reviewed By: dsainati1

Differential Revision: D13708161

fbshipit-source-id: b83dab505f2739bf4bc5077936e71ebd1800eaf4
2019-01-16 21:55:02 -08:00
Louis Lagrange cf85d0e4d6 Add HTTP cache by default (like iOS) (#18348)
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!

-->

On iOS, the cache is enabled by default but it's not the case on Android. This PR adds 10Mo of HTTP cache by default. 10Mo was chosen arbitrarily.

Fixes #16795

<!--(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)-->

I wrote it so there's no breaking change for those already using the `OkHttpClientProvider.createClient` and `OkHttpClientProvider.createClientBuilder` public methods.

1. react-native init TestAndroidCache
2. Followed https://facebook.github.io/react-native/docs/android-building-from-source.html to build  with this branch as react-native
3. Added the following code in the App.js (with correct URL_WITH_CACHE_CONTROL)
4. Made sure the debugger is closed
5. Throttled my mac's network speed with the `Network link conditioner` (edge)
6. Tapped "Fetch", it shows ~4000
7. Tapped "Fetch" again, it shows ~6

```js
import React, { Component } from 'react';
import {
  StyleSheet,
  Alert,
  View,
  Button
} from 'react-native';

type Props = {};
export default class App extends Component<Props> {
  fetch = () => {
    const start = Date.now();
    fetch('{URL_WITH_CACHE_CONTROL}').then(() => {
      const diff = Date.now() - start;
      Alert.alert(diff.toString());
    });
  };

  render() {
    return (
      <View style={styles.container}>
        <Button title={"fetch"} onPress={this.fetch} />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
});
```

None

<!--
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
-->
[ANDROID] [FEATURE] [Networking] Add HTTP caching
Pull Request resolved: https://github.com/facebook/react-native/pull/18348

Differential Revision: D13680430

Pulled By: hramos

fbshipit-source-id: 1e49cf75702db72b20a316e9cdd971605f8fe7e0
2019-01-16 20:59:22 -08:00
Valentin Shergin 091edd2ef7 Fabric: Clear separation between `commmit` and `tryCommit`
Summary: Previously we had a single `commit` function that accepts an argument that enables auto-retry mechanism. As Spencer pointed out, that wasn't so useful and clear. So, I split the method into two with more expressive names.

Reviewed By: sahrens

Differential Revision: D13681594

fbshipit-source-id: 529f729d597206e9a0ac940f005a1569a9bef707
2019-01-16 20:22:40 -08:00
Valentin Shergin 8d83d5f8eb Fabric: Unifying retain/release logic in EventTarget
Summary:
I read my code and one thing stroke me: What if the same event emitter dispatches several events during the same event beat? In the previous implementation, only the first one will be delivered because the first `release` call consumes stored strong reference.
So, I changed the API a bit to make this more explicit: we have `retain` & `release` methods and we have a getter that works (multiple times) only if the object was successfully retained.

Reviewed By: sahrens

Differential Revision: D13668147

fbshipit-source-id: c00af5f15bc7e30aa704d46bd23584b918b6f75a
2019-01-16 20:22:40 -08:00
Valentin Shergin 7d630b92dc Fabric: Lock-free events 5/n: New implementation of `toggleEventEmitters` (which does not rely on mutations)
Summary: This diff implements a new algorithm that effectively marks `EventEmitter`s enabled or disabled. The previous implementation relied on a list of mutation instructions whereas the new one analyzes the shadow trees. The mutations-based approach didn't work well because mutations describe `ShadowView`s whereas some `ShadowNode`s are simply not views (like VirtualText), but we have to enable/disable them anyway.

Reviewed By: sahrens

Differential Revision: D13642594

fbshipit-source-id: 12169e11d5685e50bcd0d8c410498c594df744b4
2019-01-16 20:22:39 -08:00
Valentin Shergin cdb983d339 Fabric: Lock-free events 4/n: Added an assert in EventTarget
Summary: See the diff for more details.

Reviewed By: sahrens

Differential Revision: D13642593

fbshipit-source-id: 8bdcc91bcc2ea1e4093bcac03d87167b8901cbb4
2019-01-16 20:22:39 -08:00
Valentin Shergin 97f9e4082c Fabric: Lock-free events 3/n: EventEmitter::DispatchMutex is not recursive mutex anymore
Summary: The mutex is a "leaf" mutex, so the code cannot reenter that, so there is no reason to be a recursive one.

Reviewed By: sahrens

Differential Revision: D13642592

fbshipit-source-id: 0fb64d3405c5d3408251dc983c186f6747bc6ee2
2019-01-16 20:22:39 -08:00
Valentin Shergin b1814b37aa Fabric: Lock-free events 2/n: Reimagining of EventTarget
Summary:
EventTargetWrapper and EventTarget were merged into one class that controls an `instanceHandle` reference and extracting a strong reference to it.

This diff also decouples the operation of retaining a strong reference (with checking a `enabled` flag) from actual usage of this reference. This allows to wrap into a mutex only first part of this process and avoid possible deadlocks.

Reviewed By: sahrens

Differential Revision: D13616382

fbshipit-source-id: 9907bc12047386fcf027929ae2ae41c0b727cd06
2019-01-16 20:22:39 -08:00
Valentin Shergin bea80b2276 Fabric: Lock-free events 1/n: Removing WeakEventTarget trick from EventEmitter
Summary:
For some time we have had a nit trick inside `EventEmitter`: When event emitter is disabled, we switch to store `EventTarget` as a weak pointer instead of complete deleting it. Given some unpredictability of JS GC, it gave us some time to restore the pointer in case if we increment the counter right after decrementing this. Apparently, we found that it doesn't always work (obviously, sigh...), so we implement the `enableCounter_` and left this feature as it is assuming that it can nice optimization that illuminates some unnecessary constraints.
But, apparently, it's actually harmful, assuming that `jsi::WeakObject` (that thing that we use to refer to actual JS target) actually has "unsafe unretained" (not "weak") semantic.
So, we have to remove this.
This change will be particularly important for coming diffs in the stack.

Reviewed By: mdvacca

Differential Revision: D13324480

fbshipit-source-id: 4c4da2984dc6a36b94b564bc9eee144142b430b0
2019-01-16 20:22:39 -08:00
Valentin Shergin 9f71a8f26e Fabric: `ShadowTree::getRootShadowNode` was removed
Summary: Because it was not idiomatic anyway. There is no point having a pointer to RootShadowNode without any guarantees that it's the current one. Using `commit` method makes this concern explicit.

Reviewed By: sahrens

Differential Revision: D13615363

fbshipit-source-id: f71ffc3c55dbdc69624933eb8b92334ed793c794
2019-01-16 20:22:39 -08:00
Valentin Shergin 84cf657308 Fabric: `ShadowTree::completeByReplacingShadowNode` was moved to RootShadowNode
Summary:
Removing additional complexity from ShadowTree should help with maintainability. Now, this class is "tricky", but short at least.
With new `commit` API, it's much more simple and expected this way.

Reviewed By: sahrens

Differential Revision: D13615365

fbshipit-source-id: 1fe851c1a2d3bdc7ac2f4a570cf0170eae3c4c67
2019-01-16 20:22:39 -08:00
Valentin Shergin c937300f5d Fabric: Layout-related methods were removed from ShadowTree
Summary: Now it's parts of RootShadowNode and Scheduler.

Reviewed By: sahrens

Differential Revision: D13615364

fbshipit-source-id: 13dbea1e69ef51b2679101915c01c6be7e15d859
2019-01-16 20:22:39 -08:00
Valentin Shergin 5a58ca4144 Fabric: New non-blocking treading model for ShadowTree
Summary:
Instead of the whole family of commit* and complete* methods, now we have one single `commit` method which performs pre- and post-commit operations and swap pointers in a thread-safe manner. The `commit` operation is also exposing `revision` number and allows perform multiple commit attempts.

`completeByReplacingShadowNode`, `measure` and `constraintLayout` are also going away to RootShadowNode class in the next commits.

Why?
* Nicer API;
* No more recursive_mutex, no more problems with thread jumps;
* All mutex locks are now leaf-locks, so no more deadlocks possible;
* Exposing `revision` should help with debugging races.

Reviewed By: sahrens

Differential Revision: D13613942

fbshipit-source-id: 94e797d2f7860717847e823b5d97c4f7b35f08df
2019-01-16 20:22:39 -08:00
Valentin Shergin 8f9ca2b9a0 Fabric: Even more systraces
Summary: Trivial.

Reviewed By: mdvacca

Differential Revision: D13664395

fbshipit-source-id: 3de5d65d6fcf8b68bce2636fc91492defdbe8405
2019-01-16 20:22:39 -08:00
Ram N aa19fa02e9 Add a way to selectively enable TurboModules
Summary:
Added a flag that checks if TurboModules are enabled, don't expose them to JS via the old module system.
All TurboModules needs to implement TurboModule interface.

Reviewed By: mdvacca

Differential Revision: D13648332

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

Differential Revision: D13695554

Pulled By: hramos

fbshipit-source-id: 250f6574b193a37b3cd237bcf42612c3e91bf813
2019-01-16 15:13:43 -08:00
John.Yang 378892bc0d RCTSegmentedControl (#23000)
Summary:
Changelog:
----------

[iOS] [Changed] -  follow #22990, move the call to requireNativeComponent from `SegmentedControlIOS.ios.js` to `RCTSegmentedControlNativeComponent.js`
Pull Request resolved: https://github.com/facebook/react-native/pull/23000

Differential Revision: D13697168

Pulled By: TheSavior

fbshipit-source-id: 83a66279d2fcd5a29d2ebc9cf5b5273947d96281
2019-01-16 14:00:00 -08:00
Daiki Ihara 3a70bf16e8 ToolbarAndroid (#23009)
Summary:
[Android] [Changed] - create standalone JS file for ToolbarAndroid, as part of #22990

I have a question.

`ToolbarAndroid` component use 2 types from other files.
They are not included files mentioned by https://github.com/facebook/react-native/issues/22990#issue-399165354.
One type `ColorValue` is very simple and I'll copy it.
But `ImageSource` type is a bit complicated I think it wolud be better to add to the codegen.
How do you think about it? TheSavior
Update: -> solved 👍

----------
- [x] yarn lint
- [x] yarn flow-check-android
- [x] yarn flow
- [x] yarn test
Pull Request resolved: https://github.com/facebook/react-native/pull/23009

Differential Revision: D13697524

Pulled By: TheSavior

fbshipit-source-id: 72ce43e1510be0986a3798d795f07ab176bd2a92
2019-01-16 13:53:53 -08:00
Nick Bell 5f3afb9fe5 #22990 add RCTDatePickerNativeComponent types (#23013)
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:

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

[iOS] [Changed] - As mentioned in #22990, I have moved native components required by DatePickerIOS.ios.js into separate files and added Flow Typing.
Pull Request resolved: https://github.com/facebook/react-native/pull/23013

Differential Revision: D13697591

Pulled By: TheSavior

fbshipit-source-id: 5aec5a2270cbfc708f3e3a67662abd8071f1333f
2019-01-16 13:41:48 -08:00
Leko d0ba9ce712 RCTMaskedView (#23001)
Summary:
This pull request is part of https://github.com/facebook/react-native/issues/22990.

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

[iOS] [Changed] - Split RCTMaskedView into RCTMaskedViewNativeComponent.
Pull Request resolved: https://github.com/facebook/react-native/pull/23001

Differential Revision: D13697245

Pulled By: TheSavior

fbshipit-source-id: 16af0b394ae32cd3c4992c2cd5ea2d3c140755b3
2019-01-16 13:34:17 -08:00
jesse 462cb10949 AndroidDropdownPicker and AndroidDialogPicker (#22999)
Summary:
Changelog:
----------

[Android] [Changed] - As mentioned in #22990, I have moved native components required by PickerAndroid.android.js into separate files and added Flow Typing.
Pull Request resolved: https://github.com/facebook/react-native/pull/22999

Differential Revision: D13697130

Pulled By: TheSavior

fbshipit-source-id: 42da73d82cca45fefa066871eed5a637811643c8
2019-01-16 13:27:08 -08:00
Leko 35823ec416 RCTTabBarItem (#23004)
Summary:
This pull request is part of https://github.com/facebook/react-native/issues/22990.

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

[iOS] [Changed] - Split RCTTabBarItem into RCTTabBarItemNativeComponent.
Pull Request resolved: https://github.com/facebook/react-native/pull/23004

Reviewed By: TheSavior

Differential Revision: D13690820

Pulled By: rickhanlonii

fbshipit-source-id: 522e55ee74a797a3930edf6821c6d8f72511cd2b
2019-01-16 13:15:14 -08:00
Maxime Nory 28230939c9 RCTSafeAreaView (#23006)
Summary:
Part of #22990

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

[iOS] [Changed] - Create individual `RCTSafeAreaViewNativeComponent` JS file from `SafeAreaView` with flow typing.
Pull Request resolved: https://github.com/facebook/react-native/pull/23006

Reviewed By: TheSavior

Differential Revision: D13690683

Pulled By: rickhanlonii

fbshipit-source-id: 7928fabf0264a6269a41148432f604e82d9b3920
2019-01-16 13:10:52 -08:00
nd-02110114 eb171d272d AndroidCheckBox (#23003)
Summary:
This PR is related to #22990

Changelog:
----------
[Android][Changed]  - move the call to requireNativeComponent from `Checkbox.android.js` to `AndroidCheckBoxNativeComponent.js`
Pull Request resolved: https://github.com/facebook/react-native/pull/23003

Reviewed By: TheSavior

Differential Revision: D13690827

Pulled By: rickhanlonii

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

Reviewed By: shergin

Differential Revision: D13616172

fbshipit-source-id: 7b7a6461216740b5a1ad5ebbead9e37de4570221
2019-01-16 12:38:22 -08:00
Eduardo Roman cfbb2278a0 guard against INF values in CompactValue
Summary:
After this diff D13403925 that got rid of `-ffast-math` we started to have a very odd behavior on Yoga when using release builds.

After digging a while we found that certain set of conditions on O2 and O3 optimization levels was causing Origami to set some `INFINITE` values on Yoga.

We found the root of the problem and fix it on Origami side. But I'm wondering if guarding agains `INFINITE` on Yoga side would be good too. Since now Yoga it's not using `-ffast-math` anymore, and I think infinite is not a a valid value anywhere on Yoga side, it seems to support the reason to guard against it.

I'm happy to abandon this diff if you guys think this is not a good solution.

Reviewed By: davidaurelio

Differential Revision: D13679319

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

Reviewed By: mhorowitz

Differential Revision: D13668327

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

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

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

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

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

Differential Revision: D6981435

Pulled By: hramos

fbshipit-source-id: 508ecea0f8874dc16a25f1dee6255481b309f8c2
2019-01-16 09:50:48 -08:00
David Aurelio 3cfe8d59bc Reflow comments
Summary:
@public

Repeated application and alternation of Clang Format rules has lead to unfortunate block comment formatting.

Here, we reflow comments

Reviewed By: SidharthGuglani

Differential Revision: D13677242

fbshipit-source-id: 3f1f5e38693eb15e9705f24fd363fc1618c78974
2019-01-16 08:47:15 -08:00
David Aurelio 53a28ee180 Fix URLs to CSS spec in comments
Summary:
@public

These URLs probably have been changed when CSSLayout was renamed to Yoga by search & replacing

Reviewed By: SidharthGuglani

Differential Revision: D13690829

fbshipit-source-id: 44dbd8fe256fc286006d164390609a7c3de6c4e6
2019-01-16 08:47:15 -08:00
Julian Hundeloh 35e7fdd79d feat: expose AnimatedEvent (#22984)
Summary:
Some third party components rely on the `AnimatedEvent` as a type (see https://github.com/kmagiera/react-native-gesture-handler/blob/master/Swipeable.js#L9). In order to not rely on a path which could change at any time it would be great to expose it.

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

[General][added] - Expose AnimatedEvent
Pull Request resolved: https://github.com/facebook/react-native/pull/22984

Differential Revision: D13682678

Pulled By: cpojer

fbshipit-source-id: 2f2b228e3f49e6afe623fd551220ef2147e79550
2019-01-16 07:04:11 -08:00
Adam Comella 7d881c1d8a RNTester: Add `allowFontScaling` example to Android (#22991)
Summary:
iOS's `allowFontScaling` example was copied to Android. Also, I added a case illustrating that `allowFontScaling` gets inherited in nested `<Text>` scenarios. This tests the bug fix from #22917. This nested case was added to both iOS and Android.

Also, moved the comment in `TextAttributes.java` from the top of the file to the top of the class definition as requested in #22917.
Pull Request resolved: https://github.com/facebook/react-native/pull/22991

Differential Revision: D13671380

Pulled By: cpojer

fbshipit-source-id: a8aae4f051c76391e33bdbd6bdc80aff9b7de5cd
2019-01-16 06:47:02 -08:00
Adam Comella 0db0d263ac Android Text: Fix `letterSpacing` rendering when `fontSize` changes (#22993)
Summary:
If you set `letterSpacing` on an outer text and then set `fontSize` on an inner text, the wrong `letterSpacing` will be rendered.

Here's an example:

```
<Text style={{ fontSize: 10, letterSpacing: 10 }}>
  <Text style={{ fontSize: 20 }}>Some text</Text>
</Text>
```

`fontSize` affects letter spacing. In this case, the bug is that setting `fontSize` to `20` doesn't cause the letter spacing to be recalculated.

Notice that the logic for applying letter spacing only applies it if the node has a different value for `getEffectiveLetterSpacing()` than its parent. The problem is that `getEffectiveLetterSpacing()` doesn't represent the final letter spacing value -- it doesn't take `fontSize` into account. Consequently, it sometimes incorrectly skips applying letter spacing as illustrated above.

The fix is to ensure `getEffectiveLetterSpacing()` represents the final rendered letter spacing value. To do this, some of the letter spacing calculation code was moved from `CustomLetterSpacingSpan` to `getEffectiveLetterSpacing()`.
Pull Request resolved: https://github.com/facebook/react-native/pull/22993

Differential Revision: D13671505

Pulled By: cpojer

fbshipit-source-id: 400f36d3fd71ab7cb6cba8508baa71f2973f8f0e
2019-01-16 05:40:48 -08:00
Adam Comella e6057095ad Android TextInput: Support `allowFontScaling` on placeholder (#22992)
Summary:
Currently, the `TextInput's` placeholder is always sized as though `allowFontScaling` is `true`.

Note that `allowFontScaling` works fine for the content of the `TextInput`. The reason is that we set the font size in two places: in the shadow node and in the Android view. The shadow node logic determines the size of the content and the Android view logic determines the size of the placeholder. The handler for the `allowFontScaling` prop is only present in the shadow node logic. Consequently, the Android view logic always uses the default value of `true` for the `allowFontScaling` prop.

The fix is to add logic for handling the `allowFontScaling` prop to the Android view.

It would be great if we could handle all text props in one spot instead of duplicating code between the shadow node and the Android view. That would eliminate this whole class of bugs. However, I don't have enough familiarity with the history of this code to know how hard that would be or if it's even possible.

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

Differential Revision: D13671400

Pulled By: cpojer

fbshipit-source-id: 40bae3cfb0ca6298e91a81c05211538935f5a0e8
2019-01-16 05:31:55 -08:00
Matt Hargett 63038500a2 Flesh out the URL polyfill a bit more (#22901)
Summary:
This expands functionality of URL minimally so Apollo Server can run in React Native contexts. Add explicit-fail getters so undefined values won't get generated from the otherwise missing implemenation.

Use of URL in apollo-server here: 458bc71ead/packages/apollo-datasource-rest/src/RESTDataSource.ts (L79)

Credit to my colleague dysonpro for debugging the issue and providing the initial working stub implementation.

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

Help reviewers and the release process by writing your own changelog entry. See http://facebook.github.io/react-native/docs/contributing#changelog for an example.

[INTERNAL] [ENHANCEMENT] - Support construction, toString(), and href() of URL objects.
Pull Request resolved: https://github.com/facebook/react-native/pull/22901

Differential Revision: D13690954

Pulled By: cpojer

fbshipit-source-id: 7966bc17be8af9bf656bffea5d530b1e626acfb3
2019-01-16 05:31:55 -08:00
Kudo Chien e3ff15052a Remove unused files and code for old JSC and gcc build (#23014)
Summary:
----------

1. Unused prebuilt old JSC for 64bits.
2. Folly patch for gcc build.
Pull Request resolved: https://github.com/facebook/react-native/pull/23014

Differential Revision: D13690139

Pulled By: cpojer

fbshipit-source-id: 64555f5b9a5fbd4156e42eeff13da721846c2521
2019-01-16 04:01:53 -08:00
Listen 1fde677cfc Remove duplicated `OnGlobalLayoutListener` to improve performance (#22849)
Summary:
We are writing a native navigation library. When there are more than a dozen `ReactRootView` in the application, the application will be very stuck. It doesn't improve much, even if we remove the invisible ReactRootView from the View hierarchy temporarily.

After debugging, we found that we were not able to remove `OnGlobalLayoutListener` in `onDetachedFromWindow` because  this listener was added twice. One is in `onAttachedToWindow` and the other is in `attachToReactInstanceManager`.

We added the following code by inheriting ReactRootView.

```java
    Override
    protected void onAttachedToWindow() {
        try {
            Method method = ReactRootView.class.getDeclaredMethod("getCustomGlobalLayoutListener");
            method.setAccessible(true);
            // remove duplicated GlobalLayoutListener
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                getViewTreeObserver().removeOnGlobalLayoutListener((ViewTreeObserver.OnGlobalLayoutListener) method.invoke(this));
            } else {
                getViewTreeObserver().removeGlobalOnLayoutListener((ViewTreeObserver.OnGlobalLayoutListener) method.invoke(this));
            }
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        super.onAttachedToWindow();
    }
```

It turns out that there is no pressure even if  opening hundreds of pages that contain ReactRootView (remove ReactRootView from the View hierarchy temporarily in the invisible pages).

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

[Android] [Fixed] - Remove duplicated `OnGlobalLayoutListener` to improve performance.
Pull Request resolved: https://github.com/facebook/react-native/pull/22849

Differential Revision: D13682818

Pulled By: hramos

fbshipit-source-id: 1f1bc8cd5fc4e01a1bc2f2a4784822b4eae92fdc
2019-01-15 20:45:07 -08:00
Eli White db5528ffa9 Use Generated Switch Schema
Summary: We are now generating the native cpp files for Switch via Buck. Deleting the hand written files and switching over.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D13666672

fbshipit-source-id: 72cf6f6af9374511f2742f8f0d996fa52e1bff5b
2019-01-15 18:10:34 -08:00
Alejandro c93f683984 - Create individual RCTSnapshotNativeComponent JS fil… (#23012)
Summary:
Part of #22990

Changelog:
----------
[iOS] [Changed] - Create individual ```RCTSnapshotNativeComponent``` JS file from ```SnapshotViewIOS```
Pull Request resolved: https://github.com/facebook/react-native/pull/23012

Differential Revision: D13683566

Pulled By: PeteTheHeat

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

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

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

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

Differential Revision: D13682727

Pulled By: hramos

fbshipit-source-id: a165af4ba78d2dbeca5bffbf60beb9ba50498f8d
2019-01-15 17:01:49 -08:00
gengjiawen 5dd9d72ec0 Fix ReactAndroid bundle issue (#22799)
Summary:
Related change: 0a293a014b.

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

[Bugfix] [Android] - fix 64bit so bundle issue.
Pull Request resolved: https://github.com/facebook/react-native/pull/22799

Differential Revision: D13669711

Pulled By: hramos

fbshipit-source-id: 0234b4731db0c74c8e4b8b738a19ae971fadb702
2019-01-15 16:49:44 -08:00
Takagi Kensuke c3bbce449c - Fix failing to bundle in Release build with ndenv of anyenv by supporting anyenv (#22875)
Summary:
refer: https://github.com/riywo/anyenv

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

[iOS] [Fixed] - Fix failing to bundle in Release build with ndenv of anyenv by supporting anyenv
Pull Request resolved: https://github.com/facebook/react-native/pull/22875

Differential Revision: D13682773

Pulled By: hramos

fbshipit-source-id: 0baacc95bd215d4724ba418ff187d51b11126326
2019-01-15 16:49:44 -08:00
chrisnojima 728a35fcf2 fix incorrect type which makes animated gifs not loop forever on device (#22987)
Summary:
https://github.com/facebook/react-native/issues/22985

This 1 liner fixes the animation looping being broken on ios devices. The original source of the bug is here: https://github.com/facebook/react-native/commit/95ef882#diff-e57b12f931820d7e0949e5cbb2701dcfR35

We set the value to a special large float, and assign it to repeatCount which is also a float, so this should be a float.

Changelog:

[iOS] [Fixed] - Fix animated GIFs not looping forever
Pull Request resolved: https://github.com/facebook/react-native/pull/22987

Differential Revision: D13682645

Pulled By: hramos

fbshipit-source-id: 96b0602b418e3ebe369427a24777cd4374ac5d48
2019-01-15 16:45:56 -08:00
Wojciech Tyczynski 3654b9edb2 Differentiate swipe and tap events (#22916)
Summary:
Motivation:
----------

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

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

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

Differential Revision: D13682705

Pulled By: hramos

fbshipit-source-id: 233ad1cecc04ca4ced75cd00e7fcb65d224ed3ca
2019-01-15 16:29:38 -08:00
Eli White bb9d013935 Dispatch event names consistent with current system
Summary: In order to match existing event names we need to remove the `on` prefix.

Reviewed By: mdvacca

Differential Revision: D13666673

fbshipit-source-id: c3e16aae4143ea45f45948e3e9de86fe690062cd
2019-01-15 15:50:04 -08:00
Eli White 8f1003fb9f Set up buck to generate native code for rncore
Summary:
Refactoring the codegen buck target from being used just for testing to a way that can be depended on for the real fabric target to replace the existing component code.

After this change, we can build a target for react native to use the codegen to create the native files for Switch. A follow up diff will be necessary to hook this up and actually replace the native files for switch.

Reviewed By: mdvacca

Differential Revision: D13662363

fbshipit-source-id: 599dd9ed9ca24ffb5c5784396f4bee7457d94d6d
2019-01-15 15:50:04 -08:00
Dulmandakh b98964ba39 bump android gradle plugin to 3.3.0 (#22988)
Summary:
Android Gradle Plugin 3.3.0 add many improvements in compile time speed, but also enable R8 shrinker.

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

[Android] [Changed] - Bump Android Gradle Plugin to 3.3.0
Pull Request resolved: https://github.com/facebook/react-native/pull/22988

Differential Revision: D13676104

Pulled By: hramos

fbshipit-source-id: 5a3834e64816222ee8a4aa6682c07ac6857fc5f6
2019-01-15 14:39:34 -08:00
Daniel Sainati 2a479a6953 remove deprecated utilities
Summary: Remove `$Subtype` and `$Supertype` utilities. Replacement was done on a best-effort basis. In many cases it sufficed to replace `$Supertype<T>` and `$Subtype<T>` with `T`, but when this was not possible `any | T` and `any & T` were used instead.

Reviewed By: jbrown215

Differential Revision: D13624765

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

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

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

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

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

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

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

</div>

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

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

Reviewed By: hramos

Differential Revision: D13564287

Pulled By: cpojer

fbshipit-source-id: fcb6ba5e20d863f4b957d20f3787f5b7a365bfdb
2019-01-15 06:29:49 -08:00
Edward Karuna abfd563b47 Copy bundled resources and js in Android App Bundle builds (#21738)
Summary:
Android App Bundle builds use the packageBundle and bundle tasks instead
of the package and assemble tasks the APK builds use. Because of this,
the resources and js bundles weren't getting copied into the final
artifact. In an App Bundle build, the merged assets must be present
during the buildPreBundle step in order to arrive in the App Bundle.
Pull Request resolved: https://github.com/facebook/react-native/pull/21738

Differential Revision: D13669288

Pulled By: cpojer

fbshipit-source-id: 0e985983f04504b69e447dbc1f3f34cf8f4eb927
2019-01-15 02:15:28 -08:00