Browse files

Fix crash when removing root nodes

Summary: If a root node is being removed and has an id of NO_ID, it was likely already removed previously, likely due to a race condition caused by RN's async nature. In those cases, let's avoid crashing the app and instead silently ignore the root view removal.

Reviewed By: mdvacca

Differential Revision: D13055140

fbshipit-source-id: ec10f4c79f2ba21614f52f57557f6b3d734c9461
  • Loading branch information...
ayc1 authored and facebook-github-bot committed Nov 14, 2018
1 parent 56a416e commit b649fa96a088a9e8ccbf3f979ebfa4a5e28a066f
Showing with 6 additions and 0 deletions.
  1. +6 −0 ReactAndroid/src/main/java/com/facebook/react/uimanager/
@@ -9,6 +9,7 @@

import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.view.View;
import com.facebook.react.common.SingleThreadAsserter;

@@ -36,6 +37,11 @@ public void addRootNode(ReactShadowNode node) {

public void removeRootNode(int tag) {
if (tag == View.NO_ID) {
// This root node has already been removed (likely due to a threading issue caused by async js
// execution). Ignore this root removal.
if (!mRootTags.get(tag)) {
throw new IllegalViewOperationException(
"View with tag " + tag + " is not registered as a root view");

0 comments on commit b649fa9

Please sign in to comment.