Title: [290590] trunk/Source
Revision
290590
Author
[email protected]
Date
2022-02-28 02:03:51 -0800 (Mon, 28 Feb 2022)

Log Message

Ensure RemoteMediaPlayerProxy sets its resource owner to pixel buffers created by its player
https://bugs.webkit.org/show_bug.cgi?id=237200

Reviewed by Eric Carlson.

Source/WebCore:

Add API to set the resource owner for a player private.
In case player private is running in GPUProcess, use resource owner to mark pixel buffers as owned by the resource owner.
Covered by existing tests.

* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::setResourceOwner):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastPixelBuffer):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateLastPixelBuffer):

Source/WebKit:

Set resource owner to the player private.

* GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp:
(WebKit::RemoteMediaPlayerManagerProxy::createMediaPlayer):
* GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::RemoteMediaPlayerProxy):
* GPUProcess/media/RemoteMediaPlayerProxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (290589 => 290590)


--- trunk/Source/WebCore/ChangeLog	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebCore/ChangeLog	2022-02-28 10:03:51 UTC (rev 290590)
@@ -1,3 +1,23 @@
+2022-02-28  Youenn Fablet  <[email protected]>
+
+        Ensure RemoteMediaPlayerProxy sets its resource owner to pixel buffers created by its player
+        https://bugs.webkit.org/show_bug.cgi?id=237200
+
+        Reviewed by Eric Carlson.
+
+        Add API to set the resource owner for a player private.
+        In case player private is running in GPUProcess, use resource owner to mark pixel buffers as owned by the resource owner.
+        Covered by existing tests.
+
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::setResourceOwner):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastPixelBuffer):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateLastPixelBuffer):
+
 2022-02-28  Carlos Garcia Campos  <[email protected]>
 
         [ATSPI] Always expose table cells (layout and CSS) that have rendered text content

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (290589 => 290590)


--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2022-02-28 10:03:51 UTC (rev 290590)
@@ -31,6 +31,7 @@
 #include "MediaPlayerIdentifier.h"
 #include "NativeImage.h"
 #include "PlatformTimeRanges.h"
+#include "ProcessIdentity.h"
 #include "VideoFrame.h"
 #include <optional>
 #include <wtf/CompletionHandler.h>
@@ -324,6 +325,8 @@
     virtual std::optional<VideoFrameMetadata> videoFrameMetadata() { return { }; }
     virtual void startVideoFrameMetadataGathering() { }
     virtual void stopVideoFrameMetadataGathering() { }
+
+    virtual void setResourceOwner(const ProcessIdentity&) { }
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (290589 => 290590)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2022-02-28 10:03:51 UTC (rev 290590)
@@ -348,6 +348,8 @@
     void startVideoFrameMetadataGathering() final;
     void stopVideoFrameMetadataGathering() final;
     std::optional<VideoFrameMetadata> videoFrameMetadata() final { return std::exchange(m_videoFrameMetadata, { }); }
+    void setResourceOwner(const ProcessIdentity& resourceOwner) final { m_resourceOwner = resourceOwner; }
+
     void checkNewVideoFrameMetadata();
 
     std::optional<bool> allTracksArePlayable() const;
@@ -472,6 +474,7 @@
     mutable std::optional<NSTimeInterval> m_cachedLiveUpdateInterval;
     std::unique_ptr<Observer<void()>> m_currentImageChangedObserver;
     std::unique_ptr<Observer<void()>> m_waitForVideoOutputMediaDataWillChangeObserver;
+    ProcessIdentity m_resourceOwner;
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (290589 => 290590)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2022-02-28 10:03:51 UTC (rev 290590)
@@ -44,6 +44,7 @@
 #import "FloatConversion.h"
 #import "FourCC.h"
 #import "GraphicsContext.h"
+#import "IOSurface.h"
 #import "ImageRotationSessionVT.h"
 #import "InbandChapterTrackPrivateAVFObjC.h"
 #import "InbandMetadataTextTrackPrivateAVF.h"
@@ -2656,6 +2657,11 @@
     if (m_lastPixelBuffer && m_imageRotationSession)
         m_lastPixelBuffer = m_imageRotationSession->rotate(m_lastPixelBuffer.get());
 
+    if (m_resourceOwner && m_lastPixelBuffer) {
+        if (auto surface = CVPixelBufferGetIOSurface(m_lastPixelBuffer.get()))
+            IOSurface::setOwnershipIdentity(surface, m_resourceOwner);
+    }
+
     m_lastImage = nullptr;
     return true;
 }

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h	2022-02-28 10:03:51 UTC (rev 290590)
@@ -279,6 +279,8 @@
     void startVideoFrameMetadataGathering() final;
     void stopVideoFrameMetadataGathering() final;
     std::optional<VideoFrameMetadata> videoFrameMetadata() final { return std::exchange(m_videoFrameMetadata, { }); }
+    void setResourceOwner(const ProcessIdentity& resourceOwner) final { m_resourceOwner = resourceOwner; }
+
     void checkNewVideoFrameMetadata(CMTime);
 
     friend class MediaSourcePrivateAVFObjC;
@@ -356,6 +358,7 @@
     bool m_isGatheringVideoFrameMetadata { false };
     std::optional<VideoFrameMetadata> m_videoFrameMetadata;
     uint64_t m_lastConvertedSampleCount { 0 };
+    ProcessIdentity m_resourceOwner;
 };
 
 String convertEnumerationToString(MediaPlayerPrivateMediaSourceAVFObjC::SeekState);

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm	2022-02-28 10:03:51 UTC (rev 290590)
@@ -33,6 +33,7 @@
 #import "AVStreamDataParserMIMETypeCache.h"
 #import "CDMSessionAVStreamSession.h"
 #import "GraphicsContext.h"
+#import "IOSurface.h"
 #import "Logging.h"
 #import "MediaSessionManagerCocoa.h"
 #import "MediaSourcePrivateAVFObjC.h"
@@ -682,6 +683,12 @@
         return false;
 
     m_lastPixelBuffer = newPixelBuffer;
+
+    if (m_resourceOwner) {
+        if (auto surface = CVPixelBufferGetIOSurface(m_lastPixelBuffer.get()))
+            IOSurface::setOwnershipIdentity(surface, m_resourceOwner);
+    }
+
     return true;
 }
 

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2022-02-28 10:03:51 UTC (rev 290590)
@@ -163,6 +163,7 @@
     void setBufferingPolicy(MediaPlayer::BufferingPolicy) override;
     void audioOutputDeviceChanged() final;
     std::optional<VideoFrameMetadata> videoFrameMetadata() final;
+    void setResourceOwner(const ProcessIdentity&) final { ASSERT_NOT_REACHED(); }
 
     MediaPlayer::ReadyState currentReadyState();
     void updateReadyState();

Modified: trunk/Source/WebKit/ChangeLog (290589 => 290590)


--- trunk/Source/WebKit/ChangeLog	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebKit/ChangeLog	2022-02-28 10:03:51 UTC (rev 290590)
@@ -1,3 +1,18 @@
+2022-02-28  Youenn Fablet  <[email protected]>
+
+        Ensure RemoteMediaPlayerProxy sets its resource owner to pixel buffers created by its player
+        https://bugs.webkit.org/show_bug.cgi?id=237200
+
+        Reviewed by Eric Carlson.
+
+        Set resource owner to the player private.
+
+        * GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp:
+        (WebKit::RemoteMediaPlayerManagerProxy::createMediaPlayer):
+        * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
+        (WebKit::RemoteMediaPlayerProxy::RemoteMediaPlayerProxy):
+        * GPUProcess/media/RemoteMediaPlayerProxy.h:
+
 2022-02-28  Kimmo Kinnunen  <[email protected]>
 
         IPC_TESTING_API MessageArgumentDescriptions.cpp is slow to compile

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp (290589 => 290590)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp	2022-02-28 10:03:51 UTC (rev 290590)
@@ -67,7 +67,7 @@
     ASSERT(m_gpuConnectionToWebProcess);
     ASSERT(!m_proxies.contains(identifier));
 
