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

2600 Коммитов

Автор SHA1 Сообщение Дата
Valentin Shergin a82d9bdfbb Fabric: Removing the old state reconciliation infra
Summary:
The experiment is shipped on both platforms

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23605898

fbshipit-source-id: 05aab7e621bfbf99534c8b0b98994cf72fbcf5dd
2020-09-09 15:08:23 -07:00
empyrical 0693d08e2f Fabric: Explicitly include algorithm in Rect.h (#29884)
Summary:
This pull request adds an include statement including the header `<algorithm>` to `react/renderer/graphics/Rect.h`.

It is needed for building with MSVC because of the use of the `std::max` function. It seems that this header is included as a side effect of some other header that's being used when building with Clang, and for some reason it is not included when being built with MSVC.

## Changelog

Changelog: [Internal][Added] - Fabric: Explicitly include algorithm in Rect.h

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

Test Plan: Files that include this header now successfully compile on MSVC.

Reviewed By: sammy-SC

Differential Revision: D23591910

Pulled By: shergin

fbshipit-source-id: d8367bbdd94bc66c05d8fa308ed46c7aca24a68a
2020-09-09 13:04:35 -07:00
Ramanpreet Nara f5c246d50e Use reader/writer lock for TurboModule cache access
Summary:
Right now, when two threads require two NativeModules, both threads fight for the same `std::mutex`. Why? Because NativeModule require can read from/write to the shared `std::unordered_map<std::string, TurboModuleHolder*>`.

**A Few Thoughts:**
- All threads should be able to read from the TurboModule cache concurrently, without issue. Only writes into the cache require exclusive access. *With our current setup, both reads and writes acquire exclusive access.*
- During the lifetime of an application, there will only be tens of NativeModule create events (i.e: writes into the TurboModule cache). However, there may be hundreds, if not thousands of TurboModule cache lookups. *We don't need to serialize those hundreds/thousands of TurboModule cache reads.*

This is a potential optimization opportunity for the TurboModule infra.

## Changes
This diff introduces a `std::shared_mutex` inside `RCTTurboModuleManager`. We use either the regular `std::mutex` or the `std::shared_mutex`, depending on whether `RCTTurboModuleSharedMutexInitEnabled()` is `YES`.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23413118

fbshipit-source-id: 0880413c691b141db98a2715648f0c3e05983307
2020-09-09 09:31:38 -07:00
Valentin Shergin 4d920fe7c9 Fabric: Enable zIndex only for non-`static`-positioned views
Summary:
The standard says that zIndex should only be defined for non-`static` positioned views. This diff implements it.
For now, it actually enables zIndex for all views in RN because there is no way to specify `position: static` but we will give that ability by changing Flow definitions in future diffs in a couple of weeks (to ensure OTA safety).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23559447

fbshipit-source-id: 20ea10c9349de2c5b1adea5735324a8f57150695
2020-09-07 11:51:20 -07:00
Valentin Shergin 902611f148 Fabric: Catching exceptions in UIManager::completeRoot earlier, in C++
Summary:
Fabric Core does not support exception safety, so technically exceptions are unrecoverable and binaries should be built without exception support.
While it's not the case, some exceptions might bubble to JavaScript realm and be caught as JavaScript exceptions. In this case, we lose the stack trace. To prevent that and to investigate one particular error we have we add this try-catch block in this diff.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D23529233

fbshipit-source-id: 7ac7fb26ac08ad26af8790172de471ac178c3a37
2020-09-04 22:53:40 -07:00
Valentin Shergin 6729a3e0bf Fabric: Reviving of RN_SHADOW_TREE_INTROSPECTION in DEBUG mode
Summary:
Shadow tree introspection was disabled for a while, now we need it back working. This diff also restructures the logic of `MountingCoordinator::pullTransaction()` splitting it into two sections, first one for the base case and the second for the overriding case.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D23374948

fbshipit-source-id: 0b5f1c598975bceb3dcb6a0eaee67ff58ef9dda1
2020-08-28 10:22:41 -07:00
Valentin Shergin bc3251c6a5 Fabric: `MountingTelemetry` renamed to `TransactionTelemetry`
Summary:
Just renaming, nothing more.
The idea of MountingTelemetry already grown to something bigger than just mounting telemetry, so we are renaming it.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D23374947

fbshipit-source-id: f60ce38b75d1ce77498b84688e59598314c69a78
2020-08-28 10:22:41 -07:00
David Vacca 871e14fd80 Fix initial render of RN Android TextInput
Summary:
This diff fixes the initial render of RN Android TextInput. The problem was that "attributedString" was not serialized until an event was sent from native side.

Changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D23383969

fbshipit-source-id: 86601434b1fbaa9f712bdb79b013a1d004bc55a4
2020-08-27 20:56:46 -07:00
Joshua Gross fe7ff13fcf LayoutAnimations: stopSurface
Summary:
Implementing stopSurface to stop ongoing animations.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23382974

fbshipit-source-id: 478e0b1ad443ceeb771b03bd1689ec2bdbe02979
2020-08-27 19:37:06 -07:00
Joshua Gross 6a3c866b6a LayoutAnimations: work on making index adjustment more robust to flattening/unflattening and many reorders
Summary:
My goal in this diff is to make LayoutAnimations more stable, and more resilient to challenging situations. Namely, LayoutAnimations already works fine with:

1) Reorders
2) Flattening/unflattening
3) Deletion and recreation of the same hierarchy
4) Updates conflicting with an existing animation

However, what if /all/ of those things are combined? Handling update conflicts with multiple ongoing animations, repeatedly flattening/unflattening the same layer of hierarchy and reordering both parents and children, etc .

This diff does not make LayoutAnimations perfect, but it does make LayoutAnimations much more resilient to situations it was not able to handle before.

My primary method of testing was to use two Playground examples: one just repeatedly queues up mutations (some animated, some not) that create, update, and delete in the same hierarchy layer. The second, more complex one, mutates between random view hierarchies that involve a lot of flattening and unflattening as well as reordering, over a depth of 5. It also exercises animations over TextInlineViews, which is more challenging.

LayoutAnimations works best with the new "Flattening Differ" for now, because the Flattening Differ produces a much smaller, nearly minimal set of instructions in cases of flattening-unflattening. I would like that to not be a hard requirement for using LayoutAnimations, but it's a good starting-point for now.

As part of this work, I also developed a lot of debugging and logging mechanisms that are handy for detecting inconsistencies and debugging crashes. Some are included in this diff behind `#define` statements that are disabled by default, and the rest will be published separately and likely cannot be landed permanently, as they're more invasive changes that are only helpful in debugging.

# Followups:

- Automate testing: write a suite of C++ tests that mutates between random diffs and guarantees that all mutations in a StubViewTree are sensible
- Construct a set of minimal repros that catalogues all remaining crashes and inconsistency issues (these seem to be extremely marginal cases and are very hard to repro - so I think it's fine to run this in prod for now, but I will follow-up as soon as I'm back to catalogue and fix all remaining issues)
- This diff focuses on *not crashing*, but it is still possible to construct a sequence of complex mutations that results in (for example) views having some opacity between 0 and 1 if animations are interrupted repeatedly. Although this is easy enough to prevent in product code - the types of scenarios I'm running in tests are very unlikely to ever happen in production - it would be nice to be *sure* that LayoutAnimations will always converge to a sensible View hierarchy with up-to-date props.
- In general, the index adjustment logic is complicated. I don't know if there's a great way around it, so I need to at least catalogue and test all edge-cases as mentioned above.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23382975

