diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.java index 953649288c239a..a1515559cd1642 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.java @@ -11,6 +11,7 @@ import com.facebook.react.bridge.LifecycleEventListener; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.UiThreadUtil; +import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.modules.core.ReactChoreographer; import com.facebook.react.uimanager.common.UIManagerType; import com.facebook.systrace.Systrace; @@ -84,7 +85,9 @@ public void removeBatchEventDispatchedListener(BatchEventDispatchedListener list @Override public void onHostResume() { - maybePostFrameCallbackFromNonUI(); + if (!ReactFeatureFlags.enableOnDemandReactChoreographer) { + maybePostFrameCallbackFromNonUI(); + } } @Override @@ -94,17 +97,21 @@ public void onHostPause() { @Override public void onHostDestroy() { - stopFrameCallback(); + if (!ReactFeatureFlags.enableOnDemandReactChoreographer) { + stopFrameCallback(); + } } public void onCatalystInstanceDestroyed() { - UiThreadUtil.runOnUiThread( - new Runnable() { - @Override - public void run() { - stopFrameCallback(); - } - }); + if (!ReactFeatureFlags.enableOnDemandReactChoreographer) { + UiThreadUtil.runOnUiThread( + new Runnable() { + @Override + public void run() { + stopFrameCallback(); + } + }); + } } private void stopFrameCallback() { @@ -133,7 +140,7 @@ private class ScheduleDispatchFrameCallback implements Choreographer.FrameCallba public void doFrame(long frameTimeNanos) { UiThreadUtil.assertOnUiThread(); - if (mShouldStop) { + if (ReactFeatureFlags.enableOnDemandReactChoreographer || mShouldStop) { mIsPosted = false; } else { post();