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

2600 Коммитов

Автор SHA1 Сообщение Дата
Samuel Susla 412fc7d324 Prevent calling onTextLayout with the same value
Summary:
Changelog: [internal]

In D23648430 (a315e4cd30) I made a mistake. I prevented calling `onTextLayout` unless there are attachments in the component. It fixed the problem because I unintentionally prevented `onTextLayout`  to be called. Therefore, changes from D23648430 (a315e4cd30) need to be reverted.

To prevent infinite loop in `onTextLayout`, ParagraphEventEmitter checks if `linesMeasurements` have changed before dispatching it to JS.

Reviewed By: shergin

Differential Revision: D23782717

fbshipit-source-id: 0e84ae4f46d79ce0cf4c7340cd32be6f562ae179
2020-09-20 08:18:55 -07:00
Kevin Gozali 7c93f5b001 Move TurboModule Core from ReactCommon/turbomodule to ReactCommon/react/nativemodule
Summary:
This diff moves the code of TurboModule Core from ReactCommon/turbomodule to ReactCommon/react/nativemodule

For iOS: Pod spec name stays as "ReactCommon/turbomodule/..." for now, only the source/header location is affected. The target will be renamed/restructured closer to TurboModule rollout.

changelog: [internal] Internal

Reviewed By: RSNara

Differential Revision: D23362253

fbshipit-source-id: c2c8207578e50821c7573255d4319b9051b58a37
2020-09-19 00:42:30 -07:00
Valentin Shergin 57dd48b246 Fabric: Marking all JS function lambdas `noexcept` in UIManagerBinding
Summary:
Exceptions in C++ work quite differently from exceptions in other languages. To make exceptions actually work **correctly** all the code needs to be written with "exceptions in mind" (e.g., see https://www.stroustrup.com/except.pdf). In short, if the code is not "exceptions ready", throwing an exception causes memory leaks, dangling pointers, and invariant violations all over the place, which will probably cause another crashes down the road (which will be especially hard to investigate and attribute to the original issue).
Fabric Core (Layout, Props parsing, ShadowNodes management, and so on) does not use exceptions because in most (all?) the cases the exception is now recoverable. So, if a program detects some internal state invariant violation or missing some resource, *logically* it's fatal. We also don't want to pay code-size and performance tax for exception support, so that's why we don't use them. It's just not the right fit for Fabric Core.

This does not mean that exceptions don't happen though. C++ standard library can throw them... sometimes. And if our library is compiled with exceptions enabled (still the case, unfortunately), an exception can bubble to JavaScript code and losing all context down the road. And it's hard to investigate such crashes. To isolate those occasional exceptions inside C++ core we are marking all C++/JS boundaries with `noexcept` that stops the bubbling.

I hope that will give us much more informative crash reports.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23787492

fbshipit-source-id: 0822dbf36fc680c15b02b5cd0f2d87328296b642
2020-09-18 17:07:29 -07:00
Valentin Shergin 1ddc6542c7 Fabric: Removing catching all exceptions in UIManager::completeRoot
Summary:
This is a revert of D23529233 (902611f148).
It turns out it was a bad idea. With this catch-all thing, we don't get new information. Yeah, we crash earlier now but seems we have even less information about the crash. :(

I think D23754284 (04c874bd9c) should fix the issue.

Changelog: [Internal] Fabric-specific internal change.

Original commit changeset: 7ac7fb26ac08

Reviewed By: sammy-SC

Differential Revision: D23786086

fbshipit-source-id: 86784df0193abfb7328c4d5a16a9af4214e9a161
2020-09-18 17:07:29 -07:00
Joshua Gross 752e709b51 Additional differ test: flattening differ should not produce DELETE and CREATE mutation for the same tag in the same frame
Summary:
See additional assertion. Tests still pass, so no other change was necessary.

Changelog: [Internal]

Differential Revision: D23775553

fbshipit-source-id: 57d3191f25dd55ab4da189207f6d201a31b175e0
2020-09-18 16:38:33 -07:00
Riley Dulin 22804a6144 Add cause to jsi::instrumentation::collectGarbage
Summary:
Continuing the adding of a "cause" field for logging to GCs.
This allows embedders of Hermes (such as React Native) to specify
the cause of a call to `collectGarbage`.

Notably, this allows Hermes to know when a GC is triggered by a memory warning.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D23742099

fbshipit-source-id: 99453e632328c00045b92a72f789d41c898dc518
2020-09-18 10:36:19 -07:00
Joshua Gross f72c6f23cf Reintroduce experiment flag for Reparenting/Flattening Differ
Summary:
This flag was deleted in D23374948 (6729a3e0bf), reintroduce it.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D23771273

fbshipit-source-id: ae9595194bf14bc740d05b2ca6e7b5e22bdd566f
2020-09-18 10:02:15 -07:00
Ramanpreet Nara 9b094ee77a Stop accessing JVM in ~JavaTurboModule
Summary:
Inside JavaTurboModule, the native `CallInvoker` is used to schedule work on the NativeModules thread. So, in ~JavaTurboModule(), I scheduled some work on the NativeModules thread. This work holds a copy of the JNI global reference to the Java NativeModule object, and when it's executed, it resets this global reference to the Java NativeModule object. This should ensure that the we don't access the JVM in ~JavaTurboModule, which could crash the program.

I also removed the redundant `quitSynchronous()` in `~CatalystInstanceImpl()`, to prevent the NativeModules thread from being deleted before we delete the `jsi::Runtime`. This shouldn't cause an issue, because we delete the NativeModules thread when we call [ReactQueueConfigurationImpl.destroy()](https://fburl.com/codesearch/p7aurwn3).

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D23744777

fbshipit-source-id: a5c8d3f2ac4287dfef9a4b4404a04b335aa0963d
2020-09-17 16:06:48 -07:00
Valentin Shergin c453dbc4cc Fabric: Enabling state auto-repeating for all state updates (gated)
Summary:
This enables a new state auto repeating mechanism built-in mechanism for all state updates which we already use for CK interop. This experiment is supposed to help with T74769670 and co.

This change is gated with MC.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23762508

fbshipit-source-id: f535513c724ace9ede570177281324eb507329c5
2020-09-17 14:47:12 -07:00
Ramanpreet Nara 9b76e217bb Copy all blocks generated by TurboModules
Summary:
The Apple documentation states: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Blocks/Articles/bxUsing.html#//apple_ref/doc/uid/TP40007502-CH5-SW1

> Typically, you shouldn’t need to copy (or retain) a block. You only need to make a copy when you expect the block to be used after destruction of the scope within which it was declared. Copying moves a block to the heap.

All blocks generated in the TurboModule infra, for callbacks and promise resolve/reject handlers, can be used after the destruction of the scope within which they were declared. Therefore, let's copy them in the hopes that they mitigate T75876134.

**Note:** We copy blocks before pushing them into the `retainedObjects` array in the legacy Infra as well. Context: D2559997 (71da2917e5), D5589246 (2a6965df90)

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23764329

fbshipit-source-id: e71360977bdff74dc570bd40f0139792860f811f
2020-09-17 13:55:08 -07:00
Joshua Gross ee38751975 Layout Events: throttle layout events sent to same node repeatedly
Summary:
Under Fabric only, we can enter an infinite layout loop where the emitted layout event oscillates between two height values that are off by a very small amount.

The cause is, in part, components that use layoutEvents to determine their dimensions: for example, using onLayout event "height" parameters to determine the height of a child. If the onLayout height changes rapidly, the child's height will change, causing another layout, ad infinitum.

This might seem like an extreme case but there are product use-cases where this is done in non-Fabric and layout stabilizes quickly. In Fabric, currently it may never stabilize.

Part of this is due to a longstanding issue that exists in Fabric and non-Fabric, that we cannot immediately fix: If in a single frame, C++ emits 100 layout events to ReactJS, ReactJS may only process 50 before committing the root. That will trigger more layout events, even though product code has only partially processed the layout events. At the next frame, the next 50 events will be processed which may again change the layout, emitting more events... etc. In most cases the tree will converge and layout values will stabilize, but in extreme cases in Fabric, it might not.

Part of this is because Fabric does not drop *stale* layout events. If 10 layout events are dispatched to the same node, it will process all 10 events in older. Non-Fabric does not have this behavior, so we're changing Fabric to drop stale events when they queue up.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D23719494

fbshipit-source-id: e44a3b3e40585b59680299db3a4efdc63cdf0de8
2020-09-17 13:20:23 -07:00
Joshua Gross 0599742db8 LayoutAnimations: at the end of every animation, issue an update mutation
Summary:
LayoutAnimations: at the end of every animation, issue an update mutation - this is so that the props data on the Mounting layer/StubViewTree layer is pointer-identical to the props data on the ShadowTree.

This unblocks iOS debug mode crashes.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D23753606

fbshipit-source-id: 407e0c2746a65e6d3ee29c1cce891cd7c1013593
2020-09-17 12:29:29 -07:00
Joshua Gross 3585bb422f Fix compilation for LayoutAnimations debug mode
Summary:
iOS needs this function to be marked as static.

Changelog: [internal]

Reviewed By: shergin

Differential Revision: D23749613

fbshipit-source-id: a8c160646853450fc7d849448bdbb45e02beb964
2020-09-17 12:29:29 -07:00
Joshua Gross b64a6618d6 Fix MountingCoordinator RN_SHADOW_TREE_INTROSPECTION + LayoutAnimations
Summary:
Currently, MountingCoordinator's RN_SHADOW_TREE_INTROSPECTION code will crash often because it assumes there is always a "new" tree to compare the old tree to. In the LayoutAnimations context this is not always the case - in fact, the majority of the time, LayoutAnimations is producing mutations for animation without a "new" tree.

Just check that the tree exists before trying to print it.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23747289

fbshipit-source-id: a1ba22aeae32ed8915a53bc33cdc199e8ce5128a
2020-09-17 12:29:29 -07:00
Joshua Gross ad400f3cf6 Fix MountingCoordinator override mode
Summary:
In MountingCoordinator override mode (used in LayoutAnimations) we must set the start and end `diff` time when no real diff happens, otherwise we will hit an assert in telemetry later.

I also ensure that the TransactionNumber is incremented in that case.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23746684

fbshipit-source-id: b1fe3864e453fdba89d43cc827bd37434abf7a4d
2020-09-17 12:29:29 -07:00
Joshua Gross 012ac09fa1 Fix LayoutAnimations assertion on `adjustDelayedMutationIndicesForMutation`
Summary:
`adjustDelayedMutationIndicesForMutation` asserts that the mutation is either Remove or Insert. At one callsite, we weren't checking the mutation type before calling `adjustDelayedMutationIndicesForMutation`.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23746617

fbshipit-source-id: 6046fec2eb4821094937b1b16f40347bbc55c20e
2020-09-17 12:29:29 -07:00
Samuel Susla e7dbd845e6 Coalesce touchMove events
Summary:
Changelog: [Internal]

To align more closely with Paper, Fabric should coalesce touchMove events.

on iOS it happens:
https://www.internalfb.com/intern/diffusion/FBS/browsefile/master/xplat/js/react-native-github/React/Base/RCTTouchEvent.m?lines=43

Reviewed By: JoshuaGross

Differential Revision: D23734212

fbshipit-source-id: a9d324a6481884905d7be6637fcafe4e71f2bd9f
2020-09-17 11:23:46 -07:00
Valentin Shergin 5b93c49e76 Fabric: Using pre-cached UIColor objects for black, white, and clear colors
Summary:
This change maps the three most used colors (black, white, clear) to corresponding predefined values in UIColor. This should meaningfully reduce the overall amount of allocated UIColor/CGColor objects. In my non-scientific measures, it reduces the number of CGColor objects from ~1500 to ~1000. And... it no much at least in terms of kilobytes. However, I still think it's a good idea to implement this because I hope that can remove some work from memory allocation infra and maybe enable some optimizations that UIKit hopefully does for black and white colors. (I tend to believe that this optimization exists because UIKit even has a classes called UIDeviceWhiteColor and UICachedDeviceWhiteColor.)

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23753506

fbshipit-source-id: 46e58dc7e6b0dcab3c83d29c7257c90ffbd95246
2020-09-17 11:12:29 -07:00
Valentin Shergin e4877ed985 Fabric: Using `optional<int>` instead of `CGColorRef` on iOS
Summary:
Finally, this diff changes the internal implementation of SharedColor to be `optional<int>`.

Initially, when we started working on the new renderer, it seemed like a good idea to allocated CGColor objects ahead of time and store them with Props. Now, this idea does not look so good, especially because:
* Having `SharedColor` as a `shared_ptr` is a quite big perf overhead for copying this thing. And the size of the object is not small.
* Having `SharedColor` as a `shared_ptr` creates huge interconnectedness among pieces of the core and rendering. E.g. improper releasing a pointer in some component view can cause a crash somewhere in the core (because both places might use the same shared `blackColor`.

On Android, we already use simple `int` as a representation of a color, and this works great. And this diff implements something very similar to Android, but a bit differently: here we use `optional<int>` instead of custom class with a single `int` field and some magic value that represents "empty value".

This approach should fix T75836417 because now we don't have allocation and deallocation when we simply assign color values.

If this solution works fine on iOS, I will do unify all implementations among all platforms.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23753507

fbshipit-source-id: 42fd6cee6bf7b39c92c88536da06ba9e8cf4d4db
2020-09-17 11:12:28 -07:00
Valentin Shergin 241795cbc4 Fabric: Color conversion functions now do not depend on internal implementations of SharedColor
Summary:
This diff changes the implementation of `RCTCreateCGColorRefFromSharedColor` and `RCTUIColorFromSharedColor` in such a way that they don't rely on the fact that SharedColor is actually a `shared_ptr<CGColorRef>`. Instead, the methods just extract color components from SharedColor and create UIColor and CGColorRef objects on demand.
This allows us to change the implementation of SharedColor without worrying much about the rest of the system, which will do in the next diff.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23753510

fbshipit-source-id: 340127527888776ebd5d241ed60c7e5220564013
2020-09-17 11:12:28 -07:00
Valentin Shergin 04c874bd9c Fabric: Using `thread_local` keyword instead on own implementation in TransactionTelemetry
Summary:
Apparently, there is C++ keyword for this.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23754284

fbshipit-source-id: 5f9bbcc72d9c586173624869d614f12d2319fb7b
2020-09-17 08:57:57 -07:00
Valentin Shergin 13bc3c87ef Fabric: Removing shared_ptr from ShadowTreeCommitTransaction's argument
Summary:
We don't need a shared_ptr here and without it the code will be faster and simpler.
This change is aligned with any clone-line callbacks we have in the Core which accepts a `const &` and return `shared_ptr<>`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D23725687

fbshipit-source-id: 1cd959f4273913175d342302e2f12752f0114768
2020-09-16 23:56:00 -07:00
Valentin Shergin 0118cbf1d1 Fabric: Introducing `ShadowTree::getCurrentRevision()`
Summary:
Previously, to get a current root shadow node for a shadow tree, we called `tryCommit` method and stole a pointer from this. That was not a very straightforward method to get things done, and most importantly we need to do this to change the shape of the ShadowTreeCommitTransaction signature (remove a shared pointer from the callback) to make it simpler, faster and allow future improvements (see the next diff).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D23725689

fbshipit-source-id: 51950b843a0e401828b6c6a38e5e2aaaf21ec166
2020-09-16 23:56:00 -07:00
Valentin Shergin bc5a15d2c8 Fabric: Using ShadowTreeRevision inside ShadowTree to store current commited tree
Summary:
Instead of storing tree separate instance variables, we now store a single object that contains them. We will need it to be able to postpone the mounting stage (we save all info we need for mounting inside the new instance variable).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23725690

fbshipit-source-id: 09dd4a0912c6f5b34d805636b62f73ca12287329
2020-09-16 23:56:00 -07:00
Valentin Shergin 047764482f Fabric: Simplifying ShadowTreeRevision implementation
Summary:
The implementation of this class is too complex for the purpose it serves. Making it simpler will make the code simpler and faster.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23725688

fbshipit-source-id: 5e1ecddb0dd3c4c4f94786e2ba0af9b67e7426ce
2020-09-16 23:56:00 -07:00
Emily Janzer b352e2da81 Create a ClickableSpan for nested Text components
Summary:
Right now nested Text components are not accessible on Android. This is because we only create a native ReactTextView for the parent component; the styling and touch handling for the child component are handled using spans. In order for TalkBack to announce the link, we need to linkify the text using a ClickableSpan.

This diff adds ReactClickableSpan, which TextLayoutManager uses to linkify a span of text when its corresponding React component has `accessibilityRole="link"`. For example:

  <Text>
    A paragraph with some
    <Text accessible={true} accessibilityRole="link" onPress={onPress} onClick={onClick}>links</Text>
    surrounded by other text.
  </Text>

With this diff, the child Text component will be announced by TalkBack ('links available') and exposed as an option in the context menu. Clicking on the link in the context menu fires the Text component's onClick, which we're explicitly forwarding to onPress in Text.js (for now - ideally this would probably use a separate event, but that would involve wiring it up in the renderer as well).

ReactClickableSpan also applies text color from React if it exists; this is to override the default Android link styling (teal + underline).

Changelog: [Android][Fixed] Make nested Text components accessible as links

Reviewed By: yungsters, mdvacca

Differential Revision: D23553222

fbshipit-source-id: a962b2833d73ec81047e86cfb41846513c486d87
2020-09-15 17:34:35 -07:00
Valentin Shergin 135993b36b Fabric: Using RootShadowNode instead of ShadowNode in ShadowTreeRevision
Summary:
It's more correct and we will rely on this in the future.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23681508

fbshipit-source-id: 5fef0ea164e8a400e6ca9a67947252b47ce6d44e
2020-09-14 15:14:50 -07:00
Valentin Shergin fbfadc24cc Fabric: Removing ShadowTreeRevision::getSharedRootShadowNode()
Summary:
It's unused code.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23681509

fbshipit-source-id: e307be8af7b11559d60024c7b8de6137ed669aaa
2020-09-14 15:14:50 -07:00
Valentin Shergin d8e770bfd0 Fabric: Removed unused code from ShadowTree
Summary:
This is dead code.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D23681510

fbshipit-source-id: d2d1f7f97921401308badc417479d11588556ef8
2020-09-14 15:14:49 -07:00
Will Holen f34b914c8d Make the preemptive compilation threshold configurable
Summary:
This diff allows specifying the preemptive compilation threshold via CompileFlags.
Users get a toggle in CLI and RuntimeConfig that allows choosing between 1. fully eager, 2. fully lazy, 3. use default thresholds ("smart"). The default is #3.

However, since we use `-O` by default, it overrides any lazy compilation when
using the `hermes` binary.

ChangeLog: [Internal] Inspector updated to use new RuntimeConfig laziness control

Reviewed By: tmikov

Differential Revision: D23356463

fbshipit-source-id: 508b7b2e6a218346c69acfec97e7891e388f0e9b
2020-09-14 12:41:14 -07:00
empyrical 300df59c77 Android: Ensure RN_FABRIC_ENABLED is defined when building with Fabric (#29939)
Summary:
This pull request tweaks the build script for `jsiruntime` to ensure that `RN_FABRIC_ENABLED` is defined when building for Android with Fabric enabled, and using the JavascriptCore JS engine. Without it, the `createWeakObject` and `lockWeakObject` methods in `JSCRuntime.cpp` will throw an exception.

## Changelog

[Internal] [Changed] - Android: Ensure RN_FABRIC_ENABLED is defined when building with Fabric

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

Test Plan: RNTester with JSC now builds and runs on Android with Fabric enabled.

Reviewed By: hramos

Differential Revision: D23671070

Pulled By: fkgozali

fbshipit-source-id: 27e69364a9f709615543be7c20b72b5536443cd8
2020-09-14 10:08:51 -07:00
Joshua Gross 6524e611d3 Fix TextInput measurement caching
Summary:
This fixes TextInput measurement caching. Previously we were not setting the correct Spannable in the cache; we needed to additional Spans to it to indicate font size and other attributes.

This brings Fabric closer to how non-Fabric was measuring Spannables for TextInputs (see ReactTextInputShadowNode.java).

This should fix a few crashes and will be most noticeable with dynamically-sized multiline textinputs where the number of lines changes over time.

This also allows us to transmit less data from C++ to Java in the majority of cases.

Changelog: [Internal]

Differential Revision: D23670779

fbshipit-source-id: cf9b8c848b9e0c2619e01766b72b074248466825
2020-09-12 21:53:22 -07:00
Joshua Gross 0b3f46b564 Deallocate JNI array after TextInput text measurement
Summary:
Every time we measure a TextInput we allocate a JNI local array and weren't cleaning it up, leading to JNI table exhaustion.

Changelog: [Internal]

Differential Revision: D23670780

fbshipit-source-id: 2ecf9770c8593eeadd70a248be58037fefdca61e
2020-09-12 21:53:22 -07:00
Joshua Gross 44229d9149 Fix key mismatch in text layout
Summary:
Changelog: [Internal]

There was a key mismatch between what Java and C++.
cacheIdMap was incorrectly initialised.

Differential Revision: D23652342

fbshipit-source-id: 66f54dc887a011afeead9420bda093e9a0c9a8ca
2020-09-12 21:53:22 -07:00
Joshua Gross 250485a94c Move implementation of AndroidTextInputState to cpp file
Summary:
Changelog: [Internal]

Move implementation to cpp file

Reviewed By: shergin

Differential Revision: D23652329

fbshipit-source-id: 1b36fb7d9523938b90ae05af35494ff10dde1582
2020-09-12 21:53:22 -07:00
Valentin Shergin 653d8540c6 Fabric: Fixing a race condition in `Scheduler::stopSurface()`
Summary:
One of the operations we do in `Scheduler::stopSurface()` is committing an empty tree to free up `ShadowNode` objects and "disable" `EventEmitter`s associated with them. Before this change, we had a gap in time between a moment when we commit an empty tree and remove the tree from the registry. During this time gap, JavaScript (or native, actually) can commit another tree and mount another new state on the screen. To prevent this, we remove the tree from the registry first and only then commit an empty tree to a uniquely owned tree.
Note that the deleted comment says that we actually have to have a tree in the registry for committing an empty tree, I don't think it's true now.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23667882

fbshipit-source-id: 387052e9f3e78e7d4446f36baed50f9caa831133
2020-09-12 15:41:34 -07:00
Paige Sun 8e9d3ceddf 7/7 Log attribution context from the image component
Summary: Changelog: [Internal] Log attribution context from the Fabric image component

Reviewed By: fkgozali

Differential Revision: D23547930

fbshipit-source-id: 125f34dac85ff6ac52a798bb1a36394436cb2c0f
2020-09-11 15:09:12 -07:00
Paige Sun acda299453 6/6 Log image-rendered for Fabric image logging
Reviewed By: fkgozali

Differential Revision: D23450649

fbshipit-source-id: 58265a2c7855a2f4371d68637f09a07921821adf
2020-09-11 15:09:12 -07:00
Paige Sun c17333d4c1 5/6 Log image-requested QPL point for Fabric images
Summary:
Changelog: [Internal] Log image-requested QPL point for Fabric images

* See D23450649 for the full lifecycle

Reviewed By: fkgozali

Differential Revision: D23448179

fbshipit-source-id: 0a78dae2d4f1e6322bbeee3574b10abe1efb30ef
2020-09-11 15:09:12 -07:00
Paige Sun 13759f192d 3/6 Add IGviewpoint for image visibility callbacks
Summary: Changelog: [Internal] Add IGviewpoint to get image visibility callbacks for when an UIImageView is in or out of view

Reviewed By: fkgozali

Differential Revision: D23428528

fbshipit-source-id: 87e4cee8fbe3c6b7da5153f87bbb530b2f990d96
2020-09-11 15:09:12 -07:00
Paige Sun d4e1202b4e 2/6 Track image request metadata in ImageTelemetry, to be passed from ImageShadowNode into RCTImageComponentView
Summary:
* Create `ImageTelemetry` as a property of ImageRequest to pass image metadata from the ImageShadowNode into RCTImageComponentView
  * ImageRequest is a object in the ImageShadowNode::ConcreteState

Reviewed By: fkgozali

Differential Revision: D23239664

fbshipit-source-id: db0f08bb889af8ce63fbe1abe88744edddb86150
2020-09-11 15:09:11 -07:00
empyrical fcfa4309f7 Fabric: Replace #import statement in SynchronousEventBeat (#29885)
Summary:
This function replaces the usage of an Objective-C `#import` statement with `#include` in `react/renderer/scheduler/SynchronousEventBeat.cpp`.

Clang seems to have no problems with `#import` being used in CPP files, but it was causing errors in MSVC. ([it has a different purpose](https://docs.microsoft.com/en-us/cpp/preprocessor/hash-import-directive-cpp?view=vs-2019) on Windows)

## Changelog

Changelog: [Internal][Changed] - Fabric: Replace #import statement in SynchronousEventBeat

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

Test Plan: This CPP file now compiles in MSVC

Reviewed By: sammy-SC

Differential Revision: D23591933

Pulled By: shergin

fbshipit-source-id: ee2cb8152f37e5ee09500af621a57b59d5a18400
2020-09-11 14:51:00 -07:00
Samuel Susla a315e4cd30 Prevent an infinite loop in Text.onTextLayout
Summary:
Changelog: [internal]

# Problem
onTextLayout was called even if there was no change to text layout. This can cause an infinite loop with onTextLayout triggering commit which triggers onTextLayout.

# Fix
Do not call onTextLayout if there is nothing to layout.

Reviewed By: yungsters

Differential Revision: D23648430

fbshipit-source-id: 055dc34a9aca0edf2c78a5812b35b80df32c9e3e
2020-09-11 11:37:29 -07:00
Valentin Shergin a8b090b128 Fabric: Another attempt to deal with failing state updates
Summary:
This is *another* attempt to solve a failed state update problem.

Unfortunately, some applications are inherently not compatible with the "let's recommit the update on the application side in case it failed" approach. The problem is that if we call `updateState` on the application side, we miss the original event window. E.g. if we need to deliver some state update with AsyncBatched priority and if the update fails, we lose the opportunity to commit it on time. These issues can be critical for some complex use-cases as ComponentKit interop.

This diff adds implementation for `updateState` that does the work a bit differently. For all failed state updates it tres to recommit them asap using `ShadowTree::commit` and calling lambda on every attempt. With this approach the update might fail in two cases:
The node disappeared from the tree, so there is no way to update it.
The lambda returned `nullptr` indicating that the update is no longer needed.

We need this for the ComponentKit interoperability layer that is very sensitive for missing state updates.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23603958

fbshipit-source-id: a3b8c09fb2f1c8302583aa5880b48fc0840224e3
2020-09-11 09:22:08 -07:00
Valentin Shergin c19b3ffae9 Fabric: Communicating a reason why a commit was unsuccessful via ShadowTree::CommitStatus
Summary:
We need it to stop repeating to commit new shadow tree in `ShadowTree::commit` when a transaction cancels the commit.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D23603959

fbshipit-source-id: d279fb3bf4190e860740a6450595d6f2fc3117f7
2020-09-11 09:22:08 -07:00
empyrical c7ec6002f1 Fabric: Use std::move on callback in Element::stateData (#29897)
Summary:
This pull request adds a call to `std::move` on the lambda capture in `Element::stateData`.

On Windows/Visual Studio 2017, this fixes a failure in the test `LayoutableShadowNodeTest.contentOriginOffset` where the error `std::bad_function_call` was being thrown. This was narrowed down to the callback being empty when called in `Element::stateData`.

7e899348c7/ReactCommon/react/renderer/element/Element.h (L98)

Making sure the callback survives with `std::move` allows that test to pass under Windows.

## Changelog

Changelog: [Internal][Changed] - Fabric: Use std::move on callback in Element::stateData

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

Test Plan: The Fabric test suite passes on Windows after this change is made. I also tested it under macOS and Linux built with Clang and they both pass with this change made.

Reviewed By: sammy-SC

Differential Revision: D23591969

Pulled By: shergin

fbshipit-source-id: e5c88bb0e94641e5128c4d49dd2f9dbfa49e9cfa
2020-09-10 10:45:59 -07:00
empyrical eafa49d5a6 Fabric Tests: Change null ShadowNode creation in StateReconciliationTest (#29899)
Summary:
In `StateReconciliationTest`, the way initializer lists are used to create null `ShadowNode`s causes this error on Visual Studio 2017 on Windows:

```cpp
auto result = (ShadowNode const *){nullptr};
```

 ---

```
StateReconciliationTest.cpp(35): error C4576: a parenthesized type followed by an init
ializer list is a non-standard explicit type conversion syntax
```

This change allows this test to compile in Visual Studio 2017, and the effected tests successfully compile and pass on Windows. They also compile and pass on Linux and macOS (both built with Clang)

## Changelog

Changelog: [Internal][Changed] - Fabric Tests: Change null ShadowNode creation in StateReconciliationTest

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

Test Plan: The Fabric test suite passes on Windows after this change is made. I also tested it under macOS and Linux built with Clang and they both pass with this change made.

Reviewed By: sammy-SC

Differential Revision: D23592007

Pulled By: shergin

fbshipit-source-id: 7c6131736d478a0bf29d6c9475ef9149b7602dd6
2020-09-10 10:41:27 -07:00
empyrical 777bf6529a Fabric Tests: Change default constructor in TestComponents' TestProps (#29898)
Summary:
This pull request changes the default constructor in the `TestProps` class in `react/renderer/core/tests/TestComponent.h`

`using ViewProps::ViewProps;` was causing problems in Visual Studio 2017 - changing it to ` TestProps() = default;` allowed dependent CPP files to compile on MSVC and caused no regressions in the Fabric test suite.

## Changelog

Changelog: [Internal] [Changed] - Fabric Tests: Change default constructor in TestComponents' TestProps

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

Test Plan: The Fabric test suite passes on Windows after this change is made. I also tested it under macOS and Linux built with Clang and they both pass with this change made.

Reviewed By: sammy-SC

Differential Revision: D23591986

Pulled By: shergin

fbshipit-source-id: 132e1c2e38fa74aa4f2c8746054d6152f30035e9
2020-09-10 10:41:27 -07:00
Ramanpreet Nara d6fef50bd9 Make __turboModuleProxy retain TurboModuleManager
Summary:
RCTTurboModuleManager can be deallocated on a non-JS thread. This could create a race, when `__turboModuleProxy` is called from JS after cleanup has started. It's safer to just let `__turboModuleProxy` retain the TurboModuleManager.

In the future, we should clarify the ownership model for TurboModuleManager, so that we can explicitly delete RCTTurboModuleManager by nullifying a singular reference to it. For now, I'd like to land this change to potentially fix/narrow down the cause of T74825789.

Right now, a few objects can own RCTTurboModuleManager:
- FBReactModule, as the creator of RCTTurboModuleManager
- RCTCxxBridge, as an `id<RCTTurboModuleRegistry>` to supplement NativeModule lookup
- NativeModules that need to look up other NativeModules
- **New:** `__turboModuleProxy`

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23608187

fbshipit-source-id: c14c8157e7670a8e32b7cd0d4c1ad5e2ab6d8abe
2020-09-09 17:30:40 -07:00
Valentin Shergin 900c3878e1 Fabric: Removing ShadowNode state revision
Summary:
We don't use it anymore.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D23605897

fbshipit-source-id: 3502726d2b249f75f6c3992b7685869cf7dd154f
2020-09-09 15:08:23 -07:00