Skip to content

Commit b554232

Browse files
cortinicofacebook-github-bot
authored andcommitted
Remove unnecessary OnBatchCompleteListener (#54685)
Summary: This interface is no longer necessary. It was used in legacy arch to communicate between `UIManagerModule` and `NativeModuleRegistry` This interface was public so I'm marking this as breaking, but I was not able to find any usage in OSS for this interface. Changelog: [Android] [Removed] - Remove unnecessary `OnBatchCompleteListener` used in Legacy Architecture Differential Revision: D87866148
1 parent b34e9c5 commit b554232

File tree

5 files changed

+2
-90
lines changed

5 files changed

+2
-90
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,6 @@ public final class com/facebook/react/bridge/NativeModuleRegistry {
959959
public final fun getModule (Ljava/lang/String;)Lcom/facebook/react/bridge/NativeModule;
960960
public final fun hasModule (Ljava/lang/Class;)Z
961961
public final fun hasModule (Ljava/lang/String;)Z
962-
public final fun onBatchComplete ()V
963962
}
964963

965964
public final class com/facebook/react/bridge/NoSuchKeyException : java/lang/RuntimeException {
@@ -4341,7 +4340,7 @@ public final class com/facebook/react/uimanager/UIManagerHelper {
43414340
public static final fun getUIManagerForReactTag (Lcom/facebook/react/bridge/ReactContext;I)Lcom/facebook/react/bridge/UIManager;
43424341
}
43434342

4344-
public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/bridge/ReactContextBaseJavaModule, com/facebook/react/bridge/LifecycleEventListener, com/facebook/react/bridge/OnBatchCompleteListener, com/facebook/react/bridge/UIManager {
4343+
public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/bridge/ReactContextBaseJavaModule, com/facebook/react/bridge/LifecycleEventListener, com/facebook/react/bridge/UIManager {
43454344
public static final field NAME Ljava/lang/String;
43464345
public static final field TAG Ljava/lang/String;
43474346
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/react/uimanager/ViewManagerResolver;I)V
@@ -4376,7 +4375,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
43764375
public fun measure (ILcom/facebook/react/bridge/Callback;)V
43774376
public fun measureInWindow (ILcom/facebook/react/bridge/Callback;)V
43784377
public fun measureLayout (IILcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
4379-
public fun onBatchComplete ()V
43804378
public fun onHostDestroy ()V
43814379
public fun onHostPause ()V
43824380
public fun onHostResume ()V

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,6 @@ private static class InstanceCallback {
172172
mOuter = new WeakReference<>(outer);
173173
}
174174

175-
public void onBatchComplete() {
176-
CatalystInstanceImpl impl = mOuter.get();
177-
if (impl != null) {
178-
impl.mNativeModulesQueueThread.runOnQueue(
179-
() -> {
180-
impl.mNativeModuleRegistry.onBatchComplete();
181-
});
182-
}
183-
}
184-
185175
public void incrementPendingJSCalls() {
186176
CatalystInstanceImpl impl = mOuter.get();
187177
if (impl != null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.kt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,6 @@ public class NativeModuleRegistry(
9494
}
9595
}
9696

97-
public fun onBatchComplete() {
98-
// The only native module that uses the onBatchComplete is the UI Manager. Hence, instead of
99-
// iterating over all the modules for find this one instance, and then calling it, we
100-
// short-circuit
101-
// the search, and simply call OnBatchComplete on the UI Manager.
102-
// With Fabric, UIManager would no longer be a NativeModule, so this call would simply go away
103-
assertLegacyArchitecture(
104-
"NativeModuleRegistry.onBatchComplete()",
105-
LegacyArchitectureLogLevel.WARNING,
106-
)
107-
modules["UIManager"]?.let {
108-
if (it.hasInstance()) {
109-
(it.module as OnBatchCompleteListener).onBatchComplete()
110-
}
111-
}
112-
}
113-
11497
public fun <T : NativeModule> hasModule(moduleInterface: Class<T>): Boolean {
11598
val annotation = moduleInterface.getAnnotation(ReactModule::class.java)
11699
requireNotNull(annotation) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/OnBatchCompleteListener.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.facebook.react.bridge.Dynamic;
2626
import com.facebook.react.bridge.GuardedRunnable;
2727
import com.facebook.react.bridge.LifecycleEventListener;
28-
import com.facebook.react.bridge.OnBatchCompleteListener;
2928
import com.facebook.react.bridge.ReactApplicationContext;
3029
import com.facebook.react.bridge.ReactContextBaseJavaModule;
3130
import com.facebook.react.bridge.ReactMarker;
@@ -89,7 +88,7 @@
8988
@Deprecated(
9089
since = "This class is part of Legacy Architecture and will be removed in a future release")
9190
public class UIManagerModule extends ReactContextBaseJavaModule
92-
implements OnBatchCompleteListener, LifecycleEventListener, UIManager {
91+
implements LifecycleEventListener, UIManager {
9392
static {
9493
LegacyArchitectureLogger.assertLegacyArchitecture(
9594
"UIManagerModule", LegacyArchitectureLogLevel.ERROR);
@@ -661,43 +660,6 @@ public void configureNextLayoutAnimation(ReadableMap config, Callback success, C
661660
mUIImplementation.configureNextLayoutAnimation(config, success);
662661
}
663662

664-
/**
665-
* To implement the transactional requirement mentioned in the class javadoc, we only commit UI
666-
* changes to the actual view hierarchy once a batch of JS->Java calls have been completed. We
667-
* know this is safe because all JS->Java calls that are triggered by a Java->JS call (e.g. the
668-
* delivery of a touch event or execution of 'renderApplication') end up in a single JS->Java
669-
* transaction.
670-
*
671-
* <p>A better way to do this would be to have JS explicitly signal to this module when a UI
672-
* transaction is done. Right now, though, this is how iOS does it, and we should probably update
673-
* the JS and native code and make this change at the same time.
674-
*
675-
* <p>TODO(5279396): Make JS UI library explicitly notify the native UI module of the end of a UI
676-
* transaction using a standard native call
677-
*/
678-
@Override
679-
public void onBatchComplete() {
680-
int batchId = mBatchId;
681-
mBatchId++;
682-
683-
SystraceMessage.beginSection(Systrace.TRACE_TAG_REACT, "onBatchCompleteUI")
684-
.arg("BatchId", batchId)
685-
.flush();
686-
for (UIManagerListener listener : mUIManagerListeners) {
687-
listener.willDispatchViewUpdates(this);
688-
}
689-
try {
690-
// If there are no RootViews registered, there will be no View updates to dispatch.
691-
// This is a hack to prevent this from being called when Fabric is used everywhere.
692-
// This should no longer be necessary in Bridgeless Mode.
693-
if (mUIImplementation.getRootViewNum() > 0) {
694-
mUIImplementation.dispatchViewUpdates(batchId);
695-
}
696-
} finally {
697-
Systrace.endSection(Systrace.TRACE_TAG_REACT);
698-
}
699-
}
700-
701663
@Override
702664
public EventDispatcher getEventDispatcher() {
703665
return mEventDispatcher;

0 commit comments

Comments
 (0)