commit 43307fa6bc0b490b20026299e81f7132c81d2959
parent fe275c09b01e3ad3d84d830999c32a958012937a
Author: Jens Stutte <jstutte@mozilla.com>
Date: Sat, 25 Oct 2025 06:46:44 +0000
Bug 1996196 - Use Now instead of NowLoRes in HTMLMediaElement. r=alwu
When using NowLoRes, there could be cases where we come here again fast enough to not see any difference when calling NowLoRes again, therefore we forced the timestamp back by a minimum duration.
There is less reason for NowLoRes these days and thanks to this we can remove the TimeDuration::Resolution usage here (the HiRes-clock advances faster than even two calls to Now in a row).
This basically re-establishes the situation before bug 1108787 patch "use NowLoRes() for progress event timing".
Differential Revision: https://phabricator.services.mozilla.com/D270040
Diffstat:
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/dom/media/mediaelement/HTMLMediaElement.cpp b/dom/media/mediaelement/HTMLMediaElement.cpp
@@ -6110,7 +6110,7 @@ void HTMLMediaElement::CheckProgress(bool aHaveNewProgress) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(mNetworkState == NETWORK_LOADING);
- TimeStamp now = TimeStamp::NowLoRes();
+ TimeStamp now = TimeStamp::Now();
if (aHaveNewProgress) {
mDataTime = now;
@@ -6128,14 +6128,7 @@ void HTMLMediaElement::CheckProgress(bool aHaveNewProgress) {
TimeDuration::FromMilliseconds(PROGRESS_MS) &&
mDataTime > mProgressTime)) {
QueueEvent(u"progress"_ns);
- // Resolution() ensures that future data will have now > mProgressTime,
- // and so will trigger another event. mDataTime is not reset because it
- // is still required to detect stalled; it is similarly offset by
- // resolution to indicate the new data has not yet arrived.
- mProgressTime = now - TimeDuration::Resolution();
- if (mDataTime > mProgressTime) {
- mDataTime = mProgressTime;
- }
+ mProgressTime = now;
if (!mProgressTimer) {
NS_ASSERTION(aHaveNewProgress,
"timer dispatched when there was no timer");
@@ -6186,7 +6179,7 @@ void HTMLMediaElement::StartProgressTimer() {
void HTMLMediaElement::StartProgress() {
// Record the time now for detecting stalled.
- mDataTime = TimeStamp::NowLoRes();
+ mDataTime = TimeStamp::Now();
// Reset mProgressTime so that mDataTime is not indicating bytes received
// after the last progress event.
mProgressTime = TimeStamp();