Bug 1757202 - Add SetAnimation, SampleAnimation and ClearAnimation markers on the compositor thread, r=mstange.

Differential Revision: https://phabricator.services.mozilla.com/D139733
This commit is contained in:
Florian Quèze 2022-03-11 07:49:05 +00:00
parent e199a5a9b2
commit 43b1fb6ca1

View File

@ -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<const char> 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<AnimationStorageData>(
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: {