From d9eb61648fc8ed6d93edbce7a365b154c267d1d0 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Fri, 22 Nov 2024 12:17:39 -0800 Subject: [PATCH] Guard against surface manager exceptions (#47910) 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] Reviewed By: javache Differential Revision: D66369969 --- .../java/com/facebook/react/fabric/FabricUIManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 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..983763385ad2a0 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,10 +625,10 @@ 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\""); + FLog.w(TAG, "Couldn't get context for surfaceId %d in getThemeData", surfaceId); return false; }