Title: [292782] trunk/Source
Revision
292782
Author
[email protected]
Date
2022-04-12 12:36:24 -0700 (Tue, 12 Apr 2022)

Log Message

Leak of MediaSourcePrivateAVFObjC and RemoteMediaSourceProxy
https://bugs.webkit.org/show_bug.cgi?id=239088
<rdar://90693094>

Reviewed by Eric Carlson.

Source/WebCore:

MediaSourcePrivateAVFObjC holds a strong reference to its MediaSourcePrivateClient, which is
a MediaSource when running in-process, but a RemoteMediaSourceProxy when running in multi-process.
In both cases, the MediaSourcePrivateClient holds a strong reference to its private object as well.
However, in the multi-process scenario, this cycle is never broken, causing a leak.

Rather than determine the correct point to break this retain-cycle, modify MediaSourcePrivateClient
to be a CanMakeWeakPtr abstract class (rather than a RefCounted one), and convert all cases where
that client's pointer is stored from a Ref/RefPtr to a WeakPtr. This means having to null-check
every time that pointer is used.

* Modules/mediasource/MediaSource.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::loadResource):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::load):
(WebCore::MediaPlayer::loadWithNextMediaEngine):
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
* platform/graphics/MediaSourcePrivateClient.h:
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
(WebCore::MediaPlayerPrivateAVFoundation::load):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::load):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::load):
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
(WebCore::MediaSourcePrivateAVFObjC::create):
(WebCore::MediaSourcePrivateAVFObjC::MediaSourcePrivateAVFObjC):
(WebCore::MediaSourcePrivateAVFObjC::duration const):
(WebCore::MediaSourcePrivateAVFObjC::buffered):
(WebCore::MediaSourcePrivateAVFObjC::seekToTime):
(WebCore::MediaSourcePrivateAVFObjC::failedToCreateRenderer):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::load):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::load):
(WebCore::MediaPlayerPrivateGStreamerMSE::unblockDurationChanges):
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
* platform/graphics/holepunch/MediaPlayerPrivateHolePunch.h:
* platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::MockMediaPlayerMediaSource::load):
* platform/mock/mediasource/MockMediaPlayerMediaSource.h:
* platform/mock/mediasource/MockMediaSourcePrivate.cpp:
(WebCore::MockMediaSourcePrivate::MockMediaSourcePrivate):
(WebCore::MockMediaSourcePrivate::duration):
(WebCore::MockMediaSourcePrivate::buffered):
(WebCore::MockMediaSourcePrivate::seekToTime):
* platform/mock/mediasource/MockMediaSourcePrivate.h:

Source/WebKit:

Adopt changes to MediaSourcePrivateClient making it a CanMakeWeakPtr class.

* GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::loadMediaSource):
* GPUProcess/media/RemoteMediaSourceProxy.h:
* WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::load):
* WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
* WebProcess/GPU/media/MediaSourcePrivateRemote.cpp:
(WebKit::MediaSourcePrivateRemote::create):
(WebKit::MediaSourcePrivateRemote::MediaSourcePrivateRemote):
(WebKit::MediaSourcePrivateRemote::seekToTime):
* WebProcess/GPU/media/MediaSourcePrivateRemote.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (292781 => 292782)


