Bug 1657960 - MOZ_LOG schedule and run of `mStyleFlushObservers` and `mLayoutFlushObservers`, r=froydnj

Depends on D86737

Differential Revision: https://phabricator.services.mozilla.com/D86738
This commit is contained in:
Honza Bambas 2020-08-13 14:41:15 +00:00
Родитель 8c06001afd
Коммит 13026539fa
4 изменённых файлов: 25 добавлений и 1 удалений

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

@ -75,7 +75,6 @@
#include "mozilla/layout/VsyncChild.h"
#include "VsyncSource.h"
#include "mozilla/VsyncDispatcher.h"
#include "nsThreadUtils.h"
#include "mozilla/Unused.h"
#include "mozilla/TimelineConsumers.h"
#include "nsAnimationManager.h"
@ -2107,6 +2106,9 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
if (!mStyleFlushObservers.RemoveElement(rawPresShell)) {
continue;
}
LogPresShellObserver::Run run(rawPresShell, this);
RefPtr<PresShell> presShell = rawPresShell;
presShell->mObservingStyleFlushes = false;
presShell->FlushPendingNotifications(
@ -2133,6 +2135,9 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
if (!mLayoutFlushObservers.RemoveElement(rawPresShell)) {
continue;
}
LogPresShellObserver::Run run(rawPresShell, this);
RefPtr<PresShell> presShell = rawPresShell;
presShell->mObservingLayoutFlushes = false;
presShell->mWasLastReflowInterrupted = false;

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

@ -23,6 +23,7 @@
#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#include "nsRefreshObservers.h"
#include "nsThreadUtils.h"
#include "mozilla/Attributes.h"
#include "mozilla/Maybe.h"
#include "mozilla/dom/VisualViewport.h"
@ -54,6 +55,7 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
mozilla::dom::VisualViewport::VisualViewportResizeEvent;
using VVPScrollEvent =
mozilla::dom::VisualViewport::VisualViewportScrollEvent;
using LogPresShellObserver = mozilla::LogPresShellObserver;
public:
explicit nsRefreshDriver(nsPresContext* aPresContext);
@ -170,6 +172,7 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
void AddStyleFlushObserver(mozilla::PresShell* aPresShell) {
MOZ_DIAGNOSTIC_ASSERT(!mStyleFlushObservers.Contains(aPresShell),
"Double-adding style flush observer");
LogPresShellObserver::LogDispatch(aPresShell, this);
mStyleFlushObservers.AppendElement(aPresShell);
EnsureTimerStarted();
}
@ -180,6 +183,7 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
void AddLayoutFlushObserver(mozilla::PresShell* aPresShell) {
MOZ_DIAGNOSTIC_ASSERT(!IsLayoutFlushObserver(aPresShell),
"Double-adding layout flush observer");
LogPresShellObserver::LogDispatch(aPresShell, this);
mLayoutFlushObservers.AppendElement(aPresShell);
EnsureTimerStarted();
}

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

@ -629,6 +629,10 @@ template <typename T>
void LogTaskBase<T>::LogDispatch(T* aEvent) {
LOG1(("DISP %p", aEvent));
}
template <typename T>
void LogTaskBase<T>::LogDispatch(T* aEvent, void* aContext) {
LOG1(("DISP %p (%p)", aEvent, aContext));
}
template <>
void LogTaskBase<IPC::Message>::LogDispatchWithPid(IPC::Message* aEvent,
@ -646,6 +650,11 @@ LogTaskBase<T>::Run::Run(T* aEvent, bool aWillRunAgain)
// time.
LOG1(("EXEC %p %p", aEvent, this));
}
template <typename T>
LogTaskBase<T>::Run::Run(T* aEvent, void* aContext, bool aWillRunAgain)
: mWillRunAgain(aWillRunAgain) {
LOG1(("EXEC %p (%p) %p", aEvent, aContext, this));
}
template <>
LogTaskBase<nsIRunnable>::Run::Run(nsIRunnable* aEvent, bool aWillRunAgain)
@ -690,6 +699,7 @@ template class LogTaskBase<MicroTaskRunnable>;
template class LogTaskBase<IPC::Message>;
template class LogTaskBase<nsTimerImpl>;
template class LogTaskBase<Task>;
template class LogTaskBase<PresShell>;
MOZ_THREAD_LOCAL(nsISerialEventTarget*)
SerialEventTargetGuard::sCurrentThreadTLS;

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

@ -1923,6 +1923,8 @@ class LogTaskBase {
// Adds a simple log about dispatch of this runnable.
static void LogDispatch(T* aEvent);
// The `aContext` pointer adds another uniqe identifier, nothing more
static void LogDispatch(T* aEvent, void* aContext);
// Logs dispatch of the message and along that also the PID of the target
// proccess, purposed for uniquely identifying IPC messages.
@ -1936,6 +1938,7 @@ class LogTaskBase {
public:
Run() = delete;
explicit Run(T* aEvent, bool aWillRunAgain = false);
explicit Run(T* aEvent, void* aContext, bool aWillRunAgain = false);
~Run();
// When this is called, the log in this RAII dtor will only say
@ -1949,6 +1952,7 @@ class LogTaskBase {
class MicroTaskRunnable;
class Task; // TaskController
class PresShell;
// Specialized methods must be explicitly predeclared.
template <>
@ -1966,6 +1970,7 @@ typedef LogTaskBase<MicroTaskRunnable> LogMicroTaskRunnable;
typedef LogTaskBase<IPC::Message> LogIPCMessage;
typedef LogTaskBase<nsTimerImpl> LogTimerEvent;
typedef LogTaskBase<Task> LogTask;
typedef LogTaskBase<PresShell> LogPresShellObserver;
// If you add new types don't forget to add:
// `template class LogTaskBase<YourType>;` to nsThreadUtils.cpp