Commit Graph

30 Commits

Author SHA1 Message Date
Joshua Gross bd1d4e9f4f StubViewTree: reenable asserts in Delete mutation path
Summary:
I had intended to make this change as part of the stack I landed earlier, but I had some poorly resolved merge conflicts that left this path disabled.

I verified that T76057501 no longer repros and ran unit tests.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D27788467

fbshipit-source-id: 42148b887c6b3c0e815f1805e6bfb3ee58503e48
2021-04-15 11:22:19 -07:00
CodemodService FBSourceClangFormatLinterBot e6dc3717e9 Daily arc lint --take CLANGFORMAT
Reviewed By: zertosh

Differential Revision: D27789747

fbshipit-source-id: ef4882e92d7755669083573c43ae6c5088bf01ab
2021-04-15 04:27:14 -07:00
Joshua Gross dc80b2dcb5 Add mounting layer test that stress-tests differ on (un)flattening
Summary:
Add mounting layer test that stress-tests differ on (un)flattening.

This fails before D27759380 and D27730952, and passes after.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D27767219

fbshipit-source-id: a7e186e510f95792da6f98f80fcae5ff8ac74775
2021-04-14 19:50:10 -07:00
Joshua Gross c83562eb1c StubViewTree: move assert to get better debug logging
Summary:
Move this assert so the debug logging executes first; in the case where this assert fires, we'll get a little more information (for Android, where attaching a Cxx debugger is a bit harder vs iOS).

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27585132

fbshipit-source-id: e3f4cc3d78587744b9e73db685eda1fd6c36ca9d
2021-04-14 19:50:09 -07:00
Joshua Gross 2d7560d7b9 StubViewTree: enable stricter REMOVE asserts
Summary:
With all known remaining issues (outside of LayoutAnimations, potentially) resolved, enable this assert.

Note for future readers: this is the first time this particular assert has EVER been enabled widely, so if we hit this assert in dev, it's great signal for debugging BUT does not necessarily indicate any wide-spread problems in prod, or with any subsystems. This will simply help us become "more correct" over time.

It is possible, but not extremely likely, that cleaning up things that cause this assert will improve stability/crashes.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27697787

fbshipit-source-id: 28fa34eba70548f5001bbd47f41dbe3c6ff3b4c1
2021-04-14 19:50:09 -07:00
Joshua Gross 88c3090066 Correct LayoutMetrics comparison and make debuggable
Summary:
Allow conversion of LayoutMetrics to DebuggableString.

We also skipped a field in comparison. It probably isn't impactful in terms of production issues, but still wasn't correct.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27709451

fbshipit-source-id: 987fc2de0a4562a295d6cbeffdd922cbf056b811
2021-04-14 09:41:41 -07:00
Joshua Gross 638e788e06 Improve StubViewTree logging when comparisons fail
Summary:
Currently we compare StubViewTrees only in contexts where equality is expected. With additional debug flags turned on, we print a verbose summary of differences between trees.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D27492937

fbshipit-source-id: 6851c2a4056cdbc9ae790070a3d86bb3f2b462fe
2021-03-31 21:33:05 -07:00
Joshua Gross 64c93977bd Log ShadowView hash with verbose StubViewTree logs; and when StubView comparisons fail
Summary:
Improve debuggability of ShadowViewTree failures by logging ShadowView hashes. This allows us to track down exactly where a change to the tree was introduced.

If necessary, if specific repros are found, logging can also be added to LayoutAnimations or other places to find out where a specific ShadowView version (identified by hash) was introduced.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D27488766

fbshipit-source-id: f4866f771fc6494435fb46f09953ea69fb280a5b
2021-03-31 21:33:05 -07:00
Joshua Gross ec51737814 Update StubViewTree logging for debugging on Android
Summary:
When playing around with issues in debug mode but without having a debugger attached, these logs are helpful.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27407772