-    auto proxy = makeUnique<RemoteMediaPlayerProxy>(*this, identifier, m_gpuConnectionToWebProcess->connection(), engineIdentifier, WTFMove(proxyConfiguration), m_gpuConnectionToWebProcess->videoFrameObjectHeap());
+    auto proxy = makeUnique<RemoteMediaPlayerProxy>(*this, identifier, m_gpuConnectionToWebProcess->connection(), engineIdentifier, WTFMove(proxyConfiguration), m_gpuConnectionToWebProcess->videoFrameObjectHeap(), m_gpuConnectionToWebProcess->webProcessIdentity());
     m_proxies.add(identifier, WTFMove(proxy));
 }
 

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp (290589 => 290590)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp	2022-02-28 10:03:51 UTC (rev 290590)
@@ -76,7 +76,7 @@
 
 using namespace WebCore;
 
-RemoteMediaPlayerProxy::RemoteMediaPlayerProxy(RemoteMediaPlayerManagerProxy& manager, MediaPlayerIdentifier identifier, Ref<IPC::Connection>&& connection, MediaPlayerEnums::MediaEngineIdentifier engineIdentifier, RemoteMediaPlayerProxyConfiguration&& configuration, RemoteVideoFrameObjectHeap& videoFrameObjectHeap)
+RemoteMediaPlayerProxy::RemoteMediaPlayerProxy(RemoteMediaPlayerManagerProxy& manager, MediaPlayerIdentifier identifier, Ref<IPC::Connection>&& connection, MediaPlayerEnums::MediaEngineIdentifier engineIdentifier, RemoteMediaPlayerProxyConfiguration&& configuration, RemoteVideoFrameObjectHeap& videoFrameObjectHeap, const WebCore::ProcessIdentity& resourceOwner)
     : m_id(identifier)
     , m_webProcessConnection(WTFMove(connection))
     , m_manager(manager)
@@ -92,6 +92,8 @@
     m_typesRequiringHardwareSupport = m_configuration.mediaContentTypesRequiringHardwareSupport;
     m_renderingCanBeAccelerated = m_configuration.renderingCanBeAccelerated;
     m_player = MediaPlayer::create(*this, m_engineIdentifier);
+    if (auto* playerPrivate = m_player->playerPrivate())
+        playerPrivate->setResourceOwner(resourceOwner);
 }
 
 RemoteMediaPlayerProxy::~RemoteMediaPlayerProxy()

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (290589 => 290590)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h	2022-02-28 09:56:27 UTC (rev 290589)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h	2022-02-28 10:03:51 UTC (rev 290590)
@@ -107,7 +107,7 @@
     , public IPC::MessageReceiver {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    RemoteMediaPlayerProxy(RemoteMediaPlayerManagerProxy&, WebCore::MediaPlayerIdentifier, Ref<IPC::Connection>&&, WebCore::MediaPlayerEnums::MediaEngineIdentifier, RemoteMediaPlayerProxyConfiguration&&, RemoteVideoFrameObjectHeap&);
+    RemoteMediaPlayerProxy(RemoteMediaPlayerManagerProxy&, WebCore::MediaPlayerIdentifier, Ref<IPC::Connection>&&, WebCore::MediaPlayerEnums::MediaEngineIdentifier, RemoteMediaPlayerProxyConfiguration&&, RemoteVideoFrameObjectHeap&, const WebCore::ProcessIdentity&);
     ~RemoteMediaPlayerProxy();
 
     WebCore::MediaPlayerIdentifier idendifier() const { return m_id; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to