Skip to content

Commit 28f3cb5

Browse files
asurdej-comcasteocanha
authored andcommitted
[HTMLMediaElement] Reschedule timeupdate event if fired too early
https://bugs.webkit.org/show_bug.cgi?id=279055 Reviewed by Xabier Rodriguez-Calvar. HTMLMediaElement fires 'timeupdate' every 250ms in repeating timer. If the timer is fired before 250ms from the last occurrence, it is silently skipped and needs to wait for another 250ms. As a result, the gap between two following timeupdate events may vary 250-500ms. This may happen in two cases: 1) Non-periodic timeupdate event is scheduled for any reason. 2) When the difference between two timer calls is lower than 250ms. This may happen when there are multiple timers to handle at the same time in ThreadTimers (maxDurationOfFiringTimers). Original author: Andrzej Surdej <Andrzej_Surdej@comcast.com> See: #1392 * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::scheduleTimeupdateEvent): Schedule next event on the remaining time difference so that maxTimeupdateEventFrequency is honored, instead of waiting a full cycle. Canonical link: https://commits.webkit.org/283264@main
1 parent 0df71ef commit 28f3cb5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Source/WebCore/html/HTMLMediaElement.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4248,8 +4248,11 @@ void HTMLMediaElement::scheduleTimeupdateEvent(bool periodicEvent)
42484248
Seconds timedelta = now - m_clockTimeAtLastUpdateEvent;
42494249

42504250
// throttle the periodic events
4251-
if (periodicEvent && timedelta < maxTimeupdateEventFrequency)
4251+
if (periodicEvent && timedelta < maxTimeupdateEventFrequency) {
4252+
// Reschedule the timer to fire at the correct time, ensuring that no full cycles are skipped
4253+
m_playbackProgressTimer.start(maxTimeupdateEventFrequency - timedelta, maxTimeupdateEventFrequency);
42524254
return;
4255+
}
42534256

42544257
// Some media engines make multiple "time changed" callbacks at the same time, but we only want one
42554258
// event at a given time so filter here

0 commit comments

Comments
 (0)