Title: [290373] trunk/Source/WebKit
Revision
290373
Author
[email protected]
Date
2022-02-23 08:00:11 -0800 (Wed, 23 Feb 2022)

Log Message

RemoteSampleBufferDisplayLayer::enqueueSample should not change media samples owned by its object heap
https://bugs.webkit.org/show_bug.cgi?id=237025
<rdar://problem/89343447>

Reviewed by Darin Adler.

Updated https://commits.webkit.org/r290358 according comments given during review.

* Platform/IPC/ArgumentCoders.h:
(IPC::ArgumentCoder<std::nullptr_t>::encode):
(IPC::ArgumentCoder<std::nullptr_t>::decode):
* WebProcess/GPU/webrtc/RemoteVideoFrameObjectHeapProxyProcessor.cpp:
(WebKit::RemoteVideoFrameObjectHeapProxyProcessor::RemoteVideoFrameObjectHeapProxyProcessor):
* WebProcess/GPU/webrtc/SharedVideoFrame.cpp:
(WebKit::SharedVideoFrameWriter::write):
(WebKit::SharedVideoFrameReader::SharedVideoFrameReader):
* WebProcess/GPU/webrtc/SharedVideoFrame.h:
(WebKit::SharedVideoFrame::encode const):
(WebKit::SharedVideoFrame::decode):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (290372 => 290373)


--- trunk/Source/WebKit/ChangeLog	2022-02-23 15:54:52 UTC (rev 290372)
+++ trunk/Source/WebKit/ChangeLog	2022-02-23 16:00:11 UTC (rev 290373)
@@ -1,3 +1,25 @@
+2022-02-23  Youenn Fablet  <[email protected]>
+
+        RemoteSampleBufferDisplayLayer::enqueueSample should not change media samples owned by its object heap
+        https://bugs.webkit.org/show_bug.cgi?id=237025
+        <rdar://problem/89343447>
+
+        Reviewed by Darin Adler.
+
+        Updated https://commits.webkit.org/r290358 according comments given during review.
+
+        * Platform/IPC/ArgumentCoders.h:
+        (IPC::ArgumentCoder<std::nullptr_t>::encode):
+        (IPC::ArgumentCoder<std::nullptr_t>::decode):
+        * WebProcess/GPU/webrtc/RemoteVideoFrameObjectHeapProxyProcessor.cpp:
+        (WebKit::RemoteVideoFrameObjectHeapProxyProcessor::RemoteVideoFrameObjectHeapProxyProcessor):
+        * WebProcess/GPU/webrtc/SharedVideoFrame.cpp:
+        (WebKit::SharedVideoFrameWriter::write):
+        (WebKit::SharedVideoFrameReader::SharedVideoFrameReader):
+        * WebProcess/GPU/webrtc/SharedVideoFrame.h:
+        (WebKit::SharedVideoFrame::encode const):
+        (WebKit::SharedVideoFrame::decode):
+
 2022-02-23  Alex Christensen  <[email protected]>
 
         Call WKNavigationDelegate.didFailProvisionalNavigation even after a cross-origin navigation with COOP

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h (290372 => 290373)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2022-02-23 15:54:52 UTC (rev 290372)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2022-02-23 16:00:11 UTC (rev 290373)
@@ -852,4 +852,9 @@
     }
 };
 
+template<> struct ArgumentCoder<std::nullptr_t> {
+    static void encode(Encoder&, const std::nullptr_t&) { }
+    static WARN_UNUSED_RETURN bool decode(Decoder&, std::nullptr_t&) { return true; }
+};
+
 } // namespace IPC

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/RemoteVideoFrameObjectHeapProxyProcessor.cpp (290372 => 290373)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/RemoteVideoFrameObjectHeapProxyProcessor.cpp	2022-02-23 15:54:52 UTC (rev 290372)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/RemoteVideoFrameObjectHeapProxyProcessor.cpp	2022-02-23 16:00:11 UTC (rev 290373)
@@ -43,7 +43,6 @@
 RemoteVideoFrameObjectHeapProxyProcessor::RemoteVideoFrameObjectHeapProxyProcessor(GPUProcessConnection& connection)
     : m_connectionID(connection.connection().uniqueID())
     , m_queue(WorkQueue::create("RemoteVideoFrameObjectHeapProxy", WorkQueue::QOS::UserInteractive))
