Skip to content

Commit 83405ff

Browse files
ayc1facebook-github-bot
authored andcommittedNov 14, 2018
Fix crash when releasing RN views
Summary: There are cases where we're trying to drop a view that is not associated with a ViewManager. This is likely caused by race conditions that can occur if we're dropping a view from JS (when it's no longer used) but at the same time dropping it from native (when layout animation ends, when the rootview gets unmounted). In either of those cases, it should be safe to ignore the drop operation because the view was likely dropped already. Reviewed By: mdvacca Differential Revision: D13036643 fbshipit-source-id: 260ffb56d32a0d670ad08f449b8df165b2533195
1 parent 9b781bd commit 83405ff

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
 

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

+5
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,11 @@ protected synchronized final void addRootViewGroup(
562562
*/
563563
protected synchronized void dropView(View view) {
564564
UiThreadUtil.assertOnUiThread();
565+
if (mTagsToViewManagers.get(view.getId()) == null) {
566+
// This view has already been dropped (likely due to a threading issue caused by async js
567+
// execution). Ignore this drop operation.
568+
return;
569+
}
565570
if (!mRootTags.get(view.getId())) {
566571
// For non-root views we notify viewmanager with {@link ViewManager#onDropInstance}
567572
resolveViewManager(view.getId()).onDropViewInstance(view);

0 commit comments

Comments
 (0)
Please sign in to comment.