Bug 1965023 - Convert media element markers to flows. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D248275
This commit is contained in:
committed by
jmuizelaar@mozilla.com
parent
2d0c0faeef
commit
2d71a5bc1e
@@ -2766,10 +2766,9 @@ void HTMLMediaElement::SelectResource() {
|
||||
LOG(LogLevel::Debug, ("%p Trying load from src=%s", this,
|
||||
NS_ConvertUTF16toUTF8(src).get()));
|
||||
if (profiler_is_collecting_markers()) {
|
||||
nsPrintfCString markerName{"%p:mozloadresource", this};
|
||||
profiler_add_marker(markerName, geckoprofiler::category::MEDIA_PLAYBACK,
|
||||
profiler_add_marker("loadresource", geckoprofiler::category::MEDIA_PLAYBACK,
|
||||
{}, LoadSourceMarker{}, nsString{src}, nsString{},
|
||||
nsString{});
|
||||
nsString{}, Flow::FromPointer(this));
|
||||
}
|
||||
|
||||
NS_ASSERTION(
|
||||
@@ -2827,9 +2826,10 @@ void HTMLMediaElement::NotifyLoadError(const nsACString& aErrorDetails) {
|
||||
NS_WARNING("Should know the source we were loading from!");
|
||||
}
|
||||
if (profiler_is_collecting_markers()) {
|
||||
profiler_add_marker(nsPrintfCString("%p:mozloaderror", this),
|
||||
profiler_add_marker("loaderror",
|
||||
geckoprofiler::category::MEDIA_PLAYBACK, {},
|
||||
LoadErrorMarker{}, aErrorDetails);
|
||||
LoadErrorMarker{}, aErrorDetails,
|
||||
Flow::FromPointer(this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3048,10 +3048,9 @@ void HTMLMediaElement::LoadFromSourceChildren() {
|
||||
NS_ConvertUTF16toUTF8(media).get()));
|
||||
|
||||
if (profiler_is_collecting_markers()) {
|
||||
nsPrintfCString markerName{"%p:mozloadresource", this};
|
||||
profiler_add_marker(markerName, geckoprofiler::category::MEDIA_PLAYBACK,
|
||||
profiler_add_marker("loadresource", geckoprofiler::category::MEDIA_PLAYBACK,
|
||||
{}, LoadSourceMarker{}, nsString{src}, nsString{type},
|
||||
nsString{media});
|
||||
nsString{media}, Flow::FromPointer(this));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
@@ -4492,6 +4491,9 @@ HTMLMediaElement::~HTMLMediaElement() {
|
||||
!mHasSelfReference,
|
||||
"How can we be destroyed if we're still holding a self reference?");
|
||||
|
||||
PROFILER_MARKER("~HTMLMediaElement", MEDIA_PLAYBACK, {}, TerminatingFlowMarker,
|
||||
Flow::FromPointer(this));
|
||||
|
||||
mWatchManager.Shutdown();
|
||||
|
||||
mShutdownObserver->Unsubscribe();
|
||||
@@ -7210,13 +7212,13 @@ void HTMLMediaElement::MakeAssociationWithCDMResolved() {
|
||||
if (mMediaKeys) {
|
||||
nsString keySystem;
|
||||
mMediaKeys->GetKeySystem(keySystem);
|
||||
profiler_add_marker(nsPrintfCString("%p:mozcdmresolved", this),
|
||||
profiler_add_marker("cdmresolved",
|
||||
geckoprofiler::category::MEDIA_PLAYBACK, {},
|
||||
CDMResolvedMarker{}, keySystem,
|
||||
mMediaKeys->GetMediaKeySystemConfigurationString());
|
||||
mMediaKeys->GetMediaKeySystemConfigurationString(),
|
||||
Flow::FromPointer(this));
|
||||
} else {
|
||||
nsPrintfCString markerName{"%p:mozremovemediakey", this};
|
||||
PROFILER_MARKER_UNTYPED(markerName, MEDIA_PLAYBACK);
|
||||
PROFILER_MARKER("removemediakey", MEDIA_PLAYBACK, {}, FlowMarker, Flow::FromPointer(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "mozilla/dom/HTMLVideoElement.h"
|
||||
#include "mozilla/dom/MediaError.h"
|
||||
#include "mozilla/dom/TimeRanges.h"
|
||||
#include "mozilla/FlowMarkers.h"
|
||||
|
||||
extern mozilla::LazyLogModule gMediaElementEventsLog;
|
||||
#define LOG_EVENT(type, msg) MOZ_LOG(gMediaElementEventsLog, type, msg)
|
||||
@@ -48,41 +49,42 @@ void nsMediaEventRunner::ReportProfilerMarker() {
|
||||
RefPtr<TimeRanges> buffered = mElement->Buffered();
|
||||
if (buffered && buffered->Length() > 0) {
|
||||
for (size_t i = 0; i < buffered->Length(); ++i) {
|
||||
profiler_add_marker(nsPrintfCString("%p:progress", mElement.get()),
|
||||
profiler_add_marker("progress",
|
||||
geckoprofiler::category::MEDIA_PLAYBACK, {},
|
||||
BufferedUpdateMarker{},
|
||||
AssertedCast<uint64_t>(buffered->Start(i) * 1000),
|
||||
AssertedCast<uint64_t>(buffered->End(i) * 1000),
|
||||
GetElementDurationMs());
|
||||
GetElementDurationMs(),
|
||||
Flow::FromPointer(mElement.get()));
|
||||
}
|
||||
}
|
||||
} else if (mEventName.EqualsLiteral("resize")) {
|
||||
MOZ_ASSERT(mElement->HasVideo());
|
||||
auto mediaInfo = mElement->GetMediaInfo();
|
||||
profiler_add_marker(nsPrintfCString("%p:resize", mElement.get()),
|
||||
profiler_add_marker("resize",
|
||||
geckoprofiler::category::MEDIA_PLAYBACK, {},
|
||||
VideoResizeMarker{}, mediaInfo.mVideo.mDisplay.width,
|
||||
mediaInfo.mVideo.mDisplay.height);
|
||||
mediaInfo.mVideo.mDisplay.height,
|
||||
Flow::FromPointer(mElement.get()));
|
||||
} else if (mEventName.EqualsLiteral("loadedmetadata")) {
|
||||
nsString src;
|
||||
mElement->GetCurrentSrc(src);
|
||||
auto mediaInfo = mElement->GetMediaInfo();
|
||||
profiler_add_marker(
|
||||
nsPrintfCString("%p:loadedmetadata", mElement.get()),
|
||||
profiler_add_marker("loadedmetadata",
|
||||
geckoprofiler::category::MEDIA_PLAYBACK, {}, MetadataMarker{}, src,
|
||||
mediaInfo.HasAudio() ? mediaInfo.mAudio.mMimeType : "none"_ns,
|
||||
mediaInfo.HasVideo() ? mediaInfo.mVideo.mMimeType : "none"_ns);
|
||||
mediaInfo.HasVideo() ? mediaInfo.mVideo.mMimeType : "none"_ns,
|
||||
Flow::FromPointer(mElement.get()));
|
||||
} else if (mEventName.EqualsLiteral("error")) {
|
||||
auto* error = mElement->GetError();
|
||||
nsString message;
|
||||
error->GetMessage(message);
|
||||
profiler_add_marker(nsPrintfCString("%p:error", mElement.get()),
|
||||
profiler_add_marker("error",
|
||||
geckoprofiler::category::MEDIA_PLAYBACK, {},
|
||||
ErrorMarker{}, message);
|
||||
ErrorMarker{}, message, Flow::FromPointer(mElement.get()));
|
||||
} else {
|
||||
nsPrintfCString markerName{"%p:", mElement.get()};
|
||||
markerName += NS_ConvertUTF16toUTF8(mEventName);
|
||||
PROFILER_MARKER_UNTYPED(markerName, MEDIA_PLAYBACK);
|
||||
auto eventName = NS_ConvertUTF16toUTF8(mEventName);
|
||||
PROFILER_MARKER(eventName, MEDIA_PLAYBACK, {}, FlowMarker, Flow::FromPointer(mElement.get()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,9 +170,10 @@ NS_IMETHODIMP nsSourceErrorEventRunner::Run() {
|
||||
LOG_EVENT(LogLevel::Debug,
|
||||
("%p Dispatching simple event source error", mElement.get()));
|
||||
if (profiler_is_collecting_markers()) {
|
||||
profiler_add_marker(nsPrintfCString("%p:sourceerror", mElement.get()),
|
||||
profiler_add_marker("sourceerror",
|
||||
geckoprofiler::category::MEDIA_PLAYBACK, {},
|
||||
ErrorMarker{}, mErrorDetails);
|
||||
ErrorMarker{}, mErrorDetails,
|
||||
Flow::FromPointer(mElement.get()));
|
||||
}
|
||||
return nsContentUtils::DispatchTrustedEvent(mElement->OwnerDoc(), mSource,
|
||||
u"error"_ns, CanBubble::eNo,
|
||||
@@ -220,12 +223,13 @@ void nsTimeupdateRunner::ReportProfilerMarker() {
|
||||
return;
|
||||
}
|
||||
auto* videoElement = mElement->AsHTMLVideoElement();
|
||||
profiler_add_marker(nsPrintfCString("%p:timeupdate", mElement.get()),
|
||||
profiler_add_marker("timeupdate",
|
||||
geckoprofiler::category::MEDIA_PLAYBACK, {},
|
||||
TimeUpdateMarker{},
|
||||
AssertedCast<uint64_t>(mElement->CurrentTime() * 1000),
|
||||
GetElementDurationMs(),
|
||||
videoElement ? videoElement->MozPaintedFrames() : 0);
|
||||
videoElement ? videoElement->MozPaintedFrames() : 0,
|
||||
Flow::FromPointer(mElement.get()));
|
||||
}
|
||||
|
||||
#undef LOG_EVENT
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "mozilla/BaseProfilerMarkersPrerequisites.h"
|
||||
#include "mozilla/ProfilerMarkers.h"
|
||||
#include "mozilla/Flow.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@@ -22,18 +23,21 @@ struct TimeUpdateMarker : public BaseMarkerType<TimeUpdateMarker> {
|
||||
MS::Format::Milliseconds},
|
||||
{"paintedFrames", MS::InputType::Uint32, "Painted Frames",
|
||||
MS::Format::Integer}, // optional, zero for audio
|
||||
{"element", MS::InputType::Uint64, "Element", MS::Format::Flow, MS::PayloadFlags::Searchable},
|
||||
};
|
||||
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
|
||||
MS::Location::MarkerTable};
|
||||
static constexpr const char* ChartLabel = "{marker.data.name}";
|
||||
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
|
||||
uint64_t aCurrentTime, uint64_t aDuration,
|
||||
uint32_t aPaintedFrames) {
|
||||
uint32_t aPaintedFrames,
|
||||
Flow aFlow) {
|
||||
aWriter.IntProperty("currentTimeMs", aCurrentTime);
|
||||
aWriter.IntProperty("mediaDurationMs", aDuration);
|
||||
if (aPaintedFrames != 0) {
|
||||
aWriter.IntProperty("paintedFrames", aPaintedFrames);
|
||||
}
|
||||
aWriter.FlowProperty("element", aFlow);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,6 +54,7 @@ struct BufferedUpdateMarker : public BaseMarkerType<BufferedUpdateMarker> {
|
||||
MS::Format::Milliseconds},
|
||||
{"mediaDurationMs", MS::InputType::Uint64, "Media Duration (Ms)",
|
||||
MS::Format::Milliseconds},
|
||||
{"element", MS::InputType::Uint64, "Element", MS::Format::Flow, MS::PayloadFlags::Searchable},
|
||||
};
|
||||
|
||||
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
|
||||
@@ -57,10 +62,12 @@ struct BufferedUpdateMarker : public BaseMarkerType<BufferedUpdateMarker> {
|
||||
static constexpr const char* ChartLabel = "{marker.data.name}";
|
||||
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
|
||||
uint64_t aBufferStart, uint64_t aBufferEnd,
|
||||
uint64_t aDuration) {
|
||||
uint64_t aDuration,
|
||||
Flow aFlow) {
|
||||
aWriter.IntProperty("bufferStartMs", aBufferStart);
|
||||
aWriter.IntProperty("bufferEndMs", aBufferEnd);
|
||||
aWriter.IntProperty("mediaDurationMs", aDuration);
|
||||
aWriter.FlowProperty("element", aFlow);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -73,15 +80,18 @@ struct VideoResizeMarker : public BaseMarkerType<VideoResizeMarker> {
|
||||
static constexpr MS::PayloadField PayloadFields[] = {
|
||||
{"width", MS::InputType::Uint64, "Width", MS::Format::Integer},
|
||||
{"height", MS::InputType::Uint64, "Height", MS::Format::Integer},
|
||||
{"element", MS::InputType::Uint64, "Element", MS::Format::Flow, MS::PayloadFlags::Searchable},
|
||||
};
|
||||
|
||||
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
|
||||
MS::Location::MarkerTable};
|
||||
static constexpr const char* ChartLabel = "{marker.data.name}";
|
||||
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
|
||||
uint64_t aWidth, uint64_t aHeight) {
|
||||
uint64_t aWidth, uint64_t aHeight,
|
||||
Flow aFlow) {
|
||||
aWriter.IntProperty("width", aWidth);
|
||||
aWriter.IntProperty("height", aHeight);
|
||||
aWriter.FlowProperty("element", aFlow);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -97,6 +107,7 @@ struct MetadataMarker : public BaseMarkerType<MetadataMarker> {
|
||||
MS::Format::String},
|
||||
{"videoMimeType", MS::InputType::CString, "Video Mimetype",
|
||||
MS::Format::String},
|
||||
{"element", MS::InputType::Uint64, "Element", MS::Format::Flow, MS::PayloadFlags::Searchable},
|
||||
};
|
||||
|
||||
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
|
||||
@@ -105,8 +116,9 @@ struct MetadataMarker : public BaseMarkerType<MetadataMarker> {
|
||||
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
|
||||
const ProfilerString16View& aSrc,
|
||||
const ProfilerString8View& aAudioMimeType,
|
||||
const ProfilerString8View& aVideoMimeType) {
|
||||
StreamJSONMarkerDataImpl(aWriter, aSrc, aAudioMimeType, aVideoMimeType);
|
||||
const ProfilerString8View& aVideoMimeType,
|
||||
Flow aFlow) {
|
||||
StreamJSONMarkerDataImpl(aWriter, aSrc, aAudioMimeType, aVideoMimeType, aFlow);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -120,6 +132,7 @@ struct CDMResolvedMarker : public BaseMarkerType<CDMResolvedMarker> {
|
||||
{"keySystem", MS::InputType::String, "Key System", MS::Format::String},
|
||||
{"configuration", MS::InputType::CString, "Configuration",
|
||||
MS::Format::String},
|
||||
{"element", MS::InputType::Uint64, "Element", MS::Format::Flow, MS::PayloadFlags::Searchable},
|
||||
};
|
||||
|
||||
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
|
||||
@@ -127,8 +140,9 @@ struct CDMResolvedMarker : public BaseMarkerType<CDMResolvedMarker> {
|
||||
static constexpr const char* ChartLabel = "{marker.data.name}";
|
||||
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
|
||||
const ProfilerString16View& aKeySystem,
|
||||
const ProfilerString8View& aConfiguration) {
|
||||
StreamJSONMarkerDataImpl(aWriter, aKeySystem, aConfiguration);
|
||||
const ProfilerString8View& aConfiguration,
|
||||
Flow aFlow) {
|
||||
StreamJSONMarkerDataImpl(aWriter, aKeySystem, aConfiguration, aFlow);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -141,13 +155,15 @@ struct LoadErrorMarker : public BaseMarkerType<LoadErrorMarker> {
|
||||
static constexpr MS::PayloadField PayloadFields[] = {
|
||||
{"errorMessage", MS::InputType::CString, "Error Message",
|
||||
MS::Format::String},
|
||||
{"element", MS::InputType::Uint64, "Element", MS::Format::Flow, MS::PayloadFlags::Searchable},
|
||||
};
|
||||
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
|
||||
MS::Location::MarkerTable};
|
||||
static constexpr const char* ChartLabel = "{marker.data.name}";
|
||||
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
|
||||
const ProfilerString8View& aErrorMsg) {
|
||||
StreamJSONMarkerDataImpl(aWriter, aErrorMsg);
|
||||
const ProfilerString8View& aErrorMsg,
|
||||
Flow aFlow) {
|
||||
StreamJSONMarkerDataImpl(aWriter, aErrorMsg, aFlow);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -160,13 +176,15 @@ struct ErrorMarker : public BaseMarkerType<ErrorMarker> {
|
||||
static constexpr MS::PayloadField PayloadFields[] = {
|
||||
{"errorMessage", MS::InputType::String, "Error Message",
|
||||
MS::Format::String},
|
||||
{"element", MS::InputType::Uint64, "Element", MS::Format::Flow, MS::PayloadFlags::Searchable},
|
||||
};
|
||||
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
|
||||
MS::Location::MarkerTable};
|
||||
static constexpr const char* ChartLabel = "{marker.data.name}";
|
||||
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
|
||||
const ProfilerString16View& aErrorMsg) {
|
||||
StreamJSONMarkerDataImpl(aWriter, aErrorMsg);
|
||||
const ProfilerString16View& aErrorMsg,
|
||||
Flow aFlow) {
|
||||
StreamJSONMarkerDataImpl(aWriter, aErrorMsg, aFlow);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -182,6 +200,7 @@ struct LoadSourceMarker : public BaseMarkerType<LoadSourceMarker> {
|
||||
{"contentType", MS::InputType::String, "Content Type",
|
||||
MS::Format::String},
|
||||
{"media", MS::InputType::String, "Media", MS::Format::String},
|
||||
{"element", MS::InputType::Uint64, "Element", MS::Format::Flow, MS::PayloadFlags::Searchable},
|
||||
};
|
||||
|
||||
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
|
||||
@@ -190,8 +209,9 @@ struct LoadSourceMarker : public BaseMarkerType<LoadSourceMarker> {
|
||||
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
|
||||
const ProfilerString16View& aSrc,
|
||||
const ProfilerString16View& aType,
|
||||
const ProfilerString16View& aMedia) {
|
||||
StreamJSONMarkerDataImpl(aWriter, aSrc, aType, aMedia);
|
||||
const ProfilerString16View& aMedia,
|
||||
Flow aFlow) {
|
||||
StreamJSONMarkerDataImpl(aWriter, aSrc, aType, aMedia, aFlow);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -205,13 +225,16 @@ struct RenderVideoMarker : public BaseMarkerType<RenderVideoMarker> {
|
||||
static constexpr MS::PayloadField PayloadFields[] = {
|
||||
{"paintedFrames", MS::InputType::Uint64, "Painted Frames",
|
||||
MS::Format::Integer},
|
||||
{"element", MS::InputType::Uint64, "Element", MS::Format::Flow, MS::PayloadFlags::Searchable},
|
||||
};
|
||||
static constexpr MS::Location Locations[] = {MS::Location::MarkerChart,
|
||||
MS::Location::MarkerTable};
|
||||
static constexpr const char* ChartLabel = "{marker.data.name}";
|
||||
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
|
||||
uint64_t aPaintedFrames) {
|
||||
uint64_t aPaintedFrames,
|
||||
Flow aFlow) {
|
||||
aWriter.IntProperty("paintedFrames", aPaintedFrames);
|
||||
aWriter.FlowProperty("element", aFlow);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user