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
This commit is contained in:
Joshua Gross 2021-04-14 19:47:39 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 0cab4469b2
Коммит 2d7560d7b9
1 изменённых файлов: 41 добавлений и 13 удалений

Просмотреть файл

@ -72,8 +72,7 @@ void StubViewTree::mutate(ShadowViewMutationList const &mutations) {
auto stubView = registry[tag];
if ((ShadowView)(*stubView) != mutation.oldChildShadowView) {
LOG(ERROR)
<< "StubView: ASSERT FAILURE: DELETE mutation assertion failure:
oldChildShadowView doesn't match stubView: ["
<< "StubView: ASSERT FAILURE: DELETE mutation assertion failure: oldChildShadowView doesn't match stubView: ["
<< mutation.oldChildShadowView.tag << "] stub hash: ##"
<< std::hash<ShadowView>{}((ShadowView)*stubView)
<< " old mutation hash: ##"
@ -103,6 +102,11 @@ oldChildShadowView doesn't match stubView: ["
<< "StubView: ASSERT FAILURE: INSERT mutation assertion failure: parentTag not found: ["
<< parentTag << "] inserting child: [" << childTag << "]";
}
if (registry.find(childTag) == registry.end()) {
LOG(ERROR)
<< "StubView: ASSERT FAILURE: INSERT mutation assertion failure: childTag not found: ["
<< parentTag << "] inserting child: [" << childTag << "]";
}
react_native_assert(registry.find(parentTag) != registry.end());
auto parentStubView = registry[parentTag];
react_native_assert(registry.find(childTag) != registry.end());
@ -121,6 +125,7 @@ oldChildShadowView doesn't match stubView: ["
parentStubView->children.begin() + mutation.index, childStubView);
} else {
auto childTag = mutation.newChildShadowView.tag;
react_native_assert(registry.find(childTag) != registry.end());
auto childStubView = registry[childTag];
childStubView->update(mutation.newChildShadowView);
}
@ -147,6 +152,24 @@ oldChildShadowView doesn't match stubView: ["
react_native_assert(parentStubView->children.size() > mutation.index);
react_native_assert(registry.find(childTag) != registry.end());
auto childStubView = registry[childTag];
if ((ShadowView)(*childStubView) != mutation.oldChildShadowView) {
LOG(ERROR)
<< "StubView: ASSERT FAILURE: REMOVE mutation assertion failure: oldChildShadowView doesn't match oldStubView: ["
<< mutation.oldChildShadowView.tag << "] stub hash: ##"
<< std::hash<ShadowView>{}((ShadowView)*childStubView)
<< " old mutation hash: ##"
<< std::hash<ShadowView>{}(mutation.oldChildShadowView);
#ifdef RN_DEBUG_STRING_CONVERTIBLE
LOG(ERROR) << "ChildStubView: "
<< getDebugPropsDescription(
(ShadowView)*childStubView, {});
LOG(ERROR) << "OldChildShadowView: "
<< getDebugPropsDescription(
mutation.oldChildShadowView, {});
#endif
}
react_native_assert(
(ShadowView)(*childStubView) == mutation.oldChildShadowView);
react_native_assert(childStubView->parentTag == parentTag);
STUB_VIEW_LOG({
std::string strChildList = "";
@ -189,7 +212,6 @@ oldChildShadowView doesn't match stubView: ["
registry.find(mutation.newChildShadowView.tag) != registry.end());
auto oldStubView = registry[mutation.newChildShadowView.tag];
react_native_assert(oldStubView->tag != 0);
if (!mutation.mutatedViewIsVirtual()) {
if ((ShadowView)(*oldStubView) != mutation.oldChildShadowView) {
LOG(ERROR)
<< "StubView: ASSERT FAILURE: UPDATE mutation assertion failure: oldChildShadowView doesn't match oldStubView: ["
@ -197,10 +219,16 @@ oldChildShadowView doesn't match stubView: ["
<< std::hash<ShadowView>{}((ShadowView)*oldStubView)
<< " old mutation hash: ##"
<< std::hash<ShadowView>{}(mutation.oldChildShadowView);
#ifdef RN_DEBUG_STRING_CONVERTIBLE
LOG(ERROR) << "OldStubView: "
<< getDebugPropsDescription((ShadowView)*oldStubView, {});
LOG(ERROR) << "OldChildShadowView: "
<< getDebugPropsDescription(
mutation.oldChildShadowView, {});
#endif
}
react_native_assert(
(ShadowView)(*oldStubView) == mutation.oldChildShadowView);
}
oldStubView->update(mutation.newChildShadowView);
// Hash for stub view and the ShadowView should be identical - this