From e81029179062a5135c9f3db6f2cbdb29b82f741f Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Tue, 16 Feb 2021 14:45:57 -0800 Subject: [PATCH] Subtle stopSurface lifecycle change Summary: Change lifecycle of stopSurface in a subtle way: mark the surface as stopped in Java first, then in Cxx (currently it happens in Cxx, then Java). This will cause us / allow us to ignore the final mounting instructions for the Surface, which are all irrelevant since they just have to do with View removal. We can rely on GC and `unmountReactApplication` to do all of this for us, and save some CPU cycles on stopSurface. Changelog: [Internal] Reviewed By: shergin Differential Revision: D26469741 fbshipit-source-id: a7f81d44c3cb2138f0ab31feb38852910410c638 --- .../java/com/facebook/react/fabric/FabricUIManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 fdbed90e7fa..ae5a01fcf68 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -280,8 +280,13 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { @ThreadConfined(ANY) @Override public void stopSurface(final int surfaceID) { - mBinding.stopSurface(surfaceID); + // Mark surfaceId as dead, stop executing mounting instructions mMountingManager.stopSurface(surfaceID); + + // Communicate stopSurface to Cxx - causes an empty ShadowTree to be committed, + // but all mounting instructions will be ignored because stopSurface was called + // on the MountingManager + mBinding.stopSurface(surfaceID); } @Override