Skip to content

[MSE][GStreamer] don't push samples while seeking #1528

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

Open
wants to merge 1 commit into
base: wpe-2.46
Choose a base branch
from

Conversation

emutavchi
Copy link
Collaborator

MediaSource::waitForTarget completes asynchronously. Even when the target time is already buffered, it still enqueues a task to compute seek time on next event loop cycle. This can lead to SourceBuffer providing media data for incorrect time, after GStreamer seek already flushed the source. For example this happens if
TrackQueue::LowLevelHandler callback was posted just before the seek.

The proposed change implements SourceBufferPrivate::isSeeking() that returns true until MSE seek is completed, effectivly blocking SourceBufferPrivate::provideMediaData during the seek.

MediaSource::waitForTarget completes asynchronously. Even when the
target time is already buffered, it still enqueues a task to compute
seek time on next event loop cycle. This can lead to SourceBuffer
providing media data for incorrect time, after GStreamer seek already
flushed the source. For example this happens if
TrackQueue::LowLevelHandler callback was posted just before the seek.

The proposed change implements SourceBufferPrivate::isSeeking() that
returns true until MSE seek is completed, effectivly blocking
SourceBufferPrivate::provideMediaData during the seek.
@emutavchi emutavchi requested a review from philn as a code owner June 27, 2025 18:54
@philn philn requested review from eocanha and removed request for philn June 29, 2025 17:31
eocanha added a commit to eocanha/WebKit that referenced this pull request Jul 3, 2025
https://bugs.webkit.org/show_bug.cgi?id=295415

Reviewed by NOBODY (OOPS!).

MediaSource::waitForTarget completes asynchronously. Even when the
target time is already buffered, it still enqueues a task to compute
seek time on next event loop cycle. This can lead to SourceBuffer
providing media data for incorrect time, after GStreamer seek already
flushed the source. For example this happens if
TrackQueue::LowLevelHandler callback was posted just before the seek.

The proposed change implements SourceBufferPrivate::isSeeking() that
returns true until MSE seek is completed, effectivly blocking
SourceBufferPrivate::provideMediaData during the seek.

See: WebPlatformForEmbedded/WPEWebKit#1528

Original author: Eugene Mutavchi <[email protected]>

* Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::doSeek): Signal the seek intent to the media source private.
* Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp:
(WebCore::MediaSourcePrivateGStreamer::willSeek): Forward the seek intent to all SourceBufferPrivates.
* Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h: Added willSeek().
* Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.cpp:
(WebCore::SourceBufferPrivateGStreamer::willSeek): Set m_isSeeking to true.
(WebCore::SourceBufferPrivateGStreamer::isSeeking const): Return m_isSeeking value.
(WebCore::SourceBufferPrivateGStreamer::seekToTime): Unset m_isSeeking and call the default SourceBufferPrivate seekToTime() implementation.
* Source/WebCore/platform/graphics/gstreamer/mse/SourceBufferPrivateGStreamer.h: Added willSeek(), isSeeking(), seekToTime() and the m_isSeeking flag.
@eocanha eocanha added the upstream Related to an upstream bug (or should be at some point) label Jul 3, 2025
@eocanha
Copy link
Member

eocanha commented Jul 3, 2025

Submitted the patch for upstream review as https://bugs.webkit.org/show_bug.cgi?id=295415 / WebKit/WebKit#47564

@emutavchi
Copy link
Collaborator Author

Hi @eocanha, any progress here?

@eocanha
Copy link
Member

eocanha commented Jul 14, 2025

It's still pending for upstream review, but the reviewer with the most appropriate knowledge to review it is currently busy with a higher priority performance regression in wpe-2.46.

@emutavchi
Copy link
Collaborator Author

Thanks for the update @eocanha

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.46
Development

Successfully merging this pull request may close these issues.

3 participants