--- trunk/Source/WebCore/ChangeLog	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/ChangeLog	2022-04-12 19:36:24 UTC (rev 292782)
@@ -1,3 +1,65 @@
+2022-04-12  Jer Noble  <[email protected]>
+
+        Leak of MediaSourcePrivateAVFObjC and RemoteMediaSourceProxy
+        https://bugs.webkit.org/show_bug.cgi?id=239088
+        <rdar://90693094>
+
+        Reviewed by Eric Carlson.
+
+        MediaSourcePrivateAVFObjC holds a strong reference to its MediaSourcePrivateClient, which is
+        a MediaSource when running in-process, but a RemoteMediaSourceProxy when running in multi-process.
+        In both cases, the MediaSourcePrivateClient holds a strong reference to its private object as well.
+        However, in the multi-process scenario, this cycle is never broken, causing a leak.
+
+        Rather than determine the correct point to break this retain-cycle, modify MediaSourcePrivateClient
+        to be a CanMakeWeakPtr abstract class (rather than a RefCounted one), and convert all cases where
+        that client's pointer is stored from a Ref/RefPtr to a WeakPtr. This means having to null-check
+        every time that pointer is used.
+
+        * Modules/mediasource/MediaSource.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::loadResource):
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::load):
+        (WebCore::MediaPlayer::loadWithNextMediaEngine):
+        * platform/graphics/MediaPlayer.h:
+        * platform/graphics/MediaPlayerPrivate.h:
+        * platform/graphics/MediaSourcePrivateClient.h:
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundation::load):
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::load):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::load):
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+        (WebCore::MediaSourcePrivateAVFObjC::create):
+        (WebCore::MediaSourcePrivateAVFObjC::MediaSourcePrivateAVFObjC):
+        (WebCore::MediaSourcePrivateAVFObjC::duration const):
+        (WebCore::MediaSourcePrivateAVFObjC::buffered):
+        (WebCore::MediaSourcePrivateAVFObjC::seekToTime):
+        (WebCore::MediaSourcePrivateAVFObjC::failedToCreateRenderer):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::load):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerMSE::load):
+        (WebCore::MediaPlayerPrivateGStreamerMSE::unblockDurationChanges):
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
+        * platform/graphics/holepunch/MediaPlayerPrivateHolePunch.h:
+        * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
+        (WebCore::MockMediaPlayerMediaSource::load):
+        * platform/mock/mediasource/MockMediaPlayerMediaSource.h:
+        * platform/mock/mediasource/MockMediaSourcePrivate.cpp:
+        (WebCore::MockMediaSourcePrivate::MockMediaSourcePrivate):
+        (WebCore::MockMediaSourcePrivate::duration):
+        (WebCore::MockMediaSourcePrivate::buffered):
+        (WebCore::MockMediaSourcePrivate::seekToTime):
+        * platform/mock/mediasource/MockMediaSourcePrivate.h:
+
 2022-04-12  Ada Chan  <[email protected]>
 
         [WebXR] Implement the WebXRFrame methods for getting joints' poses and radii

Modified: trunk/Source/WebCore/Modules/mediasource/MediaSource.h (292781 => 292782)


--- trunk/Source/WebCore/Modules/mediasource/MediaSource.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/Modules/mediasource/MediaSource.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -39,6 +39,7 @@
 #include "MediaSourcePrivateClient.h"
 #include "URLRegistry.h"
 #include <wtf/LoggerHelper.h>
+#include <wtf/RefCounted.h>
 #include <wtf/WeakPtr.h>
 
 namespace WebCore {
@@ -50,7 +51,8 @@
 class TimeRanges;
 
 class MediaSource final
-    : public MediaSourcePrivateClient
+    : public RefCounted<MediaSource>
+    , public MediaSourcePrivateClient
     , public ActiveDOMObject
     , public EventTargetWithInlineData
     , public URLRegistrable

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (292781 => 292782)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -1569,7 +1569,7 @@
             // while processing remainder of load failure.
             m_mediaSource = nullptr;
             mediaLoadingFailed(MediaPlayer::NetworkState::FormatError);
-        } else if (!m_player->load(url, contentType, m_mediaSource.get())) {
+        } else if (!m_player->load(url, contentType, *m_mediaSource)) {
             // We have to detach the MediaSource before we forget the reference to it.
             m_mediaSource->detachFromElement(*this);
             m_mediaSource = nullptr;

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -103,7 +103,7 @@
 
     void load(const String&) final { }
 #if ENABLE(MEDIA_SOURCE)
-    void load(const URL&, const ContentType&, MediaSourcePrivateClient*) final { }
+    void load(const URL&, const ContentType&, MediaSourcePrivateClient&) final { }
 #endif
 #if ENABLE(MEDIA_STREAM)
     void load(MediaStreamPrivate&) final { }
@@ -508,10 +508,9 @@
 }
 
 #if ENABLE(MEDIA_SOURCE)