fbshipit-source-id: f379d9aa2a4b9c33fa2ba8fa07870c9e31fad5e7
2020-08-27 19:37:06 -07:00
Valentin Shergin cb48b50290 Fabric: Storing commit revision number in `MountingTelemetry`
Summary:
Now we store a revision number of a Shadow Tree that leads to a transaction for which the concrete instance of MountingTelemetry corresponds. This is useful to understand how many actual transactions were skipped during a mounting phase (a mounting transaction does not directly correspond to a commit operation).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D23364663

fbshipit-source-id: 32b86bcdfc1ae97d8fff3b97a8615cc5a5b4d4a9
2020-08-27 12:33:58 -07:00
Valentin Shergin dfa25df2cf Fabric: Counting number of text measuments as part of MountingTelemetry
Summary:
With this change, we now collect the number of text measurements that we perform during the layout phase of the commit. Text measurements are the most expensive layout operations which pretty much responsible for the vast majority of time spent in the layout phase.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D23364664

fbshipit-source-id: 19514b93166b4053c2f3be37e79507f2c5248000
2020-08-27 12:33:58 -07:00
Eloy Durán 941bc0ec19 Upstream RN macOS Hermes integration bits (#29748)
Summary:
Microsoft’s RN for macOS fork supports the Hermes engine nowadays https://github.com/microsoft/react-native-macos/pull/473. As a longer term work item, we’ve started moving bits that are not invasive for iOS but _are_ a maintenance burden on us—mostly when merging—upstream. Seeing as this one is a recent addition, it seemed like a good candidate to start with.

As to the actual changes, these include:

* Sharing Android’s Hermes executor with the objc side of the codebase.
* Adding a CocoaPods subspec to build the Hermes inspector source and its dependencies (`Folly/Futures`, `libevent`).
* Adding the bits to the Xcode build phase script that creates the JS bundle for release builds to compile Hermes bytecode and source-maps…
* …coincidentally it turns out that the Xcode build phase script did _not_ by default output source-maps for iOS, which is now fixed too.

All of the Hermes bits are automatically enabled, on macOS, when providing the `hermes-engine-darwin` [npm package](https://www.npmjs.com/package/hermes-engine-darwin) and enabling the Hermes pods.

## Changelog

[General] [Added] - Upstream RN macOS Hermes integration bits

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

Test Plan:
Building RNTester for iOS and Android still works as before.

To test the actual changes themselves, you’ll have to use the macOS target in RNTester in the macOS fork, or create a new application from `master`:

<img width="812" alt="Screenshot 2020-08-18 at 16 55 06" src="https://user-images.githubusercontent.com/2320/90547606-160f6480-e18c-11ea-9a98-edbbaa755800.png">

Reviewed By: TheSavior

Differential Revision: D23304618

Pulled By: fkgozali

fbshipit-source-id: 4ef0e0f60d909f3c59f9cfc87c667189df656a3b
2020-08-27 01:18:33 -07:00
Andy Matuschak 694e22de84 Fix Catalyst text rendering by disabling inappropriate subpixel-antialiasing (#29609)
Summary:
I noticed when porting my iOS app to macOS via Catalyst that the text rendering was somewhat different on the two platforms. Text looked blurry and over-weight on macOS, even when disabling the Catalyst scaling transform.

I hazily remembered that I'd seen this problem before in my old Cocoa development days: this kind of blurring occurs when rendering text with sub-pixel anti-aliasing into an offscreen buffer which will then be traditionally composited, because when the SPAA algorithm attempts to blend with the underlying content (i.e. in the offscreen buffer), there isn't any. SPAA is disabled on iOS, so the issue wouldn't appear there. On macOS, typical approachs to displaying text (e.g. `CATextLayer`) normally disable SPAA, since it's been incompatible with the platform's compositing strategy since the transition to layer-backed views some years ago. But React Native uses `NSLayoutManager` to rasterize text (rather than relying on the system render server via `CATextLayer`), and that class doesn't touch the context's font smoothing bit before drawing.

This change makes macOS/Catalyst text rendering consistent with iOS text rendering by disabling SPAA.

It appears that the code I've modified is in the process of being refactored (for Fabric?). It looks like [this](8d6b41e9bc/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm (L111)) is the corresponding place in the new code (sammy-SC, is that right?). I'm happy to include a change to the new renderer in this patch if someone can point me at how to test that change.

## Changelog

[iOS] [Fixed] - Improved text rendering on macOS Catalyst

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

Test Plan:
1. Prepare RNTester for running on macOS (or apply [this patch](https://gist.github.com/andymatuschak/d0f5b4fc1a28efc4f860801aa1deddcd) to handle parts 1 and 2, but you'll still need to do part 3):
   1. Open the workspace, navigate to the `RNTester` target's configuration, and check the "Mac" checkbox under "Deployment Info.
   2. Flipper doesn't yet compile for Catalyst (https://github.com/facebook/react-native/issues/27845), so you must disable it by: a) commenting out `use_flipper!` and `flipper_post_install` in the Podfile, then running `pod install`; and b) removing the `FB_SONARKIT_ENABLED` preprocessor flags in the Xcode project.
   3. macOS has different signing rules from iOS; you must set a development team in the "Signing & Capabilities" tab of the `RNTester` target configuration pane. Unfortunately, you must also do this in the `Pods` project for the `React-Core-AccessibilityResources` target ([this is an issue which CocoaPods must fix](https://github.com/CocoaPods/CocoaPods/issues/8891)).
2. Run RNTester with and without the patch. You'll see that the font hinting is overweight without the patch; see screenshots below (incorrect rendering above, correct rendering below; note that fonts still remain slightly blurred because of Catalyst's window scaling transform, but that's removed on Big Sur).

![Screen Shot 2020-08-12 at 10 03 50 AM](https://user-images.githubusercontent.com/2771/90045523-0374c700-dc84-11ea-8945-2d9830bccbd1.png)
![Screen Shot 2020-08-12 at 10 03 15 AM](https://user-images.githubusercontent.com/2771/90045547-0bcd0200-dc84-11ea-88af-37a8879b4efd.png)

Reviewed By: PeteTheHeat

Differential Revision: D23344751

Pulled By: sammy-SC

fbshipit-source-id: 1bbf682b681e381a8a90e152245d9b0df8ec7697
2020-08-26 18:22:54 -07:00
Samuel Susla db7080ddde Fix default value for TextInput autoCapitalize
Summary:
Changelog: [internal]

According to React Native docs, the default value for `autoCapitalize` is `sentences`.
Fabric's TextInput default value does not align with this.

[Source](https://reactnative.dev/docs/textinput#autocapitalize)

Reviewed By: JoshuaGross

Differential Revision: D23344479

fbshipit-source-id: f9e6f2aa6e1fbba2b08cb4aff23b842e49fa8c21
2020-08-26 14:31:48 -07:00
David Vacca 25e0a15b77 Delete activityindicator module
Summary:
This diff deletes the activityindicator buck module because these files are created by the code gen.

changelog: [internal]

Reviewed By: PeteTheHeat

Differential Revision: D23227860

fbshipit-source-id: 133315a44c9181be3263e0c6227884ed15487c1f
2020-08-26 12:33:31 -07:00
Marc Horowitz 525e55f898 Look up HostObject computed properties on the right object in the prototype chain.
Summary:
The change in the hermes repository fixes the security vulnerability
CVE-2020-1911.  This vulnerability only affects applications which
allow evaluation of uncontrolled, untrusted JavaScript code not
shipped with the app, so React Native apps will generally not be affected.

This revision includes a test for the bug.  The test is generic JSI
code, so it is included in the hermes and react-native repositories.

Changelog: [Internal]

Reviewed By: tmikov

Differential Revision: D23322992 (0dee0e6036)

fbshipit-source-id: 4e88c974afe1ad33a263f9cac03e9dc98d33649a
2020-08-26 11:30:34 -07:00
Samuel Susla 19cd630f04 Clone node with state in yogaNodeCloneCallbackConnector
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23317682

fbshipit-source-id: c273804efbe48143dcecd7c62c4edced0a746bc6
2020-08-25 14:48:38 -07:00
Samuel Susla 258387ddaa Use window size instead of screen size in InputAccessoryView
Summary:
Changelog: [internal]

Use window size instead of screen size to layout InputAccessoryView.

Reviewed By: PeteTheHeat

Differential Revision: D23297141

fbshipit-source-id: d6d7223342d17a2e1b9e5fca6f999b7ad365d056
2020-08-25 06:50:34 -07:00
generatedunixname89002005287564@sandcastle995.atn2.facebook.com 835f3677c3 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D23315866

fbshipit-source-id: 8f8e71596f483754cc5f5f5c1677dc2e4f7fd72b
2020-08-25 05:16:48 -07:00
Stephy Ma 03d69fce59 Revert D23292369: Remove State Reconciliation flags and dead code
Differential Revision:
D23292369 (3cb78d5189)

Original commit changeset: 6f00070495e9

fbshipit-source-id: 7e41f6fbdbdb1b833b16c5f3f5ece35a5d7adebe
2020-08-24 19:04:09 -07:00
Samuel Susla 3cb78d5189 Remove State Reconciliation flags and dead code
Summary: Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23292369

fbshipit-source-id: 6f00070495e9947476f1dbea7776ca85002e078b
2020-08-24 15:33:07 -07:00
Joshua Gross 059e424628 Classic Differ: don't recurse down subtrees if parents are pointer-identical
Summary:
Fairly self-explanatory. Should make a fairly meaningful perf difference.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23296681

fbshipit-source-id: 727d0fb619eeef1b4bf8a47457c4746e6b31be80
2020-08-24 13:09:12 -07:00
Joshua Gross 92091b8b31 New Flattening Differ
Summary:
# What is this?

For a very long time, we've discussed the possibility of detecting Node Reparenting in the Fabric Differ. Practically, from the developer perspective, ReactJS and React Native do not allow reparenting: nodes cannot be reparented, only deleted and then recreated with entirely new tags.

However, Fabric introduced the idea of View Flattening where views deemed unnecessary would be removed from the View hierarchy entirely. This is great and improves memory usage, except for one issue: if a View becomes unflattened, or becomes flattened, the entire tree underneath it must be rebuilt.

In a past diff we introduced a mechanism to detect sibling reordering cleverly, and produce a minimal instruction set. This diff is very similar: we know the invariants around flattening and unflattening of views and we take advantage of them to produce an optimal set of instructions efficiently.

# What's different from previous attempts?

No global maps! Those are slow!

This seems to work and (hopefully) might even improve performance, since way less work is being done on the UI thread in cases when views are (un)flattened.

This *only* does extra work when flattening/unflattening happens, which gives product engineers a little more control over perf.

# So, how's it work?

This algorithm is intuitively simple (I think) but tricky to pull off, because there are lots of edge-cases.

In short: In the past, that information was hidden from the Differ: the differ didn't know if views were being reparented, it would see them
as entirely new views or as views being deleted if a View was flattened or unflattened. We very subtly change the information given to the differ:
all nodes are visible to the differ, but marked as Flattened or Unflattened. Thus, when the differ compares two nodes in the "old" and "new" tree,
it can tell not just if there are updates to the node but if it has been unflattened or flattened as well.

For example, take this tree, where * indicates that a View is flattened:

```
         A
         +
    +----+---+
    B*       X
    +        +
    |        |
+---+--+     +
E      F     Y
```

When the Differ asks for the children of A, in the past it would get a list `[E, F, X]`. That is, B* and X are both its children, but since B is flattened, it is omitted entirely from the list and
its children are substituted.

Now, when the Differ asks for the children of A, we give it this list instead: `[B*, E, F, X]`. That is: we give it a list which includes B, but B is marked as flattened.

Another wrinkle: A node `X` could have its children flattened, but still be a concrete view: so flattening/unflattening is a different operation from making a view "concrete" or "unconcrete", which can change independently of flattening.

There is one additional wrinkle: because of zIndex/stacking order, the children of `B` might not actually appear after `B` in the list. Depending on zIndex, a tree that looks like this:

```
          A
          +
   +------+------+
   B*            C*
   +             +
   |             |
+--+--+       +--+--+
D     E       F     G
```

Could actually be linearized as: `[D G B* F C* E]` (as an extreme example; but basically all permutations as possible).

This is the reason, and the *only* reason that the inner Flattener/Unflattener

## The cases we need to handle

There are 7 cases/edge-cases of flattening and unflattening that we need to handle. Practically, all cases of reordering + flattening/unflattening, and taking recursive cases into account:

1. View A and A' (A in the old tree, A' in the new tree) are matched in the differ, and A* has been flattened or unflattened. These two cases are the easiest to handle.
2. View A' has been reordered with its siblings, and has been flattened or unflattened. These cases are slightly trickier to handle.
3. While flattening or unflattening, we encounter a child that has also been unflattened or flattened. So we need to handle four cases here in total: Flatten-Flatten, Flatten-Unflatten, Unflatten-Flatten, and Unflatten-Unflatten.

Other things to think about, also covered above:

1. Ordering. Views can be reordered and flattened/unflattened at the same time.
2. zIndex ordering: children in a certain order from the ShadowNode perspective may be stacked differently from a View perspective. We use the zIndex ordering for everything in the differ, and this prevents us from performing certain optimizations (see above: we cannot assume that children come after their parent in a list; they may come before, may be interwoven with children from other parents, etc).

# Perf Implications?

Practically, there should be very little negative overhead. There is some overhead in actually performing a flattening/unflattening operation, but... not much more than before. We don't use global maps, so the cost of flattening/unflattening is basically `O(number of nodes reparented)` - note that that's direct nodes reparented, *not* descendants.

tl;dr the perf hit should be similar to reordering, which is non-zero, but close to zero, and zero-cost for any diff operations on parts of the tree that don't involve flattening/unflattening. AFAICT this is very close to an ideal solution for that reason (but I wish it was simpler overall).

# In Summary?

I hope this works out and I think it could improve a number of things downstream: perf, LayoutAnimations, Bindings, certain crashes because of platform assumptions about mutations, etc.

Is it worth it? This new implementation is substantially harder to reason about, harder to read, and harder to understand. This is an important consideration. All I can say there is that I trust the test suite I've been using, but
the decreased readability is a big negative. Hopefully we can improve this in the future.

The rest is fiddly implementation details that I sincerely hope can be improved and simplified in the future.

# Followups?

The part that makes this algorithm the most expensive is that because of zIndex ordering, we cannot assume that children are linearized after their parents and so we rely more heavily on maps for the flattening/unflattening. Our TinyMap implementation should make these `find` operations fast enough unless trees' children are constantly being reordered, but it's still worth thinking of ways to make this even faster.

Changelog: [Internal]

Reviewed By: shergin, mdvacca

Differential Revision: D23259341

fbshipit-source-id: 35d9b90caf262d601a31996ea2cb37e329c61ffc
2020-08-24 13:09:12 -07:00
Joshua Gross dd05ec3801 StubViewTree: add additional verbose logging, make slightly more resilient
Summary:
1. When testing major changes to the differ, it can be useful to have more verbose logging.
2. On Android, since asserts don't fire yet, I log which asserts are failing.

Should have no impact on any builds unless you manually set the macro here, and it will have no impact on production builds regardless.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23257859

fbshipit-source-id: 94a8e74ece8023064de0f2203db6074975f8f1f0
2020-08-24 13:09:12 -07:00
Valentin Shergin f4fa79a2e3 Fabric: Fixed dangling pointer issue in UIManager::getRelativeLayoutMetrics
Summary:
The same as D21464834 (604402678b).
It should help with T71784916.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23297325

fbshipit-source-id: 6f14f9b1d1e7d251e53819207bac26dde5afe020
2020-08-24 12:41:44 -07:00
Joshua Gross d602c51996 Simplify TextInput measurements
Summary:
Simplify the TextInput measurement mechanism.

Now, data only flows from JS->C++->Java and from Java->JS. C++ passes along AttributedStrings from JS if JS updates, and otherwise Java maintains the only source of truth.

Previously we tried to keep all three in sync. This was complicated, slow, and even lead to some crashes.

This feels a bit hacky but I believe it's the simplest way to achieve this short-term. Ideally, we would use something like `AttributedStringBox` and pass that to State from Java,
but currently everything passed through the State system from Java must be serializable as `folly::dynamic`. So, instead, we just cache one Spannable per TextInput component and
use ReactTag as the cache identifier for lookup.

An interesting side-effect is that `measure` could race with TextInput updates, but the race condition favors measuring the latest text, not outdated values.

Followups:

- Can we do this without copying the EditText Spannable on every keystroke? Maybe this approach is too aggressive, but I don't want a background thread measuring a Spannable as it's being mutated.
- Do we need to support measuring Attachments?
- How can we clean up this API? It should work for now, but feels a little hacky.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23290230

fbshipit-source-id: 832d2f397d30dfb17b77958af970d9c52a37e88b
2020-08-24 11:59:28 -07:00
Samuel Susla 2bc8ce1549 Introduce ConcreteStateTeller
Summary:
Changelog: [internal]

# What is Teller?
Teller is a bank's employee who deals with the customer on behalf of the bank. In Fabric's scenario it is a class that on behalf of the view deals with State.

# Why do we need it?
Dealing with `ConcreteState` can be complicated and patterns are often repeated among different component views. `ConcreteStateTeller` aims to resolve these issues. Examples:
- You can call teller's methods without checking for nullptr (we have had crashes because of this before).
- Methods are save to be called on any thread.
- Mechanism to retry state update if it fails is built in.

It is designed to be used from ComponentView so views don't have to talk directly to `ConcreteState`.

Reviewed By: JoshuaGross, shergin

Differential Revision: D23216865

fbshipit-source-id: 90a50702e036eac084f89743ebab687a67182dc0
2020-08-24 06:43:17 -07:00
Martin Sherburn 549563e8ab Allow Hermes to be built as a DLL on Windows
Summary:
On windows it is required to explicitly specify what symbols need to be exported from a DLL to make them accessible (using `__declspec(dllexport)`). I have added and expanded on existing macros to do this and added exports that were previously missing.

Changelog:
[Internal][Changed] - Allow Hermes to be compiled to a single DLL on windows

Reviewed By: mhorowitz

Differential Revision: D23084343

fbshipit-source-id: 832cb17b9e637e4c04dad479aae6c1fc190f968e
2020-08-24 06:07:19 -07:00
Samuel Susla 6c1ee871c0 Calling `ConcreteShadowNode::setStateData` sets mostReventState
Summary:
Changelog: [Internal]

If `ConcreteShadowNode::setStateData` is called and the node is cloned before it is mounted, the cloned node will have old state before `setStateData` was called.

To solve this, simply call `setMostRecentState` on the family inside `ConcreteShadowNode::setStateData`.

Reviewed By: JoshuaGross

Differential Revision: D23283560

fbshipit-source-id: f9822fb69e4234f776d512fc02fe13ea7de64897
2020-08-24 01:43:29 -07:00
David Vacca 1aaa3d95c0 Integrate AndroidProgressBarComponent into RN Tester OSS Android app
Summary:
This diff integratess AndroidProgressBarComponent into RN Tester OSS android app

changeLog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D23227859

fbshipit-source-id: a916c90486ec4f9664be79608a8a8f907e2634a7
2020-08-22 01:46:03 -07:00
David Vacca 62de5c001c Migrate AndroidProgressBarComponent to Fabric
Summary:
This diff migrates AndroidProgressBar component to Fabric

changeLog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D23227857

fbshipit-source-id: c5cbbdcc36e63226286cd714d601f0d4690496b2
2020-08-22 01:46:03 -07:00
David Vacca 57798408a3 Integrate Android Switch into RN Tester Android OSS app
Summary:
This diff integrates Android Switch into RN Tester Android OSS app

Changelog: [Internal] internal

Reviewed By: fkgozali

Differential Revision: D23227856

fbshipit-source-id: 0ef74456a15827f1aaa9e5b2aefb9c692cc1d1f4
2020-08-21 22:29:31 -07:00
David Vacca cae68718ba Move AndroidSwitch C++ files to make them compatible with RN OSS Build
Summary:
This diff moves AndroidSwitch C++ files to make them compatible with RN OSS Build

Changelog: [Internal] internal

Reviewed By: PeteTheHeat

Differential Revision: D23227861

fbshipit-source-id: 8f23c2eb266a47cb9af82f4159f64b987c14141b
2020-08-21 22:29:30 -07:00
David Vacca 82deeaff26 Integrate Slider into RN Tester OSS Android app
Summary:
This diff integrates Slider View Manager into RN Tester OSS Android app

Changelog: [Internal] internal

Reviewed By: fkgozali

Differential Revision: D23227858

fbshipit-source-id: d785dbdaa3e05e0dfcd7c2134769eaba72f40977
2020-08-21 22:29:30 -07:00
David Vacca 6c7a8ce87d Move Android Slider C++ files to make them compatible with RN Tester OSS build
Summary:
This diff moves Android Slider C++ files to make them compatible with RN Tester OSS build

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D23227862

fbshipit-source-id: 7a5ed1bdc03cbe715467eddd4aad9af82761d4f0
2020-08-21 14:18:48 -07:00
David Vacca 6e13ca3015 Integrate Android Picker into RN Tester OSS app
Summary:
This diff integrates AndroidPicker into RN Tester OSS app

changelog: [inernal] internal

Reviewed By: fkgozali

Differential Revision: D23199578

fbshipit-source-id: 7c34b0ee4887ffc15dbdffad464230b19f176fc8
2020-08-21 14:18:48 -07:00
David Vacca 7afb39d028 Move AndroidDialogPicker C++ files to make it compatible with RN OSS build system
Summary:
This diff moves AndroidDialogPicker C++ files to make it compatible with RN OSS build system.

changelog: [internal]

Reviewed By: fkgozali

Differential Revision: D23198857

fbshipit-source-id: 8fd4b7081f5f573946a6b9cd3fdc408488f91e13
2020-08-21 14:18:48 -07:00
David Vacca 3790569a71 Integrate Modal into RN Tester Fabric OSS APP
Summary:
This diff integrates Modal into RN Tester Fabric OSS APP

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D23183507

fbshipit-source-id: bc2513c39c783d387a985c86a12b04dadac49933
2020-08-21 14:18:48 -07:00
David Vacca 60a5223ff7 Integrate AndroidTextInput in RN Tester OSS App
Summary:
This diff integrates AndroidTextInput in RN Tester OSS App

changelog: [internal] Internal

Reviewed By: fkgozali

Differential Revision: D23179389

fbshipit-source-id: 709d71343ca374ca2ece00774f4f273145bffd20
2020-08-21 14:18:48 -07:00
David Vacca 8f306cd66a Update directory hierarchy of AndroidTextInput C++ files
Summary:
This diff updates the directory hierarchy of AndroidTextInput C++ files to be compatible with Android OSS build system

changelog: [internal] Internal

Reviewed By: PeteTheHeat

Differential Revision: D23179390

fbshipit-source-id: 1c52e4f882853799a58d44876cadd392b4a35050
2020-08-19 19:22:23 -07:00
Valentin Shergin f8e5423c89 Fabric: Make views with `accessibilityElementsHidden` form stacking context
Summary:
`accessibilityElementsHidden` property hides a subtree starting from the node with this prop from VoiceOver and TalkBack, so the node with this prop should form the stacking context (otherwise the children will mount as siblings and the property will not have an effect).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23202220

fbshipit-source-id: d87dfab5f791219551c1eb90cdf3b3fa86f9c51f
2020-08-19 12:45:30 -07:00
David Vacca 2e88b25242 Integrate Image Fabric component into OSS
Summary:
This diff integrates image Fabric component into RN Tester app

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D23177896

fbshipit-source-id: 008e86e82a262827a31b9df74a50b58a97f2e1b7
2020-08-18 19:55:51 -07:00
David Vacca 50af304b3f Integrate Fabric Text in RN Tester OSS
Summary:
This diff integrates Text component into RN OSS

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D23177414

fbshipit-source-id: 0a415f8dd8339b84465a7c8d73f3d8abd80fbecc
2020-08-18 19:55:51 -07:00
David Vacca 2d8fe89784 Move Text C++ out of inner folders
Summary:
This diff flattens the hierarchy of Text C++ files.
This is required to integrate Text into RN OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D23173556

fbshipit-source-id: ce90000cae147460aa4ddad55b7c90369fa734a2
2020-08-18 19:55:50 -07:00
Joshua Gross 49818f09f6 Remove reparenting code from differ
Summary:
Partial backout of D23123575 (1e4d8d902d). It's causing some crashes and there is a more efficient way of doing it, which I will land in a future diff.

Leaving unused feature-flags in place for now, they'll be used shortly.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23198625

fbshipit-source-id: 6e9cbc6b39898a604b8f4dfccf5a6dd238511a68
2020-08-18 17:18:17 -07:00
Lulu Wu bdbb040382 Fix Logbox Fullscreen View
Summary:
Logbox inside bridgeless surfaces was crashing and not able to open, this diff should fix it.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23043773

fbshipit-source-id: 6e584f97e53e626b9bfedd6dc997ba6ba8c08b8f
2020-08-18 12:29:45 -07:00
generatedunixname89002005287564 d13631bc64 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D23158764

fbshipit-source-id: a0341d5a41d4b61b002f1032c8ea184255d7f3db
2020-08-17 04:45:42 -07:00
Samuel Susla 4f94d7da81 Back out "Use ShadowTree::commit if failureCallback is nullptr"
Summary:
Changelog: [internal]

Original commit changeset: 5cb78a3a75a7

In D23151218 (dffec8bc7b) we switched from `ShadowTree::tryCommit` to `ShadowTree::commit` inside `UIManager::updateState`.
It fixes update state being dropped but can cause an infinite loop inside `ShadowTree::commit` because the shadow node that triggered `UIManager::updateState` can been removed before the `updateState` call is dispatched..

Reviewed By: JoshuaGross

Differential Revision: D23155228

fbshipit-source-id: f3339a4e4798880972366d6f894c14a58be1b9b2
2020-08-16 10:33:11 -07:00
Samuel Susla dffec8bc7b Use ShadowTree::commit if failureCallback is nullptr
Summary:
Changelog: [internal]

In D22940187 (774dec1e17) we introduced a mechanism to retry failed state updates from view layer.
The mechanism fixes an issue where state update is occasionally dropped with background executor enabled.

# Why is state dropped?

The state is dropped because with background executor enabled, it is possible to enter `ShadowTree::tryCommit` for the same tree from 2 different threads at once. One of thread changes `_rootShadowNode` causing the other commit to fail.

The code goes like this:

```
{
    Lock mutex
    grab reference to `rootShadowNode_` and call it `oldRootShadowNode`
    Unlock mutex
}

State reconciliation
Trigger layout
`rootShadowNode_` is untouched in this section.

{
    Lock mutex
    Check if `oldRootShadowNode` is equal to `rootShadowNode_`, if not, return false signalling failure. Now this is what happens when
    state update fails.

..... not relevant

    Unlock mutex
}

..... not relevant
```

However, in D22940187 (774dec1e17), we have taken another path. Instead of retrying to commit transaction, client is informed about the failure and it is left up to them to retry. This is correct and works. But I think it is unnecessary to this retry can be done inside UIManager::updateState.

In this diff I call `ShadowTree::commit` (version with retries) in case no `stateUpdate.failureCallback` is provided.
This makes sure that we do retry if state update fails but if Android implements `stateUpdate.failureCallback`, it is left up to view layer to retry.

Eventually we might decide to converge these two approaches.

Reviewed By: shergin

Differential Revision: D23151218

fbshipit-source-id: 5cb78a3a75a754429a8e33bd7736e683e9ed34d4
2020-08-16 03:49:45 -07:00
Joshua Gross 1e4d8d902d Core/Differ: detect and optimize reparenting
Summary:
# Summary

In previous diffs earlier in 2020, we made changes to detect and optimize reordering of views when the order of views changed underneath the same parent.

However, until now we have ignored reparenting and there's evidence of issues because of that. Because Fabric flattens views more aggressively, reparenting is also marginally more likely to happen.

This diff introduces a very general Reparenting detection. It will work with view flattening/unflattening, as well as tree grafting - subtrees moved to entirely different parts of the tree, not just a single
parent disappearing or reappearing because of flattening/unflattening.

There is also another consideration: previously, we were generating strictly too many Create+Delete operations that were redundant and could cause consistency issues, crashes, or bugs on platforms that do not handle that gracefully -
especially since the ordering of the Create+Delete is not guaranteed (a reparented view could be created "first" and then the differ could later issue a "delete" for the same view).

Intuition behind how it works: we know the cases where we can detect reparenting: it's when nodes are *not* matched up with another node from the other tree, and we're either trying to delete an entire subtree, or create an entire subtree. For perf reasons, we generate whatever set of operations comes first (say, we generate all the Delete and Remove instructions) and take note in the `ReparentingMetadata` data-structure that Delete and/or Remove have been performed for each tag (if ordering is different, we do the same for Create+Insert if those come first). Then if we later detect a corresponding subtree creation/deletion, we don't generate those mutations and we mark the previous mutations for deletion. This incurs some map lookup cost, but this is only wasteful for commits where a large tree is deleted and a large tree is created, without reparenting.

We may be able to improve perf further for certain edge-cases in the future.

# Why can't we solve this in JS?

Two things:

1. We certainly can avoid reparenting situations in JS, but it's trickier than before because of Fabric's view flattening logic - product engineers would have to think much harder about how to prevent reparenting in the general case.
2. In the case of specific views like BottomSheet that may crash if they're reparented, the solution is to make sure that the BottomSheet and the first child of the BottomSheet is never memoized, so that lifecycle functions and render are called more often; and that in every render, the BottomSheet manually clones its child, so that when the Views are recreated, the child of the BottomSheet has a tag and is an entirely different instance. This is certainly possible to do but feels like an onerous requirement for product teams, and it could be challenging to track down every specific BottomSheet that is memoized and/or hoist them higher in the view hierarchy so they're not reparented as often.

Reviewed By: shergin

Differential Revision: D23123575

fbshipit-source-id: 2fa7e1f026f87b6f0c60cad469a3ba85cdc234de
2020-08-15 19:20:33 -07:00
David Vacca cc7dd18080 Fix codegen for CXX build
Summary:
Fabric codegen is failing with running without specifying a specific platform. This diff fixes that.

Steps to reproduce:
```
buck build //xplat/js/react-native-github:generated_components-rncore --show-output
```

Error:
```
#include <react/renderer/imagemanager/primitives.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D23114403

fbshipit-source-id: 50210e74f2a99ae5a77087988c3323bdacf04128
2020-08-13 17:45:03 -07:00
Samuel Susla c429ee9974 Implement ScrollView.contentInsetAdjustmentBehavior
Summary:
Changelog: [internal]

Fabric's ScrollView was ignoring value of `ScrollView.contentInsetAdjustmentBehavior`, this diff fixes that.

Reviewed By: shergin

Differential Revision: D23102235

fbshipit-source-id: 8cf42e730b560a21d56d7e007059109ccd01154e
2020-08-13 10:11:46 -07:00
Samuel Susla b9c6e05ad5 Add comment to YogaLayoutableShadowNode::layout
Summary: Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D23075863

fbshipit-source-id: a80946e26ba6041a864efe45cefd7f43c3728a12
2020-08-13 05:56:50 -07:00
generatedunixname89002005287564 21186034af Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D23050679

fbshipit-source-id: 4b1a426425f55ef00190496e56cac0c8f1d44678
2020-08-11 05:12:56 -07:00
Joshua Gross 77accf2380 Log more diagnostics when JSI values cannot be cast to Object
Summary:
There are a few places where we cast JSI values to objects without much validation and without proper error logging, and in some places the crashes aren't symbolicated well. To make debugging easier in the short-term, I'm adding some additional logs.

Changelog: [Internal]

Reviewed By: mdvacca, RSNara

Differential Revision: D23033222

fbshipit-source-id: 9343d693a441f0af728e560a0c245bcc4eb97869
2020-08-10 16:08:50 -07:00
Samuel Susla 154ce78972 Take viewport offset into account in UIManager.measureInWindow
Summary:
Changelog: [Internal]

Fabric's UIManager.measureInWindow didn't take viewport's offset into account. This diff fixes it by including viewport's offset in `LayoutContext`.

Reviewed By: JoshuaGross

Differential Revision: D23021903

fbshipit-source-id: 9106a8789d66fe19d8cb0a9378ee5bc8f2c83005
2020-08-10 12:52:23 -07:00
Samuel Susla efd005724f Convert LayoutableShadowNodeTests to use Element<>
Summary:
Changelog: [internal]

Use `Element<>` in `LayoutableShadowNodeTests`. It makes the tests cleaner and easier to understand.

Reviewed By: JoshuaGross

Differential Revision: D23028341

fbshipit-source-id: f7a2255581bdde667db0f68c222228a5b405b22f
2020-08-10 12:52:23 -07:00
Samuel Susla 6db19b036e Introduce Element<>.stateData API
Summary:
Changelog: [Internal]

Previous interface `Element<>.state` wasn't usable because creating ConcreteState  requires ownership of component descriptor and family. Family isn't created until later and it isn't accessible to the caller.

To work around this shortcoming, we create `stateData` rather than state.

Reviewed By: JoshuaGross

Differential Revision: D23028296

fbshipit-source-id: fba35ea8e6986b77379b1dddaa37012f4234f86e
2020-08-10 12:52:22 -07:00
Samuel Susla 8d6b41e9bc Add support for onTextLayout in Text
Summary:
Changelog: [Internal]

Add `Text.onTextLayout` implementation

Reviewed By: JoshuaGross

Differential Revision: D22865139

fbshipit-source-id: 563084754ebdc9fb23463a306c526b97c61f85ec
2020-08-10 05:42:20 -07:00
Samuel Susla 43b2c6dd85 Fix conditions to fire onLayout event
Summary:
Changelog: [Internal]

# Problem

## Step 1
JS clones a node that has size {100, 100} and changes props that cause the node to increase size to {200, 200}. JS holds pointer to this node.

Now, the size (stored in LayoutableShadowNode.layoutMetrics_) changes after Yoga layout is triggered.

However, the node gets cloned inside State Reconciliation before Yoga layout phase. The JS pointer points to a node with size {100, 100}, not to a node with size {200, 200}.

## Step 2

Again, JS clones node (with old reference, therefore gets old layoutMetrics_ with size {100, 100}) and it changes props that cause the node to decrease its size back to {100, 100}.
We go all the way to Yoga layout and looking for nodes that have been affected by the node. The node, affected by the layout because it went from {200, 200} to {100, 100}, will be evaluated as not affected. This causes onLayout event to not be fired.

# Fix
We can safely remove the frame equality check (please see below). This can be done because we already check for equality before dispatching onLayout. It happens here:

https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/js/react-native-github/ReactCommon/react/renderer/components/view/ViewEventEmitter.cpp?commit=881853eb0c42625fd0812bd2652bf36fcbd614ee&lines=43

As far as I know, `affectedNodes` isn't used for anything else besides dispatching onLayout.

# Discussion

This problem manifests itself only when a node has two different sizes that it flips between. To better understand this, please watch the video in Test plan labelled "before". Notice how the text has 2 different values that it flips between.

Here is a code that was affected by it https://fburl.com/diffusion/3hwo0iy5
If you inspect it closely, you will notice that it depends on `onLayout` to return correct value to calculate offset from left.

Reviewed By: JoshuaGross

Differential Revision: D22999891

fbshipit-source-id: e2d0f5771c1bf3cd788e5e9da0155c92e33fb84e
2020-08-10 05:11:29 -07:00
David Vacca 0416f77ce4 Extend 'fabric' module to compile in OSS
Summary:
This diff extends fabric module to compile in OSS

NOTE: As a side effect of this diff, Fabric will be included into "reactnativejni" which is used by RN OSS.

I'm planning to remove this dependency in the near future - T71320460

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22991877

fbshipit-source-id: 0ab3ee410dd448bbd87130114bec27c6e6bc65c6
2020-08-07 19:49:19 -07:00
David Vacca 7d5383eea8 Extend 'textlayoutmanager' module to compile in OSS
Summary:
This diff extends the 'textlayoutmanager' module to compile in OSS
As part of this diff I also moved Android files in order to make the module compatible with Android.mk system

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22963706

fbshipit-source-id: 14a7309f589fe12c21131c7d5cef02b4323d4a93
2020-08-07 19:49:19 -07:00
David Vacca d1d42475e9 Extend 'imagemanager' module to compile in OSS
Summary:
This diff extends the 'imagemanager' module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22963701

fbshipit-source-id: 5034cf9801efa01cc39003b2060a84864c46d18e
2020-08-07 19:49:19 -07:00
David Vacca 48e9f0a1c0 Extend 'animations' module to compile in OSS
Summary:
This diff extends the 'animations' module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22963702

fbshipit-source-id: e432e2f98b47a4b0456fd5e3d0f5263631782b29
2020-08-07 11:12:02 -07:00
David Vacca 6486b8cffd Extend 'scheduler' module to compile in OSS
Summary:
This diff extends the 'scheduler' module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22963705

fbshipit-source-id: ea2b6a4fce49c4d9552deb30e89fcba165cfe772
2020-08-07 11:12:02 -07:00
David Vacca e20df93082 Extend 'templateprocessor' module to compile in OSS
Summary:
This diff extends the 'templateprocessor' module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22963703

fbshipit-source-id: c898d846a59a065c0bbfd443303e125e6b9bcba7
2020-08-07 11:12:02 -07:00
David Vacca 2fa8829305 Extend 'uimanager' module to compile in OSS
Summary:
This diff extends the 'uimanager' module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22918206

fbshipit-source-id: 2783ec6d9e53cdafab5c77a3f217b32c1c7f0b41
2020-08-07 11:12:02 -07:00
Jiayan Zhuang 3f405dcbd2 Add support for accessibilityRole = "switch"
Summary:
Changelog:
[Internal] - Add support for accessibilityRole = "switch"

Reviewed By: sammy-SC

Differential Revision: D22906500

fbshipit-source-id: 81dfbfd56a24c89ffedc0fde5a63f7bdeed0c5db
2020-08-06 13:16:48 -07:00
Jiayan Zhuang 6fa9dbabfc Update accessibilityState prop
Summary:
Changelog:
[Internal] - Add default value for accessibilityState "checked" and handle unhandled states.

It is also work for the case that accessibilityRole = "switch" and accessibilityState is set.

Reviewed By: sammy-SC

Differential Revision: D22914427

fbshipit-source-id: 4767a21f3bd109019b57bc09918758a38fbdea93
2020-08-06 12:14:38 -07:00
David Vacca 5c9c52275f Extend 'attributedstring' module to compile in OSS
Summary:
This diff extends the 'attributedstring' module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22918207

fbshipit-source-id: 35710789d2aa71826e10c29c27e9ac34b73e5344
2020-08-06 11:53:04 -07:00
David Vacca 8cfd329e9f Extend 'mounting' module to compile in OSS
Summary:
This diff extends the 'mounting' module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22918205

fbshipit-source-id: 424e33c827cb03befaaed32897a19cd6eff2dd71
2020-08-06 11:53:04 -07:00
David Vacca 459eabbef2 Extend 'better' module to compile in OSS
Summary:
This diff extends the 'better' module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22918208

fbshipit-source-id: 11cf7c093bd1d50bbb53c6b6a740a3db41971fc0
2020-08-06 11:53:04 -07:00
David Vacca 8fdb3decda Extend components/scrollview module to compile in OSS
Summary:
This diff extends components/scrollview module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22918203

fbshipit-source-id: 6a67213bdcb4b4b2d47a2ee2a9796a134d744956
2020-08-06 11:53:03 -07:00
David Vacca 99ee0309be Extend components/root module to compile in OSS
Summary:
This diff extends components/root module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22918209

fbshipit-source-id: 9ce9558f689d0a9b3b8cb7edeb891e8f4bafba6c
2020-08-06 11:53:03 -07:00
David Vacca ba195e878e Extend component/unimplementedview to compils in OSS
Summary:
This diff extends component/unimplementedview to compils in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22918204

fbshipit-source-id: 85b2338b6135aadcdd00bb798f6aaa2fdf03d81e
2020-08-06 11:53:03 -07:00
David Vacca 5d5524b266 Extend react/renderer/component/view module to compile in OSS
Summary:
This diff extends react/renderer/component/view module to compile in OSS

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22918210

fbshipit-source-id: b92e8701ac6ec93ba8f2cdbfdcc5e34cade0f218
2020-08-06 11:53:03 -07:00
David Vacca d2bb73d568 Extend react/renderer/componentregistry module to compile in OSS
Summary:
This diff extends react/renderer/componentregistry module to compile in OSS

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D22908223

fbshipit-source-id: 6cc053262fbe2bb0f631ac40cd57959267ae95fa
2020-08-06 11:53:03 -07:00
David Vacca 5f03e7ef41 Make react/renderer/mapbuffer module to compile in OSS
Summary:
This diff extends the react/renderer/mapbuffer module to compile in OSS
changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D22908221

fbshipit-source-id: d2a6da04ea73efc35e862839563262d4e89a2c56
2020-08-06 00:09:12 -07:00
David Vacca 886d1bad74 Make react/core module to compile in OSS
Summary:
Make react/core module to compile in OSS

This is necessary to make fabric compile in OSS

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D22908222

fbshipit-source-id: a37b87d02ecf77bb25693ce32cd0f3432be5daa7
2020-08-06 00:09:12 -07:00
David Vacca b97619e0aa Make graphics module to compile in OSS
Summary:
This diff creates the Android.mk file for the fabric graphics module
This is necessary to enable fabric in RN OSS
changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D22908219

fbshipit-source-id: 70ef1d06053b0ca07a71c0a2d36e4edd617b2a25
2020-08-06 00:09:12 -07:00
David Vacca 8e996487e1 Create Android MK file for debug module
Summary:
This diff creates the Android.mk file for the fabric debug module

This is necessary to enable fabric in RN OSS

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D22908220

fbshipit-source-id: f970fa1d8534a6043f60f362740bfc3e5199b511
2020-08-06 00:09:11 -07:00
David Vacca d34f3638cc Create Android OSS build system for react/renderer/components/view module
Summary:
This diff creates the Android OSS build system for the module react/renderer/components/view
As part of this diff I had to remove inner folders of react/renderer/components/view

changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D22881703

fbshipit-source-id: afb56b4f7660d000d2abb8ade0ccb60d1adfb371
2020-08-06 00:09:11 -07:00
David Vacca 7c5be8015d Create Android OSS build system for react/renderer/graphics module
Summary:
This diff creates the Android OSS build system for the module react/renderer/graphics
As part of this diff I also moved android specific files to the folder react/renderer/graphics/platform/cxx/react/renderer/graphics folder
changelog: [internal] internal

Reviewed By: fkgozali

Differential Revision: D22880975

fbshipit-source-id: 6899c3bb5ebce3a93d8487f49f1c253925a518e7
2020-08-06 00:09:11 -07:00
David Vacca 08d7b542de Create Android OSS build system for react/utils module
Summary:
This diff creates the Android OSS build system for the module react/utils

As part of this diff I also moved the module to react/utils folder

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22877265

fbshipit-source-id: 717487aacb392d0f08530763a16a638b8021d501
2020-08-05 19:02:08 -07:00
Joshua Gross 28ff63f669 Optional verbose logging for LayoutAnimations
Summary:
I've used this while debugging LayoutAnimations a few times. It compiles out to nothing when the define is not set.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22962113

fbshipit-source-id: 88b7bb1c20a07a7d804e5c81d31cf871d58bee92
2020-08-05 17:44:06 -07:00
Joshua Gross 1b575e8d1f Simplify and correct LayoutAnimations index adjustment
Summary:
Consolidated a few places where index adjustment was happening with nearly identical code. There was also one remaining case where index adjustment should be happening, but was not previously.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22962115

fbshipit-source-id: 732c026b5a3c60bb0eadb8d49826ffd6367f7f62
2020-08-05 17:44:05 -07:00
Samuel Susla b179c4bebe Fix incorrect padding in SafeAreaView
Summary:
Changelog: [Internal]

`SafeAreaViewShadowNode` we made incorrect assumption that setting `style` on YGNode and then copying it, always copies the style.

This is incorrect, style is only copied once `YGNodeCalculateLayout` has been called on either the node or its parent.

Reviewed By: JoshuaGross

Differential Revision: D22945677

fbshipit-source-id: 9c063c2dfe4d2390cf2fd10a96d2de418fa69376
2020-08-05 11:39:25 -07:00
Joshua Gross 774dec1e17 Introduce general API for setting C++ State from the View layer and getting a notification if it fails, with Android impl
Summary:
iOS will need to be implemented separately, but the shared C++ bits are in place.

Explanation: there is currently no way for the View layer to /know/ if an UpdateState call has succeeded or failed. Generally we just assume it succeeds, but if it fails we have no way of knowing or retrying.

This can cause some UI bugs. To mitigate this, I'm introducing a "failure" notification callback mechanism. The JNI bridging for this is a little complicated to avoid passing Runnable across the JNI, but it
should be much simpler on iOS.

In development this seems to make View components much more reliable.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22940187

fbshipit-source-id: 917f2932ae22d421f91fe8f4fca3f07dc089f820
2020-08-05 06:35:41 -07:00
Samuel Susla 6c01f26d27 Fix typo in UIManagerBinding's destructor
Summary: Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D22897454

fbshipit-source-id: 73cc02b9645c04dd0e15e255d7277cd87d56fde3
2020-08-04 11:16:16 -07:00
Samuel Susla 7a1d1bc355 Fix a condition in forms stacking context evaluation
Summary: Changelog: [internal]

Reviewed By: cpojer

Differential Revision: D22921257

fbshipit-source-id: cff6ca629ec9c7e5c003a58e87c5051178587892
2020-08-04 07:22:52 -07:00
Luna Wei 558b080fbf Update elliptic dependency for msggen
Summary:
## Changelog:
[Internal] [Security] - Github vulnerability reported for elliptic, T70933058

Reviewed By: cpojer

Differential Revision: D22892182

fbshipit-source-id: d300e6a738e5efbbcbdb7ed61e35f380fc43b763
2020-08-03 15:50:06 -07:00
David Vacca 8616f868d5 Create android oss build system for react/config module
Summary:
This diff creates the Android OSS build system for the module react/config

As part of this diff I also moved the module to react/config folder

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D22877264

fbshipit-source-id: 5b3c42580d2b1d73dc0abb48bcf4ff063b2f581f
2020-08-03 14:21:26 -07:00
Samuel Susla a1b6f7bd9e Fabric: Asserting if the RuntimeExecutor callback in RCTRuntimeExecutorFromBridge is not called
Summary:
The implementation of RuntimeExecutor must execute all provided callbacks. However, the implementation of RCTRuntimeExecutorFromBridge cannot guarantee it because it relies on Bridge to make the call. In this diff, we wrap the callback into a callable that asserts if it's not being called before destruction.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D22810439

fbshipit-source-id: f11932019ab6ccbab7e65db5919e0c64dcaf37ed
2020-08-03 10:45:14 -07:00
Thomas Nardone 6530f2f1c4 Tweak stdlib imports in event, utils
Summary:
Changelog:
[Internal][Fixed] - Tweaked stdlib imports

Reviewed By: SidharthGuglani

Differential Revision: D22860196

fbshipit-source-id: fc0fc1bf05ebbfae7e86bce5e960e58d5944ee5c
2020-08-03 09:28:21 -07:00
Samuel Susla c452b826df Implement ScrollView.snapToOffsets and associated props
Summary:
Changelog: [Internal]
Implementation is copied from Paper.

Reviewed By: shergin

Differential Revision: D22820677

fbshipit-source-id: 8eed7ecd4dc766e8579a89707849e041adb073eb
2020-08-03 07:08:29 -07:00
Samuel Susla 94d0078653 Implement ScrollView.snapToInterval and associated props
Summary:
Changelog: [Internal]

Implementation is copied from Paper.

Reviewed By: shergin

Differential Revision: D22794554

fbshipit-source-id: ccfa777356932d81aa986349fba1685acf65d7f1
2020-08-03 07:08:29 -07:00
Joshua Gross e3302eeeab LayoutAnimations: call onSuccess, onFailure callbacks
Summary:
Hook up onSuccess and onFailure callbacks to LayoutAnimations.

Note that in non-Fabric RN, onSuccess is not known to work in Android. I could not find any uses of onFailure and it's not documented, so for now, it is only called if the setup of the animation fails.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22889352

fbshipit-source-id: 4306debb350388dd2b7a2cbfe295eb99723988e2
2020-08-02 16:37:03 -07:00
Samuel Susla 709a3a0ceb Backout "[RN] Fabric: Enable zIndex only for non-`static` positioned views"
Summary:
Changelog: [internal]

Backout D22098586 (476ab7481e) because of issues like D22843134 (799654b105).

[428](https://fburl.com/codesearch/0dyyakf5) places with zIndex and most of them do not have position defined. This could cause views to be overlapped.

Reviewed By: JoshuaGross

Differential Revision: D22890669

fbshipit-source-id: 200d1cbe2a4c27e2a0445b315868f37418ab1d9b
2020-08-02 08:14:17 -07:00
Valentin Shergin cc78aee56a Fabric: Telemetry time point serialization functions
Summary:
Fabric's Telemetry uses `std::chrono::steady_clock::time_point`s to represent the exact moments in time when some events happen. This is the same clock that pretty much any performance tracker use (and should use), QPL included.
However, different trackers use different serializable representations of that timepoints. This diff adds functions that convert the timepoint value to UNIX Timestamp and to a number of seconds from the `steady_clock` epoch start.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D22887632

fbshipit-source-id: 2b51acddccee9af8071a34797b5015d6fd008394
2020-08-01 21:31:40 -07:00