[webkit-changes] [WebKit/WebKit] c55cda: [MSE] Change canPlayThroughRange to check buffered...

Enrique Ocaña González noreply at github.com
Mon Jan 8 07:49:29 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c55cda1034c1186dcc545119f1e5f108b86a5159
      https://github.com/WebKit/WebKit/commit/c55cda1034c1186dcc545119f1e5f108b86a5159
  Author: Enrique Ocaña González <eocanha at igalia.com>
  Date:   2024-01-08 (Mon, 08 Jan 2024)

  Changed paths:
    M LayoutTests/media/media-source/media-managedmse-resume-after-stall-expected.txt
    M LayoutTests/media/media-source/media-managedmse-resume-after-stall.html
    M LayoutTests/media/media-source/media-source-monitor-playing-event-expected.txt
    M LayoutTests/media/media-source/media-source-monitor-playing-event.html
    M Source/WebCore/Modules/mediasource/SourceBuffer.cpp
    M Source/WebCore/Modules/mediasource/SourceBuffer.h
    M Source/WebCore/platform/graphics/SourceBufferPrivate.cpp
    M Source/WebCore/platform/graphics/SourceBufferPrivateClient.h
    M Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.cpp
    M Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.h
    M Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp
    M Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h
    M Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in

  Log Message:
  -----------
  [MSE] Change canPlayThroughRange to check buffered data at the current position https://bugs.webkit.org/show_bug.cgi?id=265023

Reviewed by Xabier Rodriguez-Calvar.

The current SourceBuffer::canPlayThroughRange() implementation is based on average buffering
rate. While this approach makes sense in a context of continuous playback, where the JS app
is always trying to append data, this isn't always the case in some real life apps. For
instance, an app may append a lot of data on page load (enough for sustained playback), then
decide to wait for whatever reason, and then start playback. In those circumstances, wait
would cause the average buffering rate to be artificially low. There are more examples of
the kind of problems that a time-based/average buffering rate-based approach may cause.

See: https://github.com/WebPlatformForEmbedded/WPEWebKit/issues/928

This patch uses the Firefox strategy to this problem[1]: if the ranges to be checked have 3
seconds or more buffered after the current position, we consider that sustained playback is
possible. This solves the issues seen in some real world apps.

All the logic to monitor and compute the buffering rate has been removed, because it would
have remained unused after this change.

Based on code from Arnaud Vrac <avrac at freebox.fr> and Jean-Yves Avenard <jyavenard at mozilla.com>.

[1] https://github.com/mozilla/gecko-dev/blob/master/dom/media/mediasource/MediaSourceDecoder.cpp#L320

* LayoutTests/media/media-source/media-source-monitor-playing-event-expected.txt: Changed expectation after second append to be HAVE_CURRENT_DATA instead of HAVE_ENOUGH_DATA because the current playback implementation in MockMediaPlayerMediaSource advances playback to the end of the buffered range, so there's no 3s buffered slack after that (needed to get enough data).
* LayoutTests/media/media-source/media-source-monitor-playing-event.html: Added some clarification comments. Coalesce multiple 'waiting' events, since they're time dependant and can change between platforms.
* LayoutTests/media/media-source/media-managedmse-resume-after-stall-expected.txt: Changed expectation to conform to 3s + 3s buffered segments.
* LayoutTests/media/media-source/media-managedmse-resume-after-stall.html: Buffer a minimum of 3s (3 segments) instead of 2, because 3s is the new limit to reach canPlayThrough.
* Source/WebCore/Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::appendBuffer): Remove call to monitorBufferingRate().
(WebCore::SourceBuffer::sourceBufferPrivateAppendComplete): Ditto.
(WebCore::SourceBuffer::canPlayThroughRange): Removed implementation based on m_averageBufferRate. Now return true if the ranges have at least 3 seconds of data after currentTime (with a special case that accounts for the end of the video). Use a tolerance to prevent small errors.
(WebCore::SourceBuffer::sourceBufferPrivateDidParseSample): Deleted.
(WebCore::SourceBuffer::monitorBufferingRate): Deleted.
* Source/WebCore/Modules/mediasource/SourceBuffer.h: Deleted sourceBufferPrivateDidParseSample() and monitorBufferingRate().
* Source/WebCore/platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::processMediaSample): Remove call to sourceBufferPrivateDidParseSample(). Added comment about the tolerance being the same as in SourceBuffer::canPlayThroughRange().
* Source/WebCore/platform/graphics/SourceBufferPrivateClient.h: Deleted sourceBufferPrivateDidParseSample().
* Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.cpp:
(WebKit::RemoteSourceBufferProxy::sourceBufferPrivateDidParseSample): Deleted.
* Source/WebKit/GPUProcess/media/RemoteSourceBufferProxy.h: Deleted sourceBufferPrivateDidParseSample().
* Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.cpp:
(WebKit::SourceBufferPrivateRemote::sourceBufferPrivateDidParseSample): Deleted.
* Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.h: Deleted sourceBufferPrivateDidParseSample().
* Source/WebKit/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in: Deleted sourceBufferPrivateDidParseSample message.

Canonical link: https://commits.webkit.org/272762@main




More information about the webkit-changes mailing list