Diff
Modified: trunk/Source/WebCore/ChangeLog (278482 => 278483)
--- trunk/Source/WebCore/ChangeLog 2021-06-04 19:23:53 UTC (rev 278482)
+++ trunk/Source/WebCore/ChangeLog 2021-06-04 19:34:29 UTC (rev 278483)
@@ -1,3 +1,27 @@
+2021-06-04 Chris Dumez <[email protected]>
+
+ Stop using legacy MainThreadTaskQueue in PlatformMediaSessionManager / MediaSessionManagerCocoa
+ https://bugs.webkit.org/show_bug.cgi?id=226649
+
+ Reviewed by Eric Carlson.
+
+ Stop using legacy MainThreadTaskQueue in PlatformMediaSessionManager / MediaSessionManagerCocoa.
+ Media code should be using the HTML event loop whenever possible and can use callOnMainThread()
+ for global singleton classes that are not associated with a particular document (like
+ PlatformMediaSessionManager).
+
+ Also stop subclassing CanMakeWeakPtr<>. It doesn't make sense since the class is a singleton.
+
+ * platform/audio/PlatformMediaSessionManager.cpp:
+ (WebCore::PlatformMediaSessionManager::scheduleUpdateSessionState):
+ * platform/audio/PlatformMediaSessionManager.h:
+ * platform/audio/cocoa/MediaSessionManagerCocoa.h:
+ * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+ (WebCore::MediaSessionManagerCocoa::scheduleSessionStatusUpdate):
+ (WebCore::MediaSessionManagerCocoa::sessionWillEndPlayback):
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (WebCore::MediaSessionManageriOS::mediaServerConnectionDied):
+
2021-06-04 Wenson Hsieh <[email protected]>
Remove the unused `sourceElementID` argument in `Document::updateIsPlayingMedia` and related code
Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (278482 => 278483)
--- trunk/Source/WebCore/html/MediaElementSession.cpp 2021-06-04 19:23:53 UTC (rev 278482)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp 2021-06-04 19:34:29 UTC (rev 278483)
@@ -282,13 +282,13 @@
updateClientDataBuffering();
#if PLATFORM(IOS_FAMILY)
- manager().configureWireLessTargetMonitoring();
+ PlatformMediaSessionManager::sharedManager().configureWireLessTargetMonitoring();
#endif
if (state() != Playing || !m_element.elementIsHidden())
return;
- PlatformMediaSessionManager::SessionRestrictions restrictions = manager().restrictions(mediaType());
+ PlatformMediaSessionManager::SessionRestrictions restrictions = PlatformMediaSessionManager::sharedManager().restrictions(mediaType());
if ((restrictions & PlatformMediaSessionManager::BackgroundTabPlaybackRestricted) == PlatformMediaSessionManager::BackgroundTabPlaybackRestricted)
pauseSession();
}
@@ -726,7 +726,7 @@
#if PLATFORM(IOS_FAMILY)
m_hasPlaybackTargetAvailabilityListeners = hasListeners;
- manager().configureWireLessTargetMonitoring();
+ PlatformMediaSessionManager::sharedManager().configureWireLessTargetMonitoring();
#else
UNUSED_PARAM(hasListeners);
m_element.document().playbackTargetPickerClientStateDidChange(*this, m_element.mediaState());
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp (278482 => 278483)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2021-06-04 19:23:53 UTC (rev 278482)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2021-06-04 19:34:29 UTC (rev 278483)
@@ -128,9 +128,8 @@
return std::unique_ptr<PlatformMediaSession>(new PlatformMediaSession(manager, client));
}
-PlatformMediaSession::PlatformMediaSession(PlatformMediaSessionManager& manager, PlatformMediaSessionClient& client)
- : m_manager(makeWeakPtr(manager))
- , m_client(client)
+PlatformMediaSession::PlatformMediaSession(PlatformMediaSessionManager&, PlatformMediaSessionClient& client)
+ : m_client(client)
, m_mediaSessionIdentifier(MediaSessionIdentifier::generate())
#if !RELEASE_LOG_DISABLED
, m_logger(client.logger())
@@ -150,13 +149,10 @@
return;
m_active = active;
- if (!m_manager)
- return;
-
if (m_active)
- m_manager->addSession(*this);
+ PlatformMediaSessionManager::sharedManager().addSession(*this);
else
- m_manager->removeSession(*this);
+ PlatformMediaSessionManager::sharedManager().removeSession(*this);
}
void PlatformMediaSession::setState(State state)
@@ -168,7 +164,7 @@
m_state = state;
if (m_state == State::Playing)
m_hasPlayedSinceLastInterruption = true;
- m_manager->sessionStateChanged(*this);
+ PlatformMediaSessionManager::sharedManager().sessionStateChanged(*this);
}
void PlatformMediaSession::beginInterruption(InterruptionType type)
@@ -242,7 +238,7 @@
ALWAYS_LOG(LOGIDENTIFIER, "state = ", m_state);
- if (!m_manager->sessionWillBeginPlayback(*this)) {
+ if (!PlatformMediaSessionManager::sharedManager().sessionWillBeginPlayback(*this)) {
if (state() == Interrupted)
m_stateToRestore = Playing;
return false;
@@ -265,7 +261,7 @@
}
setState(Paused);
- m_manager->sessionWillEndPlayback(*this, shouldDelayCallingUpdateNowPlaying);
+ PlatformMediaSessionManager::sharedManager().sessionWillEndPlayback(*this, shouldDelayCallingUpdateNowPlaying);
return true;
}
@@ -291,7 +287,7 @@
{
ALWAYS_LOG(LOGIDENTIFIER);
m_client.suspendPlayback();
- m_manager->removeSession(*this);
+ PlatformMediaSessionManager::sharedManager().removeSession(*this);
}
PlatformMediaSession::MediaType PlatformMediaSession::mediaType() const
@@ -341,7 +337,7 @@
// Save and restore the interruption count so it doesn't get out of sync if beginInterruption is called because
// if we in the background.
int interruptionCount = m_interruptionCount;
- m_manager->sessionIsPlayingToWirelessPlaybackTargetChanged(*this);
+ PlatformMediaSessionManager::sharedManager().sessionIsPlayingToWirelessPlaybackTargetChanged(*this);
m_interruptionCount = interruptionCount;
}
@@ -366,12 +362,12 @@
void PlatformMediaSession::canProduceAudioChanged()
{
- m_manager->sessionCanProduceAudioChanged();
+ PlatformMediaSessionManager::sharedManager().sessionCanProduceAudioChanged();
}
void PlatformMediaSession::clientCharacteristicsChanged()
{
- m_manager->clientCharacteristicsChanged(*this);
+ PlatformMediaSessionManager::sharedManager().clientCharacteristicsChanged(*this);
}
static inline bool isPlayingAudio(PlatformMediaSession::MediaType mediaType)
@@ -404,11 +400,6 @@
return m_client.shouldOverridePauseDuringRouteChange();
}
-PlatformMediaSessionManager& PlatformMediaSession::manager()
-{
- return *m_manager;
-}
-
std::optional<NowPlayingInfo> PlatformMediaSession::nowPlayingInfo() const
{
return { };
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.h (278482 => 278483)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.h 2021-06-04 19:23:53 UTC (rev 278482)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.h 2021-06-04 19:34:29 UTC (rev 278483)
@@ -210,12 +210,9 @@
PlatformMediaSession(PlatformMediaSessionManager&, PlatformMediaSessionClient&);
PlatformMediaSessionClient& client() const { return m_client; }
- PlatformMediaSessionManager& manager();
-
private:
bool processClientWillPausePlayback(DelayCallingUpdateNowPlaying);
- WeakPtr<PlatformMediaSessionManager> m_manager;
PlatformMediaSessionClient& m_client;
MediaSessionIdentifier m_mediaSessionIdentifier;
State m_state { Idle };
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (278482 => 278483)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2021-06-04 19:23:53 UTC (rev 278482)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2021-06-04 19:34:29 UTC (rev 278483)
@@ -593,11 +593,13 @@
void PlatformMediaSessionManager::scheduleUpdateSessionState()
{
- if (updateSessionStateQueue.hasPendingTasks())
+ if (m_hasScheduledSessionStateUpdate)
return;
- updateSessionStateQueue.enqueueTask([this] {
+ m_hasScheduledSessionStateUpdate = true;
+ callOnMainThread([this] {
updateSessionState();
+ m_hasScheduledSessionStateUpdate = false;
});
}
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (278482 => 278483)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2021-06-04 19:23:53 UTC (rev 278482)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2021-06-04 19:34:29 UTC (rev 278483)
@@ -26,7 +26,6 @@
#ifndef PlatformMediaSessionManager_h
#define PlatformMediaSessionManager_h
-#include "GenericTaskQueue.h"
#include "MediaUniqueIdentifier.h"
#include "PlatformMediaSession.h"
#include "Timer.h"
@@ -41,9 +40,8 @@
class RemoteCommandListener;
class PlatformMediaSessionManager
- : public CanMakeWeakPtr<PlatformMediaSessionManager>
#if !RELEASE_LOG_DISABLED
- , private LoggerHelper
+ : private LoggerHelper
#endif
{
WTF_MAKE_FAST_ALLOCATED;
@@ -50,7 +48,6 @@
public:
WEBCORE_EXPORT static PlatformMediaSessionManager* sharedManagerIfExists();
WEBCORE_EXPORT static PlatformMediaSessionManager& sharedManager();
- WEBCORE_EXPORT static std::unique_ptr<PlatformMediaSessionManager> create();
static void updateNowPlayingInfoIfNecessary();
@@ -173,6 +170,7 @@
protected:
friend class PlatformMediaSession;
+ static std::unique_ptr<PlatformMediaSessionManager> create();
PlatformMediaSessionManager();
virtual void addSession(PlatformMediaSession&);
@@ -220,7 +218,7 @@
#endif
WeakHashSet<PlatformMediaSession::AudioCaptureSource> m_audioCaptureSources;
- MainThreadTaskQueue updateSessionStateQueue;
+ bool m_hasScheduledSessionStateUpdate { false };
#if ENABLE(WEBM_FORMAT_READER)
static bool m_webMFormatReaderEnabled;
Modified: trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h (278482 => 278483)
--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h 2021-06-04 19:23:53 UTC (rev 278482)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h 2021-06-04 19:34:29 UTC (rev 278483)
@@ -28,7 +28,6 @@
#if PLATFORM(COCOA)
#include "AudioHardwareListener.h"
-#include "GenericTaskQueue.h"
#include "NowPlayingManager.h"
#include "PlatformMediaSessionManager.h"
#include "RemoteCommandListener.h"
@@ -83,8 +82,6 @@
PlatformMediaSession* nowPlayingEligibleSession();
- MainThreadTaskQueue& taskQueue() { return m_taskQueue; }
-
void addSupportedCommand(PlatformMediaSession::RemoteControlCommandType) final;
void removeSupportedCommand(PlatformMediaSession::RemoteControlCommandType) final;
@@ -113,8 +110,6 @@
double m_lastUpdatedNowPlayingElapsedTime { NAN };
MediaUniqueIdentifier m_lastUpdatedNowPlayingInfoUniqueIdentifier;
- MainThreadTaskQueue m_taskQueue;
-
const std::unique_ptr<NowPlayingManager> m_nowPlayingManager;
RefPtr<AudioHardwareListener> m_audioHardwareListener;
Modified: trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm (278482 => 278483)
--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm 2021-06-04 19:23:53 UTC (rev 278482)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm 2021-06-04 19:34:29 UTC (rev 278483)
@@ -169,7 +169,7 @@
void MediaSessionManagerCocoa::scheduleSessionStatusUpdate()
{
- m_taskQueue.enqueueTask([this] () mutable {
+ callOnMainThread([this] () mutable {
m_nowPlayingManager->setSupportsSeeking(computeSupportsSeeking());
updateNowPlayingInfo();
@@ -228,7 +228,7 @@
{
PlatformMediaSessionManager::sessionWillEndPlayback(session, delayCallingUpdateNowPlaying);
- m_taskQueue.enqueueTask([weakSession = makeWeakPtr(session)] {
+ callOnMainThread([weakSession = makeWeakPtr(session)] {
if (weakSession)
weakSession->updateMediaUsageIfChanged();
});
@@ -236,7 +236,7 @@
if (delayCallingUpdateNowPlaying == DelayCallingUpdateNowPlaying::No)
updateNowPlayingInfo();
else {
- m_taskQueue.enqueueTask([this] {
+ callOnMainThread([this] {
updateNowPlayingInfo();
});
}
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (278482 => 278483)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2021-06-04 19:23:53 UTC (rev 278482)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2021-06-04 19:34:29 UTC (rev 278483)
@@ -126,7 +126,7 @@
return;
m_havePresentedApplicationPID = false;
- taskQueue().enqueueTask([] () {
+ callOnMainThread([] () {
providePresentingApplicationPID();
});
}