Bug 1127646 - Report MSE Join Latency and MTBR in telemetry - r=cpearce,bsmedberg

This commit is contained in:
Chris Double 2015-02-24 16:11:43 +13:00
Родитель 4792b850ba
Коммит 1ef0fc9d78
4 изменённых файлов: 99 добавлений и 1 удалений

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

@ -1219,6 +1219,9 @@ nsresult HTMLMediaElement::LoadResource()
mMediaSource = source.forget();
nsRefPtr<MediaResource> resource =
MediaSourceDecoder::CreateResource(mMediaSource->GetPrincipal());
if (IsAutoplayEnabled()) {
mJoinLatency.Start();
}
return FinishDecoderSetup(decoder, resource, nullptr, nullptr);
}
@ -2585,6 +2588,17 @@ HTMLMediaElement::ReportMSETelemetry()
Telemetry::Accumulate(Telemetry::VIDEO_MSE_UNLOAD_STATE, state);
LOG(PR_LOG_DEBUG, ("%p VIDEO_MSE_UNLOAD_STATE = %d", this, state));
Telemetry::Accumulate(Telemetry::VIDEO_MSE_PLAY_TIME_MS, SECONDS_TO_MS(mPlayTime.Total()));
LOG(PR_LOG_DEBUG, ("%p VIDEO_MSE_PLAY_TIME_MS = %f", this, mPlayTime.Total()));
Telemetry::Accumulate(Telemetry::VIDEO_MSE_BUFFERING_COUNT, mRebufferTime.Count());
LOG(PR_LOG_DEBUG, ("%p VIDEO_MSE_BUFFERING_COUNT = %d", this, mRebufferTime.Count()));
double latency = mJoinLatency.Count() ? mJoinLatency.Total() / mJoinLatency.Count() : 0.0;
Telemetry::Accumulate(Telemetry::VIDEO_MSE_JOIN_LATENCY_MS, SECONDS_TO_MS(latency));
LOG(PR_LOG_DEBUG, ("%p VIDEO_MSE_JOIN_LATENCY = %f (%d ms) count=%d\n",
this, latency, SECONDS_TO_MS(latency), mJoinLatency.Count()));
}
void HTMLMediaElement::UnbindFromTree(bool aDeep,
@ -3664,6 +3678,23 @@ nsresult HTMLMediaElement::DispatchAsyncEvent(const nsAString& aName)
nsCOMPtr<nsIRunnable> event = new nsAsyncEventRunner(aName, this);
NS_DispatchToMainThread(event);
// Only collect rebuffer and stall rate stats for MSE video.
if (!mMediaSource) {
return NS_OK;
}
if ((aName.EqualsLiteral("play") || aName.EqualsLiteral("playing"))) {
mPlayTime.Start();
mRebufferTime.Pause();
mJoinLatency.Pause();
} else if (aName.EqualsLiteral("waiting")) {
mPlayTime.Pause();
mRebufferTime.Start();
} else if (aName.EqualsLiteral("pause")) {
mPlayTime.Pause();
}
return NS_OK;
}

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

@ -1354,6 +1354,51 @@ protected:
ElementInTreeState mElementInTreeState;
public:
// Helper class to measure times for MSE telemetry stats
class TimeDurationAccumulator {
public:
TimeDurationAccumulator()
: mCount(0)
{
}
void Start() {
if (IsStarted()) {
return;
}
mStartTime = TimeStamp::Now();
}
void Pause() {
if (!IsStarted()) {
return;
}
mSum += (TimeStamp::Now() - mStartTime);
mCount++;
mStartTime = TimeStamp();
}
bool IsStarted() const {
return !mStartTime.IsNull();
}
double Total() const {
return mSum.ToSeconds();
}
uint32_t Count() const {
return mCount;
}
private:
TimeStamp mStartTime;
TimeDuration mSum;
uint32_t mCount;
};
private:
// Total time an MSE video has spent playing
TimeDurationAccumulator mPlayTime;
// Time spent buffering in an MSE video
TimeDurationAccumulator mRebufferTime;
// Time spent between video load and video playback.
TimeDurationAccumulator mJoinLatency;
};
} // namespace dom

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

@ -148,8 +148,11 @@ static const int64_t USECS_PER_S = 1000000;
// Number of microseconds per millisecond.
static const int64_t USECS_PER_MS = 1000;
// Converts milliseconds to seconds.
#define MS_TO_SECONDS(ms) ((double)(ms) / (PR_MSEC_PER_SEC))
// Converts seconds to milliseconds.
#define MS_TO_SECONDS(s) ((double)(s) / (PR_MSEC_PER_SEC))
#define SECONDS_TO_MS(s) ((int)((s) * (PR_MSEC_PER_SEC)))
// Converts from seconds to microseconds. Returns failure if the resulting
// integer is too big to fit in an int64_t.

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

@ -7399,6 +7399,25 @@
"n_buckets": 16,
"description": "The number of entries in persistent DataStorage (HSTS and HPKP data, basically)"
},
"VIDEO_MSE_JOIN_LATENCY_MS" : {
"expires_in_version": "45",
"description": "Time in MS between MSE video load and playback",
"kind": "exponential",
"high": "30000",
"n_buckets": 50
},
"VIDEO_MSE_PLAY_TIME_MS" : {
"expires_in_version": "45",
"description": "Total time spent playing MSE video",
"kind": "exponential",
"high": "7200000",
"n_buckets": 100
},
"VIDEO_MSE_BUFFERING_COUNT" : {
"expires_in_version": "45",
"description": "Count of times that MSE video was buffering",
"kind": "count"
},
"VIDEO_MSE_UNLOAD_STATE": {
"expires_in_version": "45",
"kind": "enumerated",