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 facebook-github-bot committed Nov 14, 2018
1 parent 9b781bd commit 83405ff
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,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 83405ff

Please sign in to comment.