-    , m_sharedVideoFrameReader(nullptr)
 {
     connection.addClient(*this);
     connection.connection().addWorkQueueMessageReceiver(Messages::RemoteVideoFrameObjectHeapProxyProcessor::messageReceiverName(), m_queue, this);

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp (290372 => 290373)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp	2022-02-23 15:54:52 UTC (rev 290372)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.cpp	2022-02-23 16:00:11 UTC (rev 290373)
@@ -96,11 +96,11 @@
         return sharedVideoFrame;
     }
     if (is<MediaSampleAVFObjC>(frame)) {
-        auto pixelBuffer = downcast<MediaSampleAVFObjC>(frame).pixelBuffer();
-        IOSurfaceRef surface = pixelBuffer ? CVPixelBufferGetIOSurface(pixelBuffer) : nullptr;
-        if (surface) {
-            sharedVideoFrame.buffer = MachSendRight::adopt(IOSurfaceCreateMachPort(surface));
-            return sharedVideoFrame;
+        if (auto pixelBuffer = downcast<MediaSampleAVFObjC>(frame).pixelBuffer()) {
+            if (auto surface = CVPixelBufferGetIOSurface(pixelBuffer)) {
+                sharedVideoFrame.buffer = MachSendRight::adopt(IOSurfaceCreateMachPort(surface));
+                return sharedVideoFrame;
+            }
         }
     }
     if (!write(frame.pixelBuffer(), newSemaphoreCallback, newMemoryCallback))
@@ -140,6 +140,10 @@
 {
 }
 
+SharedVideoFrameReader::SharedVideoFrameReader()
+{
+}
+
 RetainPtr<CVPixelBufferRef> SharedVideoFrameReader::read()
 {
     if (!m_storage)

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h (290372 => 290373)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h	2022-02-23 15:54:52 UTC (rev 290372)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/SharedVideoFrame.h	2022-02-23 16:00:11 UTC (rev 290373)
@@ -88,6 +88,7 @@
 public:
     enum class UseIOSurfaceBufferPool { No, Yes };
     explicit SharedVideoFrameReader(RefPtr<RemoteVideoFrameObjectHeap>&&, UseIOSurfaceBufferPool = UseIOSurfaceBufferPool::Yes);
+    SharedVideoFrameReader();
 
     void setSemaphore(IPC::Semaphore&& semaphore) { m_semaphore = WTFMove(semaphore); }
     bool setSharedMemory(const SharedMemory::IPCHandle&);
@@ -99,7 +100,7 @@
     CVPixelBufferPoolRef pixelBufferPool(const WebCore::SharedVideoFrameInfo&);
 
     RefPtr<RemoteVideoFrameObjectHeap> m_objectHeap;
-    UseIOSurfaceBufferPool m_useIOSurfaceBufferPool;
+    UseIOSurfaceBufferPool m_useIOSurfaceBufferPool { UseIOSurfaceBufferPool::Yes };
     IPC::Semaphore m_semaphore;
     RefPtr<SharedMemory> m_storage;
 
@@ -114,17 +115,7 @@
     encoder << time;
     encoder << mirrored;
     encoder << rotation;
-
-    switchOn(buffer,
-    [&](std::nullptr_t representation) {
-        encoder << (uint8_t)0;
-    }, [&](const RemoteVideoFrameReadReference& reference) {
-        encoder << (uint8_t)1;
-        encoder << reference;
-    } , [&](const MachSendRight& sendRight) {
-        encoder << (uint8_t)2;
-        encoder << sendRight;
-    });
+    encoder << buffer;
 }
 
 template<class Decoder> std::optional<SharedVideoFrame> SharedVideoFrame::decode(Decoder& decoder)
@@ -139,25 +130,9 @@
     if (!decoder.decode(frame.rotation))
         return { };
 
-    uint8_t bufferType;
-    if (!decoder.decode(bufferType))
+    if (!decoder.decode(frame.buffer))
         return { };
 
-    if (bufferType > 2)
-        return { };
-
-    if (bufferType == 1) {
-        std::optional<RemoteVideoFrameReadReference> reference;
-        decoder >> reference;
-        if (!reference)
-            return { };
-        frame.buffer = WTFMove(*reference);
-    } else if (bufferType == 2) {
-        MachSendRight sendRight;
-        if (!decoder.decode(sendRight))
-            return { };
-        frame.buffer = WTFMove(sendRight);
-    }
     return frame;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to