Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wpe-2.38] [HTMLMediaElement] Reschedule timeupdate event if fired too early #1392

Conversation

asurdej-comcast
Copy link

@asurdej-comcast asurdej-comcast commented Aug 26, 2024

HTMLMediaElement fires timeupdate every 250ms in repeating timer. If timer is fired before 250ms from the last occurance 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.
    The second may happen when there are multiple timers to handle at the same time in ThreadTimers (maxDurationOfFiringTimers)

Reproduced with https://ytlr-cert.appspot.com/latest/main.html?&test_type=progressive-test#1724678529990 maxGranularity tests

HTMLMediaElement fires `timeupdate` every 250ms in repeating timer.
If timer is fired before 250ms from the last occurance 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.
The second may happen when there are multiple timers to handle at the same time
in ThreadTimers (maxDurationOfFiringTimers)
@magomez magomez requested review from philn, calvaris and eocanha and removed request for magomez September 3, 2024 07:46
eocanha added a commit to eocanha/WebKit that referenced this pull request Sep 3, 2024
https://bugs.webkit.org/show_bug.cgi?id=279055

Reviewed by NOBODY (OOPS!).

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 <[email protected]>

See: WebPlatformForEmbedded/WPEWebKit#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.
@calvaris
Copy link
Member

calvaris commented Sep 4, 2024

I'll study this and upstream it if need it.

@eocanha
Copy link
Member

eocanha commented Sep 4, 2024

I have already submitted it upstream for review as https://bugs.webkit.org/show_bug.cgi?id=279055 / WebKit/WebKit#33060. Sorry for not mentioning it earlier.

webkit-commit-queue pushed a commit to eocanha/WebKit that referenced this pull request Sep 6, 2024
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 <[email protected]>

See: WebPlatformForEmbedded/WPEWebKit#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
eocanha pushed a commit that referenced this pull request Sep 6, 2024
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 <[email protected]>

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
@eocanha eocanha added the upstream Related to an upstream bug (or should be at some point) label Sep 6, 2024
@eocanha
Copy link
Member

eocanha commented Sep 6, 2024

Patch landed upstream as WebKit/WebKit@fb9b613 and backported to wpe-2.38 as 28f3cb5. Closing this PR.

@eocanha eocanha closed this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Related to an upstream bug (or should be at some point) wpe-2.38
Development

Successfully merging this pull request may close these issues.

4 participants