Bug 1757202 - Add more information in existing CSS Animation and CSS Transition main thread markers, r=boris.

Differential Revision: https://phabricator.services.mozilla.com/D139734
This commit is contained in:
Florian Quèze 2022-03-11 07:49:04 +00:00
Родитель 8e60938b99
Коммит ee33a6c743
1 изменённых файлов: 105 добавлений и 11 удалений

Просмотреть файл

@ -16,6 +16,7 @@
#include "mozilla/Variant.h" #include "mozilla/Variant.h"
#include "mozilla/dom/AnimationEffect.h" #include "mozilla/dom/AnimationEffect.h"
#include "mozilla/dom/AnimationPlaybackEvent.h" #include "mozilla/dom/AnimationPlaybackEvent.h"
#include "mozilla/dom/KeyframeEffect.h"
#include "mozilla/ProfilerMarkers.h" #include "mozilla/ProfilerMarkers.h"
#include "nsCSSProps.h" #include "nsCSSProps.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
@ -23,6 +24,86 @@
class nsRefreshDriver; class nsRefreshDriver;
namespace geckoprofiler::markers {
using namespace mozilla;
struct CSSAnimationMarker {
static constexpr Span<const char> MarkerTypeName() {
return MakeStringSpan("CSSAnimation");
}
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
const nsCString& aName,
const nsCString& aTarget,
nsCSSPropertyIDSet aPropertySet) {
aWriter.StringProperty("Name", aName);
aWriter.StringProperty("Target", aTarget);
nsAutoCString properties;
nsAutoCString oncompositor;
for (nsCSSPropertyID property : aPropertySet) {
if (!properties.IsEmpty()) {
properties.AppendLiteral(", ");
oncompositor.AppendLiteral(", ");
}
properties.Append(nsCSSProps::GetStringValue(property));
oncompositor.Append(nsCSSProps::PropHasFlags(
property, CSSPropFlags::CanAnimateOnCompositor)
? "true"
: "false");
}
aWriter.StringProperty("properties", properties);
aWriter.StringProperty("oncompositor", oncompositor);
}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
schema.AddKeyFormat("Name", MS::Format::String);
schema.AddKeyLabelFormat("properties", "Animated Properties",
MS::Format::String);
schema.AddKeyLabelFormat("oncompositor", "Can Run on Compositor",
MS::Format::String);
schema.AddKeyFormat("Target", MS::Format::String);
schema.SetChartLabel("{marker.data.Name}");
schema.SetTableLabel(
"{marker.name} - {marker.data.Name}: {marker.data.properties}");
return schema;
}
};
struct CSSTransitionMarker {
static constexpr Span<const char> MarkerTypeName() {
return MakeStringSpan("CSSTransition");
}
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
const nsCString& aTarget,
nsCSSPropertyID aProperty, bool aCanceled) {
aWriter.StringProperty("Target", aTarget);
aWriter.StringProperty("property", nsCSSProps::GetStringValue(aProperty));
aWriter.BoolProperty("oncompositor",
nsCSSProps::PropHasFlags(
aProperty, CSSPropFlags::CanAnimateOnCompositor));
if (aCanceled) {
aWriter.BoolProperty("Canceled", aCanceled);
}
}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
schema.AddKeyLabelFormat("property", "Animated Property",
MS::Format::String);
schema.AddKeyLabelFormat("oncompositor", "Can Run on Compositor",
MS::Format::String);
schema.AddKeyFormat("Canceled", MS::Format::String);
schema.AddKeyFormat("Target", MS::Format::String);
schema.SetChartLabel("{marker.data.property}");
schema.SetTableLabel("{marker.name} - {marker.data.property}");
return schema;
}
};
} // namespace geckoprofiler::markers
namespace mozilla { namespace mozilla {
struct AnimationEventInfo { struct AnimationEventInfo {
@ -56,8 +137,8 @@ struct AnimationEventInfo {
if ((aMessage == eAnimationCancel || aMessage == eAnimationEnd || if ((aMessage == eAnimationCancel || aMessage == eAnimationEnd ||
aMessage == eAnimationIteration) && aMessage == eAnimationIteration) &&
profiler_thread_is_being_profiled_for_markers()) { profiler_thread_is_being_profiled_for_markers()) {
nsAutoCString markerText; nsAutoCString name;
aAnimationName->ToUTF8String(markerText); aAnimationName->ToUTF8String(name);
const TimeStamp startTime = [&] { const TimeStamp startTime = [&] {
if (aMessage == eAnimationIteration) { if (aMessage == eAnimationIteration) {
@ -70,7 +151,19 @@ struct AnimationEventInfo {
TimeDuration::FromSeconds(aElapsedTime); TimeDuration::FromSeconds(aElapsedTime);
}(); }();
PROFILER_MARKER_TEXT( nsCSSPropertyIDSet propertySet;
nsAutoString target;
if (dom::AnimationEffect* effect = aAnimation->GetEffect()) {
if (dom::KeyframeEffect* keyFrameEffect = effect->AsKeyframeEffect()) {
keyFrameEffect->GetTarget()->Describe(target, true);
for (const AnimationProperty& property :
keyFrameEffect->Properties()) {
propertySet.AddProperty(property.mProperty);
}
}
}
PROFILER_MARKER(
aMessage == eAnimationIteration aMessage == eAnimationIteration
? ProfilerString8View("CSS animation iteration") ? ProfilerString8View("CSS animation iteration")
: ProfilerString8View("CSS animation"), : ProfilerString8View("CSS animation"),
@ -80,7 +173,7 @@ struct AnimationEventInfo {
aAnimation->GetOwner() aAnimation->GetOwner()
? MarkerInnerWindowId(aAnimation->GetOwner()->WindowID()) ? MarkerInnerWindowId(aAnimation->GetOwner()->WindowID())
: MarkerInnerWindowId::NoId()), : MarkerInnerWindowId::NoId()),
markerText); CSSAnimationMarker, name, NS_ConvertUTF16toUTF8(target), propertySet);
} }
} }
@ -105,13 +198,13 @@ struct AnimationEventInfo {
if ((aMessage == eTransitionEnd || aMessage == eTransitionCancel) && if ((aMessage == eTransitionEnd || aMessage == eTransitionCancel) &&
profiler_thread_is_being_profiled_for_markers()) { profiler_thread_is_being_profiled_for_markers()) {
nsAutoCString markerText; nsAutoString target;
markerText.Assign(nsCSSProps::GetStringValue(aProperty)); if (dom::AnimationEffect* effect = aAnimation->GetEffect()) {
if (aMessage == eTransitionCancel) { if (dom::KeyframeEffect* keyFrameEffect = effect->AsKeyframeEffect()) {
markerText.AppendLiteral(" (canceled)"); keyFrameEffect->GetTarget()->Describe(target, true);
}
} }
PROFILER_MARKER(
PROFILER_MARKER_TEXT(
"CSS transition", DOM, "CSS transition", DOM,
MarkerOptions( MarkerOptions(
MarkerTiming::Interval( MarkerTiming::Interval(
@ -121,7 +214,8 @@ struct AnimationEventInfo {
aAnimation->GetOwner() aAnimation->GetOwner()
? MarkerInnerWindowId(aAnimation->GetOwner()->WindowID()) ? MarkerInnerWindowId(aAnimation->GetOwner()->WindowID())
: MarkerInnerWindowId::NoId()), : MarkerInnerWindowId::NoId()),
markerText); CSSTransitionMarker, NS_ConvertUTF16toUTF8(target), aProperty,
aMessage == eTransitionCancel);
} }
} }