Open Bug 1528318 Opened 6 years ago Updated 3 years ago

Style cause stack could use a profiler label that describes the restyled element

Categories

(Core :: Gecko Profiler, enhancement, P2)

enhancement

Tracking

()

Tracking Status
firefox67 --- affected

People

(Reporter: mstange, Unassigned)

Details

Example profile: https://perfht.ml/2EaUuG0

When there's a main thread animation running, we can tell what triggers the paints by looking at the "cause" call stack of the Styles marker. In this profile, the Styles markers have the following stack:

[...]
nsRefreshDriver::Tick []
nsRefreshDriver::Tick(mozilla::layers::BaseTransactionId<mozilla::VsyncIdType>, mozilla::TimeStamp) [XUL]
{virtual override thunk({offset(-104)}, mozilla::dom::DocumentTimeline::WillRefresh(mozilla::TimeStamp))} [XUL]
mozilla::dom::DocumentTimeline::MostRecentRefreshTimeUpdated() [XUL]
mozilla::dom::CSSAnimation::Tick() [XUL]
mozilla::dom::Animation::Tick() [XUL]
mozilla::dom::Animation::UpdateTiming(mozilla::dom::Animation::SeekFlag, mozilla::dom::Animation::SyncNotifyFlag) [XUL]
mozilla::dom::KeyframeEffect::NotifyAnimationTimingUpdated() [XUL]
mozilla::EffectCompositor::RequestRestyle(mozilla::dom::Element*, mozilla::CSSPseudoElementType, mozilla::EffectCompositor::RestyleType, mozilla::EffectCompositor::CascadeLevel) [XUL]
Servo_NoteExplicitHints [XUL]
style::gecko::wrapper::GeckoElement::note_explicit_hints [XUL]
mozilla::dom::NoteDirtyElement(mozilla::dom::Element*, unsigned int) [XUL]

It would be really cool to see some description of the element that we're triggering the restyle for. For example, NoteDirtyElement could, if the profiler is running, push a profiler label with the element name, ID and class of the to-be-restyled element. Or if that has too much overhead, maybe we can somehow only push that label if we're actually capturing a stack. For example, we could pass the element down from NoteDirtyElement through nsIPresShell::EnsureStyleFlush() to nsIPresShell::SetNeedStyleFlush(), which is where we capture the stack:

  if (!mStyleCause) {
    mStyleCause = profiler_get_backtrace();
  }

And then we could push a profiler label just inside that if.

Priority: -- → P2
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.