Fix modals freezing on close with Nodes

Summary:
Modals were doing nothing (and sometimes crashing) when they were
being closed. The reason for this was due to the fact that the parent being
removed was not necessarily the view's parent. Consequently, trying to inform
said parent that its child was removed failed, because said parent wasn't a
view, and therefore had no record in mViewsToTags.

Reviewed By: sriramramani

Differential Revision: D3928850
This commit is contained in:
Ahmed El-Helw
2016-09-27 13:47:57 -07:00
parent a61766dbac
commit fc10d0d3bf
3 changed files with 43 additions and 14 deletions

View File

@@ -51,7 +51,8 @@ import com.facebook.react.uimanager.events.EventDispatcher;
private final ArrayList<FlatShadowNode> mViewsToDetachAllChildrenFrom = new ArrayList<>();
private final ArrayList<FlatShadowNode> mViewsToDetach = new ArrayList<>();
private final SparseIntArray mViewsToDrop = new SparseIntArray();
private final ArrayList<Integer> mViewsToDrop = new ArrayList<>();
private final ArrayList<Integer> mParentsForViewsToDrop = new ArrayList<>();
private final ArrayList<OnLayoutEvent> mOnLayoutEvents = new ArrayList<>();
private final ArrayList<UIViewOperationQueue.UIOperation> mUpdateViewBoundsOperations =
new ArrayList<>();
@@ -132,8 +133,9 @@ import com.facebook.react.uimanager.events.EventDispatcher;
mOnLayoutEvents.clear();
if (mViewsToDrop.size() > 0) {
mOperationsQueue.enqueueDropViews(mViewsToDrop);
mOperationsQueue.enqueueDropViews(mViewsToDrop, mParentsForViewsToDrop);
mViewsToDrop.clear();
mParentsForViewsToDrop.clear();
}
mOperationsQueue.enqueueProcessLayoutRequests();
@@ -141,7 +143,8 @@ import com.facebook.react.uimanager.events.EventDispatcher;
/* package */ void removeRootView(int rootViewTag) {
// Note root view tags with a negative value.
mViewsToDrop.put(-rootViewTag, -1);
mViewsToDrop.add(-rootViewTag);
mParentsForViewsToDrop.add(-1);
}
/**
@@ -229,7 +232,8 @@ import com.facebook.react.uimanager.events.EventDispatcher;
* @param node The node to drop the backing view for.
*/
/* package */ void dropView(FlatShadowNode node, int parentReactTag) {
mViewsToDrop.put(node.getReactTag(), parentReactTag);
mViewsToDrop.add(node.getReactTag());
mParentsForViewsToDrop.add(parentReactTag);
}
/**