Diff
Modified: trunk/Source/WebCore/ChangeLog (256903 => 256904)
--- trunk/Source/WebCore/ChangeLog 2020-02-19 04:15:11 UTC (rev 256903)
+++ trunk/Source/WebCore/ChangeLog 2020-02-19 04:50:31 UTC (rev 256904)
@@ -1,3 +1,38 @@
+2020-02-18 Youenn Fablet <[email protected]>
+
+ Reduce use of PlatformMediaSessionManager::sharedManager()
+ https://bugs.webkit.org/show_bug.cgi?id=207924
+
+ Reviewed by Eric Carlson.
+
+ The plan is to be able to have PlatformMediaSession in GPU process which might have different managers,
+ typically a manager per connection to web process.
+ For that reason, reduce the use of the sharedManager to classes that can only live in WebProcess.
+ No change of behavior.
+
+ * Modules/mediastream/MediaStreamTrack.cpp:
+ (WebCore::MediaStreamTrack::MediaStreamTrack):
+ * Modules/webaudio/AudioContext.cpp:
+ (WebCore::AudioContext::AudioContext):
+ * html/MediaElementSession.cpp:
+ (WebCore::MediaElementSession::MediaElementSession):
+ (WebCore::MediaElementSession::clientDataBufferingTimerFired):
+ (WebCore::MediaElementSession::setHasPlaybackTargetAvailabilityListeners):
+ * platform/audio/PlatformMediaSession.cpp:
+ (WebCore::PlatformMediaSession::create):
+ (WebCore::PlatformMediaSession::PlatformMediaSession):
+ (WebCore::PlatformMediaSession::~PlatformMediaSession):
+ (WebCore::PlatformMediaSession::setState):
+ (WebCore::PlatformMediaSession::clientWillBeginPlayback):
+ (WebCore::PlatformMediaSession::processClientWillPausePlayback):
+ (WebCore::PlatformMediaSession::stopSession):
+ (WebCore::PlatformMediaSession::isPlayingToWirelessPlaybackTargetChanged):
+ (WebCore::PlatformMediaSession::canProduceAudioChanged):
+ (WebCore::PlatformMediaSession::clientCharacteristicsChanged):
+ (WebCore::PlatformMediaSession::manager):
+ * platform/audio/PlatformMediaSession.h:
+ * platform/audio/PlatformMediaSessionManager.h:
+
2020-02-18 Wenson Hsieh <[email protected]>
REGRESSION (r256093): fast/events/touch/ios/block-without-overflow-scroll.html is failing
Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp (256903 => 256904)
--- trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2020-02-19 04:15:11 UTC (rev 256903)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2020-02-19 04:50:31 UTC (rev 256904)
@@ -45,6 +45,7 @@
#include "NotImplemented.h"
#include "OverconstrainedError.h"
#include "Page.h"
+#include "PlatformMediaSessionManager.h"
#include "RealtimeMediaSourceCenter.h"
#include "ScriptExecutionContext.h"
#include <wtf/CompletionHandler.h>
@@ -74,7 +75,7 @@
: ActiveDOMObject(&context)
, m_private(WTFMove(privateTrack))
, m_isCaptureTrack(m_private->isCaptureTrack())
- , m_mediaSession(PlatformMediaSession::create(*this))
+ , m_mediaSession(PlatformMediaSession::create(PlatformMediaSessionManager::sharedManager(), *this))
{
ALWAYS_LOG(LOGIDENTIFIER);
Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (256903 => 256904)
--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp 2020-02-19 04:15:11 UTC (rev 256903)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp 2020-02-19 04:50:31 UTC (rev 256904)
@@ -63,6 +63,7 @@
#include "Page.h"
#include "PannerNode.h"
#include "PeriodicWave.h"
+#include "PlatformMediaSessionManager.h"
#include "ScriptController.h"
#include "ScriptProcessorNode.h"
#include "WaveShaperNode.h"
@@ -139,7 +140,7 @@
, m_logger(document.logger())
, m_logIdentifier(uniqueLogIdentifier())
#endif
- , m_mediaSession(PlatformMediaSession::create(*this))
+ , m_mediaSession(PlatformMediaSession::create(PlatformMediaSessionManager::sharedManager(), *this))
, m_eventQueue(MainThreadGenericEventQueue::create(*this))
{
// According to spec AudioContext must die only after page navigate.
@@ -165,7 +166,7 @@
, m_logIdentifier(uniqueLogIdentifier())
#endif
, m_isOfflineContext(true)
- , m_mediaSession(PlatformMediaSession::create(*this))
+ , m_mediaSession(PlatformMediaSession::create(PlatformMediaSessionManager::sharedManager(), *this))
, m_eventQueue(MainThreadGenericEventQueue::create(*this))
, m_renderTarget(renderTarget)
{
Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (256903 => 256904)
--- trunk/Source/WebCore/html/MediaElementSession.cpp 2020-02-19 04:15:11 UTC (rev 256903)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp 2020-02-19 04:50:31 UTC (rev 256904)
@@ -105,12 +105,12 @@
}
MediaElementSession::MediaElementSession(HTMLMediaElement& element)
- : PlatformMediaSession(element)
+ : PlatformMediaSession(PlatformMediaSessionManager::sharedManager(), element)
, m_element(element)
, m_restrictions(NoRestrictions)
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
, m_targetAvailabilityChangedTimer(*this, &MediaElementSession::targetAvailabilityChangedTimerFired)
- , m_hasPlaybackTargets(PlatformMediaSessionManager::sharedManager().hasWirelessTargetsAvailable())
+ , m_hasPlaybackTargets(manager().hasWirelessTargetsAvailable())
#endif
, m_mainContentCheckTimer(*this, &MediaElementSession::mainContentCheckTimerFired)
, m_clientDataBufferingTimer(*this, &MediaElementSession::clientDataBufferingTimerFired)
@@ -201,13 +201,13 @@
updateClientDataBuffering();
#if PLATFORM(IOS_FAMILY)
- PlatformMediaSessionManager::sharedManager().configureWireLessTargetMonitoring();
+ manager().configureWireLessTargetMonitoring();
#endif
if (state() != Playing || !m_element.elementIsHidden())
return;
- PlatformMediaSessionManager::SessionRestrictions restrictions = PlatformMediaSessionManager::sharedManager().restrictions(mediaType());
+ PlatformMediaSessionManager::SessionRestrictions restrictions = manager().restrictions(mediaType());
if ((restrictions & PlatformMediaSessionManager::BackgroundTabPlaybackRestricted) == PlatformMediaSessionManager::BackgroundTabPlaybackRestricted)
pauseSession();
}
@@ -636,7 +636,7 @@
#if PLATFORM(IOS_FAMILY)
m_hasPlaybackTargetAvailabilityListeners = hasListeners;
- PlatformMediaSessionManager::sharedManager().configureWireLessTargetMonitoring();
+ manager().configureWireLessTargetMonitoring();
#else
UNUSED_PARAM(hasListeners);
m_element.document().playbackTargetPickerClientStateDidChange(*this, m_element.mediaState());
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp (256903 => 256904)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2020-02-19 04:15:11 UTC (rev 256903)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2020-02-19 04:50:31 UTC (rev 256904)
@@ -107,13 +107,14 @@
#endif
-std::unique_ptr<PlatformMediaSession> PlatformMediaSession::create(PlatformMediaSessionClient& client)
+std::unique_ptr<PlatformMediaSession> PlatformMediaSession::create(PlatformMediaSessionManager& manager, PlatformMediaSessionClient& client)
{
- return makeUnique<PlatformMediaSession>(client);
+ return std::unique_ptr<PlatformMediaSession>(new PlatformMediaSession(manager, client));
}
-PlatformMediaSession::PlatformMediaSession(PlatformMediaSessionClient& client)
- : m_client(client)
+PlatformMediaSession::PlatformMediaSession(PlatformMediaSessionManager& manager, PlatformMediaSessionClient& client)
+ : m_manager(makeWeakPtr(manager))
+ , m_client(client)
, m_state(Idle)
, m_stateToRestore(Idle)
, m_notifyingClient(false)
@@ -123,12 +124,13 @@
#endif
{
ASSERT(m_client.mediaType() >= None && m_client.mediaType() <= MediaStreamCapturingAudio);
- PlatformMediaSessionManager::sharedManager().addSession(*this);
+ manager.addSession(*this);
}
PlatformMediaSession::~PlatformMediaSession()
{
- PlatformMediaSessionManager::sharedManager().removeSession(*this);
+ if (m_manager)
+ m_manager->removeSession(*this);
}
void PlatformMediaSession::setState(State state)
@@ -140,7 +142,7 @@
m_state = state;
if (m_state == State::Playing)
m_hasPlayedSinceLastInterruption = true;
- PlatformMediaSessionManager::sharedManager().sessionStateChanged(*this);
+ m_manager->sessionStateChanged(*this);
}
void PlatformMediaSession::beginInterruption(InterruptionType type)
@@ -214,7 +216,7 @@
INFO_LOG(LOGIDENTIFIER, "state = ", m_state);
- if (!PlatformMediaSessionManager::sharedManager().sessionWillBeginPlayback(*this)) {
+ if (!m_manager->sessionWillBeginPlayback(*this)) {
if (state() == Interrupted)
m_stateToRestore = Playing;
return false;
@@ -237,7 +239,7 @@
}
setState(Paused);
- PlatformMediaSessionManager::sharedManager().sessionWillEndPlayback(*this, shouldDelayCallingUpdateNowPlaying);
+ m_manager->sessionWillEndPlayback(*this, shouldDelayCallingUpdateNowPlaying);
return true;
}
@@ -261,7 +263,7 @@
{
INFO_LOG(LOGIDENTIFIER);
m_client.suspendPlayback();
- PlatformMediaSessionManager::sharedManager().removeSession(*this);
+ m_manager->removeSession(*this);
}
PlatformMediaSession::MediaType PlatformMediaSession::mediaType() const
@@ -343,7 +345,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;
- PlatformMediaSessionManager::sharedManager().sessionIsPlayingToWirelessPlaybackTargetChanged(*this);
+ m_manager->sessionIsPlayingToWirelessPlaybackTargetChanged(*this);
m_interruptionCount = interruptionCount;
}
@@ -368,7 +370,7 @@
void PlatformMediaSession::canProduceAudioChanged()
{
- PlatformMediaSessionManager::sharedManager().sessionCanProduceAudioChanged();
+ m_manager->sessionCanProduceAudioChanged();
}
#if ENABLE(VIDEO)
@@ -395,7 +397,7 @@
void PlatformMediaSession::clientCharacteristicsChanged()
{
- PlatformMediaSessionManager::sharedManager().clientCharacteristicsChanged(*this);
+ m_manager->clientCharacteristicsChanged(*this);
}
bool PlatformMediaSession::canPlayConcurrently(const PlatformMediaSession& otherSession) const
@@ -408,6 +410,11 @@
return m_client.shouldOverridePauseDuringRouteChange();
}
+PlatformMediaSessionManager& PlatformMediaSession::manager()
+{
+ return *m_manager;
+}
+
#if !RELEASE_LOG_DISABLED
WTFLogChannel& PlatformMediaSession::logChannel() const
{
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.h (256903 => 256904)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.h 2020-02-19 04:15:11 UTC (rev 256903)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.h 2020-02-19 04:50:31 UTC (rev 256904)
@@ -41,6 +41,7 @@
class Document;
class MediaPlaybackTarget;
class PlatformMediaSessionClient;
+class PlatformMediaSessionManager;
enum class DelayCallingUpdateNowPlaying { No, Yes };
class PlatformMediaSession
@@ -54,9 +55,8 @@
{
WTF_MAKE_FAST_ALLOCATED;
public:
- static std::unique_ptr<PlatformMediaSession> create(PlatformMediaSessionClient&);
+ static std::unique_ptr<PlatformMediaSession> create(PlatformMediaSessionManager&, PlatformMediaSessionClient&);
- PlatformMediaSession(PlatformMediaSessionClient&);
virtual ~PlatformMediaSession();
enum MediaType {
@@ -199,11 +199,15 @@
bool shouldOverridePauseDuringRouteChange() const;
protected:
+ PlatformMediaSession(PlatformMediaSessionManager&, PlatformMediaSessionClient&);
PlatformMediaSessionClient& client() const { return m_client; }
+ PlatformMediaSessionManager& manager();
+
private:
bool processClientWillPausePlayback(DelayCallingUpdateNowPlaying);
+ WeakPtr<PlatformMediaSessionManager> m_manager;
PlatformMediaSessionClient& m_client;
State m_state;
State m_stateToRestore;
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (256903 => 256904)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2020-02-19 04:15:11 UTC (rev 256903)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2020-02-19 04:50:31 UTC (rev 256904)
@@ -34,6 +34,7 @@
#include <pal/system/SystemSleepListener.h>
#include <wtf/AggregateLogger.h>
#include <wtf/Vector.h>
+#include <wtf/WeakPtr.h>
namespace WebCore {
@@ -47,6 +48,7 @@
#if !RELEASE_LOG_DISABLED
, private LoggerHelper
#endif
+ , public CanMakeWeakPtr<PlatformMediaSessionManager>
{
WTF_MAKE_FAST_ALLOCATED;
public: