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

4101 Коммитов

Автор SHA1 Сообщение Дата
Joshua Gross 5c4425a456 Fix Fabric SSTs, so they actually run in Fabric instead of Paper, convert ServerSnapshotTestsAppImpl to functional component
Summary:
Update instrumentation test infra for Fabric tests.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D19961919

fbshipit-source-id: 17264b6308712dddece730effd57832817e148cf
2020-04-03 14:04:51 -07:00
Ramanpreet Nara de56649430 Add CallInvoker::invokeSync
Summary:
We'll be using a native CallInvoker to dispatch sync and async method calls to ObjC NativeModules. This native CallInvoker will hold a reference to the ObjC NativeModule's method queue.

**Why is the native CallInvoker required for ObjC NativeModules?**
In the case where the ObjC NativeModule neither provides nor requests a method queue, we must create a method queue for it. When we go to invoke a method from JS, for these NativeModules specifically, there is no way to access this method queue. A native CallInvoker is a convenient abstraction that holds on to that method queue. For async calls, we'll just call `CallInvoker::invokeAsync`, and for sync calls, we'll just call `CallInvoker::invokeSync`.

**Why do we need sync call support for native `CallInvoker`?**
In ObjC, sync NativeModule method calls block the JS thread, then execute synchronously on the NativeModule's method queue, and then unblock the JS thread. This is what'll be implemented by `CallInvoker::invokeSync`.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D20829955

fbshipit-source-id: efb9d5408a1ade81069a943c865f232d4d10acfe
2020-04-03 09:47:42 -07:00
Ramanpreet Nara eb4e2baaa9 Rename Instance::getNativeCallinvoker to Instance::getDecoratedNativeCallInvoker
Summary:
Now, instead of accepting a `std::function` that schedules work, and returning a `CallInvoker`, `Instance::getDecoratedNativeCallInvoker`  will accept a `CallInvoker` that schedules work, and return a decorated `CallInvoker`.

I think this change will help with readability. It also clarifies that the bridge is adding additional behaviour to the native `CallInvoker`.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20826885

fbshipit-source-id: a2c5681d10a4544ee3d2a0d1f1cbd386ef06d0e6
2020-04-03 09:47:41 -07:00
David Vacca 3ed1b1f4ff Add a React Feature Flag to control TextInlineView fix
Summary:
This diff adds a temporary Feature Flag to control a fix in TextInlineView (see previous diffs of the stack)

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D20812920

fbshipit-source-id: 90fece9b29ba173546d96e4d9baf1ccabb3031b2
2020-04-02 14:11:17 -07:00
David Vacca 21eb540d6e Fix TextInlineViews when UIImplementation processes two roots at the same time
Summary:
This diff cleans the variable NativeViewHierarchyOptimizer.mTagsWithLayoutVisited right after all the view updates for a rootShadowNode have been processed by the UIImplementation class.

This intends to fix the bug reported in the task: T61185028, which root cause seems related to the fact that the variable NativeViewHierarchyOptimizer.mTagsWithLayoutVisited is not cleaned up when updating multiple rootShadowNodes as part of the same batch

changelog: [Android][internal] internal bug fix

Reviewed By: JoshuaGross

Differential Revision: D20812921

