Commit Graph

4172 Commits

Author SHA1 Message Date
Amir Shalem 8a14b98193 Don't call config->setLogger(nullptr) directly to avoid having no logger at all
Summary:
Changelog: [Internal][Yoga] Don't call config->setLogger(nullptr) directly to avoid having no logger at all

Broken in D14151037 (https://github.com/facebook/react-native/commit/dc7dce130beef647b3c3d5d25d067c3557b84214) when it started calling
```
config->setLogger(nullptr);
```
instead of going thru
```
YGConfigSetLogger(config, nullptr);
```
which does the right thing by setting the logger to its default value:
https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/yoga/yoga/Yoga.cpp?commit=835911317e8b3cf7da1866e40e1c79cda0690136&lines=4320-4330

Also by default YogaConfig always have a logger:
https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/yoga/yoga/Yoga.cpp?commit=835911317e8b3cf7da1866e40e1c79cda0690136&lines=335-343

Reviewed By: SidharthGuglani

Differential Revision: D22387459

fbshipit-source-id: 4da91da87a696d38cc9d8db2acb5845d29398adb
2020-07-06 03:43:26 -07:00
Christoph Nakazawa 6d6c68c2c6 "The Metro Server" -> Metro
Summary:
Pet Peeve: Metro is a brand name. You don't say "the Metro server" just like you don't say "the iPhone phone". This is a leftover from when it used to be called "the packager server".

Note: It makes sense to refer to "the Metro server" when talking about it in the context of Metro's features, like if you are discussing "Metro's bundling" and "Metro's server". However, when talking about the tool itself, just Metro is enough.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D22330966

fbshipit-source-id: 667618363c641884df543d88cac65d1e44956ad3
2020-07-02 14:51:18 -07:00
almouro f23feced42 Fix font variant crash on Android < 4.4 (#29176)
Summary:
In RN 0.62 support for `fontVariant` was added on Android.
Using that prop crashes the app on Android below KitKat (4.3 and below)

To reproduce just add any Text with the `fontVariant` styling prop in the app:
```js
<Text style={{fontVariant: ['tabular-nums']}}>This will crash</Text>
```
It will crash any device running Android below KitKat with the error:

![image](https://user-images.githubusercontent.com/4534323/85073452-18206b80-b1bb-11ea-8d7e-96f27fa1a320.png)

This is caused by `java.utils.Objects` only being available on Android 4.4+

## Changelog

[Android] [Fixed] - Fix font variant crash on Android < 4.4
Pull Request resolved: https://github.com/facebook/react-native/pull/29176

Test Plan:
[TextUtils.equals](https://developer.android.com/reference/android/text/TextUtils#equals) was added as soon as API level 1, so no compatibility issue here.
Tested on Emulator running Android 4.1, no crash anymore.

I've searched for other occurences of `java.utils.Objects` in the project, and this was the only one, so no need to remove other occurences 

Reviewed By: JoshuaGross

Differential Revision: D22337316

Pulled By: mdvacca

fbshipit-source-id: 5507b21b237a725d596d47b5c01e269895b16d4a
2020-07-01 19:12:22 -07:00
fabriziobertoglio1987 7d8aeb4955 do not call setHyphenationFrequency on AndroidSdk < 23 (#29258)
Summary:
JoshuaGross This issue fixes https://github.com/facebook/react-native/issues/28279 as discussed in https://github.com/facebook/react-native/pull/29157#issuecomment-649993571
Avoid calling [setHyphenationFrequency](https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int)) on Android Sdk < 23.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - do not call setHyphenationFrequency on AndroidSdk < 23
Pull Request resolved: https://github.com/facebook/react-native/pull/29258

Test Plan:
| **BEFORE** | **AFTER** |
|:-------------------------:|:-------------------------:|
|  <img src="https://user-images.githubusercontent.com/24992535/86214122-05bf0e00-bb7b-11ea-93b5-2174812bfec9.png"  width="300" height="" />| <img src="https://user-images.githubusercontent.com/24992535/86214130-08216800-bb7b-11ea-9fc0-68b28638bf57.png" width="300" height="" /> |

The warning displayed with `adb logcat | grep -P "ReactTextAnchorViewManager"`

![image](https://user-images.githubusercontent.com/24992535/86214242-34d57f80-bb7b-11ea-9945-30ae25332bfb.png)

I remain available to do improvements. Thanks a lot. Fabrizio.

Reviewed By: JoshuaGross

Differential Revision: D22337095

Pulled By: mdvacca

fbshipit-source-id: d0943397af180929c48044ccbc7a9388549021b8
2020-07-01 17:45:34 -07:00
Joshua Gross c6b9cc36da Document early ViewCommand dispatch, since it is no longer gated
Summary:
In https://github.com/facebook/react-native/commit/0b63c9464872fed9ff3eb388e32850f2f8c69561, I shipped "Early ViewCommand Dispatch" everywhere but didn't provide a good summary in the commit message.

Here it is:

The "Early ViewCommand Dispatch" experiment was a success, leading to improved UI responsiveness and fewer overall crashes.

Ship to all Fabric and non-Fabric users, and clean up the code a bit.

# Context: what?

ViewCommands are now used in React Native to do things like scroll ScrollViews to a certain position; focus or blur a TextInput; control the value of controlled TextInputs; and much more. These used to be done using setNativeProps, but we're moving everything to ViewCommands, and most of that migration has already finished.

# Context: Why?

Because Fabric does not support setNativeProps, there has been an effort to move all setNativeProps callsites to ViewCommands. Since these callsites are in JS where we can't tell if we're running in Paper or Fabric, both Paper and Fabric callsites are being migrated (mostly already done) to ViewCommands. One such example is Android TextInput, which has been using ViewCommands instead of setNativeProps for several months.

This migration was largely without issues, except TheSavior and I noticed early on that certain things were just... slower with ViewCommands. It was definitely noticeable, but we determined it to be acceptable and moved on.

Recently, it became clear to me that the perf regression may not be acceptable, but there might be an "easy" solution.

# Why are ViewCommands slower than SetNativeProps?

So, a couple things. SetNativeProps on Paper would actually cause a layout pass; the same is not true for ViewCommands, so they should actually be much faster. But they're not! The reason is that ViewCommands are treated as regular mount items, and they are queued up /after/ all other mount items. That means if you're trying to interact with the UI while some part of it is updating, your ViewCommands must wait for portions of the screen to finish rendering before they execute.

In some cases, those views may even disappear before the ViewCommand executes, causing increased exceptions as well as speed degredations.

# Proposal

This experiment that ran with successful results was: to execute ViewCommands /before/ all other types of mount instructions (by maintaining a separate queue). That means if you tap on a TextInput to focus it while the screen is doing some heavy rendering, the next time the UIManager executes a batch of instructions, it will execute the focus operation out-of-order, at the very beginning. From a user perspective this is actually quite noticeable, and works much better than the older behavior.

# Why it's Not That Dangerous

* Is it possible that we'll execute instructions after the corresponding view has disappeared? This was already possible, and is actually less likely now, since it's more likely that the ViewCommand will execute before the Delete instructions executes.
* Is it possible we'll execute instructions BEFORE the view is created? Yes, this is possible and I actually found a repro for it. My solution: allow ViewCommands to be retried, exactly once. If they throw an exception the first time, we requeue which will cause the command to be executed after the current batch of mount items. Interestingly, this seems to be unnecessary in Fabric, so the logic there is a bit simpler (probably because on Android we do view preallocation under Fabric, so views are created way before they're inserted into the view hierarchy, and apparently before ViewCommands have a chance to execute).
* ViewCommands are already an imperative feature that exists outside of the normal React commit cycle. So they're already dangerous. This doesn't change that, but it does make dangerous code *faster*, so that's good.

Changelog: [Android][Changed] ViewCommands on Android now execute earlier, as a perf optimization.

Reviewed By: mdvacca

Differential Revision: D22343648

fbshipit-source-id: 310d94977ac8ca3140ee8aa272272f660efafa36
2020-07-01 17:25:32 -07:00
generatedunixname89002005287564 df6d2c50ff Daily arc lint --take GOOGLEJAVAFORMAT
Reviewed By: zertosh, bismarkito

Differential Revision: D22330388

fbshipit-source-id: 7a86a05da23728ad066702d868d805769389893f
2020-07-01 08:53:07 -07:00
Joshua Gross 0cef464fd2 StopSurface optimizations
Summary:
(1) As soon as we know we can StopSurface, stop executing all mountitems by clearing out the root tag.
(2) If a surface has been stopped and there's a batch of MountItems to execute against it, execute only the "delete" operations to clear views from memory.

Both of these should reduce memory usage and improve speed slightly around navigation pops.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22321389

fbshipit-source-id: 96a8292a8442528f1bba50d35208885cc4168170
2020-06-30 22:06:15 -07:00
Joshua Gross 0aa8ed6361 Remove useless Mounting diagnostic error
Summary:
While in theory we should never delete views before removing them from the hierarchy, there are some exceptions:

(1) Some mysterious cases that don't seem like bugs, but where the child still seems to keep a reference to the parent:
(2) When deleting views as part of stopSurface.

On #1: in the past we had issues when we assumed that ViewManager.getChildCount() would return an accurate count. Sometimes it's just... wrong. Here, I've found at least one case where a View still has a parent after it's removed from the View hierarchy. I assume this is undocumented Android behavior or an Android bug, but either way, there's nothing I can do about it.

On #2: there are valid cases where we want to delete a View without explicitly removing it from the View hierarchy (it will eventually be removed from the hierarchy when the Root view is unmounted, but it may still be "in" a View hierarchy when it's deleted).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22321374

fbshipit-source-id: 9667bbe778c418f0216550638dc26ca48a58e5fa
2020-06-30 22:06:15 -07:00
Joshua Gross f493a316fd Remove flags around Catalyst teardown
Summary:
These flags haven't been used in months. They were useful to uncover some race conditions, but will not be iterated further. The Venice project will obviate the concerns that sparked these experiments in the first place.

These flags have been hardcoded to false for a while.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22319204

fbshipit-source-id: 09415f3bb1ca56e15f357210e966d0483ff384f2
2020-06-30 16:12:05 -07:00
Joshua Gross 85f1e984bb Remove references to enableFabricStopAllSurfacesOnTeardown
Summary:
According to our experiments it's not better than "stop surface on unmount" in any way, and might regress some metrics. Unclear why, but if it's not necessary and doesn't seem to help, it doesn't make sense to continue this experiment.

We still have a mechanism on the C++ side to stop outstanding surfaces on teardown that does the same thing.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22318864

fbshipit-source-id: 7e678c63e4884382e57d996a7f4c4b7b24c8193a
2020-06-30 16:12:05 -07:00
Vojtech Novak 9e85b7ad88 ScrollView, HorizontalScrollView: do not ignore null contentOffset prop (#28760)
Summary:
motivation: I was just checking out https://github.com/facebook/react-native/commit/30cc158a875a0414cf53d4d5155410eea5d5aeea
and noticed that the commit, I believe, is missing logic for when `contentOffset` is actually `null`.

That is, consider you render `ScrollView` with `contentOffset` { x: 0, y: 100 } and then change that to null / undefined. I'd expect the content offset to invalidate (set to 0 - hope that's the default).

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - ScrollView, HorizontalScrollView: do not ignore `null` `contentOffset` prop
Pull Request resolved: https://github.com/facebook/react-native/pull/28760

Test Plan:
Tested locally within RNTester

<details><summary>code</summary>
<p>

```js
const Ex = () => {
  let _scrollView: ?React.ElementRef<typeof ScrollView> = React.useRef(null);
  const [offset, setOffset] = React.useState({x: 0, y: 20});
  setTimeout(() => {
    setOffset(undefined);
  }, 2000);

  return (
    <View>
      <ScrollView
        ref={_scrollView}
        automaticallyAdjustContentInsets={false}
        onScroll={() => {
          console.log('onScroll!');
        }}
        contentOffset={offset}
        scrollEventThrottle={200}
        style={styles.scrollView}>
        {ITEMS.map(createItemRow)}
      </ScrollView>
      <Button
        label="Scroll to top"
        onPress={() => {
          nullthrows(_scrollView.current).scrollTo({y: 0});
        }}
      />
      <Button
        label="Scroll to bottom"
        onPress={() => {
          nullthrows(_scrollView.current).scrollToEnd({animated: true});
        }}
      />
      <Button
        label="Flash scroll indicators"
        onPress={() => {
          nullthrows(_scrollView.current).flashScrollIndicators();
        }}
      />
    </View>
  );
};
```

</p>
</details>

Reviewed By: shergin

Differential Revision: D22298676

Pulled By: JoshuaGross

fbshipit-source-id: e411ba4c8a276908e354d59085d164a38ae253c0
2020-06-30 12:52:06 -07:00
TMaszko d92284216f Fix: Preserve native animated value after animated component unmount (#28841)
Summary:
After animation has been finished using Native driver there is no final value passed from the native to JS side. This causes a bug from https://github.com/facebook/react-native/issues/28114.

This PR solves this problem in the same way as `react-native-reanimated` library. When detaching it is calling native side to get the last value from Animated node and stores it on the JS side.

Preserving animated value even if animation was using `useNativeDriver: true`
Fixes https://github.com/facebook/react-native/issues/28114

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Internal] [Fixed] - Save native Animated node value on JS side in detach phase
Pull Request resolved: https://github.com/facebook/react-native/pull/28841

Test Plan: Unit tests for added getValue method passed. Green CI

Reviewed By: mdvacca

Differential Revision: D22211499

Pulled By: JoshuaGross

fbshipit-source-id: 9a3a98a9f9a8536fe2c8764f667cdabe1f6ba82a
2020-06-29 17:09:37 -07:00
fabriziobertoglio1987 0fda91ffff Adding Hyphenation Frequency prop for Text component (#29157)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/28279
android_hyphenationFrequency prop for Android Text component which sets the frequency of automatic hyphenation to use when determining word breaks.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Adding Hyphenation Frequency prop for Text component
Pull Request resolved: https://github.com/facebook/react-native/pull/29157

Test Plan:
More info are available in the [android docs](https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int)). I will add the documentation to the docs later once the pull request is taken in consideration for merging.

| **AFTER** |
|:-------------------------:|
|  <img src="https://user-images.githubusercontent.com/24992535/84919245-f8f1e300-b0c1-11ea-8a33-f30d0c9a75b7.png"  width="300" height="" />|

I remain available to do improvements. Thanks a lot. Fabrizio.

Reviewed By: TheSavior

Differential Revision: D22219548

Pulled By: JoshuaGross

fbshipit-source-id: 7e2523c25adfcd75454f60184eb73dc49891bef7
2020-06-29 16:57:12 -07:00
Joshua Gross 0b63c94648 Ship early ViewCommand dispatch everywhere
Summary:
Early ViewCommand dispatch: ship the experiment everywhere on Android.

Since ViewCommands are totally divorced from the commit cycle currently, and since they are inherently unsafe, we can create a separate queue for them
and retry them if they fail with a specific category of exceptions.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22173050

fbshipit-source-id: 494b7c6b5dfd2aec8ba77ae35d0d58d4d727b9b4
2020-06-29 15:45:11 -07:00
Joshua Gross 0a115d9c3f Ship MountItem Remove/Delete Collation
Summary:
Ship MountItem Remove/Delete Collation.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22170891

fbshipit-source-id: a9a149783bdd69df54e429da6ed9870bfb405a36
2020-06-29 15:45:11 -07:00
David Vacca 7abcaafd66 Fix crash when updating dialog props after the Activity has disappeared
Summary:
This diff avoids accessing window and activities object that has dissapear

changelog: [Android][Fix] Fix crash when updating RN dialog props after the activity disappeared

Reviewed By: JoshuaGross

Differential Revision: D22264672

fbshipit-source-id: 89c9895c8c6b6fec383a0e160847e5059616e265
2020-06-29 15:29:21 -07:00
Omer Peleg 530d11c506 Fix RN OSS build (#29221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/29221

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D22234372

fbshipit-source-id: 9b83ec3aa57254826be44ac0f73aeb34fb859337
2020-06-25 11:09:42 -07:00
Lee Callender 0967e7b26d Move ImageEditor Android files to FB Internal.
Summary: Changelog: [Android] [Removed] - Migrated ImageEditingManager to FB internal.

Reviewed By: cpojer

Differential Revision: D22123807

fbshipit-source-id: 24c3b3554f5e6152b70750a6c8212b3d3b66678f
2020-06-22 19:20:24 -07:00
David Vacca 75e6f7961f Fix measure of ReactSlider for Android API < 21
Summary:
This diff avoids calling to the method setStateListAnimator for users running in Android API < 21 (This method did not exist in Android API < 21)

changelog: [Android][Fix] Fix crash while measuring ReactSlider in Android API < 21

Reviewed By: lunaleaps

Differential Revision: D22164574

fbshipit-source-id: 8163f99eeb78302fc75e2c4938330c699ca8d363
2020-06-22 12:42:41 -07:00
Joshua Gross e661a551cb Potential fix for, and more diagnostics for, NativeAnimatedModule crash
Summary:
Searching for details and maybe a fix for T68843308 crashing in disconnectFromView, "Attempting to disconnect view that has not been connected with the given animated node".

May be related to recent refactoring but it's not clear. Change logic slightly and add more diagnostic information.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22153179

fbshipit-source-id: b95dbaf01ae8bca154c61442898b0f9d3aebb4de
2020-06-20 17:47:29 -07:00
Joshua Gross 9760a326c9 Fix MountingManager NPE
Summary:
Fix NullPointerException.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22153157

fbshipit-source-id: 77be1456a2b7f6429d2dce6eac5d9d0bca362c27
2020-06-20 17:41:02 -07:00
David Vacca f8bcb1063e Cleanup updateState method on TextInputManager
Summary:
Quick refactor to cleanup the updateState method on TextInputManager

changelog:[internal]

Reviewed By: JoshuaGross

Differential Revision: D22149752

fbshipit-source-id: 0461b1769b9a7a3b25257bbf2039dc461a164c6f
2020-06-19 21:50:43 -07:00
David Vacca 85669d8c30 EZ fix typo
Summary:
Fix typo in TextInput classes

changelog:[internal]

Reviewed By: JoshuaGross

Differential Revision: D22149753

fbshipit-source-id: f5d1f5ee8bea82e049ead7ca2664e46cdcd961a0
2020-06-19 21:50:43 -07:00
David Vacca 8cbbd93c40 Refactor Text input state
Summary:
This diff refactors the theme management for text input in order to avoid extra state updates.

changelog:[Internal]

Reviewed By: JoshuaGross

Differential Revision: D22149754

fbshipit-source-id: 8a6dbe63c8d532986dbf785c7b16323e0a980669
2020-06-19 21:50:43 -07:00
Joshua Gross 304c5d54ec MountingManager debug tool: show view hierarchies before and after remove/insert operations
Summary:
This is a useful debugging tool that will not be compiled by default, and we have some protection to only compile it in Debug builds so it's less likely to accidentally slip into production.

This has been useful for debugging C++ LayoutAnimations, since Remove/Insert mutations are delayed and fiddled around with a little.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22148853

fbshipit-source-id: 05609507cdf06b73fd3edf5cf7bc95e124ff1135
2020-06-19 20:28:05 -07:00
Joshua Gross e5a4d9550e Replace direct ViewManager calls to old UIManager with Fabric/Venice-compatible calls
Summary:
Replace direct ViewManager calls to old UIManager with Fabric/Venice-compatible calls.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22111396

fbshipit-source-id: 2de9df5a4b494f82049dba62325ee3119c80d3c3
2020-06-19 11:15:57 -07:00
Joshua Gross d183fd327b Improve MountingManager diagnostics around View removal
Summary:
It is possible (most recently, if there are bugs in LayoutAnimations, but also in general) to issue a `removeViewAt` MountItem that removes the incorrect view if, for whatever reason, the View hierarchy has become "corrupt"
and Views are out of order. I added two heuristics to catch if that happens: check the tag of the View being removed if possible, and ensure that all deleted views do not have a parent. This will turn weird visual glitches into
hard crashes, which we want once the UI has become corrupt.

My only concern here is with perf; maybe we could put these behind a debug-only flag or something, but it's probably not a huge deal.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22130186

fbshipit-source-id: 0942b019c3449d68edfb9db1fe8130ea351d1d8f
2020-06-19 11:13:35 -07:00
Tim Yung 64860972be RN: Adjust Image Blur on Android
Summary:
Adjusts the behavior of `blurRadius` for `Image` on Android so that it behaves more closely to other platforms (web and iOS).

Changelog:
[Android][Changed] - Effect of `blurRadius` now more closely matches other platforms.

Reviewed By: shergin

Differential Revision: D22118680

fbshipit-source-id: c6d14aef29b4a086e43badfa78407bfa07f9fee2
2020-06-18 14:46:49 -07:00
Lulu Wu e6fc20ee68 Keyframes is not implemented in Fabric Android
Summary:
Implement Keyframes in Fabric Android

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21952500

fbshipit-source-id: 6ba3af1afea227d58b6b12c1be629698d309a04d
2020-06-17 15:25:18 -07:00
Oleksandr Melnykov 6afc984e81 Update loading banner text and colors
Summary: This diff updates the loading banner text and color on Android to match its style on iOS.

Differential Revision: D22066823

fbshipit-source-id: 7f8d6cf1a6c4c48babe919995044978d7a81c674
2020-06-17 09:10:51 -07:00
Oleksandr Melnykov fca3a39da5 Add native module for loading split JS bundles in development
Reviewed By: mdvacca, cpojer

Differential Revision: D22001709

fbshipit-source-id: 4e378fd6ae90268e7db9092a71628205b9f7c37d
2020-06-17 09:10:51 -07:00
Joshua Gross 2e2c881147 NativeAnimatedModule should not crash if UIManager disappears
Summary:
If UIManager disappears, it's likely due to (1) teardown due to memory pressure, (2) teardown due to crash, (3) normal teardown.

In all of those cases, I would just want NativeAnimatedModule to stop executing and fail silently ASAP.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22079209

fbshipit-source-id: 21650abdfdb119a6f4abccd6962d0c09f7c7c6cd
2020-06-16 17:04:22 -07:00
Tim Yung fa0e6f8051 RN: Image Progress Event on Android
Summary:
Adds support for the `onProgress` event on `Image`, for Android.

Since Fresco does not provide a progress listener on `ControllerListener`, this uses a forwarding progress indicator `Drawable` to pass along values from `onLevelChange`.

Caveat: The ratio between `loaded` and `total` can be used, but `total` is currently always 10000. It seems that Fresco does not currently expose the content length from the network response headers.

Changelog:
[Android][Added] - Adds support for the `onProgress` event on `Image`

Reviewed By: mdvacca

Differential Revision: D22029915

fbshipit-source-id: 66174b55ed01e1a059c080e2b14415e7d268bc5c
2020-06-16 15:01:05 -07:00
Tim Yung 74ab8f6e5a RN: Consistent API for Image Events
Summary:
Changes the `onLoad` and `onError` events on `Image` to be consistent with each other and with the `ImageSource` type.

Changelog:
[Android][Breaking] - On `Image`, `onLoad` and `onError` event objects will no longer have an extra `uri` property.
[Android][Breaking] - On `Image`, `onLoad` event objects' `source.url` is now renamed to `source.uri`.
[iOS][Breaking] - On `Image`, `onLoad` event objects' `source.url` is now renamed to `source.uri`.

Reviewed By: mdvacca

Differential Revision: D22023565

fbshipit-source-id: 5ea7904c697f87e01118bdb81ed50ab0a5aecdce
2020-06-16 15:01:05 -07:00
Tim Yung 90997c26e3 RN: Cleanup ImageLoadEvent Logic (Android)
Summary:
Cleans up `ImageLoadEvent` to minimize constructor confusion and to make the dispatching logic more predictable.

Changelog:
[Internal]

Reviewed By: mdvacca

Differential Revision: D22023141

fbshipit-source-id: 17e66de867f51121a3f9a6b782dbad700a54231a
2020-06-16 15:01:05 -07:00
Joshua Gross b69041f086 Feature-flag gate stopSurface on root view unmount
Summary:
Gate stopSurface behind a feature flag.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22054480

fbshipit-source-id: 3ea48ab46aeb3532fc7a3dd83659d7c32891ec06
2020-06-15 18:43:30 -07:00
Joshua Gross 33ed358330 Bust surfaceActiveForExecution cache after executing a batch of items
Summary:
Since we were not busting the `surfaceActiveForExecution` cache, it is very possible (likely, even!) that a surfaceId is invalidated in between UI ticks but we keep executing items for that surface at the next tick.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22055303

fbshipit-source-id: 351c13535e85b30e00684fe35fc4aa79ccb5961c
2020-06-15 18:05:19 -07:00
David Vacca 6d6268e903 Fix padding flickering visible during initial render of text input
Summary:
This diff fixes a race condition that caused a flicker during initial rendering of TextInput in Fabric

The root cause is that the TextInput's State is sometimes initialized with no information from the Theme, this causes text input to be rendered with 0 padding. Later ReactTextInput manager updates TextInput state with theme data and the TextInput is re-rendered with the correct padding information.

changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D22034849

fbshipit-source-id: a2fa91f34a8340878f2ec8d231ef6c86cee08f05
2020-06-13 22:20:04 -07:00
David Vacca 1e453860d0 Ensure that layout events contain the correct padding information
Summary:
This diff changes the order of execution for the "updatePadding" mount item
Padding mountItems must be executed before layout props are updated in the view. This is necessary to ensure that events (resulting from layout changes) are dispatched with the correct padding information.

This fixes a 'flickering' bug in Marketplace Vehicles (see test plan)

changelog:[internal]

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D22034850

fbshipit-source-id: 222fa9412dd01f65a1a034f53e1eb0e7b774ec1f
2020-06-13 22:20:04 -07:00
Joshua Gross 86c38739a7 Avoid using ViewManager childCount to detect errors, since it's not reliable
Summary:
Similar to D21756178, we cannot rely on childCount since it can return zero when there are actually valid children. This both causes more exceptions than necessary when the operation would work, and pollutes error messages since the information is not strictly reliable.

Instead, we just try to get a View and thrown an exception when it's null, or in loops, loop until we hit a null child. `getChildAt` doesn't throw exceptions, it just returns null when we're out-of-bounds.

This can impact custom ViewGroups like BottomSheets, and other ViewGroups that might do interesting/weird things with children, including ReactClippingViewManager.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22035569

fbshipit-source-id: 43e98d81178faaf720face98fc84e78743f292c3
2020-06-13 18:31:41 -07:00
Joshua Gross 40b36a040f For lifecycle correctness, call scheduleMountItems even with empty BatchMountItem
Summary:
In particular, NativeAnimatedModule relies on having some signal of when there's a commit from ReactJS. In Fabric, this is the only reliable signal. Failing to call scheduleMountItems even when there's no changes to the tree will result in certain animation operations being delayed way longer than necessary.

I pass nullptr instead of empty arrays in some cases to hopefully improve perf.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22008981

fbshipit-source-id: 6bdeb46e03b5138dbfa5b077952ec0fa3dfe1eb3
2020-06-11 20:46:49 -07:00
Joshua Gross 0d073013a5 Fix typos in Native Animated error messages
Summary:
see title

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22008982

fbshipit-source-id: 056b0d99e8e81a1b11cd054e6c813002ae0b7014
2020-06-11 20:46:49 -07:00
Joshua Gross 472cf3f4ad NativeAnimatedDriver: synchronize animation lifecycle closer to Fabric or Paper lifecycle
Summary:
Switch between "Fabric" and "Non-Fabric" modes based on which types of native Views are being attached to animations. Don't allow non-Fabric to drive Fabric animations and vice-versa.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21985411

fbshipit-source-id: fb9bef1e38375b384430b4e0275e7b6d62eda7a4
2020-06-11 20:46:48 -07:00
David Vacca f53267f703 Migrate ReactText view to use uiManager.receiveEvent instead of ReactEventEmitter
Summary:
This diff refactors ReactTextView to use uiManager.receiveEvent instead of ReactEventEmitter. ReactEventEmitter.class should be replaced for uiManager.receiveEvent.

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D21982548

fbshipit-source-id: 4ed5825f62c761564aa533f4e8bb1155036df7e2
2020-06-10 22:56:02 -07:00
David Vacca 95154a6b8b Migrate usages of RCTEventEmitter.class to EventDispatcher
Summary:
This diff migrates usages of RCTEventEmitter.class to EventDispatcher.dispatchEvent.

RCTEventEmitter is not compatible with Fabric, now we need to use EventDispatcher.dispatchEvent instead.

changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D21982549

fbshipit-source-id: 9ea2d9a00f063a03c2e401fc1e328ce26bcf48df
2020-06-10 22:56:02 -07:00
David Vacca a0baba654e Expose receiveEvent as a high level API on UIManager
Summary:
This diff exposes receiveEvent on the UIManager class. This is necessary to support backward compatibility between Fabric and classic RN

changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D21979687

fbshipit-source-id: 1ec75896687d55e699f79c520e21f05fac368ee6
2020-06-10 22:56:01 -07:00
Joshua Gross 02b8e67da3 BatchMountItem debug info should log SurfaceId
Summary:
See title.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21965838

fbshipit-source-id: a3bd9d48c1fadb19a12cccaab5713cf73566bd93
2020-06-09 23:23:11 -07:00
Joshua Gross 912dac24fc Ignore PreAllocateViewMountItem if it's associated with a stopped surface
Summary:
Because of the previous diffs there's an increased chance of race conditions between JS executing and queuing up PreAllocateViewMountItems for surfaces that are stopped. Make sure those are ignored if they're queued up and a surface has been stopped.

Currently stopSurface only happens on the UI thread; PreAllocateViewMountItems can be queued from any thread, but are only executed on the UI thread. So once a batch of items starts executing, there's no race between teardown and execution: we just need to make sure we check that the surface is still running initially.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21965839

fbshipit-source-id: 0241dc171022cc923b7e38dcd110d664096dde79
2020-06-09 23:23:11 -07:00
Joshua Gross 03174f1cad Call stopSurface when ReactRootView is unregistered
Summary:
In the past, in Fabric (Android), we never called stopSurface. Ever! This is bad for memory and can cause other issues, so... let's not do that.

Instead, when the ReactRootView is being torn down, we check the View ID to see if it's a Fabric RootView, and if it is, we call Fabric's stopSurface method.

Fabric stopSurface only has impact on (1) Fabric mount instructions being executed after that point and (2) tells JS to stop running the surface, on the JS thread, asynchronously.

Anecdotally it looks like all the MountItems involved in deleting and removing views from the hierarchy are executed before stopSurface is called.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21965837

fbshipit-source-id: 5169c5a1e339fd9e016ae1234d8389b2bd30be70
2020-06-09 23:23:10 -07:00
Samuel Susla a5386ff4bf Delete animation driver when destructing scheduler
Summary:
Changelog: [Internal]

Clean up animationDriver_ in `Binding::uninstallFabricUIManager`.

Reviewed By: JoshuaGross

Differential Revision: D21923567

fbshipit-source-id: ecdc727ecbfd1d7052be0372b8d2a0ee7172f93f
2020-06-08 11:58:04 -07:00