fbshipit-source-id: 2083901094d3bd2b0b6c6799baffcf5a60cf57ae
2021-03-31 21:33:04 -07:00
Joshua Gross 63c0be55d5 EZ: Make StubViewTree "Delete" logs consistent with other logs
Summary:
See title.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27407771

fbshipit-source-id: 456cdeb65ab02d6e0ea61aa5e7cce288466e2cf5
2021-03-31 21:33:04 -07:00
Joshua Gross 4ae1a9bea8 Do not check consistency of updated Virtual views
Summary:
This impacts Android only. It's not high-impact to check the consistency of these views and they can become "inconsistent" easily in a way that is not interesting or useful to us,
since we handle "virtual" views differently on the platform.

The need for these hacks should go away in the future if/when we account for virtual views in the differ, and stop sending redundant instructions entirely.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27407779

fbshipit-source-id: 01a7ea5106ed5d94b908de03a6a710cc6275018d
2021-03-31 21:33:04 -07:00
Joshua Gross 2aee39cdc1 StubViewTree: log more information before UPDATE assertion failure
Summary:
Log more diagnostics about this assertion failure.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D27407775

fbshipit-source-id: 7f00215b8b2c0ad7378c5671f3b503daf56b9fd2
2021-03-29 20:29:36 -07:00
Joshua Gross 7ac5d48341 Generalize "isVirtualView" logic to make debug asserts consistent with platform
Summary:
On Android we have the notion of "virtual views", which are defined consistently but the logic is scattered and duplicated throughout the codebase.

The logic exists to mark nodes that exist in the ShadowTree, but not the View tree. We want to CREATE, UPDATE, and DELETE them on the platform, but not INSERT or REMOVE
them. They basically exist as EventEmitter objects.

The only issue with this is (1) duplicated code, which opened the possibility for inconsistent definition (2) StubViewTree did not account for virtualized views, which caused
assert crashes in debug mode for certain LayoutAnimations on Android.

By moving the definition to ShadowViewMutation and accounting for it in StubViewTree, asserts are correct and consistent on all platforms.

This was not caught until recently, because, until recently, no asserts actually ran on Android.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27001199

fbshipit-source-id: eb29085317037ba8a286d7813bdd57095ad4746f
2021-03-15 13:50:56 -07:00
Joshua Gross b88ec8b144 Format StubViewTree logs to be closer to other logs
Summary:
Debug logs should wrap React Tags in square brackets.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27001202

fbshipit-source-id: 32fca9d0e1467a515ca3d9d1a3e24a35c23120db
2021-03-12 09:33:24 -08:00
Joshua Gross 1fe5cac52a Remove custom STUB_VIEW_ASSERT in favor of react_native_assert
Summary:
We have a custom STUB_VIEW_ASSERT that helps debugging stub view issues on platforms (like iOS) where flushing logs around assert-time isn't 100% guaranteed.

Move that logic into react_native_assert since it's generally useful.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26567218

fbshipit-source-id: 79f5ae66fc65a0af48dbcf4c7204ac8245911cb0
2021-02-20 20:08:02 -08:00
Joshua Gross b3930f935f Convert most Fabric Cxx code to use react_native_assert instead of assert
Summary:
See react_native_assert.{h,cpp}. Because of the BUCK+Android issue where NDEBUG is always defined, we use react_native_assert instead of assert to enable xplat asserts in debug/dev mode.

This migrates most of the codebase, but probably not 100%. The goal is to increase assertion coverage on Android, not to get to 100% (yet).

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D26562866

