Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e7b146fa58fb419bc30b75c26d988444564c3cc8
https://github.com/WebKit/WebKit/commit/e7b146fa58fb419bc30b75c26d988444564c3cc8
Author: Alex Christensen <[email protected]>
Date: 2026-07-17 (Fri, 17 Jul 2026)
Changed paths:
M Source/WebCore/platform/audio/MediaSessionManagerInterface.cpp
M Source/WebCore/platform/audio/MediaSessionManagerInterface.h
M Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
M Source/WebCore/platform/audio/PlatformMediaSessionManager.h
M Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h
M Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm
M Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h
M Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm
M Source/WebKit/Sources.txt
M Source/WebKit/UIProcess/Media/RemoteMediaSessionClientProxy.cpp
M
Source/WebKit/UIProcess/Media/RemoteMediaSessionClientProxy.h
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/UIProcess/Media/RemoteMediaSessionProxy.h
R Source/WebKit/UIProcess/RemotePageMediaSessionManagerProxy.cpp
R Source/WebKit/UIProcess/RemotePageMediaSessionManagerProxy.h
M Source/WebKit/UIProcess/RemotePageProxy.cpp
M Source/WebKit/UIProcess/RemotePageProxy.h
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/WebPageProxy.h
M Source/WebKit/UIProcess/WebProcessProxy.cpp
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M Source/WebKit/WebProcess/Media/RemoteMediaSessionManager.cpp
M Source/WebKit/WebProcess/Media/RemoteMediaSessionManager.h
M
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Log Message:
-----------
Make RemoteMediaSessionManagerProxy a singleton
https://bugs.webkit.org/show_bug.cgi?id=318989
rdar://181841900
Reviewed by Jean-Yves Avenard.
Before this PR, RemoteMediaSessionManagerProxy was owned by the WebPageProxy
and communicated with the RemoteMediaSessionManager in the main frame's process,
and it had a bunch of RemotePageMediaSessionManagerProxy that forwarded messages
from other frame's processes with site isolation enabled. This pattern works
well for many other objects owned by RemotePageProxy, but it doesn't work well
for RemoteMediaSessionManagerProxy because RemoteMediaSessionManagerProxy
inherits
from WebCore::AudioSession, which needs to have a singleton. This matches the
design of AVAudioSession, and needs to stay that way because of the global
nature
of audio management on devices.
In RemoteMediaSessionManagerProxy's constructor, we call
AudioSession::setSharedSession.
Before this PR, that set the RemoteMediaSessionManagerProxy of the most recently
created WebPageProxy to be the effective singleton, which works if there's only
one WebPageProxy, but it caused issues like the crashes in rdar://180128876
which I covered up with 316744@main but it needs a better fix. This is that
fix.
I made RemoteMediaSessionManagerProxy a global singleton that owns a map of
RemoteMediaSessionProxy objects, each of which knows what process its
RemoteMediaSessionManager lives in. RemoteMediaSessionProxy is now the message
sender instead of RemoteMediaSessionManagerProxy, and each one sends to the
correct process that initially sent
RemoteMediaSessionManagerProxy::AddMediaSession.
RemoteMediaSessionManagerProxy inherits from MediaSessionManagerCocoa which
uses a WebCore::PageIdentifier to find a WebCore::Page to call
hasActiveNowPlayingSessionChanged, and that abstraction doesn't work well
with
RemoteMediaSessionManagerProxy being in the UI process where there is
no WebCore::Page, so I made the PageIdentifier optional to skip that piece
for now, but a better abstraction is needed in a followup PR to use a client
of some sort to call hasActiveNowPlayingSessionChanged.
Before and after this PR, RemoteMediaSessionManagerProxy sends 3 IPC messages.
RemoteMediaSessionManager::SetCurrentMediaSession is sent to each process with
nullopt indicating the current media session is in another process or the
identifier indicating it's in the receiving process. That is kept with this PR.
SetAudioSessionCategory and SetAudioSessionPreferredBufferSize, though, are
changed from only sending to the main frame's process to sending to all
RemoteMediaSessionManagers currently in the map.
Since the key of m_sessionProxies comes from multiple processes and the
MediaSessionIdentifier could collide, I make the key ProcessQualified and
update all uses and findAndUpdateSession to use
the process identifier of the
process that sent IPC to prevent collisions and keep process scope to prevent
processes from manipulating each other's media sessions.
This change should only affect browsing with site isolation or remote media
session
manager enabled. This can be seen in the caller of
RemoteMediaSessionManager::create
which is protected by such checks.
* Source/WebCore/platform/audio/MediaSessionManagerInterface.cpp:
(WebCore::MediaSessionManagerInterface::MediaSessionManagerInterface):
* Source/WebCore/platform/audio/MediaSessionManagerInterface.h:
* Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::PlatformMediaSessionManager):
* Source/WebCore/platform/audio/PlatformMediaSessionManager.h:
* Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h:
*
Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(WebCore::MediaSessionManagerCocoa::MediaSessionManagerCocoa):
(WebCore::MediaSessionManagerCocoa::removeSession):
(WebCore::MediaSessionManagerCocoa::updateActiveNowPlayingSession):
* Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h:
* Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::MediaSessionManageriOS):
* Source/WebKit/Sources.txt:
* Source/WebKit/UIProcess/Media/RemoteMediaSessionClientProxy.cpp:
(WebKit::RemoteMediaSessionClientProxy::RemoteMediaSessionClientProxy):
(WebKit::RemoteMediaSessionClientProxy::attachToSession):
(WebKit::RemoteMediaSessionClientProxy::resumeAutoplaying):
(WebKit::RemoteMediaSessionClientProxy::mayResumePlayback):
(WebKit::RemoteMediaSessionClientProxy::suspendPlayback):
(WebKit::RemoteMediaSessionClientProxy::setShouldPlayToPlaybackTarget):
(WebKit::RemoteMediaSessionClientProxy::sessionManager const):
*
Source/WebKit/UIProcess/Media/RemoteMediaSessionClientProxy.h:
* Source/WebKit/UIProcess/Media/RemoteMediaSessionManagerProxy.cpp:
(WebKit::RemoteMediaSessionManagerProxy::singleton):
(WebKit::RemoteMediaSessionManagerProxy::RemoteMediaSessionManagerProxy):
(WebKit::RemoteMediaSessionManagerProxy::~RemoteMediaSessionManagerProxy):
(WebKit::RemoteMediaSessionManagerProxy::addMediaSession):
(WebKit::RemoteMediaSessionManagerProxy::removeMediaSession):
(WebKit::RemoteMediaSessionManagerProxy::setCurrentMediaSession):
(WebKit::RemoteMediaSessionManagerProxy::mediaSessionStateChanged):
(WebKit::RemoteMediaSessionManagerProxy::setCurrentSession):
(WebKit::RemoteMediaSessionManagerProxy::mediaSessionWillBeginPlayback):
(WebKit::RemoteMediaSessionManagerProxy::setCategory):
(WebKit::RemoteMediaSessionManagerProxy::setPreferredBufferSize):
(WebKit::RemoteMediaSessionManagerProxy::findAndUpdateSession):
(WebKit::RemoteMediaSessionManagerProxy::sharedPreferencesForWebProcess
const):
(WebKit::RemoteMediaSessionManagerProxy::create): Deleted.
(WebKit::RemoteMediaSessionManagerProxy::messageSenderConnection const):
Deleted.
(WebKit::RemoteMediaSessionManagerProxy::messageSenderDestinationID const):
Deleted.
* Source/WebKit/UIProcess/Media/RemoteMediaSessionManagerProxy.h:
(WebKit::RemoteMediaSessionManagerProxy::process const): Deleted.
* Source/WebKit/UIProcess/Media/RemoteMediaSessionManagerProxy.messages.in:
* Source/WebKit/UIProcess/Media/RemoteMediaSessionProxy.cpp:
(WebKit::RemoteMediaSessionProxy::create):
(WebKit::RemoteMediaSessionProxy::RemoteMediaSessionProxy):
(WebKit::RemoteMediaSessionProxy::setShouldPlayToPlaybackTarget):
(WebKit::RemoteMediaSessionProxy::messageSenderConnection const):
(WebKit::RemoteMediaSessionProxy::messageSenderDestinationID const):
* Source/WebKit/UIProcess/Media/RemoteMediaSessionProxy.h:
* Source/WebKit/UIProcess/RemotePageMediaSessionManagerProxy.cpp: Removed.
*
Source/WebKit/UIProcess/RemotePageMediaSessionManagerProxy.h: Removed.
* Source/WebKit/UIProcess/RemotePageProxy.cpp:
(WebKit::RemotePageProxy::disconnect):
(WebKit::RemotePageProxy::injectPageIntoNewProcess):
* Source/WebKit/UIProcess/RemotePageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didAttachToRunningProcess):
(WebKit::WebPageProxy::resetState):
(WebKit::WebPageProxy::remoteMediaSessionManagerProxy): Deleted.
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::dispatchMessage):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Media/RemoteMediaSessionManager.cpp:
(WebKit::RemoteMediaSessionManager::create):
* Source/WebKit/WebProcess/Media/RemoteMediaSessionManager.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::m_allowsImmersiveEnvironments):
Canonical link:
https://flagged.apple.com:443/proxy?t2=dz9x2z1Hz6&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzE3Mzk2QG1haW4=&emid=c559d539-4af3-4173-9810-e088793b5519&c=11
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications