Fix flattening/unflattening case on Android

Summary:
There are cases where we Delete+Create a node in the same frame. Practically, the new differ should prevent this, but we don't want to rely on that necessarily.

See comments for further justification on why deleteView can do less work overall.

In reparenting cases, this causes crashes because dropView removes *and deletes* children that shouldn't necessarily be deleted.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D23775453

fbshipit-source-id: c577c5af8c27cfb185d527f0afd8aeb08ee3a5fe
This commit is contained in:
Joshua Gross
2020-09-18 16:35:46 -07:00
committed by Facebook GitHub Bot
parent d8b70b19b3
commit fa44c46e37
@@ -577,13 +577,15 @@ public class MountingManager {
return;
}
View view = viewState.mView;
if (view != null) {
dropView(view, false);
} else {
mTagToViewState.remove(reactTag);
}
// To delete we simply remove the tag from the registry.
// In the past we called dropView here, but we want to rely on either
// (1) the correct set of MountInstructions being sent to the platform
// and/or (2) dropView being called by stopSurface.
// If Views are orphaned at this stage and leaked, it's a problem in
// the differ or LayoutAnimations, not MountingManager.
// Additionally, as documented in `dropView`, we cannot always trust a
// view's children to be up-to-date.
mTagToViewState.remove(reactTag);
}
@UiThread