fbshipit-source-id: a7bf2055b973e1d3650ed8d68a6d02d556604af9
2021-02-19 20:52:52 -08:00
Joshua Gross fb1833eede Consolidate various debug-only flags into flags.h (#30988)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/30988

We have a bunch of flags scattered throughout the codebase with poor hygiene and commenting. Consolidate.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26392518

fbshipit-source-id: 2823de123a5009d6b8c358e8a3f451b9fa0e05b7
2021-02-17 18:00:47 -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 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
Valentin Shergin 5d4514b492 Fabric: Small improvements in StubViewTree for more easier testing
Summary:
Added a couple of simple methods for quering view information.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D25562530

fbshipit-source-id: 697bea8d87c21d72475fb4896af3215f9279f34b
2020-12-15 11:45:45 -08:00
Samuel Susla 5677d812aa Disable assert in StubViewTree until it is resolved
Summary:
Changelog: [internal]

The assert is still firing, let's disable it until we can investigate why layout animations creates two delete mount instructions.

Reviewed By: majak

Differential Revision: D25216794

fbshipit-source-id: 6328a2afb5eaf7fceebdc05bc75804f2eb44ddd2
2020-11-30 07:55:13 -08:00
Joshua Gross 5bd5fcdd38 LayoutAnimations: ensure that all mutations retain the correct "old" node
Summary:
The current implementation of LayoutAnimations assumed that the "previous/old" ShadowView passed into the diff mutation didn't matter except for purposes of diffing.

As it turns out, iOS components could possibly use the "old" version of props, state, etc - so we should try to keep track of the current value in the tree as much as possible.

This diff accomplishes that by keeping track of the "previous" view, which the AnimationDriver will update over time. This also allows us to simplify logic around conflicting animations.

I'm also adding a few additional asserts to assist in debugging.

This doesn't totally eliminate all asserts hit on iOS, yet, but it does reduce the number of times the asserts are hit in StubViewTree.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D25048644

fbshipit-source-id: d00aeece5af04624d8193063be453c7ce4a6e565
2020-11-19 14:53:23 -08:00
Samuel Susla 5af6a44de3 Back out "Back out "[RN] Fabric: Strengthening StubView mutating validation""
Summary:
Changelog: [internal]

Original commit changeset: b6109a45f153

Reviewed By: JoshuaGross

Differential Revision: D25020497

fbshipit-source-id: c52d5ad03dd1049ac66ecb2d82b5018a05bb4f19
2020-11-19 11:57:55 -08:00
Samuel Susla 53862a1b5a Back out "Fabric: Strengthening StubView mutating validation"
Summary:
Changelog: [internal]

Original commit changeset: 8c8a3d8e205c

Reviewed By: ShikaSD

Differential Revision: D24951341

fbshipit-source-id: b6109a45f1537a9edc702eafac1736e801fbedc9
2020-11-13 08:50:52 -08:00
Valentin Shergin 97a4598bab Fabric: Strengthening StubView mutating validation
Summary:
This diff adds more enforcement for consistency of `ShadowNodeMutation`s, including:
* `Props` object for newly created or updated view must not be nullptr;
* `oldShadowView` must describe the previous state of the view for `Update` instruction;
* `ignoreDuplicateCreates` option was removed.

I suspect some of the crashes we see in Fabric are caused by a violation of one of these constraints. If one of these fails in debug builds, we will get an early signal.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D24880821

fbshipit-source-id: 8c8a3d8e205ce34f6e0335e8a2b0cf676930c284
2020-11-11 10:56:27 -08:00
Joshua Gross f40cdcdfe7 LayoutAnimations: remove "ConsecutiveMetadata" adjustment concept, adjust immediate and delayed mutation indices at the same time
Summary:
Index adjustment is tricky. Seems more reliable to adjust each immediate mutation, and then immediately adjust delayed mutations based on it, rinse and repeat.

Previously it was possible to construct examples where the UI would get into a weird state because index adjustment caused items to be inserted in the wrong location.

Changelog: [Internal]

Reviewed By: kacieb

Differential Revision: D24232926

fbshipit-source-id: f8c445213528c2d2aedacf3e0c73c5bbeb62bc3d
2020-10-09 19:02:19 -07:00
Joshua Gross e1b63ae17e Add additional logging and asserts to StubViewTree
Summary:
Helps in testing LayoutAnimations or differ changes.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23797890

fbshipit-source-id: 1e612c04f9fbb256f2ace8a4a2ed9a477b4695a1
2020-09-20 14:54:00 -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
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
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