Title: [293852] branches/safari-613-branch/Source/WebKit

Diff

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (293851 => 293852)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-05-05 18:35:58 UTC (rev 293851)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-05-05 18:36:01 UTC (rev 293852)
@@ -2,6 +2,63 @@
 
         Apply patch. rdar://problem/88904160
 
+    2022-05-05  Kimmo Kinnunen  <[email protected]>
+
+            Multiple concurrency violations in LibWebRTCCodecsProxy
+            https://bugs.webkit.org/show_bug.cgi?id=236767
+            <rdar://88904160>
+
+            Reviewed by Antti Koivisto.
+
+            - ThreadMessageReceivers should not add IPC listeners in constructors,
+            as the delivery starts right away and uses the unconstructed virtual pointer.
+            - The work queue functions should not use GPUConnectionToWebProcess, as that is
+            main thread object.
+            - Locked m_encoders, m_decoders are sometimes accessed without lock.
+
+            Instead:
+            - Add the IPC listeners in initialize function.
+            - Remove the IPC listeners when GPUConnectionToWebProcess disconnects.
+            - Store the thread-safe conection, video frame object heap, process identity
+            objects as member variables.
+            - Do not lock m_encoders, m_decoders. If they are work queue instances,
+            just access them in the work queue functions. Add thread requirements
+            to the variables so that the compiler checks the access.
+            - Use IPC testing assertions when skipping incorrect messages.
+            - Use separate atomic counter (bool) to check if allowsExitUnderMemoryPressure.
+
+            No new tests, tested with existing tests and ASAN.
+
+            * GPUProcess/GPUConnectionToWebProcess.cpp:
+            (WebKit::GPUConnectionToWebProcess::~GPUConnectionToWebProcess):
+            (WebKit::GPUConnectionToWebProcess::didClose):
+            * GPUProcess/GPUConnectionToWebProcess.h:
+            * GPUProcess/webrtc/LibWebRTCCodecsProxy.h:
+            * GPUProcess/webrtc/LibWebRTCCodecsProxy.mm:
+            (WebKit::LibWebRTCCodecsProxy::create):
+            (WebKit::LibWebRTCCodecsProxy::LibWebRTCCodecsProxy):
+            (WebKit::LibWebRTCCodecsProxy::stopListeningForIPC):
+            (WebKit::LibWebRTCCodecsProxy::initialize):
+            (WebKit::LibWebRTCCodecsProxy::dispatchToThread):
+            (WebKit::LibWebRTCCodecsProxy::createDecoderCallback):
+            (WebKit::LibWebRTCCodecsProxy::createH264Decoder):
+            (WebKit::LibWebRTCCodecsProxy::createH265Decoder):
+            (WebKit::LibWebRTCCodecsProxy::createVP9Decoder):
+            (WebKit::LibWebRTCCodecsProxy::releaseDecoder):
+            (WebKit::LibWebRTCCodecsProxy::createEncoder):
+            (WebKit::LibWebRTCCodecsProxy::releaseEncoder):
+            (WebKit::LibWebRTCCodecsProxy::initializeEncoder):
+            (WebKit::LibWebRTCCodecsProxy::findEncoder):
+            (WebKit::LibWebRTCCodecsProxy::encodeFrame):
+            (WebKit::LibWebRTCCodecsProxy::setEncodeRates):
+            (WebKit::LibWebRTCCodecsProxy::setSharedVideoFrameSemaphore):
+            (WebKit::LibWebRTCCodecsProxy::setSharedVideoFrameMemory):
+            (WebKit::LibWebRTCCodecsProxy::allowsExitUnderMemoryPressure const):
+
+2022-05-05  Alan Coon  <[email protected]>
+
+        Apply patch. rdar://problem/88904160
+
     2022-04-22  Kimmo Kinnunen  <[email protected]>
 
             Multiple concurrency violations in LibWebRTCCodecsProxy

Modified: branches/safari-613-branch/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp (293851 => 293852)


--- branches/safari-613-branch/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp	2022-05-05 18:35:58 UTC (rev 293851)
+++ branches/safari-613-branch/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp	2022-05-05 18:36:01 UTC (rev 293852)
@@ -252,7 +252,7 @@
 
 void RemoteGraphicsContextGL::copyTextureFromMedia(WebCore::MediaPlayerIdentifier mediaPlayerIdentifier, uint32_t texture, uint32_t target, int32_t level, uint32_t internalFormat, uint32_t format, uint32_t type, bool premultiplyAlpha, bool flipY, CompletionHandler<void(bool)>&& completionHandler)
 {
-    assertIsCurrent(m_workQueue());
+    assertIsCurrent(workQueue());
 #if USE(AVFOUNDATION)
     UNUSED_VARIABLE(premultiplyAlpha);
     ASSERT_UNUSED(target, target == GraphicsContextGL::TEXTURE_2D);

Modified: branches/safari-613-branch/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h (293851 => 293852)


--- branches/safari-613-branch/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h	2022-05-05 18:35:58 UTC (rev 293851)
+++ branches/safari-613-branch/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h	2022-05-05 18:36:01 UTC (rev 293852)
@@ -31,6 +31,7 @@
 #include "DataReference.h"
 #include "RTCDecoderIdentifier.h"
 #include "RTCEncoderIdentifier.h"
+#include <WebCore/ProcessIdentity.h>
 #include <atomic>
 #include <wtf/ThreadAssertions.h>
 
@@ -63,7 +64,7 @@
 private:
     explicit LibWebRTCCodecsProxy(GPUConnectionToWebProcess&);
     void initialize();
-    auto createDecoderCallback(RTCDecoderIdentifier, bool useRemoteFrames);
+    auto createDecoderCallback(RTCDecoderIdentifier);
     WorkQueue& workQueue() const { return m_queue; }
 
     // IPC::Connection::ThreadMessageReceiver
@@ -87,8 +88,10 @@
 
     CFDictionaryRef ioSurfacePixelBufferCreationOptions(IOSurfaceRef);
 
+    Ref<IPC::Connection> m_connection;
+    Ref<WorkQueue> m_queue;
+    const WebCore::ProcessIdentity m_resourceOwner;
 
-    Ref<WorkQueue> m_queue;
     HashMap<RTCDecoderIdentifier, webrtc::LocalDecoder> m_decoders WTF_GUARDED_BY_LOCK(workQueue());
     HashMap<RTCEncoderIdentifier, webrtc::LocalEncoder> m_encoders WTF_GUARDED_BY_LOCK(workQueue());
     std::atomic<bool> m_hasEncodersOrDecoders { false };

Modified: branches/safari-613-branch/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm (293851 => 293852)


--- branches/safari-613-branch/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm	2022-05-05 18:35:58 UTC (rev 293851)
+++ branches/safari-613-branch/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm	2022-05-05 18:36:01 UTC (rev 293852)
@@ -37,6 +37,7 @@
 #import <WebCore/CVUtilities.h>
 #import <WebCore/LibWebRTCProvider.h>
 #import <WebCore/RemoteVideoSample.h>
+#import <WebCore/MediaSampleAVFObjC.h>
 #import <webrtc/sdk/WebKit/WebKitDecoder.h>
 #import <webrtc/sdk/WebKit/WebKitEncoder.h>
 #import <wtf/BlockPtr.h>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to