Commit Graph

3825 Commits

Author SHA1 Message Date
David Vacca 2d40369237 Disable collapsing of mounting instructions
Summary:
Disable collapsing of mounting instructions

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D18387365

fbshipit-source-id: dbb6325297ef73d902fbe519726accd40a78b559
2019-11-07 18:26:27 -08:00
Valentin Shergin 9883da167b Fabric: Removing RuntimeExecutor from EventBeatManager
Summary:
This diff changes the implementation a little bit:
* We don't use RuntimeExecutor there anymore (because it's already been used in EventBeat). The actual purpose of EventBeatManager was distilled to "provide a tick synchronized with the main run loop";
* Now we use dedicated EventBeatManagerObserver interface to decouple this functionality from EventBeat-intrinsic functionality;
* A bunch of small clean-ups.
* Now we ensure threading and capturing ownership in a single function in AsyncEventBeat class. Before this change, the EventBeatManager called `beat` function of the EventBeat directly bypassing AsyncEventBeat class, and effectively bypassing the check that underlying infra still exists (aka EventBeat::OwnerBox feature). That alone might fix some C++ crashes that we see.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18307655

fbshipit-source-id: 3b582cb71085ed99ee94f8e6d575196c2082557b
2019-11-07 09:43:07 -08:00
Valentin Shergin 68782d2239 Fabric: Removing unnecessary code from EventBeatManager
Summary:
* We no more pollute the global namespace with JSI stuff;
* We don't use JSI here, so why to include;
* We don't use `Instance`, so why to forward-declare this;

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D18307654

fbshipit-source-id: b6c3ad55d7bd605074db9fa1d4bc58a73e0b2d74
2019-11-07 09:43:06 -08:00
Valentin Shergin 50b171ff8b Fabric: Removing scheduling to JS thread from EventBeatManager.java
Summary:
The C++ counterpart of EventBeatManager uses RuntimeExecutor for that, so it's redundant to do that in EventBeatManager.java.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18307657

fbshipit-source-id: 65823b25d691a56540247d317e3c0e86685150c8
2019-11-07 09:43:06 -08:00
Joshua Gross b7c2d4389a Guard against result of getUIManager(...) being null
Summary:
`getUIManagerX(...)` can return null now. Guard in a few places that use it or add comments.

Changelog: [Internal]

Reviewed By: alexeylang

Differential Revision: D18351197

fbshipit-source-id: f077835468a75d1af24cfb4210989ba875ff9086
2019-11-06 12:14:09 -08:00
Oleksandr Melnykov e99b926d27 Use generated Java delegate for setting properties on ReactDialogPickerManager and ReactDropdownPickerManager
Summary:
This diff migrates ReactDialogPickerManager and ReactDropdownPickerManager to use the generated delegates for setting their properties.

Changelog:
[Android] [Added] - Use generated Java delegate for setting properties on ReactDialogPickerManager and ReactDropdownPickerManager

Reviewed By: mdvacca

Differential Revision: D17930994

fbshipit-source-id: 009ad9eceb683b7170eddeccfd986b1dc5cb8c0b
2019-11-06 05:23:45 -08:00
Emily Janzer 6598292ede Add a field + getter for instanceKey to ReactContext
Summary:
Adding a new String field for `instanceKey` to ReactContext, which is set via a new constructor on ReactApplicationContext. Also adding getters to ReactContext and ThemedReactContext so that it's accessible from any instance/subclass of ReactContext.

This will only be used in bridgeless mode.

Reviewed By: mdvacca

Differential Revision: D18316556

fbshipit-source-id: 9757da72fde4ba36034c1e129326461fed496229
2019-11-05 19:01:53 -08:00
Joshua Gross f77abc583c Add UI asserts and logs to a few more places
Summary:
Add UI asserts to ensure thread safety of some operations.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18339981

fbshipit-source-id: 9162b6351f40bdd543d3e255691e9f54d1934589
2019-11-05 18:20:01 -08:00
Joshua Gross b1b97b8b45 UiThreadUtil.assertX should only throw in DEBUG mode
Summary:
Turns out that `SoftAssertions.java` has always been a lie - it actually always throws exceptions. Migrate it to using `ReactSoftException`.

