Backout - Schedule a Choreographer callback only if there is ongoing animation

Summary: caused performace problems with react app

Reviewed By: gpalves

Differential Revision: D51617862

fbshipit-source-id: 38c0c06dacdd7aa862fd523a7ce136e54ed55fa2
This commit is contained in:
Nicholas Block
2023-11-28 08:57:23 -08:00
committed by Facebook GitHub Bot
parent a8fc20616f
commit 528f97152b
@@ -25,7 +25,6 @@ import com.facebook.react.bridge.UIManager;
import com.facebook.react.bridge.UIManagerListener;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.core.ReactChoreographer;
import com.facebook.react.uimanager.GuardedFrameCallback;
@@ -248,13 +247,14 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec
return;
}
if (!ReactFeatureFlags.enableOnDemandReactChoreographer
|| nodesManager != null && nodesManager.hasActiveAnimations()) {
Assertions.assertNotNull(mReactChoreographer)
.postFrameCallback(
ReactChoreographer.CallbackType.NATIVE_ANIMATED_MODULE,
mAnimatedFrameCallback);
}
// TODO: Would be great to avoid adding this callback in case there are no active
// animations and no outstanding tasks on the operations queue. Apparently frame
// callbacks can only be posted from the UI thread and therefore we cannot schedule
// them directly from other threads.
Assertions.assertNotNull(mReactChoreographer)
.postFrameCallback(
ReactChoreographer.CallbackType.NATIVE_ANIMATED_MODULE,
mAnimatedFrameCallback);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
@@ -1116,7 +1116,6 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec
opsAndArgs.getInt(i++), opsAndArgs.getInt(i++));
break;
case OP_CODE_START_ANIMATING_NODE:
enqueueFrameCallback();
animatedNodesManager.startAnimatingNode(
opsAndArgs.getInt(i++), opsAndArgs.getInt(i++), opsAndArgs.getMap(i++), null);
break;