From dd485091850fa35a73766f5903950476f49acb75 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Wed, 24 Aug 2022 05:09:12 -0700 Subject: [PATCH] Unbreak LAYOUT_ANIMATION_VERBOSE_LOGGING Summary: Noticed this logging was broken when enabling the flag. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D38616851 fbshipit-source-id: acf0ab75918b389586cb713c2edf5a6bf83ee7a2 --- .../react/uimanager/layoutanimation/BUCK | 4 +- .../animations/LayoutAnimationDriver.cpp | 2 +- .../LayoutAnimationKeyFrameManager.cpp | 41 ++++++++----------- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/BUCK b/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/BUCK index 1dcd20c2514..9e25be3b51d 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/layoutanimation/BUCK @@ -5,9 +5,7 @@ rn_robolectric_test( srcs = glob(["**/*.java"]), contacts = ["oncall+react_native@xmail.facebook.com"], language = "JAVA", - visibility = [ - "PUBLIC", - ], + visibility = ["PUBLIC"], deps = [ YOGA_TARGET, react_native_dep("third-party/java/assertj:assertj-core"), diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp index a24d7c4a2cf..7c91b6b329c 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp @@ -59,7 +59,7 @@ void LayoutAnimationDriver::animationMutationsForFrame( mutationsList.emplace_back(ShadowViewMutation::UpdateMutation( keyframe.viewPrev, mutatedShadowView, keyframe.parentView)); - PrintMutationInstruction("Animation Progress:", updateMutation); + PrintMutationInstruction("Animation Progress:", mutationsList.back()); keyframe.viewPrev = std::move(mutatedShadowView); diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 2160e541efc..00b8cfa69ef 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -37,24 +36,12 @@ namespace react { #ifdef LAYOUT_ANIMATION_VERBOSE_LOGGING static std::string GetMutationInstructionString( ShadowViewMutation const &mutation) { - bool mutationIsRemove = mutation.type == ShadowViewMutation::Type::Remove; - bool mutationIsInsert = mutation.type == ShadowViewMutation::Type::Insert; - bool mutationIsDelete = mutation.type == ShadowViewMutation::Type::Delete; - bool mutationIsCreate = mutation.type == ShadowViewMutation::Type::Create; - std::string mutationType = - (mutationIsRemove - ? "REMOVE" - : (mutationIsInsert - ? "INSERT" - : (mutationIsDelete - ? "DELETE" - : (mutationIsCreate ? "CREATE" : "UPDATE")))); - return mutationType + " [" + - std::to_string( - mutationIsInsert || mutationIsCreate - ? mutation.newChildShadowView.tag - : mutation.oldChildShadowView.tag) + - "]->[" + std::to_string(mutation.parentShadowView.tag) + "] @" + + Tag tag = mutation.type == ShadowViewMutation::Type::Insert || + mutation.type == ShadowViewMutation::Type::Create + ? mutation.newChildShadowView.tag + : mutation.oldChildShadowView.tag; + return getDebugName(mutation) + " [" + std::to_string(tag) + "]->[" + + std::to_string(mutation.parentShadowView.tag) + "] @" + std::to_string(mutation.index); } @@ -1638,15 +1625,19 @@ void LayoutAnimationKeyFrameManager::deleteAnimationsForStoppedSurfaces() surfaceIdsToStop_.clear(); } +#ifdef LAYOUT_ANIMATION_VERBOSE_LOGGING + std::ostringstream surfaceIdsStr; + std::copy( + surfaceIdsToStop.begin(), + surfaceIdsToStop.end(), + std::ostream_iterator(surfaceIdsStr, ", ")); + LOG(ERROR) << "LayoutAnimations: stopping animations due to stopSurface on " + << surfaceIdsStr.str(); +#endif + for (auto it = inflightAnimations_.begin(); it != inflightAnimations_.end();) { const auto &animation = *it; - -#ifdef LAYOUT_ANIMATION_VERBOSE_LOGGING - LOG(ERROR) - << "LayoutAnimations: stopping animation due to stopSurface on " - << surfaceId; -#endif if (surfaceIdsToStop.find(animation.surfaceId) != surfaceIdsToStop.end()) { it = inflightAnimations_.erase(it);