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 51be066ce2f..b3ef0937492 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -188,7 +188,7 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { ThemedReactContext reactContext = new ThemedReactContext( - mReactApplicationContext, rootView.getContext(), reactRootView.getSurfaceID()); + mReactApplicationContext, rootView.getContext(), reactRootView.getSurfaceID(), rootTag); mMountingManager.startSurface(rootTag, rootView, reactContext); String moduleName = reactRootView.getJSModuleName(); if (ENABLE_FABRIC_LOGS) { @@ -220,7 +220,7 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { final int rootTag = ReactRootViewTagGenerator.getNextRootViewTag(); Context context = rootView.getContext(); ThemedReactContext reactContext = - new ThemedReactContext(mReactApplicationContext, context, moduleName); + new ThemedReactContext(mReactApplicationContext, context, moduleName, rootTag); if (ENABLE_FABRIC_LOGS) { FLog.d(TAG, "Starting surface for module: %s and reactTag: %d", moduleName, rootTag); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java index 834208a962e..15701d63618 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.java @@ -27,20 +27,32 @@ import com.facebook.react.bridge.ReactContext; public class ThemedReactContext extends ReactContext { private final ReactApplicationContext mReactApplicationContext; - @Nullable private final String mSurfaceID; + @Nullable private final String mModuleName; + private final int mSurfaceId; + @Deprecated public ThemedReactContext(ReactApplicationContext reactApplicationContext, Context base) { - this(reactApplicationContext, base, null); + this(reactApplicationContext, base, null, -1); + } + + @Deprecated + public ThemedReactContext( + ReactApplicationContext reactApplicationContext, Context base, @Nullable String moduleName) { + this(reactApplicationContext, base, moduleName, -1); } public ThemedReactContext( - ReactApplicationContext reactApplicationContext, Context base, @Nullable String surfaceID) { + ReactApplicationContext reactApplicationContext, + Context base, + @Nullable String moduleName, + int surfaceId) { super(base); if (reactApplicationContext.hasCatalystInstance()) { initializeWithInstance(reactApplicationContext.getCatalystInstance()); } mReactApplicationContext = reactApplicationContext; - mSurfaceID = surfaceID; + mModuleName = moduleName; + mSurfaceId = surfaceId; } @Override @@ -64,11 +76,27 @@ public class ThemedReactContext extends ReactContext { } /** - * @return a {@link String} that represents the ID of the js application that is being rendered - * with this {@link ThemedReactContext} + * This is misnamed but has some uses out in the wild. It will be deleted in a future release of + * RN. + * + * @return a {@link String} that represents the module name of the js application that is being + * rendered with this {@link ThemedReactContext} */ + @Deprecated public @Nullable String getSurfaceID() { - return mSurfaceID; + return mModuleName; + } + + /** + * @return a {@link String} that represents the module name of the js application that is being + * rendered with this {@link ThemedReactContext} + */ + public @Nullable String getModuleName() { + return mModuleName; + } + + public int getSurfaceId() { + return mSurfaceId; } public ReactApplicationContext getReactApplicationContext() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 324885a494e..5c1383d0e17 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -451,9 +451,14 @@ public class UIManagerModule extends ReactContextBaseJavaModule Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIManagerModule.addRootView"); final int tag = ReactRootViewTagGenerator.getNextRootViewTag(); final ReactApplicationContext reactApplicationContext = getReactApplicationContext(); + + // We pass in a surfaceId of -1 here - it is used only in Fabric. final ThemedReactContext themedRootContext = new ThemedReactContext( - reactApplicationContext, rootView.getContext(), ((ReactRoot) rootView).getSurfaceID()); + reactApplicationContext, + rootView.getContext(), + ((ReactRoot) rootView).getSurfaceID(), + -1); mUIImplementation.registerRootView(rootView, tag, themedRootContext); Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactCallerContextFactory.java b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactCallerContextFactory.java index 46e9573fdb0..cb1c6a33604 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactCallerContextFactory.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactCallerContextFactory.java @@ -20,9 +20,9 @@ public interface ReactCallerContextFactory { /** * This method will be called at the time {@link ReactImageManager} creates {@link ReactImageView} * - * @param surfaceID {@link String} used to log the name of the surface + * @param surfaceName {@link String} used to log the name of the surface * @return an {@link Object} that represents the CallerContext. */ @Nullable - Object getOrCreateCallerContext(@Nullable String surfaceID, @Nullable String analyticTag); + Object getOrCreateCallerContext(@Nullable String surfaceName, @Nullable String analyticTag); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java index 397a8378d60..d1250c7563f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageManager.java @@ -107,7 +107,7 @@ public class ReactImageManager extends SimpleViewManager { public ReactImageView createViewInstance(ThemedReactContext context) { Object callerContext = mCallerContextFactory != null - ? mCallerContextFactory.getOrCreateCallerContext(context.getSurfaceID(), null) + ? mCallerContextFactory.getOrCreateCallerContext(context.getModuleName(), null) : getCallerContext(); return new ReactImageView( context, getDraweeControllerBuilder(), mGlobalImageLoadListener, callerContext); @@ -129,7 +129,7 @@ public class ReactImageManager extends SimpleViewManager { if (mCallerContextFactory != null) { view.updateCallerContext( mCallerContextFactory.getOrCreateCallerContext( - ((ThemedReactContext) view.getContext()).getSurfaceID(), analyticTag)); + ((ThemedReactContext) view.getContext()).getModuleName(), analyticTag)); } }