From 1db253c438f1fa29734617128364323331ddeb8e Mon Sep 17 00:00:00 2001 From: Gijs Weterings <gweterings@meta.com> Date: Wed, 9 Apr 2025 02:38:39 -0700 Subject: [PATCH] Apply Nullsafe FIXMEs for xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java (#50359) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50359 Added nullsafe FIXMEs for easier reviewing of next diff, where we fix them Changelog: [Internal] Reviewed By: javache Differential Revision: D71979578 --- .../react/fabric/mounting/SurfaceMountingManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index 12d726ab9f3f18..2228c641f20980 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -90,6 +90,7 @@ public class SurfaceMountingManager { private final Set<Integer> mViewsToDeleteAfterTouchFinishes = new HashSet<>(); // This is null *until* StopSurface is called. + // NULLSAFE_FIXME[Field Not Initialized] private SparseArrayCompat<Object> mTagSetForStoppedSurface; private final int mSurfaceId; @@ -315,9 +316,13 @@ public void stopSurface() { // Evict all views from cache and memory // TODO: clear instead of nulling out to simplify null-safety in this class + // NULLSAFE_FIXME[Field Not Nullable] mTagToViewState = null; + // NULLSAFE_FIXME[Field Not Nullable] mJSResponderHandler = null; + // NULLSAFE_FIXME[Field Not Nullable] mRootViewManager = null; + // NULLSAFE_FIXME[Field Not Nullable] mMountItemExecutor = null; mThemedReactContext = null; mOnViewAttachMountItems.clear(); @@ -659,6 +664,7 @@ public void createViewUnsafe( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "SurfaceMountingManager::createViewUnsafe(" + componentName + ")"); try { + // NULLSAFE_FIXME[Parameter Not Nullable] ReactStylesDiffMap propMap = new ReactStylesDiffMap(props); ViewState viewState = new ViewState(reactTag); @@ -672,6 +678,7 @@ public void createViewUnsafe( // View Managers are responsible for dealing with inital state and props. viewState.mView = viewManager.createView( + // NULLSAFE_FIXME[Parameter Not Nullable] reactTag, mThemedReactContext, propMap, stateWrapper, mJSResponderHandler); viewState.mViewManager = viewManager; } @@ -930,8 +937,10 @@ public void updateState(final int reactTag, @Nullable StateWrapper stateWrapper) throw new IllegalStateException("Unable to find ViewManager for tag: " + reactTag); } Object extraData = + // NULLSAFE_FIXME[Parameter Not Nullable] viewManager.updateState(viewState.mView, viewState.mCurrentProps, stateWrapper); if (extraData != null) { + // NULLSAFE_FIXME[Parameter Not Nullable] viewManager.updateExtraData(viewState.mView, extraData); } @@ -1026,6 +1035,7 @@ private void onViewStateDeleted(ViewState viewState) { // For non-root views we notify viewmanager with {@link ViewManager#onDropInstance} ViewManager viewManager = viewState.mViewManager; if (!viewState.mIsRoot && viewManager != null) { + // NULLSAFE_FIXME[Parameter Not Nullable] viewManager.onDropViewInstance(viewState.mView); } }