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

467 Коммитов

Автор SHA1 Сообщение Дата
David Aurelio 9b6bbe69d6 Move node cloning to `YGConfig`
Summary:
@public

Encapsulates node cloning within `YGConfig`.
This is necessary for allowing for context-aware cloning functions, which will ultimately allow for removal of weak global JNI references.

Reviewed By: shergin

Differential Revision: D14132608

fbshipit-source-id: 0dec114c8e172b1e34a4b7fd146c43f13c151ade
2019-02-20 11:59:21 -08:00
Eric Lewis c3df673f12 Fabric: Fix dangling brace (#23540)
Summary:
This pull request fixes a dangling brace, causing Xcode to be unable to build RCTFabricSample.

[General] [Fixed] - Fabric: Xcode build issue
Pull Request resolved: https://github.com/facebook/react-native/pull/23540

Differential Revision: D14142990

Pulled By: hramos

fbshipit-source-id: d6c2313d831e2ea5d22c77543814b86bfe8a1d53
2019-02-19 21:55:18 -08:00
Héctor Ramos 2c25e34060 Use new yearless copyright header format
Summary: Use the new copyright header format used elsewhere in the React Native repository.

Reviewed By: shergin

Differential Revision: D14091706

fbshipit-source-id: b27b8e6bcdf2f3d9402886dbc6b68c305150b7d5
2019-02-19 10:35:12 -08:00
Jonathan Kim c02f278d8f xplat// -> fbsource//xplat/ for xplat/js
Reviewed By: scottrice

Differential Revision: D14076351

fbshipit-source-id: f803d2af438a5eb3f18c981793e17b6293d8ef1c
2019-02-14 23:53:32 -08:00
Valentin Shergin b3961aff2a Fabric: Fixed small perf problem in RCTImageManager
Summary:
This changes fix small perf problem in RCTImageManager (and layout!) saving (in my completly non-scientific tests) up to 2 ms.
Maybe that's not much, but it fires during layout (and ShadowNodeTree reconsiliation processes), so it has to be very performant.

Reviewed By: JoshuaGross

Differential Revision: D14072077

fbshipit-source-id: 0baa54584dc3ae6a5f43be13fd152b84801c8539
2019-02-14 20:09:16 -08:00
Valentin Shergin 13d87e9ad2 Fabric: Fixed object ownership problem in ImageManager
Summary:
Sometimes, when we deal with ImageRequest and ImageResponseObserverCoordinator we subscribe for status (or access the coordinator) without owning an ImageRequest. In those cases, we have to retain the coordinator explicitly.
For those cases, ImageRequest now exposes `ImageResponseObserverCoordinator` as a `std::shared_ptr`.

Eg, concretely in the code, `completionBlock` and `progressBlock` copied a raw pointer to the observer inside which can lead to a crash when ImageRequest is being deallocated before we received an image data.

Reviewed By: JoshuaGross

Differential Revision: D14072079

fbshipit-source-id: e10120bc05bf685e288f7b3d69092714dcd91d43
2019-02-14 00:43:03 -08:00
David Vacca 959fdf6049 ReadableNativeMap -> ReadableMap
Summary:
This diff refactors JNI methods used by the Binding.cpp class in order to use ReadableMap instead of ReadableNativeMap
This will be helpful to provide a different implementation of ReadableMap from C++

Reviewed By: shergin

Differential Revision: D14077762

fbshipit-source-id: 595b0c2d3a2d6070112257b65c1141a8af36f0e1
2019-02-14 00:07:40 -08:00
empyrical 1ec9325bae Fabric: Change naming scheme of `ShadowNodeFragment` placeholders (#23437)
Summary:
This pull request implements some suggestions made in #23414, namely:

* Rename `ShadowNodeFragment::nullSharedProps()` (and family) to `ShadowNodeFragment::propsPlaceholder()`;
* Introduce similar functions for the rest of members (tag and rootTag);

Later pull requests to remove designated initializers from Fabric (for MSVC support) will use these

I'd like to do the rename of `rootTag` to `surfaceId` as well, but would make sense to do in a separate diff as that would result in a great deal of changes.

[General] [Changed] - Changed naming scheme of `ShadowNodeFragment` placeholders, and added placeholders for remaining members
Pull Request resolved: https://github.com/facebook/react-native/pull/23437

Reviewed By: mdvacca

Differential Revision: D14072007

Pulled By: shergin

fbshipit-source-id: d5bb10a82c16d45955f417a49b503f215c4bc521
2019-02-13 22:03:01 -08:00
empyrical 1cb34cb761 Fabric/DebugStringConvertibleItem.h: Fix for MSVC (#23436)
Summary:
This pull request removes a constructor in `DebugStringConvertibleItem.h` that was causing this issue in MSVC:

```
DebugStringConvertibleItem.cpp(20): error C2600: 'facebook::react::DebugStringConvertibleItem::DebugStringConvertibleItem': cannot define a compiler-generated special member function (must be declared in the class first)
```

It was likely conflicting with the constructor that has default values for all of its arguments.

[General] [Fixed] - Fixed `DebugStringConvertibleItem` compilation on MSVC
Pull Request resolved: https://github.com/facebook/react-native/pull/23436

Reviewed By: shergin

Differential Revision: D14067760

Pulled By: mdvacca

fbshipit-source-id: 303cf9b3559932c3d06514a1f3a8739d0f6f9dc2
2019-02-13 18:59:33 -08:00
Valentin Shergin 222e650885 Fabric: Systraces are temporary disabled in Fabric C++ code
Summary: Now in BUCK file only, not in code.

Reviewed By: JoshuaGross

Differential Revision: D14019271

fbshipit-source-id: e1396be7156a374a1379a147ddecb83b51686121
2019-02-11 16:01:05 -08:00
Valentin Shergin 77838b5504 Fabric: Systraces are back
Summary:
It's better to comment `DWITH_FBSYSTRACE` out in BUCK files instead of removing them from the code.
I'll publish the BUCK changes as separate diff for simpler backout in the future.

Reviewed By: mdvacca

Differential Revision: D14019272

fbshipit-source-id: 8b322b5c115efe33c15929e008b97a05220813df
2019-02-11 16:01:05 -08:00
Valentin Shergin 1a26f97eb0 Clang-format for all files in Fabric folder
Summary:
Trivial.
If you have troubles with rebasing on top of this revision, run this on your diff:
$ find */*.h */*.mm */*.cpp */*.m -exec clang-format -style=file -i {} \;

Reviewed By: JoshuaGross

Differential Revision: D14018903

fbshipit-source-id: fd0ce2da0e11954e683385402738c701045e727c
2019-02-11 13:07:09 -08:00
Valentin Shergin 21290b569b Fabric: Enable all Fabric tests for Android
Summary: All our C++ Fabric tests are cross-platform, so it makes sense to run them for all platforms (especially because platform may behaive differently).

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D13984574

fbshipit-source-id: e384c03c7f9839be38a1910e04ba2f7725abc378
2019-02-08 20:18:19 -08:00
David Vacca 6a71d51250 Trivial rename
Summary: Trivial rename

Reviewed By: fkgozali

Differential Revision: D14011984

fbshipit-source-id: dd2e7e0221bdad7b482c6a39b1cc877779c9704c
2019-02-08 18:55:35 -08:00
Valentin Shergin fd3b8f2000 Fabric: Introducing Better: For faster, clear and ideomatic codebase
Summary:
`Better` is a trivial collection of basic tools borrowed from other low-level general purpose libraries (like Folly, Abseil or Boost). The main goals of Better:
 - Make the codebase more portable;
 - Make the dependency list explicit (by decoupling it as a dependency list of Better);
 - Make relying on modern C++ patterns and tools in code simple and easy.
 - Make executing experiments with different dependencies easier.

 As a first example usage, this diff replaces std::unordered_map with an efficient one from folly on the one of the hottest paths.

Reviewed By: JoshuaGross

Differential Revision: D13944565

fbshipit-source-id: 5fa2c4abe6c17f7361eddcc25f968b6440d5d9db
2019-02-08 13:57:33 -08:00
Valentin Shergin 9842e39019 Fabric: folly::dynamic was replaced with RawValue in prop-parsing infra
Summary:
Our long-term plan is to completely illuminate `jsi::Value`-to-`folly::dynamic` serialization step in prop parsing process improving performance and memory pressure. At the same time, we don't want to introduce a hard dependency in application code to JSI because it exposes direct access to VM and prevents parsing some data that come *NOT* from JSVM.
RawValue is an extremely light-weight (hopefully fully optimized-out) abstraction that provides limited JSON-like and C++-idiomatic interface.

The current particular implementation is still using `folly::dynamic` inside, but I have fully JSI-powered one which will replace the current one right after we figure out how to deal with folly::dynamic-specific callsites. Or we can implement RawValue in a hybrid manner if a code-size implication of that will be minimal.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D13962466

fbshipit-source-id: e848522fd242f21e9e771773f2103f1c1d9d7f21
2019-02-06 16:34:46 -08:00
Valentin Shergin b0c8275369 Fabric: Lost comment in EventQueue
Summary: Just a comment.

Reviewed By: JoshuaGross

Differential Revision: D13962465

fbshipit-source-id: 31780a8ccf02d768e3d4b91e7205ceb0ee10fedf
2019-02-06 16:34:46 -08:00
Valentin Shergin 2332cb6fe2 Fabric: A bunch of `#ifdef ANDROID`
Summary: Nothing really changed; the change is only to better express an original intent.

Reviewed By: JoshuaGross

Differential Revision: D13962464

fbshipit-source-id: f385db8ba8662f2150181e47fc6a2a981f809e96
2019-02-06 16:34:46 -08:00
Joshua Gross 550a14c216 ImageResponseObserverCoordinator does not need to be shared_ptr
Summary: Don't use shared_ptr in this case, it's not needed.

Reviewed By: shergin

Differential Revision: D13965413

fbshipit-source-id: ec98c13f53c7d558a0cb68cea0f97568dd202cd8
2019-02-06 11:51:32 -08:00
Joshua Gross b6318acbab Support image props for Slider component, feature parity with pre-Fabric Slider
Summary: The biggest change is that (1) the image proxy/observer code from the Image component has been generalized, (2) the four image props for the Slider component are fully supported, (3) a handful of props that were ignored or buggy on iOS now perform as expected.

Reviewed By: shergin

Differential Revision: D13954892

fbshipit-source-id: bec8ad3407c39a1cb186d9541a73b509dccc92ce
2019-02-05 17:31:40 -08:00
David Vacca 7f27888878 Add performance counters for Fabric
Summary:
This diff adds performance loggers for Fabric in Android to be able to compare current version or RN with Fabric

This is the summary of Points and Annotations:

- **UIManager_CommitStart**: time that React starts the commit (react tree is ready to start rendering in native)
- **UIManager_LayoutTime**: this is the time it takes to calculate layout in yoga
- **UIManager_FabricFinishTransactionTime**: Time it takes transform "C++ mutationInstructions" into "Java MountItems" and cross boundaries from C++ to Java (including serialization of data) (THIS IS ONLY FABRIC)
- **UIManager_DispatchViewUpdates**: time right before RN moves the mount operations to the Queue that is going to be processed in the next tick UI thread
- **UIManager_BatchRunStart**: time right before the mountItems are going to be process in the UI Thread
- **UIManager_BatchedExecutionTime**: time it took to run batched mountItems (usually layout and prop updates on views)
- **UIManager_NonBatchedExecutionTime**: time it took to run non-batched mountItems (usually creation of views)

Reviewed By: fkgozali

Differential Revision: D13838337

fbshipit-source-id: 0a707619829e7d95ce94d9305ff434d1224afc46
2019-02-04 17:27:30 -08:00
zhongwuzw cca1cdf9b3 Fix typo of startSurface comments (#23264)
Summary:
N/A

[iOS] [Fixed] - Fix typo of startSurface comments
Pull Request resolved: https://github.com/facebook/react-native/pull/23264

Differential Revision: D13941762

Pulled By: cpojer

fbshipit-source-id: 9ec3ef767e46428c6a67553c3275fb7b7cea16eb
2019-02-04 08:07:44 -08:00
David Vacca 842b9c106a Temporary remove systraces from Fabric core code
Summary: This is a temporary change to measure production data

Reviewed By: fkgozali

Differential Revision: D13906807

fbshipit-source-id: 2a2f71aa379c4aca63c7bb4a9644704f713cb088
2019-02-02 13:08:06 -08:00
Joshua Gross 28b8b8e370 Use feature flags in Fabric C++ core, in particular for paragraph measurement caching
Summary: The goal is to be able to use MobileConfig params inside of core React Native C++ code. This works on Catalyst iOS now and Wilde; need to add support for FB4A and Catalyst Android.

Reviewed By: fkgozali

Differential Revision: D13883007

fbshipit-source-id: 115fe6cc884d2a0b9ca26dadf867a5f0ae99f262
2019-02-01 18:19:11 -08:00
Joshua Gross 10e4a851ad Address some paragraph measure cache follow-up nits
Summary: Changing some T& to const T&, removing unnecessary shared_ptr.

Reviewed By: shergin

Differential Revision: D13845619

fbshipit-source-id: 2678f67f24445e3db105619a07534f5200e313fe
2019-01-31 19:18:55 -08:00
Joshua Gross 88bc80c518 Update hash functions to use folly:#️⃣:hash_combine
Summary: Following hashing best practices.

Reviewed By: shergin

Differential Revision: D13827893

fbshipit-source-id: 3786f1e42b176a973890989be7b33efce4825ac6
2019-01-28 14:36:30 -08:00
Joshua Gross a9049442f7 Fabric: Use LRU to cache results of ParagraphShadowNode::measure
Summary: Use a folly LRU implementation to cache results of ParagraphShadowNode::measure, which Yoga asks for repeatedly. Should have a substantial speed improvement on Android and iOS, or at least that's the dream.

Reviewed By: mdvacca

Differential Revision: D13795808

fbshipit-source-id: 5716af0fe0517a72716e48113c8125bb788735d7
2019-01-25 17:00:51 -08:00
Joshua Gross b905548a3b Fabric: Replace ImageLoader promise implementation with observer model
Summary: Folly promises/futures have been replaced by an observer model which keeps track of loading state. This resolves at least one crash that I can no longer repro and simplifies the code a bit (IMO).

Reviewed By: shergin

Differential Revision: D13743393

fbshipit-source-id: 2b650841525db98b2f67add85f2097f24259c6cf
2019-01-25 09:24:09 -08:00
David Vacca 5bc709d517 Temporary render <View> for <AndroidTextInput> component
Summary: Temporary render <View> for <AndroidTextInput> component to unlock testing basic React Screens that uses TextInput

Reviewed By: sahrens

Differential Revision: D13768283

fbshipit-source-id: 9fda8c633f03ec9e88dccef3525726e1a9d60f73
2019-01-23 11:31:56 -08:00
Joshua Gross c40a782b3a Fabric: Add Fabric-compatible Slider component to iOS
Summary: Fabric-compatible Slider component, minus image support (coming soon!)

Reviewed By: shergin

Differential Revision: D13644717

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

Reviewed By: sahrens

Differential Revision: D13681594

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

Reviewed By: sahrens

Differential Revision: D13668147

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

Reviewed By: sahrens

Differential Revision: D13642594

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

Reviewed By: sahrens

Differential Revision: D13642593

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

Reviewed By: sahrens

Differential Revision: D13642592

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

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

Reviewed By: sahrens

Differential Revision: D13616382

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

Reviewed By: mdvacca

Differential Revision: D13324480

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

Reviewed By: sahrens

Differential Revision: D13615363

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

Reviewed By: sahrens

Differential Revision: D13615365

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

Reviewed By: sahrens

Differential Revision: D13615364

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

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

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

Reviewed By: sahrens

Differential Revision: D13613942

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

Reviewed By: mdvacca

Differential Revision: D13664395

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

Reviewed By: shergin

Differential Revision: D13616172

fbshipit-source-id: 7b7a6461216740b5a1ad5ebbead9e37de4570221
2019-01-16 12:38:22 -08:00
Eli White db5528ffa9 Use Generated Switch Schema
Summary: We are now generating the native cpp files for Switch via Buck. Deleting the hand written files and switching over.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D13666672

fbshipit-source-id: 72cf6f6af9374511f2742f8f0d996fa52e1bff5b
2019-01-15 18:10:34 -08:00
Valentin Shergin cb14b06309 Fabric: More systraces for Diffing and Commit phase
Summary: Trivial.

Reviewed By: mdvacca

Differential Revision: D13644482

fbshipit-source-id: 90cfa04797682e57fc4de009fe4a412167b9e8cd
2019-01-11 18:13:55 -08:00
Valentin Shergin 7bf6f2c238 Fabric: Layout/Yoga related systrace sections
Summary: Trivial.

Reviewed By: mdvacca

Differential Revision: D13643275

fbshipit-source-id: 67a562b899f077d7ca53b64456807a8d7c8fe6b7
2019-01-11 18:13:55 -08:00
David Aurelio 7406276a5b Remove enum count macros
Summary:
@public
Removes all `YG...Count` macros for enums and replaces them with `facebook::yoga::enums::count<YG...>()`.
This removes the need to manually maintain enum counts.

Same as D13597449, working around a defect in clang < 3.9

Reviewed By: amir-shalem

Differential Revision: D13634622

fbshipit-source-id: 344dc70e167b0caf746fe396cedd200f54e52219
2019-01-11 03:11:58 -08:00
Amir Shalem 1feda5e5c8 Revert D13597449: [Yoga][cleanup] Remove enum count macros
Differential Revision:
D13597449

Original commit changeset: edcee225ada4

fbshipit-source-id: 1afc24833c8657a8a198bc4529d98c8f605b7fbd
2019-01-10 23:51:29 -08:00
David Aurelio 35a136801c Remove enum count macros
Summary:
@public
Removes all `YG...Count` macros for enums and replaces them with `facebook::yoga::enums::count<YG...>()`.
This removes the need to manually maintain enum counts.

Reviewed By: shergin

Differential Revision: D13597449

fbshipit-source-id: edcee225ada4058e94f3a727246763e3cc45873d
2019-01-10 07:56:15 -08:00
David Vacca 9380ec0d23 Fix 'global reference table overflow' error in Fabric
Summary: This diff ensures that the 'measure' method in TextLayoutManager is memoized using a static variable.

Reviewed By: fkgozali

Differential Revision: D13585508

fbshipit-source-id: 9275a4d193b8abb0c3aaffd5a5535234717475e1
2019-01-04 16:36:32 -08:00