Expose the backend via UIManager

Summary:
### Summary

Exposes the animation backend via UIManager by introducing two new methods: `unstable_setAnimationBackend` and `unstable_getAnimationBackend`. The `NativeAnimatedNodesManagerProvider` is updated to initialize the animation backend using the `useSharedAnimatedBackend` feature flag.

Reviewed By: zeyap

Differential Revision: D81137954
This commit is contained in:
Bartlomiej Bloniarz
2025-09-30 07:18:13 -07:00
committed by Facebook GitHub Bot
parent 41d856c40f
commit 3a7ef613d5
3 changed files with 19 additions and 0 deletions
@@ -66,6 +66,8 @@ NativeAnimatedNodesManagerProvider::getOrCreate(
};
if (ReactNativeFeatureFlags::useSharedAnimatedBackend()) {
// TODO: this should be initialized outside of animated, but for now it
// was convenient to do it here
animationBackend_ = std::make_shared<AnimationBackend>(
std::move(startOnRenderCallback_),
std::move(stopOnRenderCallback_),
@@ -73,6 +75,8 @@ NativeAnimatedNodesManagerProvider::getOrCreate(
nativeAnimatedNodesManager_ =
std::make_shared<NativeAnimatedNodesManager>(animationBackend_);
uiManager->unstable_setAnimationBackend(animationBackend_);
} else {
nativeAnimatedNodesManager_ =
std::make_shared<NativeAnimatedNodesManager>(
@@ -678,6 +678,15 @@ void UIManager::setNativeAnimatedDelegate(
nativeAnimatedDelegate_ = delegate;
}
void UIManager::unstable_setAnimationBackend(
std::weak_ptr<AnimationBackend> animationBackend) {
animationBackend_ = animationBackend;
}
std::weak_ptr<AnimationBackend> UIManager::unstable_getAnimationBackend() {
return animationBackend_;
}
void UIManager::animationTick() const {
if (animationDelegate_ != nullptr &&
animationDelegate_->shouldAnimateFrame()) {
@@ -36,6 +36,7 @@ namespace facebook::react {
class UIManagerBinding;
class UIManagerCommitHook;
class UIManagerMountHook;
class AnimationBackend;
class UIManager final : public ShadowTreeDelegate {
public:
@@ -62,6 +63,9 @@ class UIManager final : public ShadowTreeDelegate {
* the pointer before being destroyed.
*/
void setAnimationDelegate(UIManagerAnimationDelegate* delegate);
void unstable_setAnimationBackend(
std::weak_ptr<AnimationBackend> animationBackend);
std::weak_ptr<AnimationBackend> unstable_getAnimationBackend();
/**
* Execute stopSurface on any UIMAnagerAnimationDelegate.
@@ -258,6 +262,8 @@ class UIManager final : public ShadowTreeDelegate {
std::unique_ptr<LazyShadowTreeRevisionConsistencyManager>
lazyShadowTreeRevisionConsistencyManager_;
std::weak_ptr<AnimationBackend> animationBackend_;
};
} // namespace facebook::react