mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1350930 - Move profiler markers for reflow and style flushes from the refresh driver into the PresShell. r=bz
MozReview-Commit-ID: FQs2zsIU2zO --HG-- extra : rebase_source : 166617f5966cbad18401bc590a266ce00d858bab
This commit is contained in:
parent
39b9263245
commit
ae94ae81a4
@ -4210,6 +4210,12 @@ PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush)
|
||||
// type.
|
||||
if (!mIsDestroying) {
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
AutoProfilerTracing tracingStyleFlush("Paint", "Styles",
|
||||
Move(mStyleCause));
|
||||
mStyleCause = nullptr;
|
||||
#endif
|
||||
|
||||
mPresContext->RestyleManager()->ProcessPendingRestyles();
|
||||
}
|
||||
|
||||
@ -4224,6 +4230,11 @@ PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush)
|
||||
? FlushType::Layout
|
||||
: FlushType::InterruptibleLayout) &&
|
||||
!mIsDestroying) {
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
AutoProfilerTracing tracingLayoutFlush("Paint", "Reflow",
|
||||
Move(mReflowCause));
|
||||
mReflowCause = nullptr;
|
||||
#endif
|
||||
didLayoutFlush = true;
|
||||
mFrameConstructor->RecalcQuotesAndCounters();
|
||||
viewManager->FlushDelayedResize(true);
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "mozilla/StyleSetHandle.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "gfxPoint.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
@ -1697,6 +1698,14 @@ protected:
|
||||
// A hash table of heap allocated weak frames.
|
||||
nsTHashtable<nsPtrHashKey<WeakFrame>> mWeakFrames;
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
// These two fields capture call stacks of any changes that require a restyle
|
||||
// or a reflow. Only the first change per restyle / reflow is recorded (the
|
||||
// one that caused a call to SetNeedStyleFlush() / SetNeedLayoutFlush()).
|
||||
UniqueProfilerBacktrace mStyleCause;
|
||||
UniqueProfilerBacktrace mReflowCause;
|
||||
#endif
|
||||
|
||||
// Most recent canvas background color.
|
||||
nscolor mCanvasBackgroundColor;
|
||||
|
||||
|
@ -18,6 +18,12 @@ nsIPresShell::SetNeedLayoutFlush()
|
||||
shell->mNeedLayoutFlush = true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
if (!mReflowCause) {
|
||||
mReflowCause = profiler_get_backtrace();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -29,6 +35,12 @@ nsIPresShell::SetNeedStyleFlush()
|
||||
shell->mNeedStyleFlush = true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
if (!mStyleCause) {
|
||||
mStyleCause = profiler_get_backtrace();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1857,9 +1857,6 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||
DispatchScrollEvents();
|
||||
|
||||
if (mPresContext && mPresContext->GetPresShell()) {
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
Maybe<AutoProfilerTracing> tracingStyleFlush;
|
||||
#endif
|
||||
AutoTArray<nsIPresShell*, 16> observers;
|
||||
observers.AppendElements(mStyleFlushObservers);
|
||||
for (uint32_t j = observers.Length();
|
||||
@ -1870,13 +1867,6 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||
if (!mStyleFlushObservers.RemoveElement(shell))
|
||||
continue;
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
if (!tracingStyleFlush) {
|
||||
tracingStyleFlush.emplace("Paint", "Styles", Move(mStyleCause));
|
||||
mStyleCause = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPresShell> shellKungFuDeathGrip(shell);
|
||||
shell->mObservingStyleFlushes = false;
|
||||
shell->FlushPendingNotifications(ChangesToFlush(FlushType::Style, false));
|
||||
@ -1892,9 +1882,6 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||
}
|
||||
} else if (i == 2) {
|
||||
// This is the FlushType::Layout case.
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
Maybe<AutoProfilerTracing> tracingLayoutFlush;
|
||||
#endif
|
||||
AutoTArray<nsIPresShell*, 16> observers;
|
||||
observers.AppendElements(mLayoutFlushObservers);
|
||||
for (uint32_t j = observers.Length();
|
||||
@ -1905,13 +1892,6 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||
if (!mLayoutFlushObservers.RemoveElement(shell))
|
||||
continue;
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
if (!tracingLayoutFlush) {
|
||||
tracingLayoutFlush.emplace("Paint", "Reflow", Move(mReflowCause));
|
||||
mReflowCause = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIPresShell> shellKungFuDeathGrip(shell);
|
||||
shell->mObservingLayoutFlushes = false;
|
||||
shell->mWasLastReflowInterrupted = false;
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "nsHashKeys.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "mozilla/layers/TransactionIdAllocator.h"
|
||||
|
||||
class nsPresContext;
|
||||
@ -160,15 +159,6 @@ public:
|
||||
bool AddStyleFlushObserver(nsIPresShell* aShell) {
|
||||
NS_ASSERTION(!mStyleFlushObservers.Contains(aShell),
|
||||
"Double-adding style flush observer");
|
||||
// We only get the cause for the first observer each frame because capturing
|
||||
// a stack is expensive. This is still useful if (1) you're trying to remove
|
||||
// all flushes for a particial frame or (2) the costly flush is triggered
|
||||
// near the call site where the first observer is triggered.
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
if (!mStyleCause) {
|
||||
mStyleCause = profiler_get_backtrace();
|
||||
}
|
||||
#endif
|
||||
bool appended = mStyleFlushObservers.AppendElement(aShell) != nullptr;
|
||||
EnsureTimerStarted();
|
||||
|
||||
@ -180,15 +170,6 @@ public:
|
||||
bool AddLayoutFlushObserver(nsIPresShell* aShell) {
|
||||
NS_ASSERTION(!IsLayoutFlushObserver(aShell),
|
||||
"Double-adding layout flush observer");
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
// We only get the cause for the first observer each frame because capturing
|
||||
// a stack is expensive. This is still useful if (1) you're trying to remove
|
||||
// all flushes for a particial frame or (2) the costly flush is triggered
|
||||
// near the call site where the first observer is triggered.
|
||||
if (!mReflowCause) {
|
||||
mReflowCause = profiler_get_backtrace();
|
||||
}
|
||||
#endif
|
||||
bool appended = mLayoutFlushObservers.AppendElement(aShell) != nullptr;
|
||||
EnsureTimerStarted();
|
||||
return appended;
|
||||
@ -420,11 +401,6 @@ private:
|
||||
mozilla::RefreshDriverTimer* ChooseTimer() const;
|
||||
mozilla::RefreshDriverTimer* mActiveTimer;
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
UniqueProfilerBacktrace mReflowCause;
|
||||
UniqueProfilerBacktrace mStyleCause;
|
||||
#endif
|
||||
|
||||
// nsPresContext passed in constructor and unset in Disconnect.
|
||||
mozilla::WeakPtr<nsPresContext> mPresContext;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user