Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a2aebcb3a8edd1d1eff788e4fe509dbdb758e026
      
https://github.com/WebKit/WebKit/commit/a2aebcb3a8edd1d1eff788e4fe509dbdb758e026
  Author: Jean-Yves Avenard <[email protected]>
  Date:   2026-08-15 (Sat, 15 Aug 2026)

  Changed paths:
    M Source/WebCore/platform/audio/MediaSessionManagerClient.h
    M Source/WebCore/platform/audio/MediaSessionManagerInterface.cpp
    M Source/WebKit/GPUProcess/GPUProcess.cpp
    M Source/WebKit/GPUProcess/GPUProcess.h
    M Source/WebKit/GPUProcess/GPUProcess.messages.in
    M Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp
    M Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp
    M Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h
    M Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp
    M Source/WebKit/UIProcess/GPU/GPUProcessProxy.h
    M Source/WebKit/UIProcess/GPU/GPUProcessProxy.messages.in
    M Source/WebKit/UIProcess/Media/RemoteMediaSessionManagerProxy.cpp
    M Source/WebKit/UIProcess/Media/RemoteMediaSessionManagerProxy.h
    M Source/WebKit/UIProcess/Media/RemoteMediaSessionManagerProxy.messages.in
    M Source/WebKit/UIProcess/Media/RemoteMediaSessionProxy.cpp
    M Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.cpp
    M Source/WebKit/WebProcess/Media/RemoteMediaSessionManager.cpp
    M Source/WebKit/WebProcess/Media/RemoteMediaSessionManager.h

  Log Message:
  -----------
  [site-isolation] The content process should decide whether playback may begin 
and activate the audio session itself
https://bugs.webkit.org/show_bug.cgi?id=321774
rdar://184896873

Reviewed by Eric Carlson.

Under site isolation, three things ran in the UI process when then didn't have 
to:

1) The playback admission ran in the UI process on a mirrored session:
    RemoteMediaSessionManager::sessionWillBeginPlayback sent 
MediaSessionWillBeginPlayback and waited
    for granted, which RemoteMediaSessionManagerProxy computed by running the 
base
    sessionWillBeginPlayback on a RemoteMediaSessionProxy. Both inputs to that 
decision were in the
    content process already: the session state, since interruptions reached it
    from the GPU process through RemoteAudioSession::beginInterruptionRemote,
    and the restrictions, which RemoteMediaSessionManager::addRestriction kept
    there as well as forwarding.

2) The UI process activated the audio session on behalf of each content 
process, per process since
    319006@main: an activation queue and per-process state, 
TryToSetAudioSessionActiveForProcess to
    the GPU process, and AudioSessionActiveStateChangedForProcess back from it. 
That hop decided
    nothing. It carried a ProcessIdentifier and a bool to
    RemoteAudioSessionProxyManager::tryToSetActiveForProcess, which a content 
process could reach
    directly through its own RemoteAudioSessionProxy, and where the arbitration 
across processes had
    always been.

3) The check meant to stop the content process driving the GPU process at the 
same time read
    sharedPreferencesForWebProcessValue().remoteMediaSessionManagerEnabled, 
which was false by
    default and was not set by --site-isolation, while WebPage installed the 
RemoteMediaSessionManager
    when either that preference or SiteIsolationEnabled was set. So both 
processes drove the same
    process's audio session, each through its own activation chain and neither 
aware of the other's,
    and resetToConsistentStateForTesting() reached the GPU process between test 
iterations for the
    same reason.

RemoteMediaSessionManager::sessionWillBeginPlayback now calls the base 
implementation, so the whole
admission runs where the sessions, their state and the restrictions are, and
MediaSessionWillBeginPlayback becomes a void message, sent so that the UI 
process can still make
the session current and enforce the concurrent playback restriction across 
every process's
sessions. RemoteAudioSession sends TryToSetActive to the GPU process again, so 
the activation
failure arrives on the activation reply, resolving or rejecting the waiters that
MediaSessionManagerInterface::sessionWillBeginPlayback already reads;
clientWillBeginPlayback's CompletionHandler is unchanged.

Activation runs as it did before 318337@main: the content process's 
AudioSession::singleton()
is a RemoteAudioSession, whose tryToSetActive sends TryToSetActive to that
process's RemoteAudioSessionProxy in the GPU process. The proxy hands it to
RemoteAudioSessionProxyManager, which arbitrates against the other processes'
proxies and activates the audio session the GPU process owns.
The reply resolves or rejects the promise the content process is waiting on, and
RemoteAudioSessionProxy::configurationChanged pushes the resulting state back to
it.

The UI process no longer activates an audio session on behalf of another 
process, because it does
not need to: nothing there reads a per-process active state now, the concurrent 
playback
restriction and the current session work from PlatformMediaSession state, and 
the GPU process has
the real state first-hand. RemoteMediaSessionManagerProxy stays the UI 
process's shared audio
session, as 303417@main made it, so this process reports the configuration the 
content processes
see, and its tryToSetActiveInternal resolves without doing anything.

RemoteMediaSessionManager::processWillSuspend and processDidResume are removed 
with the messages
they sent: the base versions deactivate and re-activate this process's own 
session, which reaches
the GPU process now that the check in 3) is gone.

