From 43b1fb6ca19c845a3b6d1336ac84cd1fc0bb452b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Qu=C3=A8ze?= Date: Fri, 11 Mar 2022 07:49:05 +0000 Subject: [PATCH] Bug 1757202 - Add SetAnimation, SampleAnimation and ClearAnimation markers on the compositor thread, r=mstange. Differential Revision: https://phabricator.services.mozilla.com/D139733 --- gfx/layers/CompositorAnimationStorage.cpp | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/gfx/layers/CompositorAnimationStorage.cpp b/gfx/layers/CompositorAnimationStorage.cpp index c336653fcc91..61c32e93d49c 100644 --- a/gfx/layers/CompositorAnimationStorage.cpp +++ b/gfx/layers/CompositorAnimationStorage.cpp @@ -12,6 +12,7 @@ #include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent #include "mozilla/layers/CompositorThread.h" // for CompositorThreadHolder #include "mozilla/layers/OMTAController.h" // for OMTAController +#include "mozilla/ProfilerMarkers.h" #include "mozilla/ScopeExit.h" #include "mozilla/ServoStyleConsts.h" #include "mozilla/webrender/WebRenderTypes.h" // for ToWrTransformProperty, etc @@ -20,6 +21,34 @@ #include "nsLayoutUtils.h" #include "TreeTraversal.h" // for ForEachNode, BreadthFirstSearch +namespace geckoprofiler::markers { + +using namespace mozilla; + +struct CompositorAnimationMarker { + static constexpr Span MarkerTypeName() { + return MakeStringSpan("CompositorAnimation"); + } + static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter, + uint64_t aId, nsCSSPropertyID aProperty) { + aWriter.IntProperty("pid", int64_t(aId >> 32)); + aWriter.IntProperty("id", int64_t(aId & 0xffffffff)); + aWriter.StringProperty("property", nsCSSProps::GetStringValue(aProperty)); + } + static MarkerSchema MarkerTypeDisplay() { + using MS = MarkerSchema; + MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable}; + schema.AddKeyLabelFormat("pid", "Process Id", MS::Format::Integer); + schema.AddKeyLabelFormat("id", "Animation Id", MS::Format::Integer); + schema.AddKeyLabelFormat("property", "Animated Property", + MS::Format::String); + schema.SetTableLabel("{marker.name} - {marker.data.property}"); + return schema; + } +}; + +} // namespace geckoprofiler::markers + namespace mozilla { namespace layers { @@ -29,6 +58,11 @@ void CompositorAnimationStorage::ClearById(const uint64_t& aId) { MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); MutexAutoLock lock(mLock); + PROFILER_MARKER("ClearAnimation", GRAPHICS, + MarkerInnerWindowId(mCompositorBridge->GetInnerWindowId()), + CompositorAnimationMarker, aId, + mAnimations[aId]->mAnimation.LastElement().mProperty); + mAnimatedValues.Remove(aId); mAnimations.erase(aId); } @@ -140,6 +174,11 @@ void CompositorAnimationStorage::SetAnimations(uint64_t aId, mAnimations[aId] = std::make_unique( AnimationHelper::ExtractAnimations(aLayersId, aValue)); + PROFILER_MARKER("SetAnimation", GRAPHICS, + MarkerInnerWindowId(mCompositorBridge->GetInnerWindowId()), + CompositorAnimationMarker, aId, + mAnimations[aId]->mAnimation.LastElement().mProperty); + // If there is the last animated value, then we need to store the id to remove // the value if the new animation doesn't produce any animated data (i.e. in // the delay phase) when we sample this new animation. @@ -202,6 +241,14 @@ bool CompositorAnimationStorage::SampleAnimations( const PropertyAnimationGroup& lastPropertyAnimationGroup = animationStorageData->mAnimation.LastElement(); + PROFILER_MARKER( + "SampleAnimation", GRAPHICS, + MarkerOptions( + MarkerThreadId(CompositorThreadHolder::GetThreadId()), + MarkerInnerWindowId(mCompositorBridge->GetInnerWindowId())), + CompositorAnimationMarker, iter.first, + lastPropertyAnimationGroup.mProperty); + // Store the AnimatedValue switch (lastPropertyAnimationGroup.mProperty) { case eCSSProperty_background_color: {