diff --git a/packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.cpp b/packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.cpp index 1530892f8fd..707c7090a0d 100644 --- a/packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.cpp +++ b/packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.cpp @@ -69,7 +69,7 @@ NativeAnimatedNodesManager::~NativeAnimatedNodesManager() noexcept { stopRenderCallbackIfNeeded(); } -std::optional NativeAnimatedNodesManager::getValue(Tag tag) { +std::optional NativeAnimatedNodesManager::getValue(Tag tag) noexcept { auto node = getAnimatedNode(tag); if (node) { return node->value(); @@ -84,7 +84,7 @@ std::optional NativeAnimatedNodesManager::getValue(Tag tag) { std::unique_ptr NativeAnimatedNodesManager::animatedNode( Tag tag, - const folly::dynamic& config) { + const folly::dynamic& config) noexcept { auto typeName = config["type"].asString(); auto type = AnimatedNode::getNodeTypeByName(typeName); @@ -145,7 +145,7 @@ std::unique_ptr NativeAnimatedNodesManager::animatedNode( void NativeAnimatedNodesManager::createAnimatedNode( Tag tag, - const folly::dynamic& config) { + const folly::dynamic& config) noexcept { auto node = animatedNode(tag, config); if (node) { std::lock_guard lock(connectedAnimatedNodesMutex_); @@ -156,7 +156,7 @@ void NativeAnimatedNodesManager::createAnimatedNode( void NativeAnimatedNodesManager::connectAnimatedNodes( Tag parentTag, - Tag childTag) { + Tag childTag) noexcept { react_native_assert(parentTag); react_native_assert(childTag); @@ -175,7 +175,7 @@ void NativeAnimatedNodesManager::connectAnimatedNodes( void NativeAnimatedNodesManager::connectAnimatedNodeToView( Tag propsNodeTag, - Tag viewTag) { + Tag viewTag) noexcept { react_native_assert(propsNodeTag); react_native_assert(viewTag); @@ -195,7 +195,7 @@ void NativeAnimatedNodesManager::connectAnimatedNodeToView( void NativeAnimatedNodesManager::disconnectAnimatedNodeFromView( Tag propsNodeTag, - Tag viewTag) { + Tag viewTag) noexcept { react_native_assert(propsNodeTag); react_native_assert(viewTag); @@ -215,7 +215,7 @@ void NativeAnimatedNodesManager::disconnectAnimatedNodeFromView( void NativeAnimatedNodesManager::disconnectAnimatedNodes( Tag parentTag, - Tag childTag) { + Tag childTag) noexcept { react_native_assert(parentTag); react_native_assert(childTag); @@ -231,13 +231,13 @@ void NativeAnimatedNodesManager::disconnectAnimatedNodes( } } -void NativeAnimatedNodesManager::restoreDefaultValues(Tag tag) { +void NativeAnimatedNodesManager::restoreDefaultValues(Tag tag) noexcept { if (auto propsNode = getAnimatedNode(tag)) { propsNode->restoreDefaultValues(); } } -void NativeAnimatedNodesManager::dropAnimatedNode(Tag tag) { +void NativeAnimatedNodesManager::dropAnimatedNode(Tag tag) noexcept { std::lock_guard lock(connectedAnimatedNodesMutex_); animatedNodes_.erase(tag); } @@ -269,21 +269,23 @@ void NativeAnimatedNodesManager::stopAnimationsForNode(Tag nodeTag) { void NativeAnimatedNodesManager::setAnimatedNodeOffset( Tag /*tag*/, - double /*offset*/) { + double /*offset*/) noexcept { LOG(WARNING) << "SetAnimatedNodeOffset is unimplemented"; } -void NativeAnimatedNodesManager::flattenAnimatedNodeOffset(Tag /*tag*/) { +void NativeAnimatedNodesManager::flattenAnimatedNodeOffset( + Tag /*tag*/) noexcept { LOG(WARNING) << "FlattenAnimatedNodeOffset is unimplemented"; } -void NativeAnimatedNodesManager::extractAnimatedNodeOffset(Tag /*tag*/) { +void NativeAnimatedNodesManager::extractAnimatedNodeOffset( + Tag /*tag*/) noexcept { LOG(WARNING) << "ExtractAnimatedNodeOffset is unimplemented"; } void NativeAnimatedNodesManager::updateAnimatedNodeConfig( Tag /*tag*/, - const folly::dynamic& /*config*/) { + const folly::dynamic& /*config*/) noexcept { LOG(WARNING) << "UpdateAnimatedNodeConfig is unimplemented"; } @@ -293,7 +295,7 @@ void NativeAnimatedNodesManager::startAnimatingNode( int animationId, Tag animatedNodeTag, const folly::dynamic& config, - const std::optional& endCallback) { + const std::optional& endCallback) noexcept { if (auto iter = activeAnimations_.find(animationId); iter != activeAnimations_.end()) { // reset animation config @@ -330,7 +332,7 @@ void NativeAnimatedNodesManager::startAnimatingNode( void NativeAnimatedNodesManager::stopAnimation( int animationId, - bool /*isTrackingAnimation*/) { + bool /*isTrackingAnimation*/) noexcept { if (auto iter = activeAnimations_.find(animationId); iter != activeAnimations_.end()) { iter->second->stopAnimation(); @@ -341,7 +343,7 @@ void NativeAnimatedNodesManager::stopAnimation( void NativeAnimatedNodesManager::addAnimatedEventToView( Tag viewTag, const std::string& eventName, - const folly::dynamic& eventMapping) { + const folly::dynamic& eventMapping) noexcept { const auto animatedValueTag = (eventMapping.count("animatedValueTag") != 0u) ? static_cast(eventMapping["animatedValueTag"].asInt()) : 0; @@ -370,7 +372,7 @@ void NativeAnimatedNodesManager::addAnimatedEventToView( void NativeAnimatedNodesManager::removeAnimatedEventFromView( Tag viewTag, const std::string& eventName, - Tag animatedValueTag) { + Tag animatedValueTag) noexcept { const auto key = EventAnimationDriverKey{ viewTag, EventEmitter::normalizeEventType(eventName)}; auto driversIter = eventDrivers_.find(key); @@ -387,7 +389,7 @@ static thread_local bool isOnRenderThread_{false}; void NativeAnimatedNodesManager::handleAnimatedEvent( Tag viewTag, const std::string& eventName, - const EventPayload& eventPayload) { + const EventPayload& eventPayload) noexcept { // We currently reject events that are not on the same thread as `onRender` // callbacks, as the assumption is these events can synchronously update // UI components or otherwise Animated nodes with single-threaded assumptions. @@ -436,7 +438,7 @@ void NativeAnimatedNodesManager::handleAnimatedEvent( } std::shared_ptr -NativeAnimatedNodesManager::ensureEventEmitterListener() { +NativeAnimatedNodesManager::ensureEventEmitterListener() noexcept { if (!eventEmitterListener_) { eventEmitterListener_ = std::make_shared( [weakSelf = weak_from_this()]( @@ -476,13 +478,13 @@ void NativeAnimatedNodesManager::stopRenderCallbackIfNeeded() noexcept { } } -bool NativeAnimatedNodesManager::isAnimationUpdateNeeded() const { +bool NativeAnimatedNodesManager::isAnimationUpdateNeeded() const noexcept { return !activeAnimations_.empty() || !updatedNodeTags_.empty() || isGestureAnimationInProgress_; } void NativeAnimatedNodesManager::updateNodes( - const std::set& finishedAnimationValueNodes) { + const std::set& finishedAnimationValueNodes) noexcept { auto nodesQueue = std::deque{}; const auto is_node_connected_to_finished_animation = @@ -682,7 +684,7 @@ bool NativeAnimatedNodesManager::onAnimationFrame(uint64_t timestamp) { } std::optional NativeAnimatedNodesManager::managedProps( - Tag tag) { + Tag tag) noexcept { std::lock_guard lock(connectedAnimatedNodesMutex_); const auto iter = connectedAnimatedNodes_.find(tag); if (iter != connectedAnimatedNodes_.end()) { @@ -694,14 +696,14 @@ std::optional NativeAnimatedNodesManager::managedProps( return {}; } -bool NativeAnimatedNodesManager::isOnRenderThread() const { +bool NativeAnimatedNodesManager::isOnRenderThread() const noexcept { return isOnRenderThread_; } // listeners void NativeAnimatedNodesManager::startListeningToAnimatedNodeValue( Tag tag, - ValueListenerCallback&& callback) { + ValueListenerCallback&& callback) noexcept { if (auto iter = animatedNodes_.find(tag); iter != animatedNodes_.end() && iter->second->type() == AnimatedNodeType::Value) { static_pointer_cast(iter->second) @@ -712,7 +714,8 @@ void NativeAnimatedNodesManager::startListeningToAnimatedNodeValue( } } -void NativeAnimatedNodesManager::stopListeningToAnimatedNodeValue(Tag tag) { +void NativeAnimatedNodesManager::stopListeningToAnimatedNodeValue( + Tag tag) noexcept { if (auto iter = animatedNodes_.find(tag); iter != animatedNodes_.end() && iter->second->type() == AnimatedNodeType::Value) { static_pointer_cast(iter->second) @@ -727,7 +730,7 @@ void NativeAnimatedNodesManager::schedulePropsCommit( Tag viewTag, const folly::dynamic& props, bool layoutStyleUpdated, - bool forceFabricCommit) { + bool forceFabricCommit) noexcept { // When fabricCommitCallback_ & directManipulationCallback_ are both // available, we commit layout props via Fabric and the other using direct // manipulation; if only one is available, we commit all props using that diff --git a/packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.h b/packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.h index 4d2f5a243c9..6e4d9e26228 100644 --- a/packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.h +++ b/packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.h @@ -71,35 +71,35 @@ class NativeAnimatedNodesManager return nullptr; } - std::optional getValue(Tag tag); + std::optional getValue(Tag tag) noexcept; // graph - void createAnimatedNode(Tag tag, const folly::dynamic& config); + void createAnimatedNode(Tag tag, const folly::dynamic& config) noexcept; - void connectAnimatedNodes(Tag parentTag, Tag childTag); + void connectAnimatedNodes(Tag parentTag, Tag childTag) noexcept; - void connectAnimatedNodeToView(Tag propsNodeTag, Tag viewTag); + void connectAnimatedNodeToView(Tag propsNodeTag, Tag viewTag) noexcept; - void disconnectAnimatedNodes(Tag parentTag, Tag childTag); + void disconnectAnimatedNodes(Tag parentTag, Tag childTag) noexcept; - void disconnectAnimatedNodeFromView(Tag propsNodeTag, Tag viewTag); + void disconnectAnimatedNodeFromView(Tag propsNodeTag, Tag viewTag) noexcept; - void restoreDefaultValues(Tag tag); + void restoreDefaultValues(Tag tag) noexcept; - void dropAnimatedNode(Tag tag); + void dropAnimatedNode(Tag tag) noexcept; // mutations void setAnimatedNodeValue(Tag tag, double value); - void setAnimatedNodeOffset(Tag tag, double offset); + void setAnimatedNodeOffset(Tag tag, double offset) noexcept; - void flattenAnimatedNodeOffset(Tag tag); + void flattenAnimatedNodeOffset(Tag tag) noexcept; - void extractAnimatedNodeOffset(Tag tag); + void extractAnimatedNodeOffset(Tag tag) noexcept; - void updateAnimatedNodeConfig(Tag tag, const folly::dynamic& config); + void updateAnimatedNodeConfig(Tag tag, const folly::dynamic& config) noexcept; // drivers @@ -107,36 +107,38 @@ class NativeAnimatedNodesManager int animationId, Tag animatedNodeTag, const folly::dynamic& config, - const std::optional& endCallback); + const std::optional& endCallback) noexcept; - void stopAnimation(int animationId, bool isTrackingAnimation = false); + void stopAnimation( + int animationId, + bool isTrackingAnimation = false) noexcept; void addAnimatedEventToView( Tag viewTag, const std::string& eventName, - const folly::dynamic& eventMapping); + const folly::dynamic& eventMapping) noexcept; void removeAnimatedEventFromView( Tag viewTag, const std::string& eventName, - Tag animatedValueTag); + Tag animatedValueTag) noexcept; - std::shared_ptr getEventEmitterListener() { + std::shared_ptr getEventEmitterListener() noexcept { return ensureEventEmitterListener(); } // listeners void startListeningToAnimatedNodeValue( Tag tag, - ValueListenerCallback&& callback); + ValueListenerCallback&& callback) noexcept; - void stopListeningToAnimatedNodeValue(Tag tag); + void stopListeningToAnimatedNodeValue(Tag tag) noexcept; void schedulePropsCommit( Tag viewTag, const folly::dynamic& props, bool layoutStyleUpdated, - bool forceFabricCommit); + bool forceFabricCommit) noexcept; /** * Commits all pending animated property updates to their respective views. @@ -166,31 +168,32 @@ class NativeAnimatedNodesManager void startRenderCallbackIfNeeded(); - void updateNodes(const std::set& finishedAnimationValueNodes = {}); + void updateNodes( + const std::set& finishedAnimationValueNodes = {}) noexcept; - std::optional managedProps(Tag tag); + std::optional managedProps(Tag tag) noexcept; - bool isOnRenderThread() const; + bool isOnRenderThread() const noexcept; private: void stopRenderCallbackIfNeeded() noexcept; bool onAnimationFrame(uint64_t timestamp); - bool isAnimationUpdateNeeded() const; + bool isAnimationUpdateNeeded() const noexcept; void stopAnimationsForNode(Tag nodeTag); - std::shared_ptr ensureEventEmitterListener(); + std::shared_ptr ensureEventEmitterListener() noexcept; void handleAnimatedEvent( Tag tag, const std::string& eventName, - const EventPayload& payload); + const EventPayload& payload) noexcept; std::unique_ptr animatedNode( Tag tag, - const folly::dynamic& config); + const folly::dynamic& config) noexcept; std::unordered_map> animatedNodes_; std::unordered_map connectedAnimatedNodes_;