Commits 318337@main and 319006@main are reverted apart from their tests.

* Source/WebCore/platform/audio/MediaSessionManagerClient.h:
* Source/WebCore/platform/audio/MediaSessionManagerInterface.cpp:
(WebCore::PageMediaSessionManagerClient::tryToSetAudioSessionActive): Deleted.
* Source/WebKit/GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::tryToSetAudioSessionActiveForProcess): Deleted.
* Source/WebKit/GPUProcess/GPUProcess.h:
* Source/WebCore/platform/audio/MediaSessionManagerClient.h:
* Source/WebCore/platform/audio/MediaSessionManagerInterface.cpp:
(WebCore::PageMediaSessionManagerClient::tryToSetAudioSessionActive): Deleted.
* Source/WebKit/GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::tryToSetAudioSessionActiveForProcess): Deleted.
* Source/WebKit/GPUProcess/GPUProcess.h:
* Source/WebKit/GPUProcess/GPUProcess.messages.in:
* Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp:
(WebKit::RemoteAudioSessionProxy::tryToSetActive): Stop telling the UI process 
about this process's
active state.
* Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp:
(WebKit::RemoteAudioSessionProxyManager::tryToSetActiveForProcess): Deleted the 
ProcessIdentifier
overload, which existed for a caller with no proxy of its own. The 
RemoteAudioSessionProxy overload,
which every activation goes through and which holds the arbitration, is 
unchanged.
* Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h:
* Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp:
(WebKit::GPUProcessProxy::tryToSetAudioSessionActiveForProcess): Deleted.
(WebKit::GPUProcessProxy::audioSessionActiveStateChangedForProcess): Deleted.
* Source/WebKit/UIProcess/GPU/GPUProcessProxy.h:
* Source/WebKit/UIProcess/GPU/GPUProcessProxy.messages.in:
* Source/WebKit/UIProcess/Media/RemoteMediaSessionManagerProxy.cpp:
(WebKit::RemoteMediaSessionManagerProxyClient): Deleted.
(WebKit::RemoteMediaSessionManagerProxy::RemoteMediaSessionManagerProxy): Keep 
this manager as the
shared audio session, and stop making it the deactivation authority.
(WebKit::RemoteMediaSessionManagerProxy::removeMediaSession): No per-process 
activation to drop.
(WebKit::RemoteMediaSessionManagerProxy::webProcessWillShutDown): Ditto.
(WebKit::RemoteMediaSessionManagerProxy::updateMediaSessionStates): Stop 
activating a process while
it has audio capture sources; the content process does that from its own 
capture count.
(WebKit::RemoteMediaSessionManagerProxy::mediaSessionWillBeginPlayback): Run 
only the part that
needs every process's sessions.
(WebKit::RemoteMediaSessionManagerProxy::tryToSetActiveInternal): Resolve 
without doing anything.
(WebKit::RemoteMediaSessionManagerProxy::remoteAudioConfigurationChanged): Take 
the descriptive
configuration only.
(WebKit::RemoteMediaSessionManagerProxy::setAudioSessionActiveForProcess): 
Deleted.
(WebKit::RemoteMediaSessionManagerProxy::reevaluateAudioSessionActivation): 
Deleted.
(WebKit::RemoteMediaSessionManagerProxy::enqueueAudioSessionActivation): 
Deleted.
(WebKit::RemoteMediaSessionManagerProxy::sendNextActivationIPC): Deleted.
(WebKit::RemoteMediaSessionManagerProxy::deactivateAllAudioSessions): Deleted.
(WebKit::RemoteMediaSessionManagerProxy::hasActiveAudioSession const): Deleted.
(WebKit::RemoteMediaSessionManagerProxy::processForSession const): Deleted.
(WebKit::RemoteMediaSessionManagerProxy::processRequiresAudioSession const): 
Deleted.
(WebKit::RemoteMediaSessionManagerProxy::remoteProcessWillSuspend): Deleted.
(WebKit::RemoteMediaSessionManagerProxy::remoteProcessDidResume): Deleted.
* Source/WebKit/UIProcess/Media/RemoteMediaSessionManagerProxy.h:
* Source/WebKit/UIProcess/Media/RemoteMediaSessionManagerProxy.messages.in:
* Source/WebKit/UIProcess/Media/RemoteMediaSessionProxy.cpp:
(WebKit::RemoteMediaSessionProxy::updateState): Stop re-evaluating activation 
from the UI process.
* Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.cpp:
(WebKit::RemoteAudioSession::sendNextActivationIPC): Always send the activation 
to the GPU process.
(WebKit::RemoteAudioSession::configurationChanged): Forward the configuration 
to the UI process on a
muted, buffer size, sample rate or routing change only.
* Source/WebKit/WebProcess/Media/RemoteMediaSessionManager.cpp:
(WebKit::RemoteMediaSessionManager::sessionWillBeginPlayback): Decide here, and 
tell the UI process
when playback may begin.
(WebKit::RemoteMediaSessionManager::processWillSuspend): Deleted.
(WebKit::RemoteMediaSessionManager::processDidResume): Deleted.
* Source/WebKit/WebProcess/Media/RemoteMediaSessionManager.h:

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



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

Reply via email to