Skip to content

Commit

Permalink
Fix crash when releasing RN views
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ayc1 authored and kelset committed Nov 26, 2018
1 parent 5ba44f7 commit de3711e
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -563,6 +563,11 @@ protected synchronized final void addRootViewGroup(
*/
protected synchronized void dropView(View view) {
UiThreadUtil.assertOnUiThread();
if (mTagsToViewManagers.get(view.getId()) == null) {
// This view has already been dropped (likely due to a threading issue caused by async js
// execution). Ignore this drop operation.
return;
}
if (!mRootTags.get(view.getId())) {
// For non-root views we notify viewmanager with {@link ViewManager#onDropInstance}
resolveViewManager(view.getId()).onDropViewInstance(view);
Expand Down

0 comments on commit de3711e

Please sign in to comment.