From 68126ed470f59d519dd2e81d66ee1fbcb565d32c Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 12 Nov 2020 15:52:41 -0800 Subject: [PATCH] Skip execution of IntBufferBatchMountItem if surface has stopped Summary: Fixes crashes in surface teardown / navigating away from a surface. Changelog: [Internal] Reviewed By: shergin Differential Revision: D24907216 fbshipit-source-id: 7bd7578c81687c7e64e8f70fecf8446bb333a1ed --- .../com/facebook/react/fabric/FabricUIManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index a61694b67c2..f769f708f43 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -968,6 +968,16 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { } } + // Make sure surface associated with this MountItem has been started, and not stopped. + // TODO T68118357: clean up this logic and simplify this method overall + if (mountItem instanceof IntBufferBatchMountItem) { + IntBufferBatchMountItem batchMountItem = (IntBufferBatchMountItem) mountItem; + if (!surfaceActiveForExecution( + batchMountItem.getRootTag(), "dispatchMountItems IntBufferBatchMountItem")) { + continue; + } + } + mountItem.execute(mMountingManager); } catch (Throwable e) { // If there's an exception, we want to log diagnostics in prod and rethrow.