From f038ef4e0dd3629bd0eb6ff72d2e4c3a99091fe7 Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Fri, 7 Oct 2016 18:39:12 -0700 Subject: [PATCH] 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 --- .../java/com/facebook/react/flat/FlatUIImplementation.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java index 753cb88b9..be4fb1c42 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java @@ -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; }