diff --git a/vnext/ReactUWP/Modules/Animated/AnimationDriver.cpp b/vnext/ReactUWP/Modules/Animated/AnimationDriver.cpp index e99f8002376..eea8f212935 100644 --- a/vnext/ReactUWP/Modules/Animated/AnimationDriver.cpp +++ b/vnext/ReactUWP/Modules/Animated/AnimationDriver.cpp @@ -19,6 +19,12 @@ namespace react { }(); } + AnimationDriver::~AnimationDriver() + { + if (m_scopedBatch) + m_scopedBatch.Completed(m_scopedBatchCompletedToken); + } + void AnimationDriver::StartAnimation() { const auto [animation, scopedBatch] = MakeAnimation(m_config); @@ -32,7 +38,7 @@ namespace react { } scopedBatch.End(); - scopedBatch.Completed([endCallback = m_endCallback, animatedValue, id = m_id](auto sender, auto) + m_scopedBatchCompletedToken = scopedBatch.Completed([endCallback = m_endCallback, animatedValue, id = m_id](auto sender, auto) { if (endCallback) { @@ -45,6 +51,7 @@ namespace react { }); m_animation = animation; + m_scopedBatch = scopedBatch; } void AnimationDriver::StopAnimation() diff --git a/vnext/ReactUWP/Modules/Animated/AnimationDriver.h b/vnext/ReactUWP/Modules/Animated/AnimationDriver.h index 35fe867d6ea..fa6400e9941 100644 --- a/vnext/ReactUWP/Modules/Animated/AnimationDriver.h +++ b/vnext/ReactUWP/Modules/Animated/AnimationDriver.h @@ -14,6 +14,7 @@ namespace react { namespace uwp { { public: AnimationDriver(int64_t id, int64_t animatedValueTag, const Callback& endCallback, const folly::dynamic& config, const std::shared_ptr& manager); + virtual ~AnimationDriver(); void StartAnimation(); void StopAnimation(); @@ -35,6 +36,7 @@ namespace react { namespace uwp { std::weak_ptr m_manager{}; winrt::Windows::UI::Composition::CompositionAnimation m_animation{ nullptr }; + winrt::Windows::UI::Composition::CompositionScopedBatch m_scopedBatch{ nullptr }; //auto revoker for scopedBatch.Completed is broken, tracked by internal bug #22399779 winrt::event_token m_scopedBatchCompletedToken{}; }; diff --git a/vnext/ReactUWP/Modules/Animated/NativeAnimatedNodeManager.cpp b/vnext/ReactUWP/Modules/Animated/NativeAnimatedNodeManager.cpp index 7dbe0608176..a375f017d2f 100644 --- a/vnext/ReactUWP/Modules/Animated/NativeAnimatedNodeManager.cpp +++ b/vnext/ReactUWP/Modules/Animated/NativeAnimatedNodeManager.cpp @@ -39,57 +39,57 @@ namespace react { { case AnimatedNodeType::Style: { - m_styleNodes.emplace(tag, std::make_unique(StyleAnimatedNode(tag, config, manager))); + m_styleNodes.emplace(tag, std::make_unique(tag, config, manager)); break; } case AnimatedNodeType::Value: { - m_valueNodes.emplace(tag, std::make_unique(ValueAnimatedNode(tag, config, manager))); + m_valueNodes.emplace(tag, std::make_unique(tag, config, manager)); break; } case AnimatedNodeType::Props: { - m_propsNodes.emplace(tag, std::make_unique(PropsAnimatedNode(tag, config, instance, manager))); + m_propsNodes.emplace(tag, std::make_unique(tag, config, instance, manager)); break; } case AnimatedNodeType::Interpolation: { - m_valueNodes.emplace(tag, std::make_unique(InterpolationAnimatedNode(tag, config, manager))); + m_valueNodes.emplace(tag, std::make_unique(tag, config, manager)); break; } case AnimatedNodeType::Addition: { - m_valueNodes.emplace(tag, std::make_unique(AdditionAnimatedNode(tag, config, manager))); + m_valueNodes.emplace(tag, std::make_unique(tag, config, manager)); break; } case AnimatedNodeType::Subtraction: { - m_valueNodes.emplace(tag, std::make_unique(SubtractionAnimatedNode(tag, config, manager))); + m_valueNodes.emplace(tag, std::make_unique(tag, config, manager)); break; } case AnimatedNodeType::Division: { - m_valueNodes.emplace(tag, std::make_unique(DivisionAnimatedNode(tag, config, manager))); + m_valueNodes.emplace(tag, std::make_unique(tag, config, manager)); break; } case AnimatedNodeType::Multiplication: { - m_valueNodes.emplace(tag, std::make_unique(MultiplicationAnimatedNode(tag, config, manager))); + m_valueNodes.emplace(tag, std::make_unique(tag, config, manager)); break; } case AnimatedNodeType::Modulus: { - m_valueNodes.emplace(tag, std::make_unique(ModulusAnimatedNode(tag, config, manager))); + m_valueNodes.emplace(tag, std::make_unique(tag, config, manager)); break; } case AnimatedNodeType::Diffclamp: { - m_valueNodes.emplace(tag, std::make_unique(DiffClampAnimatedNode(tag, config, manager))); + m_valueNodes.emplace(tag, std::make_unique(tag, config, manager)); break; } case AnimatedNodeType::Transform: { - m_transformNodes.emplace(tag, std::make_unique(TransformAnimatedNode(tag, config, manager))); + m_transformNodes.emplace(tag, std::make_unique(tag, config, manager)); break; } case AnimatedNodeType::Tracking: @@ -147,10 +147,10 @@ namespace react { switch (AnimationTypeFromString(animationConfig.find("type").dereference().second.getString())) { case AnimationType::Decay: - m_activeAnimations.emplace(animationId, std::make_unique(DecayAnimationDriver(animationId, animatedNodeTag, endCallback, animationConfig, manager))); + m_activeAnimations.emplace(animationId, std::make_unique(animationId, animatedNodeTag, endCallback, animationConfig, manager)); break; case AnimationType::Frames: - m_activeAnimations.emplace(animationId, std::make_unique(FrameAnimationDriver(animationId, animatedNodeTag, endCallback, animationConfig, manager))); + m_activeAnimations.emplace(animationId, std::make_unique(animationId, animatedNodeTag, endCallback, animationConfig, manager)); break; case AnimationType::Spring: //TODO: implement spring animations tracked by issue #2681 @@ -214,12 +214,12 @@ namespace react { const auto key = std::make_tuple(viewTag, eventName); if (m_eventDrivers.count(key)) { - m_eventDrivers.at(key).emplace_back(std::make_unique(EventAnimationDriver(pathList, valueNodeTag, manager))); + m_eventDrivers.at(key).emplace_back(std::make_unique(pathList, valueNodeTag, manager)); } else { auto vector = std::vector>{}; - vector.emplace_back(std::make_unique(EventAnimationDriver(pathList, valueNodeTag, manager))); + vector.emplace_back(std::make_unique(pathList, valueNodeTag, manager)); m_eventDrivers.insert({ key, std::move(vector) }); } }