зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1492395 - Make event markers in profiler timeline per event, not per event listener, r=mstange
--HG-- extra : rebase_source : 53b205eabc2f318cdaa91e91bd1bad0c27d8a5dd
This commit is contained in:
Родитель
b12b62d352
Коммит
b05284f24f
|
@ -66,6 +66,10 @@
|
|||
using namespace mozilla::tasktracer;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
#include "ProfilerMarkerPayload.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
@ -1109,8 +1113,49 @@ EventDispatcher::Dispatch(nsISupports* aTarget,
|
|||
EventChainPostVisitor postVisitor(preVisitor);
|
||||
MOZ_RELEASE_ASSERT(!aEvent->mPath);
|
||||
aEvent->mPath = &chain;
|
||||
EventTargetChainItem::HandleEventTargetChain(chain, postVisitor,
|
||||
aCallback, cd);
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
if (profiler_is_active()) {
|
||||
// Add a profiler label and a profiler marker for the actual
|
||||
// dispatch of the event.
|
||||
// This is a very hot code path, so we need to make sure not to
|
||||
// do this extra work when we're not profiling.
|
||||
if (!postVisitor.mDOMEvent) {
|
||||
// This is tiny bit slow, but happens only once per event.
|
||||
// Similar code also in EventListenerManager.
|
||||
nsCOMPtr<EventTarget> et = aEvent->mOriginalTarget;
|
||||
RefPtr<Event> event = EventDispatcher::CreateEvent(et, aPresContext,
|
||||
aEvent,
|
||||
EmptyString());
|
||||
event.swap(postVisitor.mDOMEvent);
|
||||
}
|
||||
nsAutoString typeStr;
|
||||
postVisitor.mDOMEvent->GetType(typeStr);
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(
|
||||
"EventDispatcher::Dispatch", OTHER, typeStr);
|
||||
|
||||
profiler_add_marker(
|
||||
"DOMEvent",
|
||||
MakeUnique<DOMEventMarkerPayload>(typeStr,
|
||||
aEvent->mTimeStamp,
|
||||
"DOMEvent",
|
||||
TRACING_INTERVAL_START));
|
||||
|
||||
EventTargetChainItem::HandleEventTargetChain(chain, postVisitor,
|
||||
aCallback, cd);
|
||||
|
||||
profiler_add_marker(
|
||||
"DOMEvent",
|
||||
MakeUnique<DOMEventMarkerPayload>(typeStr,
|
||||
aEvent->mTimeStamp,
|
||||
"DOMEvent",
|
||||
TRACING_INTERVAL_END));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
EventTargetChainItem::HandleEventTargetChain(chain, postVisitor,
|
||||
aCallback, cd);
|
||||
}
|
||||
aEvent->mPath = nullptr;
|
||||
|
||||
preVisitor.mEventStatus = postVisitor.mEventStatus;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
#include "EventListenerService.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -52,10 +51,6 @@
|
|||
#include "nsIFrame.h"
|
||||
#include "nsDisplayList.h"
|
||||
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
#include "ProfilerMarkerPayload.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
|
@ -1249,6 +1244,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
|
|||
(aEvent->IsTrusted() || listener->mFlags.mAllowUntrustedEvents)) {
|
||||
if (!*aDOMEvent) {
|
||||
// This is tiny bit slow, but happens only once per event.
|
||||
// Similar code also in EventDispatcher.
|
||||
nsCOMPtr<EventTarget> et = aEvent->mOriginalTarget;
|
||||
RefPtr<Event> event = EventDispatcher::CreateEvent(et, aPresContext,
|
||||
aEvent,
|
||||
|
@ -1301,46 +1297,16 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
|
|||
hasRemovedListener = true;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsPIDOMWindowInner> innerWindow =
|
||||
WindowFromListener(listener, aItemInShadowTree);
|
||||
mozilla::dom::Event* oldWindowEvent = nullptr;
|
||||
if (innerWindow) {
|
||||
oldWindowEvent = innerWindow->SetEvent(*aDOMEvent);
|
||||
}
|
||||
#ifdef MOZ_GECKO_PROFILER
|
||||
if (profiler_is_active()) {
|
||||
// Add a profiler label and a profiler marker for the actual
|
||||
// dispatch of the event.
|
||||
// This is a very hot code path, so we need to make sure not to
|
||||
// do this extra work when we're not profiling.
|
||||
nsAutoString typeStr;
|
||||
(*aDOMEvent)->GetType(typeStr);
|
||||
AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(
|
||||
"EventListenerManager::HandleEventInternal", OTHER, typeStr);
|
||||
|
||||
uint16_t phase = (*aDOMEvent)->EventPhase();
|
||||
profiler_add_marker(
|
||||
"DOMEvent",
|
||||
MakeUnique<DOMEventMarkerPayload>(typeStr, phase,
|
||||
aEvent->mTimeStamp,
|
||||
"DOMEvent",
|
||||
TRACING_INTERVAL_START));
|
||||
nsresult rv =
|
||||
HandleEventSubType(listener, *aDOMEvent, aCurrentTarget);
|
||||
|
||||
rv = HandleEventSubType(listener, *aDOMEvent, aCurrentTarget);
|
||||
|
||||
phase = (*aDOMEvent)->EventPhase();
|
||||
profiler_add_marker(
|
||||
"DOMEvent",
|
||||
MakeUnique<DOMEventMarkerPayload>(typeStr, phase,
|
||||
aEvent->mTimeStamp,
|
||||
"DOMEvent",
|
||||
TRACING_INTERVAL_END));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
rv = HandleEventSubType(listener, *aDOMEvent, aCurrentTarget);
|
||||
}
|
||||
if (innerWindow) {
|
||||
Unused << innerWindow->SetEvent(oldWindowEvent);
|
||||
}
|
||||
|
|
|
@ -112,7 +112,6 @@ DOMEventMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
|
|||
|
||||
WriteTime(aWriter, aProcessStartTime, mTimeStamp, "timeStamp");
|
||||
aWriter.StringProperty("eventType", NS_ConvertUTF16toUTF8(mEventType).get());
|
||||
aWriter.IntProperty("phase", mPhase);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -125,13 +125,12 @@ private:
|
|||
class DOMEventMarkerPayload : public TracingMarkerPayload
|
||||
{
|
||||
public:
|
||||
DOMEventMarkerPayload(const nsAString& aEventType, uint16_t aPhase,
|
||||
DOMEventMarkerPayload(const nsAString& aEventType,
|
||||
const mozilla::TimeStamp& aTimeStamp,
|
||||
const char* aCategory, TracingKind aKind)
|
||||
: TracingMarkerPayload(aCategory, aKind)
|
||||
, mTimeStamp(aTimeStamp)
|
||||
, mEventType(aEventType)
|
||||
, mPhase(aPhase)
|
||||
{}
|
||||
|
||||
DECL_STREAM_PAYLOAD
|
||||
|
@ -139,7 +138,6 @@ public:
|
|||
private:
|
||||
mozilla::TimeStamp mTimeStamp;
|
||||
nsString mEventType;
|
||||
uint16_t mPhase;
|
||||
};
|
||||
|
||||
class UserTimingMarkerPayload : public ProfilerMarkerPayload
|
||||
|
|
Загрузка…
Ссылка в новой задаче