This file hasn't been touched at all since it was originally open-sourced, besides codemods!

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18336020

fbshipit-source-id: cba3db25a9f9d61325dd3f7843e92e984ae56281
2019-11-05 15:36:29 -08:00
David Vacca e885ddedb9 Fix crash when using TextInput.FontVariant prop in Android API level < 26
Summary:
This diff fixes a crash when using TextInput.FontVariant prop in Android API level < 26

Changelog: Fix TextInput.FontVariant prop in Android API level < 26 (related to PR https://github.com/facebook/react-native/pull/27006)

Reviewed By: JoshuaGross

Differential Revision: D18331807

fbshipit-source-id: 5eac4d9e38eb099fae1287d128f3f8c249b0b8bc
2019-11-05 14:40:19 -08:00
Joshua Gross a7f56e73e4 Add UI-Thread assertions in methods that mutate Views
Summary:
As part of `T54997838` we're auditing where removeView could possibly be called in a background thread, and adding annotations to indicate places where we don't think it's possible.

Changelog: [internal]

Reviewed By: makovkastar

Differential Revision: D18320461

fbshipit-source-id: 84b6b9e293d903f835fc42bc98614efb54158986
2019-11-05 13:18:59 -08:00
David Vacca 3281714312 Ensure that ReactInstanceManager is still alive when animation system updates views in Fabric
Summary:
This diff ensures that ReactInstanceManager has a valid catalystInstance when updating views as part of the animation system.
This also force the update of views to be posted in the UI Thread

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D18311782

fbshipit-source-id: 1f1e7b0d34346f34b3607e5b75e5c14cda3f4861
2019-11-05 12:33:07 -08:00
Vincent Cheung 1df8bd4932 Fix multiple set-cookie not aggregated correctly in response headers (#27066)
Summary:
Multiple `set-cookie` headers should be aggregated as one `set-cookie` with values in a comma separated list. It is working as expected on iOS but not on Android. On Android, only the last one is preserved

The problem arises because `NetworkingModule.translateHeaders()` uses `WritableNativeMap` as the translated headers but uses both native and non-native methods. The mixup causes out of sync data that both sets of methods do no agree. A simple fix is to use `Bundle` as the storage and only convert it to `WritableMap` at the end in one go

Related issues: https://github.com/facebook/react-native/issues/26280, https://github.com/facebook/react-native/issues/21795, https://github.com/facebook/react-native/issues/23185

## Changelog

[Android] [Fixed] - Fix multiple headers of the same name (e.g. `set-cookie`) not aggregated correctly
Pull Request resolved: https://github.com/facebook/react-native/pull/27066

Test Plan:
A mock api, https://demo6524373.mockable.io/, will return 2 `set-cookie` as follows:
```
set-cookie: cookie1=value1
set-cookie: cookie2=value2
```

Verify the following will print the `set-cookie` with a value `cookie1=value1, cookie2=value2`
```javascript
  fetch('https://demo6524373.mockable.io/')
    .then(response => {
      console.log(response.headers);
    });
```
On iOS, `set-cookie` will have `cookie1=value1, cookie2=value2` while on Android it will have `cookie2=value2` (preserving only the last one)

Differential Revision: D18298933

Pulled By: cpojer

fbshipit-source-id: ce53cd41d7c6de0469700617900f30a7d0914c26
2019-11-05 03:30:02 -08:00
Valentin Shergin 2690e7363c Fabric: Cross-platform implementation of monotonicTimeInMilliseconds
Summary:
Now the function supports iOS.
We will use it soon.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D18285828

fbshipit-source-id: b9c16433e9c75ab4c071e4bd55074757372f6c0a
2019-11-04 18:21:12 -08:00
Ramanpreet Nara 1d315608ef Make RCTCameraRollManager TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTCameraRollManager TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18148892

fbshipit-source-id: de49e368615032b2c4de129dc55191c562cbdfbe
2019-11-04 16:07:24 -08:00
Ramanpreet Nara 7e5de4e241 Make RedBox TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RedBox TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18142255

fbshipit-source-id: 2d130aca93a88ac7c983ce0e4848955ffb0be518
2019-11-04 16:07:23 -08:00
Ramanpreet Nara fe3ae9dce8 Make RCTDevMenu and RCTDevSettings TurboModule-compatible
Summary:
Changelog:
[iOS][Added] - Make RCTDevMenu and RCTDevSettings TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18148890

fbshipit-source-id: bd4f0b2797e299cd963e34fa47044a9e1232efe0
2019-11-04 16:07:23 -08:00
Janic Duplessis 686ab49107 Don't restore default values when components unmount (#26978)
Summary:
There are some cases where restoring default values on component unmount is not desirable. For example in react-native-screens we want to keep the native view displayed after react has unmounted them. Restoring default values causes an issue there because it will change props controlled my native animated back to their default value instead of keeping whatever value they had been animated to.

Restoring default values is only needed for updates anyway, where removing a prop controlled by native animated need to be reset to its default value since react no longer tracks its value.

This splits restoring default values and disconnecting from views in 2 separate native methods, this way we can restore default values only on component update and not on unmount. This takes care of being backwards compatible for JS running with the older native code.

## Changelog

[General] [Fixed] - NativeAnimated - Don't restore default values when components unmount
Pull Request resolved: https://github.com/facebook/react-native/pull/26978

Test Plan:
- Tested in an app using react-native-screens to make sure native views that are kept after their underlying component has been unmount don't change. Also tested in RNTester animated example.

- Tested that new JS works with old native code

Reviewed By: mmmulani

Differential Revision: D18197735

Pulled By: JoshuaGross

fbshipit-source-id: 20fa0f31a3edf1bc57ccb03df9d1486aba83edc4
2019-11-04 15:40:09 -08:00
David Vacca 595f5ac64d Fix Collapsing of Delete-Create mounting instructions
Summary:
This diff fixes the Collapsing of Delete-Create mounting instructions algorithm. By mistake I switch the conditions before landing the original diff.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D18306616

fbshipit-source-id: 50cd8ca67adcaf172ce51896df684fed270b2d51
2019-11-04 14:34:33 -08:00
Oleksandr Melnykov 8d31e38966 Integrate StickerInputView into Fabric on Android
Summary:
This diff integrates `StickerInputView` into Fabric on Android.

Changelog: [Internal]

Reviewed By: mdvacca, cpojer

Differential Revision: D18029223

fbshipit-source-id: 2e412b83f9af347e01606d526c04e13d1f2bfbb8
2019-11-04 12:42:26 -08:00
David Vacca 94ba059679 Introduce the IS_DEVELOPMENT_ENVIRONMENT flag
Summary:
This diff introduces the flag IS_DEVELOPMENT_ENVIRONMENT that will be used in Fabric to control the logging of props, localData and state ONLY during development.
Using DEBUG mode to control the logging of this kind of data is not enough.

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D18290351

fbshipit-source-id: cf0824bd15b9f1c509bbb284b85761166099bc42
2019-11-04 10:52:28 -08:00
David Vacca 894ee72278 Collapse Delete-Create mounting instructions
Summary:
This diff implements an optimization / fix in the mounting layer of Fabric Android to ignore the "deletion" and "creation" of views for the same tag in the same commit.
This operation is adding ~100 ns for every commit (I measured this using a release APK running in a real device). I created a QE to enable / disable this optimization and to measure the performance impact of this change in production

Changelog: Implement optimization in mounting layer of Fabric

Reviewed By: JoshuaGross

Differential Revision: D18279240

fbshipit-source-id: d6fdeb2a9676bcfaf47886893eed5024bf86204b
2019-11-03 14:54:01 -08:00
David Vacca 70904f6163 Add new parameter in Binding to configure collapsing of Delete-Create Mounting instructions
Summary:
This diff adds a new parameter in Binding class to configure the collapsing of Delete-Create Mounting instructions. This is necessary to fix T55696973.
I'm configuring this in order to measure the cost of this fix in produiction environment.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D18279239

fbshipit-source-id: b7743f6364b66d19c9ae7309919926debf574213
2019-11-03 13:12:22 -08:00
David Vacca 87e1734217 Add extra logging in FabricUIManager
Summary:
Easy diff to extend logging in FabricUIManager class

Changelog: Add extra logging in Fabric Android

Reviewed By: shergin

Differential Revision: D18277487

fbshipit-source-id: 387bdb4b237bdbdc0d65263c1f125ad5c9e26b18
2019-11-03 01:47:55 -07:00
Ramanpreet Nara 56ad1bd38a Assert TurboModuleRegistry is not null
Summary:
Looking at the crash reports from T46487253:
1. This crash happens only with TurboModule-compatible NativeModules.
2. Users who experience this crash are in the TurboModules test group.

Therefore, the crash happens while trying to load TurboModules.

The stack trace of the crash includes [this lookup via the NativeModule system](https://fburl.com/diffusion/vxj9goz5). When TurboModules are enabled, we can only start executing this line if one of two things are true:
1. The TurboModuleRegistry is null in CatalystInstanceImpl.
2. The TurboModuleRegistry isn't null but the NativeModule returned by the TurboModuleRegistry is null.

We can protect against 1 by asserting that when `ReactFeatureFlags.useTurboModules` is `true`, `mTurboModuleRegistry` is not null. Once this check lands, unless there's a race with setting `ReactFeatureFlags.useTurboModules`, we should be able to rule out 1.

Changelog:
[Added][Android] - Assert TurboModuleRegistry isn't null before using it in CatalystInstanceImpl

Reviewed By: PeteTheHeat

Differential Revision: D18211935

fbshipit-source-id: de88c033425c474ef80b73386b7182b1d3bb382f
2019-11-01 19:24:09 -07:00
David Vacca 34989c88e0 Stop logging props and local data
Summary:
Quick diff to avoid the logging of Props, State and localData in Fabric Android.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D18277486

fbshipit-source-id: 462335e7dadaab2bd39a8ede6318f52f95dfb53a
2019-11-01 14:31:31 -07:00
Ramanpreet Nara 7233ae4f11 Make RCTAppState TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTAppState TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18142253

fbshipit-source-id: 5bd8afa6e3ee98f92aac3b2ebdfe63b9f7afc775
2019-11-01 12:06:21 -07:00
Ramanpreet Nara dc12676e3a Make RCTStatusBarManager TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTStatusBarManager TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18130374

fbshipit-source-id: 3ec226bcff17e47ffd9eba05e32c1eb68d6135b2
2019-11-01 12:06:20 -07:00
Ramanpreet Nara a257083d2b Split NativeStatusBarManager into NativeStatusBarManager{Android,IOS}
Summary:
The `StatusBarManager` NativeModule does not have a uniform API on iOS and Android. In particular, the `setStyle` and the `setHidden` methods have an additional parameter on iOS:

```
/**
 *  - statusBarStyles can be:
 *    - 'default'
 *    - 'dark-content'
 *    - 'light-content'
 */
+setStyle: (statusBarStyle?: ?string, animated: boolean) => void;
/**
 *  - withAnimation can be: 'none' | 'fade' | 'slide'
 */
+setHidden: (hidden: boolean, withAnimation: string) => void;
```

If we keep the NativeModule spec the same between the two platforms, we'd have to keep the second parameter optional for both methods. This works for `setHidden`, because the second parameter is a string, and optional strings are allowed. However, for `setStyle`, the second parameter is a number, and we don't support optional numbers/booleans on Android in the NativeModule system. If we keep the optional number, then the following check triggers in our RedBox tests on iOS, which makes them fail: https://fburl.com/diffusion/b7adezd9.

So, since the two specs are sufficiently different, I figured that the easiest path forward is to split them apart.

Changelog:
[iOS][Changed] - Separated NativeStatusBarManager into NativeStatusBarManager{IOS,Android}

Reviewed By: PeteTheHeat

Differential Revision: D18214161

fbshipit-source-id: 6fd8b8c5f576244b5b90ee47faa7f50508c5e1d3
2019-11-01 12:06:20 -07:00
Sidharth Guglani d729f0e922 Use compiler flag -fvisibility=hidden
Summary:
Using compiler flag -fvisibility=hidden and explicitly setting visibility to default to public methods

#Changelog:
[Internal] [Yoga] Use compiler flag -fvisibility=hidden for reducing yoga binary size

Reviewed By: astreet

Differential Revision: D18029030

fbshipit-source-id: 545e73f9c25f3108fc9d9bb7f08c157dbc8da005
2019-11-01 11:47:07 -07:00
David Vacca 00266693b3 Avoid copying vector in mounting layer of Fabric
Summary:
easy diff to avoid the constant copy of a vector when calling the method Binding.createRemoveAndDeleteMultiMountItem. Since we are not modifing the vector inside the method createRemoveAndDeleteMultiMountItem it's not necessary to copy it.

Changelog: Improve performance in mounting of Fabric views

Reviewed By: JoshuaGross

Differential Revision: D18250376

fbshipit-source-id: c984214a8148bab521cec51d42ba54a4b73e3e67
2019-10-31 17:21:14 -07:00
David Vacca 2afc4e2482 Remove unused variable in ReactTextInputManager
Summary:
quick diff to remove unused variable in ReactTextInputManager

Changelog: Remove unused variable in ReactTextInputManager

Reviewed By: JoshuaGross

Differential Revision: D18250377

fbshipit-source-id: 93c0dc9384fda811d53b078715101f3317af9753
2019-10-31 17:21:14 -07:00
Rick Hanlon 93f4bb23e2 LogBox - Don't show native redbox for JS errors on Android
Summary:
Will not show native redboxes when LogBox handles them

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D18236608

fbshipit-source-id: 1c60c69419b1a823594caf650d67693d4ad2076b
2019-10-31 16:26:44 -07:00
David Vacca afd836957f Fix Text paddings in Fabric
Summary:
Text paddings in Fabric are managed by LayoutMetrics, the current implementation of Fabric is incorrectly using padding data from Text Props to set the padding in the view.
This diff refactors the update of Text in Fabric in order to avoid using padding prop data

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D18211638

fbshipit-source-id: de05e7daa6185d854ce1b6580a1e44ae55d3176e
2019-10-31 14:02:49 -07:00
Elisa Lou 27d7d3fed5 update android AppearanceModule to support dark mode in all OS versions
Summary:
We no longer need to gate by OS version since we want to allow in-app theming. This diff ensures that we are passing in the updated system context to retrieve the correct app theme.

Changelog:
[Android] Enable AppearanceModule for all OS versions

Reviewed By: mdvacca

Differential Revision: D18224915

fbshipit-source-id: 42d5db8497d8bead32c49e3e2a25d4ba779e2b33
2019-10-31 10:05:38 -07:00
Joshua Gross 426868b6c2 Add enable_nullify_catalyst_instance_on_destroy MC and gate setting mCatalystInstance to null in ReactContext
Summary:
Mostly for easing open-source migration and not making a backwards-incompatible change (yet), we'll set this to false by default. Every app can opt-in to this if wanted but it's not necessary. This change is part of experiments surrounding more-aggressive teardown for Fabric and Bridgeless mode.

Changelog: [Internal] - This has the effect of (by default) disabling the previous diff which caused ReactContext teardown to always set mCatalystInstance to null. Now that is opt-in behavior and off by default, so it's not longer a breaking change.

Reviewed By: mdvacca

Differential Revision: D18207302

fbshipit-source-id: 7acfc894415e966f652c7049849eef79c440a135
2019-10-29 16:21:12 -07:00
Maurus Cuelenaere c2c4b43dfe Add Android support for fontVariant prop (#27006)
Summary:
Android was missing support for the `fontVariant` prop in TextViews, this PR adds that.

## Changelog

[Android] [Added] - Add Android support for fontVariant prop
Pull Request resolved: https://github.com/facebook/react-native/pull/27006

Test Plan:
Since I can't get RNTester to work locally (it crashes when loading `libyoga.so` on `No implementation found for long com.facebook.yoga.YogaNative.jni_YGConfigNew()`), I'll post some screenshots below of our app showing the difference.

We are using a slightly different [version](https://github.com/getdelta/react-native/commit/10cafcaa0798e5dbe8b56d461885fa84c6953739) of this commit, since we're still on 0.60, but the gist remains the same when rebased on master.

Before:
![Screenshot_20191025-130325__01](https://user-images.githubusercontent.com/1682432/67566586-7b3f2880-f728-11e9-85c0-57667d645153.jpg)

After:
![Screenshot_20191025-130444__01](https://user-images.githubusercontent.com/1682432/67566599-842ffa00-f728-11e9-988a-1b12ee393b83.jpg)

Differential Revision: D18179642

Pulled By: mdvacca

fbshipit-source-id: 03a050aa76e7bafa0343354dfa778cf74af5abd2
2019-10-29 00:29:20 -07:00
Marco Munizaga 6ebd3b046e Cap selection indices when text changes (#26680)
Summary:
This PR https://github.com/facebook/react-native/pull/22723 cached selections, so if you had a cached selection indicies, but updated the text to be an empty string, then this would crash.

As reported in https://github.com/facebook/react-native/issues/25265 and other issues of `setSpan(4 ... 4) ends beyond length`

## Changelog

[Android] [fixed] - Crash in TextInput
Pull Request resolved: https://github.com/facebook/react-native/pull/26680

Test Plan:
```
input.setNativeProps({ text: "xxx", selection: {"begin": 0, "end": 3}});
input.setNativeProps({ text: ""});
```

Differential Revision: D18189703

Pulled By: cpojer

fbshipit-source-id: 67d9615a863fd22598be8d6d4553dec5ac8837ed
2019-10-28 22:38:53 -07:00
Joshua Gross 0bea6a9b19 Work around ancient race condition in ReactInstanceManager
Summary:
See T55861104. In rare cases if `removeReactInstanceEventListener` is called right after (like, a small number of CPU instructions later, on a different thread) we allocate the `listeners` array with a certain size, then we could have one or more `null` listeners in the array, which is what we've been seeing in prod, at very low volumes, for several years. Without solving the root of the race condition we can just add a null check here.

Maybe it's also possible that if `addReactInstanceEventListener` is called on another thread in a racey way, that the size will be incremented on the array before we can access the additional member. That seems crazy, but maybe.

While this has been firing for multiple years it seems like a more recent change caused a regression. This diff doesn't address that and only resolves the crash.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D18192801

fbshipit-source-id: c1000cfcdf6f251b03061d1386eabb9f0617a7d3
2019-10-28 19:28:01 -07:00
Yoga Setiawan d7c222a6a7 Update Broken Link #devcjog25 (#27025)
Summary:
Update broken link  https://github.com/facebook/react-native/blob/master/react-native-cli/CONTRIBUTING.md to https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md
## Changelog
Pull Request resolved: https://github.com/facebook/react-native/pull/27025

Differential Revision: D18173631

Pulled By: cpojer

fbshipit-source-id: c3634c43c4de7e39e56ec31ef17b9f31db517128
2019-10-28 12:11:45 -07:00
Joshua Gross aa27645cf0 Guard against UIManagerHelper.getUIManager returning null
Summary:
Because the `mCatalystInstance` of the ReactContext can be null during teardown, there are technicaly cases where `UIManagerHelper.getUIManager` can return null. In those cases we check for a CatalystInstance and raise a SoftException, and return null. We must then guard in every case where we call `getUIManager` to prevent NullPointerExceptions.

See T56103679.

Currently crashes are coming from `PropsAnimatedNode.restoreDefaultValues` calling `UIManagerModule.synchronouslyUpdateViewOnUIThread` on teardown/at the end of an animation as RN is being torn down.

This can happen in both Paper and Fabric.

In dev this will still crash because the SoftException will trigger a crash. It will be a noop with logged warnings in production builds.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D18165576

fbshipit-source-id: 7059e04ca339208dd64a0a08a375b565cb8cda02
2019-10-27 23:13:33 -07:00
Joshua Gross b55146f776 Check that CatalystInstance is active for non-NativeModule callsites of ReactContext.getJSModule
Summary:
In previous diffs I migrated many (all?) NativeModules in FB and open-source to check for `hasActiveCatalystInstance` before calling `getJSModule`. We log SoftExceptions in those cases to find more potential race condition and lifecycle bugs without crashing.

In this diff, I migrate all the non-NativeModule callsites that I could find.

Previous diffs: see D18032458, D18035359, D18032788, D18092136, D18092137, D18112989, D18134400

Changelog: [Internal]

Reviewed By: mdvacca, mmmulani

Differential Revision: D18134694

fbshipit-source-id: 4729abfb84280b634463b1cd9b4dd808f310b6e7
2019-10-25 16:16:00 -07:00
Joshua Gross 9446277fc1 Simplify API of getReactApplicationContextIfActiveOrWarn
Summary:
Simplify the API of `getReactApplicationContextIfActiveOrWarn`. We don't need to pass so much information into this method to collect good SoftExceptions.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18134400

fbshipit-source-id: 0a250ab0252a44121f3339a31506a0a6c4c7cd35
2019-10-25 16:16:00 -07:00
David Vacca a1a56fe4e5 Add NonNull annotation to FabricUIManager API
Summary:
This diff annotates FabricUIManager class with NonNull annotations, this will help analysis of nullability plus improving integration with Kotlin clients

Changelog: Add NonNull annotation to FabricUIManager API

Reviewed By: JoshuaGross

Differential Revision: D18010917

fbshipit-source-id: 760ba04b78693cb184172c0fe613c7f808a49031
2019-10-25 15:11:53 -07:00
David Vacca a8ce2dcf89 Refactor logging of Fabric React Markers when running on the UI Thread
Summary:
This diff refactors the execution of the logging of Fabric React markers to be executed after the MountItems are executed on the UI Thred
Changelog: Improve logging of Fabric react markers

Reviewed By: JoshuaGross

Differential Revision: D18010920

fbshipit-source-id: e36306102d190119a89c16e660b855acab1528fe
2019-10-25 15:11:52 -07:00
David Vacca c5321e8514 Refactor the cancellation of DispatchUIFrameCallback
Summary:
This diff refactors the stopping of DispatchUIFrameCallback on FabricUIManager to make it thread safe

Changelog: Refactor the cancellation of dispatching of Mounting operations for Fabric

Reviewed By: JoshuaGross

Differential Revision: D18010922

fbshipit-source-id: 305bc65576698cb785a2a2308cbd03db4a9a97e4
2019-10-25 15:11:52 -07:00
David Vacca 619e27e9a1 Annotate core classes of Fabric with NonNull and Nullable annotations
Summary:
This diff annotates core classes of Fabric with NonNull and Nullable annotations, this will help analysis of nullability plus improving integration with Kotlin clients

Changelog: Add NonNull annotation to Fabric core classes

Reviewed By: shergin

Differential Revision: D18010918

fbshipit-source-id: 40fe68470b97cdf740f52dfeb9130465aab5e6df
2019-10-25 15:11:51 -07:00
David Vacca a58fcbff0b Add NonNull annotation to Fabric Event classes
Summary:
This diff annotates Fabric MountingManager and Events classes with NonNull annotations, this will help analysis of nullability plus improving integration with Kotlin clients

Changelog: Add NonNull annotation to Fabric Event classes

Reviewed By: shergin

Differential Revision: D18010923

fbshipit-source-id: fb9d5683bbd51fa25dda9b2023f9c411c3ff541d
2019-10-25 15:11:50 -07:00
David Vacca 27d71fc725 Make sure MountItems use @NonNull annotation
Summary:
This diff annotates MountItems classes with NonNull annotations, this will help analysis of nullability plus improving integration with Kotlin clients
Changelog: Add NonNull annotation to Fabric MountItems

Reviewed By: JoshuaGross

Differential Revision: D18010921

fbshipit-source-id: 4c2bded87f7af1ddb941b2a49e390e51984890c0
2019-10-25 15:11:50 -07:00
Dulmandakh fa0155d0ea fix specs buck (#26996)
Summary:
This PR fixes specs Buck, thus Android CI.

## Changelog

[Android] [Changed] - fix specs Buck, thus Android CI
Pull Request resolved: https://github.com/facebook/react-native/pull/26996

Test Plan: Android CI is green

Differential Revision: D18139049

Pulled By: RSNara

fbshipit-source-id: 5ade3f3ff7834cb172f03ec99c58136e949aff62
2019-10-25 10:22:06 -07:00