Skip to content

Commit

Permalink
[MSE] Prevent false-positive "stalled" event iff MSE used
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=226882
<rdar://problem/79454993>

Reviewed by Alicia Boya Garcia.

Source/WebCore:

"progress" and "stalled" events make no sense in context of MSE:
w3c/media-source#88
and hence they will likely be removed soon:
https://w3c.github.io/media-source/#h-note-19

This patch is authored by Pawel Lampe <pawel.lampe@gmail.com>.
See: #711

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::progressEventTimerFired): Only fire the progess event if the player supports progress monitoring.
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::supportsProgressMonitoring const): Forward call to the player private.
* platform/graphics/MediaPlayer.h: Added new supportsProgressMonitoring() method.
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::supportsProgressMonitoring const): Added method, defaulting to true to trigger the old behaviour.
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h: Return false on new supportsProgressMonitoring() method to prevent progress event triggering.

LayoutTests:

* platform/glib/imported/w3c/web-platform-tests/media-source/mediasource-append-buffer-expected.txt: Updated expectations.

Canonical link: https://commits.webkit.org/241359@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282059 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Scony authored and eocanha committed Sep 15, 2022
1 parent 1dd175d commit 35fa0c0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Source/WebCore/html/HTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2885,6 +2885,8 @@ void HTMLMediaElement::progressEventTimerFired()
ASSERT(m_player);
if (m_networkState != NETWORK_LOADING)
return;
if (!m_player->supportsProgressMonitoring())
return;

MonotonicTime time = MonotonicTime::now();
Seconds timedelta = time - m_previousProgressTime;
Expand Down
5 changes: 5 additions & 0 deletions Source/WebCore/platform/graphics/MediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,11 @@ bool MediaPlayer::supportsScanning() const
return m_private->supportsScanning();
}

bool MediaPlayer::supportsProgressMonitoring() const
{
return m_private->supportsProgressMonitoring();
}

bool MediaPlayer::requiresImmediateCompositing() const
{
return m_private->requiresImmediateCompositing();
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/platform/graphics/MediaPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ class WEBCORE_EXPORT MediaPlayer : public MediaPlayerEnums, public RefCounted<Me
bool supportsFullscreen() const;
bool supportsScanning() const;
bool canSaveMediaData() const;
bool supportsProgressMonitoring() const;
bool requiresImmediateCompositing() const;
bool doesHaveAttribute(const AtomString&, AtomString* value = nullptr) const;
PlatformLayer* platformLayer() const;
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class MediaPlayerPrivateInterface {
virtual bool supportsPictureInPicture() const { return false; }
virtual bool supportsFullscreen() const { return false; }
virtual bool supportsScanning() const { return false; }
virtual bool supportsProgressMonitoring() const { return true; }
virtual bool requiresImmediateCompositing() const { return false; }

virtual bool canSaveMediaData() const { return false; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class MediaPlayerPrivateGStreamerMSE : public MediaPlayerPrivateGStreamer {

void sourceSetup(GstElement*) override;

// return false to avoid false-positive "stalled" event - it should be soon addressed in the spec
// see: https://github.com/w3c/media-source/issues/88
// see: https://w3c.github.io/media-source/#h-note-19
bool supportsProgressMonitoring() const override { return false; }

void setReadyState(MediaPlayer::ReadyState);
void waitForSeekCompleted();
void seekCompleted();
Expand Down

0 comments on commit 35fa0c0

Please sign in to comment.