Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4dd78df3a13ebaa6d39c5e2745c159ab9af0f392
      
https://github.com/WebKit/WebKit/commit/4dd78df3a13ebaa6d39c5e2745c159ab9af0f392
  Author: Jean-Yves Avenard <[email protected]>
  Date:   2026-05-13 (Wed, 13 May 2026)

  Changed paths:
    A 
LayoutTests/media/media-source/media-source-duration-truncation-ended-expected.txt
    A LayoutTests/media/media-source/media-source-duration-truncation-ended.html
    M LayoutTests/platform/glib/TestExpectations
    M 
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

  Log Message:
  -----------
  [MSE] 'ended' event never fires when MediaSource.endOfStream() is
called while playback is parked at buffered-range end equal to
the final duration
https://bugs.webkit.org/show_bug.cgi?id=314628
rdar://problem/176863546

Reviewed by Jer Noble.

In the WPT mediasource-duration.html "setting same duration multiple
times does not fire duplicate durationchange" subtest, after the test
removes data past a target point, sets MediaSource.duration to that
point, and calls endOfStream(), the HTMLMediaElement 'ended' event
is never fired and the test harness times out.

HTMLMediaElement::mediaPlayerTimeChanged() is the only site that
schedules 'ended' (now >= dur && playbackRate > 0). In this scenario
none of the existing call sites for timeChanged() reach it after
MediaSource has transitioned to 'ended':

  - The notifyTimeReachedAndStall boundary-observer callback fired
    earlier when playback first reached the buffered-range end, but at
    that moment duration was still the pre-truncation value, so
    stallTime != duration() and it took the mid-content branch. It
    pinned the synchronizer at the boundary and does not fire again.
  - HTMLMediaElement::mediaPlayerDurationChanged only seeks when
    now > dur strictly; the equality case (currentTime == new duration)
    doesn't trigger seekInternal, so no completeSeek -> timeChanged.
  - MediaSource::monitorSourceBuffers handles readyState transitions
    per MSE spec but does not schedule 'ended'.

We stop firing a `timeupdate` event whenever we stall() this is handled
by the MediaSource::monitorSourceBuffers algorithm.

Had we stalled at the end of the video element, when endOfStream() is called
force the transition of the media element to ended by calling 
mediaPlayerTimeChanged.

Test: media/media-source/media-source-duration-truncation-ended.html
Canonical link: https://commits.webkit.org/313141@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to