fbshipit-source-id: 28067ee29a931d7a9e9c33c90aceb4e3512dac1a
2020-04-02 14:11:17 -07:00
maciej simka 6f627f684b Split loadApplicationScript into initializeRuntime and loadBundle (#27844)
Summary:
This is the first of three PRs related to enabling multi-bundle support in React Native. More details, motivation and reasoning behind it can be found in RFC [here](https://github.com/react-native-community/discussions-and-proposals/issues/152).

Logic responsible for installing globals was pulled out from `loadApplicationScript` to `initializeRuntime` since it should be ran only once, what was left was renamed to `loadBundle`.

It's based on dratwas work from [here](https://github.com/callstack/react-native/tree/feat/multibundle/split-load-application), but applied to current `master` to avoid rebasing 3-months old branch and issues that come with that.

## Changelog

[Internal] [Changed] - split `loadApplicationScript` into `initializeRuntime` and `loadBundle` to enable multi-bundle support in the future
Pull Request resolved: https://github.com/facebook/react-native/pull/27844

Test Plan: Initialized new RN app with CLI, set RN to build from source and verified the still app builds and runs OK using code from this branch.

Reviewed By: rickhanlonii

Differential Revision: D19888605

Pulled By: ejanzer

fbshipit-source-id: 24ace48ffe8978796591fe7c6cf53a61b127cce6
2020-04-01 17:52:39 -07:00
Joshua Gross eab7fc008f Remove unused feature flag: logDroppedViews
Summary:
Remove unused internal feature flag, logDroppedViews.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D20797353

fbshipit-source-id: 1bfea7fcce9e80cdb92cda59a89c7dd817d4a581
2020-04-01 17:07:07 -07:00
Joshua Gross 00ed57eb91 Remove unused feature flag: enableExtraWebViewLogs
Summary:
Hard-coded to false everywhere, and write-only. We never read from this.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20788252

fbshipit-source-id: ae117ebc51db7045947b9713602527ff4220833e
2020-04-01 17:07:07 -07:00
Joshua Gross 3963f34980 Remove unused Feature Flag: lazilyLoadViewManagers
Summary:
Remove unused feature flag. This is not used within Facebook and I'm not aware of usage outside of FB.

Changelog: [Removed] Removing Android feature flag: lazilyLoadViewManagers

Reviewed By: mdvacca

Differential Revision: D20788210

fbshipit-source-id: 435316e3de7830d7cb7f14537351883e4fc6eeaa
2020-04-01 17:07:06 -07:00
Joshua Gross e7c3f9d838 Remove unused feature flag: useMapNativeAccessor
Summary:
useMapNativeAccessor isn't being used anywhere.

Changelog: [Internal] Removing unused internal feature flags: mUseMapNativeAccessor and mUseArrayNativeAccessor

Reviewed By: mdvacca

Differential Revision: D20788147

fbshipit-source-id: bf670508326813602cb544f86d3d2164651d3394
2020-04-01 17:07:06 -07:00
Rick Hanlon 52b3105f65 Implement RCTWarn equivalent on Android
Summary:
## Overview
This diff is an RFC to port a logging feature from iOS to Android.

Changelog: [Internal]

## Motivation
On iOS we have the following log functions and behaviors available for logging native warnings and errors:

- **Warnings** (`RCTLogWarn`)
  - Log level 'warn' to console
  - Display warning in LogBox
- **Errors** (`RCTLogError`)
  - Log level 'error' to console
  - Display a native RedBox (needs converted to show a LogBox if available)
- **Logs**
  - We also have `RCTLog`, `RCTTrace`, `RCTAdvice`, `RCTInfo`, which just log to the console.

In Java, we have:
- **Warnings**
  - **None**, added in this diff
- **Errors** (`DevSupportManager.showNewJavaError`)
  - Log level 'error' to console with `FLog.e`
  - Display a native RedBox (needs converted to show a LogBox if available
- **Logs**
  - `ReactSoftException` (crashes the app??)
  - `ReactNoCrashSoftException` (only logs??)
  - Others?

## Details

This diff adds a method to pair with `RCTLogWarn`, `DevSupportManager.showNewJavaWarning`, which will log to the console and show a LogBox warning if LogBox is available.

## Concerns

I have a few concerns/questions about the state of logging on Android:
- Should/can we move all of the logging to it's own class, like how RCTLog works?
- Why does some logging happen on DevSupportManager and some in other classes?
- If we moved it all to it's own class, how could we access the reactContext to call the RCTLog JS module

Reviewed By: JoshuaGross

Differential Revision: D20056394

fbshipit-source-id: 32d57e300685e46da8039fc77cb22b4084acf81a
2020-04-01 16:45:54 -07:00
Ramanpreet Nara 9b94a541d8 Get CallInvokers from the bridge
Summary:
## Context
For now, assume TurboModules doesn't exist.

**What happens when we call an async NativeModule method?**
Everytime JS calls an async NativeModule method, we don't immediately execute it. The legacy infra pushes the call into some queue managed by `MessageQueue.js`. This queue is "flushed" or "emptied" by the following events:
- **Flushed:** A C++ -> JS call. NativeModule async methods can called with an `onSuccess` and/or `onFail` callback(s). Calling `NativeToJsBridge::invokeCallback` to invoke one of these callbacks is one way for ObjC++/C++/Java to call into JS. Another way is via JSModule method calls, which are initiated by `NativeToJsBridge::callFunction`.
- **Flushed:** When `JSIExecutor::flush` is called. Since TurboModules don't exist, this only happens when we call `JSIExecutor::loadApplicationScript`.
- **Emptied:** When more than 5 ms have passed, and the queue hasn't been flushed/emptied, on the next async NativeModule method call, we add to the queue. Afterwards, we empty it, and invoke all the NativeModule method calls.

**So, what's the difference between flushed and emptied?**
> Note: These are two terms I just made up, but the distinction is important.

If the queue was "flushed", and it contained at least one NativeModule method call, `JsToNativeBridge` dispatches the `onBatchComplete` event. On Android, the UIManager module is the only module that listens to this event. This `onBatchComplete` event doesn't fire if the queue was "emptied".

**Why does any of this matter?**
1. TurboModules exist.
2. We need the TurboModules infra to have `JsToNativeBridge` dispatch `onBatchComplete`, which depends on:
   - **Problem 1:** The queue being flushed on calls into JS from Java/C++/ObjC++.
   - **Problem 2:** There being queued up NativeModule async method calls when the queue is flushed.

In D14656466, fkgozali fixed Problem 1 by making every C++/Java/Obj -> JS call from TurboModules also execute `JSIExecutor::flush()`. This means that, with TurboModules, we flush the NativeModule async method call queue as often as we do without TurboModules. So far, so good. However, we still have one big problem: As we convert more NativeModules to TurboModules, the average size of the queue of NativeModule method calls will become smaller and smaller, because more NativeModule method calls will be TurboModule method calls. This queue will more often be empty than not. Therefore, we'll end up dispatching the `onBatchComplete` event less often with TurboModules enabled. So, somehow, when we're about to flush the NativeModule method call queue, we need `JsToNativeBridge` to understand that we've executed TurboModule method calls in the batch. These calls would have normally been queued, which would have led the queue size to be non-zero. So if, during a batch, some TurboModule async method calls were executed, `JsToNativeBridge` should dispatch `onBatchComplete`.

**So, what does this diff do?**
1. Make `Instance` responsible for creating the JS `CallInvoker`.
2. Make `NativeToJsBridge` responsible for creating the native `CallInvoker`. `Instance` calls into `NativeToJsBridge` to get  the native `CallInvoker`.
3. Hook up `CatalystInstanceImpl`, the Android bridge, with the new JS `CallInvoker`, and the new native `CallInvoker`. This fixes `onBatchComplete` on Android. iOS work is pending.

Changelog:
[Android][Fixed] - Ensure `onBatchComplete` is dispatched correctly with TurboModules

Reviewed By: mdvacca

Differential Revision: D20717931

fbshipit-source-id: bc3ccbd6c135b7f084edbc6ddb4d1e3c0c7e0875
2020-04-01 11:39:18 -07:00
Samuel Susla e653cb06f8 Pass isRTL flag from FabricUIManager Fabric core
Summary:
Changelog: [Internal]

Send `isRTL` flag and `doLeftAndRightSwapInRTL`  flags from Java to Fabric Core.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D20776005

fbshipit-source-id: 946c239d9a11ebea958b0a6d04f2316b7cd77311
2020-04-01 08:39:53 -07:00
Emilis Baliukonis 232517a574 Implement nativePerformanceNow to improve Profiler API results (#27885)
Summary:
When experimenting with React Profiler API (https://reactjs.org/docs/profiler.html), I noticed that durations are integers without a debugger, but they are doubles with higher precision when debugger is attached. After digging into React Profiler code, I found out that it's using `performance.now()` to accumulate execution times of individual units of work. Since this method does not exist in React Native, it falls back to Javascript `Date`, leading to imprecise results.

This PR introduces `global.nativePerformanceNow` function which returns precise native time, and a very basic `performance` polyfill with `now` function.

This will greatly improve React Profiler API results, which is essential for profiling and benchmark tools.

Solves https://github.com/facebook/react-native/issues/27274

## Changelog

[General] [Added] - Implement `nativePerformanceNow` and `performance.now()`
Pull Request resolved: https://github.com/facebook/react-native/pull/27885

Test Plan:
```
const initialTime = global.performance.now();
setTimeout(() => {
  const newTime = global.performance.now();
  console.warn('duration', newTime - initialTime);
}, 1000);
```

### Android + Hermes

![Screenshot_1580198068](https://user-images.githubusercontent.com/13116854/73245757-af0d6c80-41b5-11ea-8130-dde14ebd41a3.png)

### Android + JSC

![Screenshot_1580199089](https://user-images.githubusercontent.com/13116854/73246157-92256900-41b6-11ea-87a6-ac222383200c.png)

### iOS

![Simulator Screen Shot - iPhone 8 - 2020-01-28 at 10 06 49](https://user-images.githubusercontent.com/13116854/73245871-f136ae00-41b5-11ea-9e31-b1eff5717e62.png)

Reviewed By: ejanzer

Differential Revision: D19888289

Pulled By: rickhanlonii

fbshipit-source-id: ab8152382da9aee9b4b3c76f096e45d40f55da6c
2020-03-31 10:23:51 -07:00
Joshua Gross b8664182da Remove allowDisablingImmediateExecutionOfScheduleMountItems feature flag
Summary:
No longer needed.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20747684

fbshipit-source-id: a8077519b7670d72e23267b1c1423556ec97be3f
2020-03-30 16:50:41 -07:00
Nicholas Tinsley 6a61557b24 Early return on tinting CursorDrawable if no color supplied
Summary:
There's (potentially) a lot of expensive reflection calls here that, as best I can tell, end up being ignored if the supplied color is null. Better to early return.

Changelog: [General] [Internal] Preclude reflection when setting cursor color if color is null

Reviewed By: JoshuaGross

Differential Revision: D20670594

fbshipit-source-id: 480a988355bbd79008002c4326d4b35035ec2a95
2020-03-30 13:06:43 -07:00
Nicholas Tinsley e7a14b803f Fix CursorDrawable Color Tint for Android 10+
Summary:
Accessing this field via reflection is explicitly blacklisted by Google in Android 10 and higher. They have provided a new API to change the color, which I have implemented here. [The old setColorFilter is deprecated](https://developer.android.com/reference/android/graphics/drawable/Drawable#setColorFilter(int,%20android.graphics.PorterDuff.Mode)) so I also updated that method call as well.

Changelog: [General] [Fixed] Use new setTextCursorDrawable API for Android 10

Reviewed By: JoshuaGross

Differential Revision: D20656068

fbshipit-source-id: 58a92b57c0a892c7c87fc5d735e4ceaa4e987ec7
2020-03-30 13:06:43 -07:00
Spencer Ahrens cd1344620c experiment to preload RN bridge after fb4a bookmarks render
Summary:
Changelog:
[Android][Internal] add internal supermodule label

Reviewed By: mdvacca

Differential Revision: D20434200

fbshipit-source-id: fae50309cdd0df4a4523c2f88d1c8e01a7163575
2020-03-30 11:14:48 -07:00
Rick Hanlon 011eb4cea5 Remove "Debug with Nuclide" option
Summary: This is no longer needed.

Reviewed By: cpojer

Differential Revision: D20722274

fbshipit-source-id: 5bc3104e90811d724f42aadbf137ab8eff718ca0
2020-03-30 10:09:20 -07:00
Joshua Gross 50a34bcd7f Optimize diff algorithm to produce fewer remove+insert ("move") paired instructions
Summary:
An evolution of D20633188 but more performant.

There are three optimized paths before the slow path.

The first optimized path tries to pair identical nodes from old/new tree, and generate Update mutations, until we hit nodes that are different (indicating either a remove or an insert). This already existed.

The next two optimizations, introduced by Tim in his JS pseudocode, were inspired by ReactJS's diffing algorithm. They work in cases where the rest of the nodes are (1) all removals/deletes or (2) all creates+inserts.

Finally, if those final two optimized paths can't run, it's because there is a mix of delete+remove, create+insert, and "move" operations, mixed at the beginning, middle, and/or end of the list.

This has slightly better average/best-case complexity as the previous implementation.
In particularly pathological cases where all nodes are arbitrarily reordered, or reversed, for instance (ABCDE->EDCBA) the algorithm has the same complexity as the previous algorithm (quadratic).

For now iOS is pinned to the older differ

Changelog: [Internal] Experiment to optimize diffing algorithm in Fabric

Reviewed By: shergin

Differential Revision: D20684094

fbshipit-source-id: d29fba95a0328156c023e1c87804f23770ee1d91
2020-03-27 19:07:53 -07:00
Kevin Gozali 25f7aea86c Replace fbsource// with // in xplat/js/ files [1]
Summary:
`fbsource//xplat` and `//xplat` are equivalent for FB BUCK targets. Removing extra prefix for consistency.

Changelog: [Internal]

Reviewed By: scottrice

Differential Revision: D20495655

fbshipit-source-id: a57b72f694c533e2e16dffe74eccb8fdec1f55f5
2020-03-25 21:55:47 -07:00
Eddie Dugan 56b0f5cb6b RN picker - fix types in AndroidDialogPickerManagerInterface
Summary:
according to [this crash report](https://our.intern.facebook.com/intern/logview/details/facebook_android_crashes/7ba7056481015482c6166d65cb97e49d/?trace_key=1506fe36a70dd5e50cdc8968f6317f27), `value` was throwing an NPE despite being null-checked. this is because it was an `int` rather than an `Integer`, so the null check wasn't working

Changelog: Fix types in AndroidDialogPickerManagerInterface

Reviewed By: mdvacca

Differential Revision: D20646343

fbshipit-source-id: a27587e0a48f5782bcf5ffddb604018218e65206
2020-03-25 10:54:22 -07:00
Michael Bolin 0b9ea60b4f Back out "Upgrade Prettier from 1.17 to 2.0.2."
Differential Revision: D20639755

fbshipit-source-id: 5028563f9cf0527a30b4259daac50cdc03934bfd
2020-03-24 21:47:35 -07:00
Michael Bolin cf44650b3f Upgrade Prettier from 1.17 to 2.0.2.
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
2020-03-24 20:24:47 -07:00
Jack Wang 05e2ec601b Changing Order Of mOverrideColorScheme In Constructor
Summary:
Changelog: [Android] [Updated]

mOverrideColorScheme should be assigned before the first colorSchemeForCurrentConfiguration call, so the initial setting of mColorScheme will reflect the override

Reviewed By: zackargyle

Differential Revision: D20630173

fbshipit-source-id: a2a2d174d3fc40c14f27dce6a7fa8e67203480c9
2020-03-24 15:33:40 -07:00
Spencer Ahrens 33f20242f6 Hopefully fix so loading crashes
Summary:
Changelog:

[Android][Internal] Fix potential initializer interruption threading crashes.

Reviewed By: mdvacca

Differential Revision: D20615755

fbshipit-source-id: 58b706deeb6df1998caff5bf2ae9ec60114313fe
2020-03-24 11:25:47 -07:00
Luna Wei 44f213b40e Modify pending deletion tags to be cross manageChildren
Summary:
Changelog: [Internal]

Removing historic layout animations index adjustment (D20323928) broke the Dating Secret Crush screen.

Since flushing animations (D20319824) had to be reverted due to issues with Saved + Privacy Shortcuts (https://fburl.com/tasks/eijtmifu) we need to track pending deletions across `manageChildren` operations.

Reviewed By: JoshuaGross

Differential Revision: D20601079

fbshipit-source-id: c6f116683750e97abe7f988cf361d2a6449e90e6
2020-03-23 17:36:13 -07:00
Eddie Dugan 22eb711c84 RN picker - implement background color
Summary:
add support to the android implementation of the Picker component for setting the background color.

Changelog: [Android] [Added] - Support item background color in Dialog Picker

Differential Revision: D20566131

fbshipit-source-id: d693b40803fa1051ec955c5728994c820fecd9e9
2020-03-23 08:37:16 -07:00
generatedunixname89002005287564 327fbd0509 Daily `arc lint --take BUCKFORMAT`
Reviewed By: zertosh

Differential Revision: D20593906

fbshipit-source-id: b056947c698508119dc9d4d1bba202295b8f0fda
2020-03-23 05:58:06 -07:00
Héctor Ramos 987b902dc0 Fix `test_android`: Remove references to fbsource cell (#28363)
Summary:
Fixes https://github.com/facebook/react-native/issues/28361.

## Changelog

[Internal] [CI] - Fix test_android
Pull Request resolved: https://github.com/facebook/react-native/pull/28363

Test Plan:
Prior to fix:

```
react-native $ ./scripts/circleci/buck_fetch.sh
Guessing 168a69309928ba16065cdb33b1775a4af9f924a6 as the last one used version.
Using additional configuration options from /Users/hramos/.buckconfig.d/experiments, /etc/buckconfig.d/fb_chef.ini, /etc/buckconfig.d/fb_chef_override.ini
Invalidating internal cached state: Watchman failed to start. This may cause slower builds.
Parsing buck files: finished in 1.5 sec
Buck wasn't able to parse /Users/hramos/git/react-native/ReactAndroid/src/main/java/com/facebook/fbreact/specs/BUCK:
IOError: [Errno 2] No such file or directory: '/Users/hramos/git/react-native/tools/build_defs/platform_defs.bzl'
Call stack:
  File "/Users/hramos/git/react-native/.buckd/resources/168a69309928ba16065cdb33b1775a4af9f924a6/buck_server/buck_parser/profiler.py", line 507, in wrapped
    return func(*args, **kwargs)
  File "/Users/hramos/git/react-native/ReactAndroid/src/main/java/com/facebook/fbreact/specs/BUCK", line 1
    load("//tools/build_defs:platform_defs.bzl", "ANDROID")
  File "/Users/hramos/git/react-native/.buckd/resources/168a69309928ba16065cdb33b1775a4af9f924a6/buck_server/buck_parser/profiler.py", line 507, in wrapped
    return func(*args, **kwargs)

This error happened while trying to get dependency '//ReactAndroid/src/main/java/com/facebook/fbreact/specs:FBReactNativeSpec' of target '//ReactAndroid/src/main/java/com/facebook/react/devsupport:devsupport'
```
After fix:

```
react-native $ ./scripts/circleci/buck_fetch.sh
+ buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
Guessing 168a69309928ba16065cdb33b1775a4af9f924a6 as the last one used version.
Using additional configuration options from /Users/hramos/.buckconfig.d/experiments, /etc/buckconfig.d/fb_chef.ini, /etc/buckconfig.d/fb_chef_override.ini
Invalidating internal cached state: Watchman failed to start. This may cause slower builds.
Parsing buck files: finished in 1.1 sec
Configuration 'ANDROID_SDK' points to an invalid directory '/opt/android_sdk'.
    When creating rule //ReactAndroid/src/main/java/com/facebook/hermes/instrumentation:instrumentation.
```

> Note: I don't have the Android SDK configured in this machine.

Verified on Circle CI. `test_android` is now green: https://circleci.com/gh/facebook/react-native/140682?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

Reviewed By: cpojer

Differential Revision: D20564934

Pulled By: hramos

fbshipit-source-id: 5d843b8f113c4db5391ee39addc3ff259d962290
2020-03-20 15:36:54 -07:00
Joshua Gross b54257c628 Introduce early dispatch of ViewCommands in FabricUIManager
Summary:
Earlier this week I introduced a change in the old, non-Fabric renderer (D20378633 D20427803) that (gated behind a feature-flag) executes ViewCommands before all other types of commands, as a perf optimization and (I think) a potential fix for a category of race conditions.

I've added more details in comments here.

The Fabric renderer uses the same feature-flag that I introduced for the non-Fabric renderer.

Changelog: [Internal] Fabric

Reviewed By: mdvacca

Differential Revision: D20449186

fbshipit-source-id: bb3649f565f32c417a6247369902333989a043aa
2020-03-19 23:02:05 -07:00
Joshua Gross 0fe548aa2a Only retry ViewCommand mount items if exception is marked as "Retryable"
Summary:
Instead of just blindly retrying all ViewCommands if they fail - which could be dangerous, since it's arbitrary imperative commands we'd be executing twice, potentially with bad app state - we only retry if the ViewCommand throws a "RetryableMountingLayerException".

Changelog: [Internal] Optimization to ViewCommands

Reviewed By: mdvacca

Differential Revision: D20529985

fbshipit-source-id: 0217b43f4bf92442bcc7ca48c8ae2b9a9e543dc9
2020-03-19 23:02:04 -07:00
Joshua Gross 7561adac77 Consolidate "dispatchMountItems" reentrancy prevention code, and retry code, in one function
Summary:
Simplifying the dispatchMountItems reentrance and retry logic.

Motivation: cleanup so I can work on dispatching ViewCommands before anything else.

Importantly, this gives us the properties that:
1) Only one function is responsible for calling dispatchMountItems
2) Only one function is responsible for deciding if we shouldn't call dispatchMountItems due to reentrance
3) Only one function is responsible for all cleanup
4) Only one function maintains all of the relevant flags (except dispatchPreMountItems... two total now, instead of 4 before)

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20437035

fbshipit-source-id: 5370366790eb25f653bee6c1950e747458374a61
2020-03-19 23:02:04 -07:00
Ramanpreet Nara 950826f6b5 Back out "Track animations and flush them"
Summary:
Original commit changeset: b594d0e6e9b6

D20319824 introduced a problem in LayoutAnimations, which makes surfaced as the problem in T63911344. This diff reverts D20319824.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D20541918

fbshipit-source-id: ff72b839f57d39051122920a38b2632cbb5ec362
2020-03-19 20:49:36 -07:00
Joshua Gross bb7f4dc818 Early ViewCommand dispatch: retry exactly once, log soft errors in one place
Summary:
As a followup to T63997094, I think it is better to attempt to execute early once, and then to execute the ViewCommand after the current batch of mount instructions if that fails. If both fail, then log a soft exception.

This is to support the use-case here, when ScrollView.scrollToEnd is called during the render pass, before any Views are mounted on the screen: https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/xplat/js/RKJSModules/Apps/Profile/ProfileEdit/ui/featured_highlights_migration/ProfileEditFeaturedHighlightsMigrationProfilePreview.js?commit=75f66a9077abb81b7797079b567df759dd023a79&lines=221-229

Changelog: [Internal] Fix for dispatching ViewCommands early

Reviewed By: mdvacca

Differential Revision: D20478681

fbshipit-source-id: 052b3ecf4913a0096f590637faf0f68a072e2427
2020-03-16 19:41:47 -07:00
Joshua Gross 5296a740a7 Dispatching ViewCommands to a non-existent tag should log SoftException, but not crash
Summary:
Patch for T63997094.

Will still crash in debug mode, and log soft errors, so as not to entirely hide errors.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20473855

fbshipit-source-id: 8b052b1ae3c886f83d6a7922feb158172cdcd33d
2020-03-16 13:28:08 -07:00
Jack Wang 45d7df6cf7 Adding interface callback for dynamic color scheme
Summary:
Changelog: [Android] [Added]

Adding:
- OverrideColorScheme interface to AppearanceModule
- setOverrideColorScheme method to AppearanceModule

This allows RN surfaces's color scheme to be overriden by custom theme from the app.
When set, AppearanceModule will use the value from OverrideColorScheme instead of system theme (light/dark)

Reviewed By: JoshuaGross

Differential Revision: D20405810

fbshipit-source-id: 8e562148a75231781649b615fdaf3368beeb477d
2020-03-13 22:06:04 -07:00
Héctor Ramos 07def55396 fbshipit-source-id: da15f69185e724eaf7d4bc78dbc61fcdcb3074d5 2020-03-13 21:46:45 -07:00
Joshua Gross f3a53fd338 TextInput: keep less stateful data on the View
Summary:
Allow JS to keep track of mostRecentEventCount and pass it into each event or prop update. We really don't want to separately keep track of that data.

In non-Fabric, the ShadowNode will keep track of the mostRecentEventCount associated to prop updates. In Fabric, that happens on the C++ ShadowNode.

Changelog: [Internal] Simplification to TextInput native state

Reviewed By: mdvacca

Differential Revision: D20374573

fbshipit-source-id: 385fba6ec69a071c78832a686b397699a6c55d67
2020-03-11 12:32:40 -07:00
Joshua Gross 8b61578076 Maintain a separate queue for ViewCommands and execute before everything else
Summary:
ViewCommands are sort of like setNativeProps updates, in that they're direct manipulations of Views on-screen that don't go through the normal
commit/diff process that other UI updates do. This is an MVP that shows how we can do this in non-Fabric RN.

Changelog: [Internal] experiment, allow ViewCommands to be executed before other types of UIOperations

Reviewed By: axe-fb, mdvacca

Differential Revision: D20378633

fbshipit-source-id: 5f3c54d3c84b4e4f7cb060a9505b20b0e5b7afed
2020-03-10 20:26:44 -07:00
generatedunixname89002005287564 837c3db49e Daily `arc lint --take GOOGLEJAVAFORMAT`
Reviewed By: zertosh

Differential Revision: D20360867

fbshipit-source-id: 737748733ff6826b2f20760fcb301988ff46e278
2020-03-10 05:41:35 -07:00
Joshua Gross 2f45961beb Protect against View context not being a ThemedReactContext in AndroidTextInput in Android 4
Summary:
See D19204032. In some cases the View might not have a ThemedReactContext, it may be wrapped, so we use a previously-created helper to get the correct context from the View or we throw a soft exception.

Changelog: [Internal] Fabric change

Reviewed By: mdvacca

Differential Revision: D20355126

fbshipit-source-id: 469a3b7f8f2d3b98236f3170dd62c4a6e7e1e46f
2020-03-09 20:45:01 -07:00
Joshua Gross 3cc69d2e2b Work around crash when default colors are null
Summary:
Work around crash in Android TextInput when default colors are null.

This likely indicates that the Context is corrupted in some way, so this is not a permanent solution.

Changelog: [Internal] Raise soft exception is default platform text color isn't defined

Reviewed By: mdvacca

Differential Revision: D20351080

fbshipit-source-id: d912c9348272c2f3a3b8d571d465d482060efe5a
2020-03-09 20:45:01 -07:00
Luna Wei c938c0afbf Adjust Layout Animation with pending deletion set
Summary:
Changelog: [Internal]
This solves the problem of viewToAdd indices being invalid if the deletes are asynchronous within the scope of one `manageChildren` call.

Since deletions are performed first, we keep a set of tags being deleted.
During view insertion, we iterate through and filter those tags out of our count.

Reviewed By: JoshuaGross

Differential Revision: D20324643

fbshipit-source-id: 150230428fcd65b8c43cc1f2331e9ce02d31fff9
2020-03-09 18:33:53 -07:00
Luna Wei dedf9372ca Track animations and flush them
Summary:
Changelog: [Internal]

Track delete animations and when `manageChildren` is called on a certain view tag, finish all pending deletion animations before manipulating children

Reviewed By: JoshuaGross

Differential Revision: D20319824

fbshipit-source-id: b594d0e6e9b6fecc5eca2938f284be631494e55c
2020-03-09 15:56:38 -07:00
Luna Wei d3b93f7578 Remove all layout index adjustments
Summary:
Changelog: [Internal]

# Context Timeline

* ~March 2019 landed D14529038 (I'll be referring to this as "index adjustment fix")
which attempted to fix a reproducible issue with layout animations: P127130177, see Spencer's diff for more context: D14245985

* May 2019 I realized that "index adjustment fix" has a bug in it and attempted to fix with D15485132, but was eventually reverted because of other crashes

* Just recently have been getting tasks related to crashes that are attempting to either remove or add a view that is out of bounds which is caused by invalid index because of the "index adjustment fix".

# What is this diff doing?
I'm removing the "index adjustment fix" because I found that the original layout animation repro, P127130177, no longer repros on  latest master with the "index adjustment fix" reverted.

Additionally, I've found a consistent crash in (RN bookmark > Sample Integration App > Relay Sample Friends) of a bad view deletion because of the "index adjustment fix"

Removing the index adjustment fix may have effects elsewhere but it seems better to remove this and go back to what layout animations was doing a year ago than to continue on in this half-baked state.

Reviewed By: JoshuaGross

Differential Revision: D20323928

fbshipit-source-id: ba4a222915add00e98a9936ba2a8efc4006fb8e3
2020-03-09 15:56:37 -07:00
Jesse Katsumata 42c1957aff chore: fix typo in comments (#28269)
Summary:
Fixed some typos in the comment.

## Changelog

[Internal] [Fixed] - Fixed typo in the comments
Pull Request resolved: https://github.com/facebook/react-native/pull/28269

Test Plan: Changes are only made in the comments, so test is not necessary.

Reviewed By: cpojer

Differential Revision: D20342637

Pulled By: shergin

fbshipit-source-id: f6e7dd538ee54c43e1570c35e1f8c4502054e328
2020-03-09 15:37:33 -07:00
David Vacca c3d0729550 Fix rendering of TextInput in Catalyst App
Summary:
This diff fixes the rendering of the TextInput RNTester examples in catalyst app.
The root cause of the bug is that we were parsing the props of the text using the TextAttributeProps class, this is incorrect because TextAttributeProps is a holder of the C++ TextAttributes and not TextProps, but the name is confusing.
As a consecuence there was some mistmaches of types during parsing and that was throwing an exception in some examples.

I created the task T63643819 to refactor these classes to make this cleaner.
I'll be working on T63643819 next week, now I want to unblock this bug.

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D20320969

fbshipit-source-id: 7b47546ba4f34df2a7fa151ab200823ea2eeb696
2020-03-06 23:07:32 -08:00
David Vacca acbf9e18ea Deprecate method UIManagerModule.resolveRootTagFromReactTag
Summary:
In this diff I'm doing the following:
- Deprecating the method UIManagerModule.resolveRootTagFromReactTag
- Removing the callsites to the method UIManagerModule.resolveRootTagFromReactTag
- Refactoring the callsites in order to keep the same behavior for rootTags
- Throwing an exception if this method was being called with a non rootTag
- Controlling this change of behavior with a MC

This is possible because long time ago we refactored all the callsites to this method to ensure we only use rootTag. I'm making extra steps to make sure this deprecation is safe and we don't break production if this method was being called with a non Root Tag.

changelog: [Android][Deprecated] We are deprecating the method UIManagerModule.resolveRootTagFromReactTag, this will not be supported in the next version of RN

Reviewed By: fkgozali

Differential Revision: D20309166

fbshipit-source-id: 8b89ba889313ae03ed543f402b68f1bb4064ca68
2020-03-06 13:29:01 -08:00
Logan Daniels b85cb0cf7a Back out "Moving towards UIWindowScene support"
Summary:
Original commit changeset: ae2a4478e2e7

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D20289851

fbshipit-source-id: 1167ce8f5135411b80630b523c91c10e2b7eece1
2020-03-05 15:58:44 -08:00