Skip to content

Commit 1bdd2a0

Browse files
cortinicometa-codesync[bot]
authored andcommitted
Remove unnecessary OnBatchCompleteListener (#54685)
Summary: Pull Request resolved: #54685 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 Reviewed By: javache Differential Revision: D87866148 fbshipit-source-id: 49212da16509c8012faaf69152ca6be6990f92e4
1 parent 2b76371 commit 1bdd2a0

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
@@ -958,7 +958,6 @@ public final class com/facebook/react/bridge/NativeModuleRegistry {
958958
public final fun getModule (Ljava/lang/String;)Lcom/facebook/react/bridge/NativeModule;
959959
public final fun hasModule (Ljava/lang/Class;)Z
960960
public final fun hasModule (Ljava/lang/String;)Z
961-
public final fun onBatchComplete ()V
962961
}
963962

964963
public final class com/facebook/react/bridge/NoSuchKeyException : java/lang/RuntimeException {
@@ -4334,7 +4333,7 @@ public final class com/facebook/react/uimanager/UIManagerHelper {
43344333
public static final fun getUIManagerForReactTag (Lcom/facebook/react/bridge/ReactContext;I)Lcom/facebook/react/bridge/UIManager;
43354334
}
43364335

4337-
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 {
4336+
public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/bridge/ReactContextBaseJavaModule, com/facebook/react/bridge/LifecycleEventListener, com/facebook/react/bridge/UIManager {
43384337
public static final field NAME Ljava/lang/String;
43394338
public static final field TAG Ljava/lang/String;
43404339
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/react/uimanager/ViewManagerResolver;I)V
@@ -4369,7 +4368,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
43694368
public fun measure (ILcom/facebook/react/bridge/Callback;)V
43704369
public fun measureInWindow (ILcom/facebook/react/bridge/Callback;)V
43714370
public fun measureLayout (IILcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
4372-
public fun onBatchComplete ()V
43734371
public fun onHostDestroy ()V
43744372
public fun onHostPause ()V
43754373
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
@@ -166,16 +166,6 @@ private static class InstanceCallback {
166166
mOuter = new WeakReference<>(outer);
167167
}
168168

169-
public void onBatchComplete() {
170-
CatalystInstanceImpl impl = mOuter.get();
171-
if (impl != null) {
172-
impl.mNativeModulesQueueThread.runOnQueue(
173-
() -> {
174-
impl.mNativeModuleRegistry.onBatchComplete();
175-
});
176-
}
177-
}
178-
179169
public void incrementPendingJSCalls() {
180170
CatalystInstanceImpl impl = mOuter.get();
181171
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)