Skip to content

Commit b649fa9

Browse files
ayc1facebook-github-bot
authored andcommittedNov 14, 2018
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
1 parent 56a416e commit b649fa9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎ReactAndroid/src/main/java/com/facebook/react/uimanager/ShadowNodeRegistry.java

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import android.util.SparseArray;
1111
import android.util.SparseBooleanArray;
12+
import android.view.View;
1213
import com.facebook.react.common.SingleThreadAsserter;
1314

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

3738
public void removeRootNode(int tag) {
3839
mThreadAsserter.assertNow();
40+
if (tag == View.NO_ID) {
41+
// This root node has already been removed (likely due to a threading issue caused by async js
42+
// execution). Ignore this root removal.
43+
return;
44+
}
3945
if (!mRootTags.get(tag)) {
4046
throw new IllegalViewOperationException(
4147
"View with tag " + tag + " is not registered as a root view");

0 commit comments

Comments
 (0)
Please sign in to comment.