Title: [244034] trunk/Source/WebCore
Revision
244034
Author
[email protected]
Date
2019-04-08 13:22:11 -0700 (Mon, 08 Apr 2019)

Log Message

LibWebRTCMediaEndpoint does not need to hop to the signaling thread to gather stats
https://bugs.webkit.org/show_bug.cgi?id=196697
<rdar://problem/47477113>

Reviewed by Eric Carlson.

It is not thread safe to use m_backend in another thread than the main thread.
It is not useful anymore to hop to the signaling thread to gather stats.
No change of behavior.

* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::getStats):
(WebCore::LibWebRTCMediaEndpoint::gatherStatsForLogging):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (244033 => 244034)


--- trunk/Source/WebCore/ChangeLog	2019-04-08 19:31:45 UTC (rev 244033)
+++ trunk/Source/WebCore/ChangeLog	2019-04-08 20:22:11 UTC (rev 244034)
@@ -1,3 +1,19 @@
+2019-04-08  Youenn Fablet  <[email protected]>
+
+        LibWebRTCMediaEndpoint does not need to hop to the signaling thread to gather stats
+        https://bugs.webkit.org/show_bug.cgi?id=196697
+        <rdar://problem/47477113>
+
+        Reviewed by Eric Carlson.
+
+        It is not thread safe to use m_backend in another thread than the main thread.
+        It is not useful anymore to hop to the signaling thread to gather stats.
+        No change of behavior.
+
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::getStats):
+        (WebCore::LibWebRTCMediaEndpoint::gatherStatsForLogging):
+
 2019-04-08  Antoine Quint  <[email protected]>
 
         [ Mac WK2 iOS Debug ] REGRESSION(r233667) Layout Test imported/w3c/web-platform-tests/web-animations/interfaces/DocumentTimeline/constructor.html is a flaky failure

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (244033 => 244034)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2019-04-08 19:31:45 UTC (rev 244033)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2019-04-08 20:22:11 UTC (rev 244034)
@@ -284,9 +284,9 @@
     m_backend->CreateAnswer(&m_createSessionDescriptionObserver, { });
 }
 
-void LibWebRTCMediaEndpoint::getStats(Ref<DeferredPromise>&& promise, WTF::Function<void(rtc::scoped_refptr<LibWebRTCStatsCollector>&&)>&& getStatsFunction)
+rtc::scoped_refptr<LibWebRTCStatsCollector> LibWebRTCMediaEndpoint::createStatsCollector(Ref<DeferredPromise>&& promise)
 {
-    auto collector = LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)]() mutable -> RefPtr<RTCStatsReport> {
+    return LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)]() mutable -> RefPtr<RTCStatsReport> {
         ASSERT(isMainThread());
         if (protectedThis->isStopped())
             return nullptr;
@@ -300,33 +300,24 @@
             return nullptr;
         return report;
     });
-    LibWebRTCProvider::callOnWebRTCSignalingThread([getStatsFunction = WTFMove(getStatsFunction), collector = WTFMove(collector)]() mutable {
-        getStatsFunction(WTFMove(collector));
-    });
 }
 
 void LibWebRTCMediaEndpoint::getStats(Ref<DeferredPromise>&& promise)
 {
-    getStats(WTFMove(promise), [this](auto&& collector) {
-        if (m_backend)
-            m_backend->GetStats(WTFMove(collector));
-    });
+    if (m_backend)
+        m_backend->GetStats(createStatsCollector(WTFMove(promise)));
 }
 
 void LibWebRTCMediaEndpoint::getStats(webrtc::RtpReceiverInterface& receiver, Ref<DeferredPromise>&& promise)
 {
-    getStats(WTFMove(promise), [this, receiver = rtc::scoped_refptr<webrtc::RtpReceiverInterface>(&receiver)](auto&& collector) mutable {
-        if (m_backend)
-            m_backend->GetStats(WTFMove(receiver), WTFMove(collector));
-    });
+    if (m_backend)
+        m_backend->GetStats(rtc::scoped_refptr<webrtc::RtpReceiverInterface>(&receiver), createStatsCollector(WTFMove(promise)));
 }
 
 void LibWebRTCMediaEndpoint::getStats(webrtc::RtpSenderInterface& sender, Ref<DeferredPromise>&& promise)
 {
-    getStats(WTFMove(promise), [this, sender = rtc::scoped_refptr<webrtc::RtpSenderInterface>(&sender)](auto&& collector)  mutable {
-        if (m_backend)
-            m_backend->GetStats(WTFMove(sender), WTFMove(collector));
-    });
+    if (m_backend)
+        m_backend->GetStats(rtc::scoped_refptr<webrtc::RtpSenderInterface>(&sender), createStatsCollector(WTFMove(promise)));
 }
 
 static RTCSignalingState signalingState(webrtc::PeerConnectionInterface::SignalingState state)
@@ -832,10 +823,7 @@
 
 void LibWebRTCMediaEndpoint::gatherStatsForLogging()
 {
-    LibWebRTCProvider::callOnWebRTCSignalingThread([protectedThis = makeRef(*this)] {
-        if (protectedThis->m_backend)
-            protectedThis->m_backend->GetStats(protectedThis.ptr());
-    });
+    m_backend->GetStats(this);
 }
 
 class RTCStatsLogger {

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h (244033 => 244034)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2019-04-08 19:31:45 UTC (rev 244033)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2019-04-08 20:22:11 UTC (rev 244034)
@@ -153,7 +153,7 @@
     void startLoggingStats();
     void stopLoggingStats();
 
-    void getStats(Ref<DeferredPromise>&&, WTF::Function<void(rtc::scoped_refptr<LibWebRTCStatsCollector>&&)>&&);
+    rtc::scoped_refptr<LibWebRTCStatsCollector> createStatsCollector(Ref<DeferredPromise>&&);
 
     MediaStream& mediaStreamFromRTCStream(webrtc::MediaStreamInterface&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to