Don't resolve root parent when dropping a view in Nodes

Summary:
In Nodes, we added logic when we dropped a view to also pass the
parent, so we could tell the parent that \"hey, this view is now dropped\"
so that it can be released. While this is fine, there are some crashes due
to the fact that the root node is not being found when we drop the child.

I've spent a lot of time thinking about how this could happen, and the only
plausible explanation I can come up with is that we first detach all views
from the root, then drop the root, and then drop one of the children that
was detached. I can't think of a good way why this would happen.

In the interest of protecting from this crash, this patch adds a check as to
whether or not the id of the parent is that of a root id, and, if so, it
doesn't run the logic that tells this view that this view was removed.

This should be safe, because the root most view should not have clipping
enabled (since it's a vanilla view group as opposed to a scrolling view).

Reviewed By: sriramramani

Differential Revision: D3991682
This commit is contained in:
Ahmed El-Helw 2016-10-07 18:39:12 -07:00
parent ab5de9b9ae
commit f038ef4e0d
1 changed files with 2 additions and 1 deletions

View File

@ -377,7 +377,8 @@ public class FlatUIImplementation extends UIImplementation {
while (tmpNode != null) {
if (tmpNode instanceof FlatShadowNode) {
FlatShadowNode flatTmpNode = (FlatShadowNode) tmpNode;
if (flatTmpNode.mountsToView() && flatTmpNode.isBackingViewCreated()) {
if (flatTmpNode.mountsToView() && flatTmpNode.isBackingViewCreated() &&
flatTmpNode.getParent() != null) {
tag = flatTmpNode.getReactTag();
break;
}