Bug 1919123 - part4 : add marker to report how many video frames has been painted. r=media-playback-reviewers,padenot

Differential Revision: https://phabricator.services.mozilla.com/D222568
This commit is contained in:
alwu 2024-09-24 19:12:25 +00:00
parent 9c3aeab366
commit d3243193b2
4 changed files with 36 additions and 2 deletions

View File

@ -92,6 +92,7 @@ namespace mozilla::dom {
// Number of milliseconds between timeupdate events as defined by spec
#define TIMEUPDATE_MS 250
class HTMLVideoElement;
class MediaError;
class MediaSource;
class PlayPromise;
@ -152,6 +153,8 @@ class HTMLMediaElement : public nsGenericHTMLElement,
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
void Init();
virtual HTMLVideoElement* AsHTMLVideoElement() { return nullptr; };
// `eMandatory`: `timeupdate` occurs according to the spec requirement.
// Eg.
// https://html.spec.whatwg.org/multipage/media.html#seeking:event-media-timeupdate

View File

@ -39,6 +39,8 @@ class HTMLVideoElement final : public HTMLMediaElement {
using HTMLMediaElement::GetPaused;
HTMLVideoElement* AsHTMLVideoElement() override { return this; };
void Invalidate(ImageSizeChanged aImageSizeChanged,
const Maybe<nsIntSize>& aNewIntrinsicSize,
ForceInvalidate aForceInvalidate) override;

View File

@ -9,6 +9,7 @@
#include "mozilla/Casting.h"
#include "mozilla/ProfilerState.h"
#include "mozilla/dom/HTMLMediaElement.h"
#include "mozilla/dom/HTMLVideoElement.h"
#include "mozilla/dom/TimeRanges.h"
extern mozilla::LazyLogModule gMediaElementEventsLog;
@ -205,11 +206,13 @@ void nsTimeupdateRunner::ReportProfilerMarker() {
if (!profiler_is_collecting_markers()) {
return;
}
auto* videoElement = mElement->AsHTMLVideoElement();
profiler_add_marker(nsPrintfCString("%p:timeupdate", mElement.get()),
geckoprofiler::category::MEDIA_PLAYBACK, {},
TimeUpdateMarker{},
AssertedCast<uint64_t>(mElement->CurrentTime() * 1000),
GetElementDurationMs());
GetElementDurationMs(),
videoElement ? videoElement->MozPaintedFrames() : 0);
}
#undef LOG_EVENT

View File

@ -20,14 +20,20 @@ struct TimeUpdateMarker : public BaseMarkerType<TimeUpdateMarker> {
MS::Format::Milliseconds},
{"mediaDurationMs", MS::InputType::Uint64, "Media Duration (Ms)",
MS::Format::Milliseconds},
{"paintedFrames", MS::InputType::Uint32, "Painted Frames",
MS::Format::Integer}, // optional, zero for audio
};
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) {
uint64_t aCurrentTime, uint64_t aDuration,
uint32_t aPaintedFrames) {
aWriter.IntProperty("currentTimeMs", aCurrentTime);
aWriter.IntProperty("mediaDurationMs", aDuration);
if (aPaintedFrames != 0) {
aWriter.IntProperty("paintedFrames", aPaintedFrames);
}
}
};
@ -126,4 +132,24 @@ struct CDMResolvedMarker : public BaseMarkerType<CDMResolvedMarker> {
}
};
// This marker is for HTMLVideoElement
struct RenderVideoMarker : public BaseMarkerType<RenderVideoMarker> {
static constexpr const char* Name = "HTMLMediaElement:RenderVideo";
static constexpr const char* Description =
"A marker shows how many video frames has been painted";
using MS = MarkerSchema;
static constexpr MS::PayloadField PayloadFields[] = {
{"paintedFrames", MS::InputType::Uint64, "Painted Frames",
MS::Format::Integer},
};
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) {
aWriter.IntProperty("paintedFrames", aPaintedFrames);
}
};
} // namespace mozilla