Skip to content

Commit

Permalink
Prevent NPE on ThemedReactContext
Browse files Browse the repository at this point in the history
Summary:
When pre-prerendering a surface without rendering it, "SurfaceMountingManager.getContext()" will return null since no ThemedReactContext is passed into it:
https://www.internalfb.com/code/fbsource/[0f4812c8039d975b3651dfa756d60a882bf8e193]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java?lines=298-317

Changelog:
[Android][Fixed] - Prevent NPE on ThemedReactContext

Reviewed By: ShikaSD

Differential Revision: D31691022

fbshipit-source-id: 4cca6c4550a77075f8fd754dbf21fe5bf5da77e6
  • Loading branch information
luluwu2032 authored and facebook-github-bot committed Oct 17, 2021
1 parent e1b698c commit f1b5fe1
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,11 @@ public boolean getThemeData(int surfaceId, float[] defaultTextInputPadding) {
SurfaceMountingManager surfaceMountingManager =
mMountingManager.getSurfaceManagerEnforced(surfaceId, "getThemeData");
ThemedReactContext themedReactContext = surfaceMountingManager.getContext();

if (themedReactContext == null) {
FLog.w(TAG, "\"themedReactContext\" is null when call \"getThemeData\"");
return false;
}
float[] defaultTextInputPaddingForTheme =
UIManagerHelper.getDefaultTextInputPadding(themedReactContext);
defaultTextInputPadding[0] = defaultTextInputPaddingForTheme[PADDING_START_INDEX];
Expand Down

0 comments on commit f1b5fe1

Please sign in to comment.