-bool MediaPlayer::load(const URL& url, const ContentType& contentType, MediaSourcePrivateClient* mediaSource)
+bool MediaPlayer::load(const URL& url, const ContentType& contentType, MediaSourcePrivateClient& mediaSource)
 {
     ASSERT(!m_reloadTimer.isActive());
-    ASSERT(mediaSource);
 
     m_mediaSource = mediaSource;
     m_contentType = contentType;
@@ -623,7 +622,7 @@
     if (m_private) {
 #if ENABLE(MEDIA_SOURCE)
         if (m_mediaSource)
-            m_private->load(m_url, m_contentMIMETypeWasInferredFromExtension ? ContentType() : m_contentType, m_mediaSource.get());
+            m_private->load(m_url, m_contentMIMETypeWasInferredFromExtension ? ContentType() : m_contentType, *m_mediaSource);
         else
 #endif
 #if ENABLE(MEDIA_STREAM)

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -358,7 +358,7 @@
 
     bool load(const URL&, const ContentType&, const String& keySystem);
 #if ENABLE(MEDIA_SOURCE)
-    bool load(const URL&, const ContentType&, MediaSourcePrivateClient*);
+    bool load(const URL&, const ContentType&, MediaSourcePrivateClient&);
 #endif
 #if ENABLE(MEDIA_STREAM)
     bool load(MediaStreamPrivate&);
@@ -738,7 +738,7 @@
     PitchCorrectionAlgorithm m_pitchCorrectionAlgorithm { PitchCorrectionAlgorithm::BestAllAround };
 
 #if ENABLE(MEDIA_SOURCE)
-    RefPtr<MediaSourcePrivateClient> m_mediaSource;
+    WeakPtr<MediaSourcePrivateClient> m_mediaSource;
 #endif
 #if ENABLE(MEDIA_STREAM)
     RefPtr<MediaStreamPrivate> m_mediaStream;

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -52,7 +52,7 @@
     virtual void load(const URL& url, const ContentType&, const String&) { load(url.string()); }
 
 #if ENABLE(MEDIA_SOURCE)
-    virtual void load(const URL&, const ContentType&, MediaSourcePrivateClient*) = 0;
+    virtual void load(const URL&, const ContentType&, MediaSourcePrivateClient&) = 0;
 #endif
 #if ENABLE(MEDIA_STREAM)
     virtual void load(MediaStreamPrivate&) = 0;

Modified: trunk/Source/WebCore/platform/graphics/MediaSourcePrivateClient.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/MediaSourcePrivateClient.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/MediaSourcePrivateClient.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -23,20 +23,19 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef MediaSourcePrivateClient_h
-#define MediaSourcePrivateClient_h
+#pragma once
 
 #if ENABLE(MEDIA_SOURCE)
 
 #include "PlatformTimeRanges.h"
 #include <wtf/Logger.h>
-#include <wtf/RefCounted.h>
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
 class MediaSourcePrivate;
 
-class MediaSourcePrivateClient : public RefCounted<MediaSourcePrivateClient> {
+class MediaSourcePrivateClient : public CanMakeWeakPtr<MediaSourcePrivateClient> {
 public:
     virtual ~MediaSourcePrivateClient() = default;
 
@@ -59,5 +58,3 @@
 }
 
 #endif // ENABLE(MEDIA_SOURCE)
-
-#endif

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -205,7 +205,7 @@
 }
 
 #if ENABLE(MEDIA_SOURCE)
-void MediaPlayerPrivateAVFoundation::load(const URL&, const ContentType&, MediaSourcePrivateClient*)
+void MediaPlayerPrivateAVFoundation::load(const URL&, const ContentType&, MediaSourcePrivateClient&)
 {
     setNetworkState(MediaPlayer::NetworkState::FormatError);
 }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -166,7 +166,7 @@
     // MediaPlayerPrivatePrivateInterface overrides.
     void load(const String& url) override;
 #if ENABLE(MEDIA_SOURCE)
-    void load(const URL&, const ContentType&, MediaSourcePrivateClient*) override;
+    void load(const URL&, const ContentType&, MediaSourcePrivateClient&) override;
 #endif
 #if ENABLE(MEDIA_STREAM)
     void load(MediaStreamPrivate&) override { setNetworkState(MediaPlayer::NetworkState::FormatError); }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -166,7 +166,7 @@
 private:
     // MediaPlayerPrivateInterface
     void load(const String& url) override;
-    void load(const URL&, const ContentType&, MediaSourcePrivateClient*) override;
+    void load(const URL&, const ContentType&, MediaSourcePrivateClient&) override;
 #if ENABLE(MEDIA_STREAM)
     void load(MediaStreamPrivate&) override;
 #endif

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2022-04-12 19:36:24 UTC (rev 292782)
@@ -280,7 +280,7 @@
     m_player->networkStateChanged();
 }
 
-void MediaPlayerPrivateMediaSourceAVFObjC::load(const URL&, const ContentType&, MediaSourcePrivateClient* client)
+void MediaPlayerPrivateMediaSourceAVFObjC::load(const URL&, const ContentType&, MediaSourcePrivateClient& client)
 {
     ALWAYS_LOG(LOGIDENTIFIER);
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -95,7 +95,7 @@
 
     void load(const String&) override;
 #if ENABLE(MEDIA_SOURCE)
-    void load(const URL&, const ContentType&, MediaSourcePrivateClient*) override;
+    void load(const URL&, const ContentType&, MediaSourcePrivateClient&) override;
 #endif
     void load(MediaStreamPrivate&) override;
     void cancelLoad() override;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2022-04-12 19:36:24 UTC (rev 292782)
@@ -450,7 +450,7 @@
 }
 
 #if ENABLE(MEDIA_SOURCE)
-void MediaPlayerPrivateMediaStreamAVFObjC::load(const URL&, const ContentType&, MediaSourcePrivateClient*)
+void MediaPlayerPrivateMediaStreamAVFObjC::load(const URL&, const ContentType&, MediaSourcePrivateClient&)
 {
     // This media engine only supports MediaStream URLs.
     scheduleDeferredTask([this] {

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -59,7 +59,7 @@
 #endif
 {
 public:
-    static Ref<MediaSourcePrivateAVFObjC> create(MediaPlayerPrivateMediaSourceAVFObjC&, MediaSourcePrivateClient*);
+    static Ref<MediaSourcePrivateAVFObjC> create(MediaPlayerPrivateMediaSourceAVFObjC&, MediaSourcePrivateClient&);
     virtual ~MediaSourcePrivateAVFObjC();
 
     MediaPlayerPrivateMediaSourceAVFObjC* player() const { return m_player.get(); }
@@ -120,7 +120,7 @@
     void failedToCreateRenderer(RendererType);
 
 private:
-    MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC&, MediaSourcePrivateClient*);
+    MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC&, MediaSourcePrivateClient&);
 
     void sourceBufferPrivateDidChangeActiveState(SourceBufferPrivateAVFObjC*, bool active);
     void sourceBufferPrivateDidReceiveInitializationSegment(SourceBufferPrivateAVFObjC*);
@@ -134,7 +134,7 @@
     friend class SourceBufferPrivateAVFObjC;
 
     WeakPtr<MediaPlayerPrivateMediaSourceAVFObjC> m_player;
-    RefPtr<MediaSourcePrivateClient> m_client;
+    WeakPtr<MediaSourcePrivateClient> m_client;
     Vector<RefPtr<SourceBufferPrivateAVFObjC>> m_sourceBuffers;
     Vector<SourceBufferPrivateAVFObjC*> m_activeSourceBuffers;
     Deque<SourceBufferPrivateAVFObjC*> m_sourceBuffersNeedingSessions;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm	2022-04-12 19:36:24 UTC (rev 292782)
@@ -46,14 +46,14 @@
 #pragma mark -
 #pragma mark MediaSourcePrivateAVFObjC
 
-Ref<MediaSourcePrivateAVFObjC> MediaSourcePrivateAVFObjC::create(MediaPlayerPrivateMediaSourceAVFObjC& parent, MediaSourcePrivateClient* client)
+Ref<MediaSourcePrivateAVFObjC> MediaSourcePrivateAVFObjC::create(MediaPlayerPrivateMediaSourceAVFObjC& parent, MediaSourcePrivateClient& client)
 {
     auto mediaSourcePrivate = adoptRef(*new MediaSourcePrivateAVFObjC(parent, client));
-    client->setPrivateAndOpen(mediaSourcePrivate.copyRef());
+    client.setPrivateAndOpen(mediaSourcePrivate.copyRef());
     return mediaSourcePrivate;
 }
 
-MediaSourcePrivateAVFObjC::MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC& parent, MediaSourcePrivateClient* client)
+MediaSourcePrivateAVFObjC::MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC& parent, MediaSourcePrivateClient& client)
     : m_player(parent)
     , m_client(client)
     , m_isEnded(false)
@@ -64,7 +64,7 @@
 {
     ALWAYS_LOG(LOGIDENTIFIER);
 #if !RELEASE_LOG_DISABLED
-    m_client->setLogIdentifier(m_logIdentifier);
+    client.setLogIdentifier(m_logIdentifier);
 #endif
 }
 
@@ -121,12 +121,16 @@
 
 MediaTime MediaSourcePrivateAVFObjC::duration() const
 {
-    return m_client->duration();
+    if (m_client)
+        return m_client->duration();
+    return MediaTime::invalidTime();
 }
 
 std::unique_ptr<PlatformTimeRanges> MediaSourcePrivateAVFObjC::buffered()
 {
-    return m_client->buffered();
+    if (m_client)
+        return m_client->buffered();
+    return nullptr;
 }
 
 void MediaSourcePrivateAVFObjC::durationChanged(const MediaTime&)
@@ -236,7 +240,8 @@
 
 void MediaSourcePrivateAVFObjC::seekToTime(const MediaTime& time)
 {
-    m_client->seekToTime(time);
+    if (m_client)
+        m_client->seekToTime(time);
 }
 
 MediaTime MediaSourcePrivateAVFObjC::fastSeekTimeForMediaTime(const MediaTime& targetTime, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold)
@@ -357,7 +362,8 @@
 
 void MediaSourcePrivateAVFObjC::failedToCreateRenderer(RendererType type)
 {
-    m_client->failedToCreateRenderer(type);
+    if (m_client)
+        m_client->failedToCreateRenderer(type);
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2022-04-12 19:36:24 UTC (rev 292782)
@@ -361,7 +361,6 @@
 {
     ALWAYS_LOG(LOGIDENTIFIER);
 
-    ASSERT(!m_client);
     sourceBufferMap().remove(m_mapID);
     destroyStreamDataParser();
     destroyRenderers();

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -353,7 +353,7 @@
 }
 
 #if ENABLE(MEDIA_SOURCE)
-void MediaPlayerPrivateGStreamer::load(const URL&, const ContentType&, MediaSourcePrivateClient*)
+void MediaPlayerPrivateGStreamer::load(const URL&, const ContentType&, MediaSourcePrivateClient&)
 {
     // Properly fail so the global MediaPlayer tries to fallback to the next MediaPlayerPrivate.
     m_networkState = MediaPlayer::NetworkState::FormatError;

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -138,7 +138,7 @@
     bool hasAudio() const final { return m_hasAudio; }
     void load(const String &url) override;
 #if ENABLE(MEDIA_SOURCE)
-    void load(const URL&, const ContentType&, MediaSourcePrivateClient*) override;
+    void load(const URL&, const ContentType&, MediaSourcePrivateClient&) override;
 #endif
 #if ENABLE(MEDIA_STREAM)
     void load(MediaStreamPrivate&) override;

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -123,7 +123,7 @@
     m_player->networkStateChanged();
 }
 
-void MediaPlayerPrivateGStreamerMSE::load(const URL& url, const ContentType&, MediaSourcePrivateClient* mediaSource)
+void MediaPlayerPrivateGStreamerMSE::load(const URL& url, const ContentType&, MediaSourcePrivateClient& mediaSource)
 {
     auto mseBlobURI = makeString("mediasource", url.string().isEmpty() ? "blob://"_s : url.string());
     GST_DEBUG("Loading %s", mseBlobURI.ascii().data());
@@ -317,7 +317,7 @@
     ASSERT(isMainThread());
 
     MediaTime previousDuration = m_mediaTimeDuration;
-    m_mediaTimeDuration = m_mediaSource->duration();
+    m_mediaTimeDuration = m_mediaSource ? m_mediaSource->duration() : MediaTime::invalidTime();
 
     GST_TRACE("previous=%s, new=%s", toString(previousDuration).utf8().data(), toString(m_mediaTimeDuration).utf8().data());
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -49,7 +49,7 @@
     static void registerMediaEngine(MediaEngineRegistrar);
 
     void load(const String&) override;
-    void load(const URL&, const ContentType&, MediaSourcePrivateClient*) override;
+    void load(const URL&, const ContentType&, MediaSourcePrivateClient&) override;
 
     void updateDownloadBufferingFlag() override { };
 
@@ -105,7 +105,7 @@
 
     void propagateReadyStateToPlayer();
 
-    RefPtr<MediaSourcePrivateClient> m_mediaSource;
+    WeakPtr<MediaSourcePrivateClient> m_mediaSource;
     RefPtr<MediaSourcePrivateGStreamer> m_mediaSourcePrivate;
     MediaTime m_mediaTimeDuration;
     bool m_areDurationChangesBlocked = false;

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -104,7 +104,7 @@
 {
     ASSERT(isMainThread());
 
-    MediaTime duration = m_mediaSource->duration();
+    MediaTime duration = m_mediaSource ? m_mediaSource->duration() : MediaTime::invalidTime();
     GST_TRACE("duration: %f", duration.toFloat());
     if (!duration.isValid() || duration.isNegativeInfinite())
         return;
@@ -144,7 +144,7 @@
 
 MediaTime MediaSourcePrivateGStreamer::duration() const
 {
-    return m_mediaSource->duration();
+    return m_mediaSource ? m_mediaSource->duration() : MediaTime::invalidTime();
 }
 
 MediaTime MediaSourcePrivateGStreamer::currentMediaTime() const
@@ -185,7 +185,9 @@
 
 std::unique_ptr<PlatformTimeRanges> MediaSourcePrivateGStreamer::buffered()
 {
-    return m_mediaSource->buffered();
+    if (m_mediaSource)
+        return m_mediaSource->buffered();
+    return nullptr;
 }
 
 #if !RELEASE_LOG_DISABLED

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourcePrivateGStreamer.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -92,7 +92,7 @@
 
     HashSet<RefPtr<SourceBufferPrivateGStreamer>> m_sourceBuffers;
     HashSet<SourceBufferPrivateGStreamer*> m_activeSourceBuffers;
-    Ref<MediaSourcePrivateClient> m_mediaSource;
+    WeakPtr<MediaSourcePrivateClient> m_mediaSource;
     MediaPlayerPrivateGStreamerMSE& m_playerPrivate;
     bool m_isEnded { false };
     bool m_hasAllTracks { false };

Modified: trunk/Source/WebCore/platform/graphics/holepunch/MediaPlayerPrivateHolePunch.h (292781 => 292782)


--- trunk/Source/WebCore/platform/graphics/holepunch/MediaPlayerPrivateHolePunch.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/graphics/holepunch/MediaPlayerPrivateHolePunch.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -53,7 +53,7 @@
 
     void load(const String&) final;
 #if ENABLE(MEDIA_SOURCE)
-    void load(const URL&, const ContentType&, MediaSourcePrivateClient*) final { };
+    void load(const URL&, const ContentType&, MediaSourcePrivateClient&) final { };
 #endif
 #if ENABLE(MEDIA_STREAM)
     void load(MediaStreamPrivate&) final { };

Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp (292781 => 292782)


--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -111,9 +111,9 @@
     ASSERT_NOT_REACHED();
 }
 
-void MockMediaPlayerMediaSource::load(const URL&, const ContentType&, MediaSourcePrivateClient* source)
+void MockMediaPlayerMediaSource::load(const URL&, const ContentType&, MediaSourcePrivateClient& source)
 {
-    m_mediaSourcePrivate = MockMediaSourcePrivate::create(*this, *source);
+    m_mediaSourcePrivate = MockMediaSourcePrivate::create(*this, source);
 }
 
 void MockMediaPlayerMediaSource::cancelLoad()

Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h (292781 => 292782)


--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -67,7 +67,7 @@
 private:
     // MediaPlayerPrivate Overrides
     void load(const String& url) override;
-    void load(const URL&, const ContentType&, MediaSourcePrivateClient*) override;
+    void load(const URL&, const ContentType&, MediaSourcePrivateClient&) override;
 #if ENABLE(MEDIA_STREAM)
     void load(MediaStreamPrivate&) override { }
 #endif

Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp (292781 => 292782)


--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -52,7 +52,7 @@
 #endif
 {
 #if !RELEASE_LOG_DISABLED
-    m_client->setLogIdentifier(m_player.mediaPlayerLogIdentifier());
+    client.setLogIdentifier(m_player.mediaPlayerLogIdentifier());
 #endif
 }
 
@@ -85,12 +85,16 @@
 
 MediaTime MockMediaSourcePrivate::duration()
 {
-    return m_client->duration();
+    if (m_client)
+        return m_client->duration();
+    return MediaTime::invalidTime();
 }
 
 std::unique_ptr<PlatformTimeRanges> MockMediaSourcePrivate::buffered()
 {
-    return m_client->buffered();
+    if (m_client)
+        return m_client->buffered();
+    return nullptr;
 }
 
 void MockMediaSourcePrivate::durationChanged(const MediaTime&)
@@ -161,7 +165,8 @@
 
 void MockMediaSourcePrivate::seekToTime(const MediaTime& time)
 {
-    m_client->seekToTime(time);
+    if (m_client)
+        m_client->seekToTime(time);
 }
 
 MediaTime MockMediaSourcePrivate::seekToTime(const MediaTime& targetTime, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold)

Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h (292781 => 292782)


--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -96,7 +96,7 @@
     friend class MockSourceBufferPrivate;
 
     MockMediaPlayerMediaSource& m_player;
-    Ref<MediaSourcePrivateClient> m_client;
+    WeakPtr<MediaSourcePrivateClient> m_client;
     Vector<RefPtr<MockSourceBufferPrivate>> m_sourceBuffers;
     Vector<MockSourceBufferPrivate*> m_activeSourceBuffers;
     bool m_isEnded { false };

Modified: trunk/Source/WebKit/ChangeLog (292781 => 292782)


--- trunk/Source/WebKit/ChangeLog	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebKit/ChangeLog	2022-04-12 19:36:24 UTC (rev 292782)
@@ -1,3 +1,25 @@
+2022-04-12  Jer Noble  <[email protected]>
+
+        Leak of MediaSourcePrivateAVFObjC and RemoteMediaSourceProxy
+        https://bugs.webkit.org/show_bug.cgi?id=239088
+        <rdar://90693094>
+
+        Reviewed by Eric Carlson.
+
+        Adopt changes to MediaSourcePrivateClient making it a CanMakeWeakPtr class.
+
+        * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+        (WebKit::RemoteMediaPlayerProxy::loadMediaSource):
+        * GPUProcess/media/RemoteMediaSourceProxy.h:
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+        (WebKit::MediaPlayerPrivateRemote::load):
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.h:
+        * WebProcess/GPU/media/MediaSourcePrivateRemote.cpp:
+        (WebKit::MediaSourcePrivateRemote::create):
+        (WebKit::MediaSourcePrivateRemote::MediaSourcePrivateRemote):
+        (WebKit::MediaSourcePrivateRemote::seekToTime):
+        * WebProcess/GPU/media/MediaSourcePrivateRemote.h:
+
 2022-04-12  Ada Chan  <[email protected]>
 
         [WebXR] Implement the WebXRFrame methods for getting joints' poses and radii

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp (292781 => 292782)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -171,7 +171,7 @@
     }
 
     m_mediaSourceProxy = adoptRef(*new RemoteMediaSourceProxy(*m_manager->gpuConnectionToWebProcess(), mediaSourceIdentifier, webMParserEnabled, *this));
-    m_player->load(url, contentType, m_mediaSourceProxy.get());
+    m_player->load(url, contentType, *m_mediaSourceProxy);
     getConfiguration(configuration);
     completionHandler(WTFMove(configuration));
 }

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaSourceProxy.h (292781 => 292782)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaSourceProxy.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaSourceProxy.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -33,6 +33,7 @@
 #include <WebCore/MediaSourcePrivate.h>
 #include <WebCore/MediaSourcePrivateClient.h>
 #include <wtf/MediaTime.h>
+#include <wtf/RefCounted.h>
 #include <wtf/WeakPtr.h>
 
 namespace IPC {
@@ -52,7 +53,8 @@
 class RemoteMediaPlayerProxy;
 
 class RemoteMediaSourceProxy final
-    : public WebCore::MediaSourcePrivateClient
+    : public RefCounted<RemoteMediaSourceProxy>
+    , public WebCore::MediaSourcePrivateClient
     , private IPC::MessageReceiver {
     WTF_MAKE_FAST_ALLOCATED;
 public:

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (292781 => 292782)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -790,7 +790,7 @@
 }
 
 #if ENABLE(MEDIA_SOURCE)
-void MediaPlayerPrivateRemote::load(const URL& url, const ContentType& contentType, MediaSourcePrivateClient* client)
+void MediaPlayerPrivateRemote::load(const URL& url, const ContentType& contentType, MediaSourcePrivateClient& client)
 {
     if (m_remoteEngineIdentifier == MediaPlayerEnums::MediaEngineIdentifier::AVFoundationMSE) {
         auto identifier = RemoteMediaSourceIdentifier::generate();

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (292781 => 292782)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -198,7 +198,7 @@
     void prepareForPlayback(bool privateMode, WebCore::MediaPlayer::Preload, bool preservesPitch, bool prepare) final;
 
 #if ENABLE(MEDIA_SOURCE)
-    void load(const URL&, const WebCore::ContentType&, WebCore::MediaSourcePrivateClient*) final;
+    void load(const URL&, const WebCore::ContentType&, WebCore::MediaSourcePrivateClient&) final;
 #endif
 #if ENABLE(MEDIA_STREAM)
     void load(WebCore::MediaStreamPrivate&) final;

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaSourcePrivateRemote.cpp (292781 => 292782)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaSourcePrivateRemote.cpp	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaSourcePrivateRemote.cpp	2022-04-12 19:36:24 UTC (rev 292782)
@@ -46,14 +46,14 @@
 
 using namespace WebCore;
 
-Ref<MediaSourcePrivateRemote> MediaSourcePrivateRemote::create(GPUProcessConnection& gpuProcessConnection, RemoteMediaSourceIdentifier identifier, RemoteMediaPlayerMIMETypeCache& mimeTypeCache, const MediaPlayerPrivateRemote& mediaPlayerPrivate, MediaSourcePrivateClient* client)
+Ref<MediaSourcePrivateRemote> MediaSourcePrivateRemote::create(GPUProcessConnection& gpuProcessConnection, RemoteMediaSourceIdentifier identifier, RemoteMediaPlayerMIMETypeCache& mimeTypeCache, const MediaPlayerPrivateRemote& mediaPlayerPrivate, MediaSourcePrivateClient& client)
 {
     auto mediaSourcePrivate = adoptRef(*new MediaSourcePrivateRemote(gpuProcessConnection, identifier, mimeTypeCache, mediaPlayerPrivate, client));
-    client->setPrivateAndOpen(mediaSourcePrivate.copyRef());
+    client.setPrivateAndOpen(mediaSourcePrivate.copyRef());
     return mediaSourcePrivate;
 }
 
-MediaSourcePrivateRemote::MediaSourcePrivateRemote(GPUProcessConnection& gpuProcessConnection, RemoteMediaSourceIdentifier identifier, RemoteMediaPlayerMIMETypeCache& mimeTypeCache, const MediaPlayerPrivateRemote& mediaPlayerPrivate, MediaSourcePrivateClient* client)
+MediaSourcePrivateRemote::MediaSourcePrivateRemote(GPUProcessConnection& gpuProcessConnection, RemoteMediaSourceIdentifier identifier, RemoteMediaPlayerMIMETypeCache& mimeTypeCache, const MediaPlayerPrivateRemote& mediaPlayerPrivate, MediaSourcePrivateClient& client)
     : m_gpuProcessConnection(gpuProcessConnection)
     , m_identifier(identifier)
     , m_mimeTypeCache(mimeTypeCache)
@@ -69,7 +69,7 @@
     m_gpuProcessConnection->messageReceiverMap().addMessageReceiver(Messages::MediaSourcePrivateRemote::messageReceiverName(), m_identifier.toUInt64(), *this);
 
 #if !RELEASE_LOG_DISABLED
-    m_client->setLogIdentifier(m_logIdentifier);
+    client.setLogIdentifier(m_logIdentifier);
 #endif
 }
 
@@ -191,7 +191,8 @@
 
 void MediaSourcePrivateRemote::seekToTime(const MediaTime& time)
 {
-    m_client->seekToTime(time);
+    if (m_client)
+        m_client->seekToTime(time);
 }
 
 #if !RELEASE_LOG_DISABLED

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaSourcePrivateRemote.h (292781 => 292782)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaSourcePrivateRemote.h	2022-04-12 19:26:56 UTC (rev 292781)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaSourcePrivateRemote.h	2022-04-12 19:36:24 UTC (rev 292782)
@@ -57,7 +57,7 @@
 #endif
 {
 public:
-    static Ref<MediaSourcePrivateRemote> create(GPUProcessConnection&, RemoteMediaSourceIdentifier, RemoteMediaPlayerMIMETypeCache&, const MediaPlayerPrivateRemote&, WebCore::MediaSourcePrivateClient*);
+    static Ref<MediaSourcePrivateRemote> create(GPUProcessConnection&, RemoteMediaSourceIdentifier, RemoteMediaPlayerMIMETypeCache&, const MediaPlayerPrivateRemote&, WebCore::MediaSourcePrivateClient&);
     virtual ~MediaSourcePrivateRemote();
 
     // MediaSourcePrivate overrides
@@ -82,7 +82,7 @@
 #endif
 
 private:
-    MediaSourcePrivateRemote(GPUProcessConnection&, RemoteMediaSourceIdentifier, RemoteMediaPlayerMIMETypeCache&, const MediaPlayerPrivateRemote&, WebCore::MediaSourcePrivateClient*);
+    MediaSourcePrivateRemote(GPUProcessConnection&, RemoteMediaSourceIdentifier, RemoteMediaPlayerMIMETypeCache&, const MediaPlayerPrivateRemote&, WebCore::MediaSourcePrivateClient&);
 
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
     void seekToTime(const MediaTime&);
@@ -91,7 +91,7 @@
     RemoteMediaSourceIdentifier m_identifier;
     RemoteMediaPlayerMIMETypeCache& m_mimeTypeCache;
     WeakPtr<MediaPlayerPrivateRemote> m_mediaPlayerPrivate;
-    RefPtr<WebCore::MediaSourcePrivateClient> m_client;
+    WeakPtr<WebCore::MediaSourcePrivateClient> m_client;
     Vector<RefPtr<SourceBufferPrivateRemote>> m_sourceBuffers;
 
 #if !RELEASE_LOG_DISABLED
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to