Commit Graph

312 Commits

Author SHA1 Message Date
Valentin Shergin 1e9f63fe27 Fabric: Fixed a prop application bug in LegacyViewManagerInterop
Summary:
The standard merge_patch (aka RFC7386) mechanism that we used before removes the key-value pairs from the original object in case if the patch has a `null` value. And we don't need it there because we should pass this null value down to the mounting layer to clean up this prop there. Besides that, the patch should not be recursive because props are not divisible.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D26435620

fbshipit-source-id: 0d7612c6ca04dcbc122ff6add3777674e3868af8
2021-02-12 16:51:43 -08:00
Valentin Shergin 1da2369b9e RN] Fabric: New way to specify layout constraints for YGNodeCalculateLayout
Summary:
In D26292378 (https://github.com/facebook/react-native/commit/81147b6f793fbc00b81501393371bb332641f4c8) we changed the way the layout constraints are specified to Yoga for measuring and layout. This is a second iteration of the change that slightly more correct and fixes other problematic cases we discovered. See also the commend in the code.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D26412484

fbshipit-source-id: 06011982a63cd4d3b61ae295f9aba6f8dab6ca02
2021-02-12 15:44:39 -08:00
Igor Klemenski c37d49492b Work around max path length during source build of RN Android (#30776)
Summary:
Building ReactAndroid from source on Windows has recently hit the limitation of maximum path lengths.
At build time, during the `:ReactAndroid:buildReactNdkLib` task, the linker tries to access several of the intermediate binaries located deep in the tmp folder hierarchy, eg.
```
D:\r\ReactAndroid\build\tmp\buildReactNdkLib/local/armeabi-v7a/objs/react_render_components_progressbar/D_/r/ReactAndroid/__/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.o
```
**Suggested fix:** for modules such as `react_render_components_progressbar` and `react_render_components_picker`, rename them to `rrc_progressbar` etc.

**NOTE**: this assumes that the fix from https://github.com/facebook/react-native/issues/30535 is in place. This regression happened while https://github.com/facebook/react-native/issues/30535 has been pending checkin.

**Other mitigations I've tried:**
- setting [`LOCAL_SHORT_COMMANDS`](https://developer.android.com/ndk/guides/android_mk#local_short_commands) for the problematic modules or `APP_SHORT_COMMANDS` for the root project. Turns out those commands don't work on the NDK version RN requires, but even after manually applying a [patch ](https://android-review.googlesource.com/c/platform/ndk/+/1126440) to my local copy of the NDK, these flags had no effect.
- moving the repo directory higher in the file system tree, and using short directory names `D:\r\...` was not enough
- creating virtual drive letters for specific long paths with the [`sust`](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/subst#examples) command is not workable, since they depend on the source folder structure, and get partly generated by the build system, which I can't plug into
- just enabling long path support on Windows is not enough, since the compiler toolchain doesn't support them.
## Changelog

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

[Android] [Fixed] - Fix source build on Windows machines vol. 2

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

Test Plan:
Run `.\gradlew installArchives`

Before:
![image](https://user-images.githubusercontent.com/12816515/105435667-a1e15d00-5c12-11eb-9fcd-d0c278aaf477.png)
Now:
![image](https://user-images.githubusercontent.com/12816515/105435741-c2a9b280-5c12-11eb-88d5-a69ae56bbf50.png)

Differential Revision: D26194286

Pulled By: mdvacca

fbshipit-source-id: 778b5a0515148e2ace19e7902f74301831ebed94
2021-02-11 12:32:33 -08:00
David Vacca 68207541d9 Increase severity for yoga logs
Summary:
This diff increases the severity for yoga logs to match all other logs in Fabric

changelog: [internal] internal

Differential Revision: D26315760

fbshipit-source-id: 1de3c23513ad8ce1630e3d0e3576f60608aac7de
2021-02-09 23:19:28 -08:00
Joshua Gross 97ecb5eb19 StubViewTree: ensure nodes don't have parents when they're inserted
Summary:
iOS and Android platform code already explicitly check this invariant: nodes cannot have parents when they're inserted into the View hierarchy.

Check this in the core so we get these checks in unit tests, and earlier in the core before platform code runs.

Changelog: [Internal]

Reviewed By: shergin, mdvacca

Differential Revision: D26331842

fbshipit-source-id: c12bc9066d280cb85ccc9e754c9fa475927e6080
2021-02-09 22:43:44 -08:00
Joshua Gross 248704e8de Rename unit tests to match filenames
Summary:
Rename tests to match filenames so results appear correctly in console.

Changelog: [internal]

Reviewed By: PeteTheHeat

Differential Revision: D26306214

fbshipit-source-id: 58ce5ee0f5df5d7da38da8a2653a042ab7c26bb2
2021-02-09 22:43:44 -08:00
Joshua Gross 077f1d233c Remove Android-specific ViewShadowNode concrete/flattened view hack
Summary:
This hack was introduced to fix T63560216. See before/after, it no longer repros.

Changelog: [Internal]

Differential Revision: D26306134

fbshipit-source-id: 7e6f886d76f3c54912fbb548069c31faaac08786
2021-02-09 22:43:43 -08:00
Joshua Gross 03390d7c87 Differ: fix confusion between flattening and concreteness of views
Summary:
During earlier testing I didn't fully realize that Android disables a core bit of View Flattening: Views can be concrete or non-concrete; and their children can be flattened or not. None of these properties are mutually exclusive with each other.

Except on Android - that functionality is currently disabled. A View can be either flattened and non-concrete, or non-flat and concrete. So there are some flattening edge-cases hit on iOS but not Android, due to the larger state-space on iOS.

To test, I forced Android to align with iOS and tested; and then tested on iOS; and ensured no mounting errors, assertions, or crashes were hit during some specific tests.

Changelog: [Internal]

Differential Revision: D26298872

fbshipit-source-id: 2f0f78127a7bf057c7cf109005f1dae74f0ff6ba
2021-02-09 22:43:43 -08:00
Joshua Gross 84d0a2ed4e Flush glog lines at the end of StubViewTree mutate function
Summary:
On iOS, log lines are not entirely flushed when an assert is hit right after (or during) this mutate function. Make sure to flush log lines regularly during this function so that debugging is easier.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D26291789

fbshipit-source-id: 47af109cdc3dcfc6bf08cbb41db06e9260bfaa08
2021-02-09 22:43:43 -08:00
Joshua Gross e723294630 LayoutAnimations: remove dead code
Summary:
remove dead code; this flag is always defaulted to false, and not used anywhere

Changelog: [Internal]

Reviewed By: sammy-SC, mdvacca

Differential Revision: D26271507

fbshipit-source-id: e2277cc24f164c53f2e8a0aa72456ac400834d70
2021-02-09 22:43:42 -08:00
Joshua Gross 49baf65844 LayoutAnimations: assert -> LA_ASSERT
Summary:
Add LA_ASSERT macro, this just makes debugging easier on Android since these asserts are compiled out for us even in debug.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D26271508

fbshipit-source-id: 9be8c71e273d762a4f31ff1fcc629ce48218b98d
2021-02-09 22:43:42 -08:00
Joshua Gross 76c384ff61 LayoutAnimations: in setup, guard against props being null in prod
Summary:
These asserts don't run in prod; only set starting/final view props if the result props object is non-null.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D26271512

fbshipit-source-id: b495c014a062cf255fd4b5cb8609582f23edcec8
2021-02-09 22:43:42 -08:00
Joshua Gross 2218952d8b LayoutAnimations: when detecting conflicting mutations: crash more in debug, fail elegantly in prod
Summary:
In this case where there's an ongoing UPDATE animation and an INSERT of the same node, make sure the ongoing animation type is what we expect, and that the `newChildShadowView` is valid.

We were already guarding against these, but we should (1) crash more in debug and (2) fail more elegantly in prod when the asserts don't run.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D26271514

fbshipit-source-id: 48e7d37a2493241f16099d9fe5ecb0d247707ca7
2021-02-09 22:43:41 -08:00
Samuel Susla 5c202cafd6 Simplify content mode conversion
Summary:
Changelog: [internal]

To avoid typecasting, let's return `UIViewContentMode`. This way we get rid of a condition to check if contentMode is repeat.

Reviewed By: JoshuaGross

Differential Revision: D26252431

fbshipit-source-id: 94ef7af1a76f13c91b696d57ceecc2453bbc9d8d
2021-02-09 04:03:48 -08:00
Ramanpreet Nara ab21226457 Migrate away from "@fbsource//tools/build_defs/apple:flag_defs.bzl"
Summary:
We still have usages of "fbsource//tools/build_defs/apple:flag_defs.bzl" in react-native-github. But this should get us closer towards not using the fbsource cell. Hopefully, this is enough to unbreak the  test_docker CircleCI build.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D26289304

fbshipit-source-id: 1c6464bb84df4f82f8a797321a73a1ed324e319a
2021-02-08 16:04:51 -08:00
Valentin Shergin 81147b6f79 Fabric: Changes in YogaLayoutableShadowNode::applyLayoutConstraints that prevent descendant nodes overgrow to infinity
Summary:
Instead of changing Yoga styles for a root node, now we pass available height and width to YGNodeCalculateLayout directly.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC, mdvacca

Differential Revision: D26292378

fbshipit-source-id: f99127e1cbddc1d57e4ee116afc141cbff5054ab
2021-02-08 15:36:57 -08:00
Joshua Gross 95cab24a6e LayoutAnimations: assert that tag >0 instead of != 0
Summary:
LayoutAnimations: assert that tag >0 instead of != 0. It's possible that a corrupt tag value would be below zero which is not valid.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26271515

fbshipit-source-id: a62445ad29d60e5180e62ec4c6d5b08784655808
2021-02-05 00:57:42 -08:00
Joshua Gross 1c2a95d6c6 LayoutAnimations: when setting up animation start/final ShadowViews, ensure props are not null
Summary:
LayoutAnimations: when setting up animation start/final ShadowViews, ensure props are not null

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26271510

fbshipit-source-id: 8d99ba8272fb63103a8d85bb0e14d02256a6d74d
2021-02-05 00:57:41 -08:00
Joshua Gross cc9a3e27c2 LayoutAnimations: ensure that interpolated props are never null
Summary:
ensure that interpolated props are never null

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26271516

fbshipit-source-id: d012e530e92dabce1e0a7df8edf670e90367a892
2021-02-05 00:57:41 -08:00
Joshua Gross f0a599a112 LayoutAnimations: in createInterpolatedShadowView, ensure that props are never null
Summary:
props should never be null

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26271513

fbshipit-source-id: 126f4e11f0f0f4e4c911e445fa8f6632a1c77cf2
2021-02-05 00:57:41 -08:00
Joshua Gross 87fe643a2f LayoutAnimations: ensure that we always have a valid ComponentDescriptor
Summary:
We should always be able to reference a ComponentDescriptor. If there are any valid cases where the ComponentDescriptor doesn't exist (?) we need to document those and investigate more.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26271511

fbshipit-source-id: 659d160f82f1e78025d3dbe16efa0fa2d072d15f
2021-02-05 00:57:41 -08:00
Joshua Gross 512fd0e0b8 Add asserts to LayoutAnimations to check that ShadowViews are always valid
Summary:
Make sure there's no corruption happening to these ShadowViews.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D26271509

fbshipit-source-id: 01bfa1bfce56e72b48304fe15b6f6426d3b5247e
2021-02-05 00:57:40 -08:00
Sara Valderrama bb796be9e1 fix rounding for translation to android/ios colors
Summary:
Currently, there is a bug with the way that fabric translates float values for color components to hex/int value (which android uses). There are two main problems with the current setup. The first is that we are using 256 as our ratio instead of 255 which is the maximum value for any color component in hex. The second is that we cast the components to ints instead of rounding which truncates the values. We uncovered this with UIQR because our off-by-one color values were incorrectly off a little bit extra for fabric surfaces.

Changelog: [Internal] updates the float-to-int value conversion for color components to be fully accurate

Reviewed By: shergin

Differential Revision: D26161396

fbshipit-source-id: 884e27ffa01b116f9307c00298bb8d888f9f6dd7
2021-02-04 14:18:41 -08:00
Valentin Shergin fc24bb4af0 Fabric: Support for setIsJSResponder, all the native changes
Summary:
This is a Fabric-compliant implementation of `JSResponder` feature. To make it work e2e we also need to update FabricRenderer in React repository. But before we can do this, we need to ship the native changes.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D24630027

fbshipit-source-id: 70c30e1250b554d83862956b536714704093072f
2021-02-04 13:16:29 -08:00
David Vacca 1e6d2e983a Remove strong reference from TM infra
Summary:
This diff refactor strong references on TM infra to use weak references and avoid leaking objects

changelog: [internal] internal

Reviewed By: RSNara

Differential Revision: D26229814

fbshipit-source-id: d4a327dba227378d23764433d5917eb4378a4453
2021-02-03 12:56:17 -08:00
Samuel Susla 177e147335 Add tests for AttributedStringBox
Summary: Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D26168698

fbshipit-source-id: 4416c01a3d4b3721964e2c73e145fb346f45a66a
2021-02-02 14:18:25 -08:00
Samuel Susla 64d9364095 Copy data in updateState instead of moving them
Summary:
Changelog: [internal]

`UpdateState` lambda can be called multiple times because of state auto-repeater. But previously we moved state data into the lambda and then moved it into constructor shared data constructor. If auto-repeater called update state lambda again, the data would be in invalid state.
To fix this, state data has to be copied into shared data constructor.

Background executor was more likely to kick trigger state auto-repeater, that's why the crash was happening in BE experiment.
State-autorepeater was enabled at the end of December. That explains why the crash started appearing in v301 (prior to 301, this crash was not happening).

Reviewed By: JoshuaGross, shergin

Differential Revision: D26173800

fbshipit-source-id: 46d1bae226e607d04d5ba28e6c2a8ec86258593a
2021-02-01 10:17:56 -08:00
Valentin Shergin d6341c4fad Fabric: Using ShadowNodeTraits::Trait::MeasurableYogaNode in ParagraphShadowNode
Summary:
Similarly to D25937710 (https://github.com/facebook/react-native/commit/3d166a0a4c08fdaae9174625d7baba247f84fdea) we are moving away from using imperative methods that dirty Yoga node.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D26069354

fbshipit-source-id: 3d4e1bd4715a204d90174c7ea29b56438778bfa3
2021-01-31 22:21:51 -08:00
Samuel Susla 67699ba9f2 Fix test setup in attributedString module
Summary:
changelog: [internal]

Tests were not running because of `#ifdef ANDROID` directive.
Tests had leaks and were using asserts instead of `EXPECT_EQ`.

Reviewed By: JoshuaGross

Differential Revision: D26168536

fbshipit-source-id: 453fe06a965c48f54d4bad6fe6653b6f45c39ccd
2021-01-31 15:10:58 -08:00
Samuel Susla dce1863bf9 Put moved from AttributedStringBox into consistent state
Summary:
Changelog: [internal]

Fixes an inconsistency that `AttributedStringBox` can get into.

Example of inconsitency:
After `AttributedStringBox` is moved (move constructor or move assignment operator), moved from `AttributedStringBox` needs to be set into blank state. Its mode needs to be `Value`, `opaquePointer_` should be nullptr and `value_` empty AttributedString. This was not the case before as the default move constructor and operator would leave `mode_` as `OpaquePointer` but ivar representing opaquePointer would be nullptr.

Reviewed By: JoshuaGross

Differential Revision: D26168142

fbshipit-source-id: eed2a7c3a165ae5e1f269822c12042c6ccbd3388
2021-01-31 15:10:58 -08:00
Valentin Shergin 9d4096b296 Fabric: Using SurfaceManager for testing SurfaceHandler infrastructure
Summary:
The diff implements a way to use `SurfaceHandler` without using `SurfaceHandler` directly for testing and transitioning purposes. If a boolean flag is enabled all calls related to surface management will be redirected to an appropriate `SurfaceHandler` via `SurfaceManager`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D26125955

fbshipit-source-id: 8760c237d486897ea0c32867c921d445a7f24edc
2021-01-29 17:47:51 -08:00
Valentin Shergin 7a290d1596 Fabric: Introducing SurfaceHandler
Summary:
This implements `SurfaceHandler`, a new primitive for controlling the Surface life-cycle that ensures ownership, preserves state, maintains internal invariants, and simplifies surface manipulation from the application side.

For now, all this is an unused code. The coming diff will introduce an experiment that will route all surfaceId-based APIs to SurfaceHandler-based ones.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D24290777

fbshipit-source-id: f2ff2b58e6d46e971a548f9f02113a1c783c4940
2021-01-29 07:54:19 -08:00
Samuel Susla 6b1a899ef7 BackgroundExecutor: rename shouldCancel to shouldYield
Summary:
Changelog: [internal]

Name `shouldCancel` is misleading. It implies the commit is cancelled and doesn't happen.
`shouldYield` expresses the intent better, because the commit's changes do eventually reach mounting layer but the current commit is rather yielding to the next one.

Reviewed By: mdvacca

Differential Revision: D26126121

fbshipit-source-id: 18988f217cbc651f0010f6e2381682bdbaed8bd4
2021-01-28 12:40:12 -08:00
Samuel Susla f92cc5ba77 Background Executor: only cancel commit if it is for the same surface
Summary:
Changelog: [internal]

In theory, a commit from different surface could cancel a commit for unrelated surface. Adding surfaceId to cancellation logic assures this doesn't happen.

Reviewed By: shergin

Differential Revision: D26126003

fbshipit-source-id: 15b9b73f1000a2b4ae882e0a5129fe26fbb53fd2
2021-01-28 12:40:11 -08:00
Samuel Susla d5a1bbe64a Background Executor: Move complete root event counting to static variable
Summary:
Changelog: [internal]

This simplifies logic, there is no need to keep the counter as an ivar of UIManager.

Reviewed By: JoshuaGross, shergin

Differential Revision: D26125928

fbshipit-source-id: bd266586463a9f9b85d6dc189cdab19f79e3d107
2021-01-28 12:40:11 -08:00
Samuel Susla fc1f0df465 Introducing: Props forwarding whe cloning shadow node
Summary:
Changelog: [internal]

If ShadowNode has not been mounted, forward rawProps from `sourceShadowNode` to newly cloned shadow node.
This is Android specific change, on iOS the logic should remain unchanged.

Reviewed By: JoshuaGross

Differential Revision: D26049264

fbshipit-source-id: 7c201bc2d4e99eec024065714d2172c5c817153c
2021-01-28 11:21:21 -08:00
Samuel Susla 78df536c78 Call updateMountedFlag in ShadowTree::tryCommit only if commit will go to native
Summary:
Changelog: [internal]

`updateMountedFlag` needs to be called only when new revision will be mounted. In case a commit is throttled, this wasn't the case. Therefore, moving cancellation of commit so it happens before `updateMountedFlag`. We already cancel commits on that place so it should be safe.

Reviewed By: shergin

Differential Revision: D26049262

fbshipit-source-id: e0ecdd2d8f0cdb09d0c0a07ad3931ce77bcf03cf
2021-01-28 04:43:25 -08:00
Valentin Shergin a0ab688216 Fabric: Using UIManagerBinding::getBinding() to access the binding on demand
Summary:
This changes how we access UIManagerBinding in Fabric code. Instead of storing a pointer to it and accessing it, now we just request it from JavaScript runtime on demand. After a week of testing, I hope we will be able to simplify retaining and referencing logic between UIManager and UIManagerBinding. The change is gated just in case to have the ability to turn this new implementation off.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D26082788

fbshipit-source-id: 211c551fe1aaba9b0bff18478e40e1e1f32e999c
2021-01-26 14:58:23 -08:00
Valentin Shergin a8fbe7269f Fabric: Setting mountingOverrideDelegate for MountingCoordinator directly
Summary:
Before this change, `mountingOverrideDelegate` was proxied via `Scheduler::startSurface` and `ShadowTree::ShadowTree` constructor down to `MountingCordinator`. Now we set it on the `MountingCoordinator` directly.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D26049076

fbshipit-source-id: 7f1ecf2c8b6f264a7e59d19881464fe529c53d30
2021-01-26 14:58:22 -08:00
Valentin Shergin 9e16ac93ed Fabric: Simplifications in UIManagerBinding::completeRoot
Summary:
This is a small simplification of the logic we have in UIManagerBinding choosing the way to call `completeRoot`. It removes an additional check for for `sharedUIManager->backgroundExecutor_` not being empty. We don't need it because it never changes and we already have the same check several lines above.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25953674

fbshipit-source-id: 683b3e51a792160d480551a65c40492ce28938e4
2021-01-25 21:57:58 -08:00
Valentin Shergin 9117840f1c Fabric: Removing Scheduler::rootComponentDescriptor_
Summary:
This diff simplifies `ShadowTree` constructor by removing `rootComponentDescriptor` argument. It was previously stored and supplied by `Scheduler`; now `ShadowTree` class allocates one instance of it for all instances of `ShadowTree`. The `RootComponentDescriptor` instance of it is only needed to clone a `RootShadowNode` instance; it cannot issue events, state updates, or anything like that because it does not have React counterpart.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D26048466

fbshipit-source-id: ec02b1b4bcc917efe17cef58112fa870b341c85f
2021-01-25 14:12:14 -08:00
Joshua Gross 82e9cb1b4e Add SurfaceId to ShadowView
Summary:
See title. Not used in this diff; see next diff in stack.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26001014

fbshipit-source-id: 475eb265f1c27bd9aff978a49652764a50287e47
2021-01-21 23:47:34 -08:00
Valentin Shergin 6079256fcc Fabric: SchedulerToolbox::commitHooks, a way to pass commit hooks to UIManager via Scheduler API
Summary:
Even though CommitHooks, in general, should be implemented as part of the Core and explicitly registered inside the code, sometimes it's handy to pass specify some additional commit hooks during Scheduler initialization (e.g. hooks that are parts of DevEx tools). Now it's possible.

We will use it soon in Timeline feature.

Changelog: [Internal] Fabric-specific internal change.

Differential Revision: D25920577

fbshipit-source-id: 00f33b7b576c9812afd70c364b5cceb3521da16b
2021-01-19 20:57:55 -08:00
Joshua Gross 9b1f3b16b0 Back out hacks to fix T83141606
Summary:
Original commit changeset: 3ed8e78e31b0

Backing-out D25938851 (https://github.com/facebook/react-native/commit/69b3016171bb2f994dd4a62c34c2c4645b5a7d56) and D25935785 (https://github.com/facebook/react-native/commit/bdea479a1faa0f1f7d7c9d9162212cce94bc9720). Based on analysis documented in T83141606, I believe this issue should be fixed in JS.

Additionally, this crash actually has nothing to do with (un)flattening or the differ; it is a side-effect of stale ShadowNodes being cloned, which I believe is either UB or a contract violation. Either way, it should probably be fixed either in JS, or in node cloning. So this isn't the right solution for this issue and should be reverted.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25949569

fbshipit-source-id: 8cf1094a767da98fff4430da60d223412e029545
2021-01-19 00:29:41 -08:00
Joshua Gross 69b3016171 Followup to D25935785: mark more mutation instructions as "recreated"
Summary:
As a follow up to D25935785 (https://github.com/facebook/react-native/commit/bdea479a1faa0f1f7d7c9d9162212cce94bc9720), there are more cases where nodes are "recreated" due to unflattening.

This has no impact anywhere (yet) as far as I'm aware, but could fix the same issues as D25935785 (https://github.com/facebook/react-native/commit/bdea479a1faa0f1f7d7c9d9162212cce94bc9720) (on Android only).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25938851

fbshipit-source-id: 3ed8e78e31b0b911e274ecc395a43bc6cb6d5f9d
2021-01-16 23:34:37 -08:00
Valentin Shergin 3d166a0a4c Fabric: Using ShadowNodeTraits::Trait::MeasurableYogaNode in TextInput
Summary:
It is the correct way to deal with the measure function.

I believe it can fix the crash we see with TextInput state update. The crash is probably caused by invalid value of `shadowNodeRawPtr` in `YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector`.
It's hard to reconstruct the full chain of events but I think it's related: Yoga's dirty flag influences cloning, so the improper setting of this flag can misalign "natural" ShadowNode cloning (influenced by changes in the tree) and YGNode-initiated cloning (triggered by layout process).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25937710

fbshipit-source-id: a4e7c9dd8f5e6598fc662f4c6ee8061fd795e20d
2021-01-16 15:53:55 -08:00
Valentin Shergin 8684ef499f Fabric: Implementation for ShadowNodeTraits::Trait::MeasurableYogaNode
Summary:
This implements the `MeasurableYogaNode` trait in `YogaLayoutableShadowNode`. We had this trait from the very beginning but never used it. Now, if the trait is specified, `YogaLayoutableShadowNode` will set the measure function for the node and dirty it during cloning.

Previously, we used (and still use) a dedicated method for setting up the measure function - `YogaLayoutableShadowNode::enableMeasurement()`. The problem with it is that to make it work we have to dirty the Yoga node every time we clone it. And the only proper way to do this in the `YogaLayoutableShadowNode` constructor because if we do it later ancestor nodes could not observe this and react to this. Therefore we have to have a trait for it.

The plan is to use it for TextInput first to fix a crash (see the next diff). After we confirm it works fine, we will replace all the usages of `enableMeasurement` with the new trait.

This diff also renames the other two yoga-related traits (to make them less verbose and look unified), adds more comments, and asserts.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D25937711

fbshipit-source-id: fafbd5d62537ac09e02ffbfd56adab6d629d791d
2021-01-16 15:53:55 -08:00
Joshua Gross bdea479a1f Fix Android crash: mark re-created nodes in Differ
Summary:
Android has some optimizations around view allocation and pre-allocation that, in the case of View Unflattening, can cause "Create" mutations to be skipped.

To make sure that doesn't happen, we add a flag to ShadowViewMutation (in the core) that any platform can consume, that indicates if the mutation is a "recreation" mutation.

It is still a bit unclear why this is needed, in the sense that I would expect props revision to increment if a view is unflattened. However, there is at least one documented reproduction where that is *not* the case. So for now, we'll have a hack pending further investigation.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25935785

fbshipit-source-id: 6fb4f0a6dedba0fe46ba3cd558ac1daa70f671f5
2021-01-16 11:05:54 -08:00
Valentin Shergin 16a1fc7b7a Fabric: Introducing ShadowTree::CommitMode
Summary:
CommitMode allows customizing the side-effects of commit operations. In `Suspended` mode, the results of commit operations will not be passed down to a MountingCoordinator which will result in skipping the mounting phase completely.
This is one of the core elements of the Pre-rendering infrastructure.

Changelog: [Internal] Fabric-specific internal change.

Differential Revision: D24290773

fbshipit-source-id: c10ec20d13f3131fc632352ef22f4465c9dfb3c2
2021-01-15 16:23:14 -08:00
Ramanpreet Nara 8fe25fcd5b Remove TurboModuleSchema and clean up JavaTurboModule
Summary:
This concludes the TurboModule JS codegen cleanup.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25915167

fbshipit-source-id: 901468fd559a7b3d75b929e9ff1167544e71a2d5
2021-01-14 19:14:23 -08:00