Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7a75b47064bbcbb0b68623b4a58e0b94902ccc90
https://github.com/WebKit/WebKit/commit/7a75b47064bbcbb0b68623b4a58e0b94902ccc90
Author: Vivienne Watermeier <[email protected]>
Date: 2026-06-09 (Tue, 09 Jun 2026)
Changed paths:
M Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
M Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
M
Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp
Log Message:
-----------
[GStreamer] Rework suspending the player when muted and hidden
https://bugs.webkit.org/show_bug.cgi?id=315755
Reviewed by Xabier Rodriguez-Calvar.
When the player is both muted and invisible, we try to suspend it (by just
pausing the playback pipeline),
to save on resources. However so far this is happens quite inconsistently, with
multiple issues:
First, suspends are tied too much to visibility changes - (un)muting can't
suspend/resume,
so this refactors them out into `managePlayerSuspend()`, and also renames the
relevant variables/methods
to reflect that they're about suspends, not player visibility.
Second, we are currently not able to suspend the player if it's already muted
and hidden at creation:
Either we ignore it because we don't have a pipeline yet, or because it's in
NULL.
In this scenario, we would also not yet have a target state to resume to, until
e.g. a play() request later on,
so we need reintroduce a separate boolean flag (m_isSuspended) to make sure we
know to delay that state change until we resume.
Finally, `m_isMuted` is currently updated inconsistently, and in some scenarios
only from a notify::mute callback.
This presents a race condition, if we try to suspend after muting the player,
but read m_isMuted before the callback
updates it. To avoid this, `isMuted()` now directly checks with the pipeline so
we have a single source of truth.
Only `notifyPlayerOfMute()` still uses the flag to avoid sending redundant
notifications.
* Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::play):
(WebCore::MediaPlayerPrivateGStreamer::changePipelineState): Clear saved state
if a change < PLAYING is requested; so a sequence like (suspend -> play() ->
pause() -> unsuspend) doesn't end up in the wrong state.
(WebCore::MediaPlayerPrivateGStreamer::isMuted const):
(WebCore::MediaPlayerPrivateGStreamer::setMuted): Also check here if we need to
suspend.
(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): After creating the
pipeline, also check here if we need to suspend.
(WebCore::MediaPlayerPrivateGStreamer::setViewportVisibility):
(WebCore::MediaPlayerPrivateGStreamer::managePlayerSuspend): Added. Handles
suspending/resuming the pipeline when needed.
(WebCore::MediaPlayerPrivateGStreamer::paint):
* Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
(WebCore::MediaPlayerPrivateGStreamer::isSuspended const):
(WebCore::MediaPlayerPrivateGStreamer::isPausedByViewport const): Deleted.
*
Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::updateStates): Go forward with the
state change even when suspended; changePipelineState() needs to save the new
target state
Canonical link: https://commits.webkit.org/314795@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications