From 4c04106d620456cc563ce6f5031566594a8893b4 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Fri, 22 Nov 2024 11:31:56 -0800 Subject: [PATCH] Guard against surface manager exceptions Summary: It seems there could be a race where a commit is being processed on the JS thread after the surface has been removed from the mounting manager. Since we don't actually need to retrieve the default paddings in these cases, there's no reason we need an enforced read of the SurfaceMountingManager. ## Changelog [Internal] Differential Revision: D66369969 --- .../main/java/com/facebook/react/fabric/FabricUIManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 8ad955bc966e4c..4dc381c1d9f1fa 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -625,8 +625,8 @@ private long measureMapBuffer( * @return if theme data is available in the output parameters. */ public boolean getThemeData(int surfaceId, float[] defaultTextInputPadding) { - Context context = - mMountingManager.getSurfaceManagerEnforced(surfaceId, "getThemeData").getContext(); + SurfaceMountingManager surfaceMountingManager = mMountingManager.getSurfaceManager(surfaceId); + Context context = surfaceMountingManager != null ? surfaceMountingManager.getContext() : null; if (context == null) { FLog.w(TAG, "\"themedReactContext\" is null when call \"getThemeData\""); return false;