Changeset 244034 in webkit


Ignore:
Timestamp:
Apr 8, 2019 1:22:11 PM (5 years ago)
Author:
youenn@apple.com
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):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r244032 r244034  
     12019-04-08  Youenn Fablet  <youenn@apple.com>
     2
     3        LibWebRTCMediaEndpoint does not need to hop to the signaling thread to gather stats
     4        https://bugs.webkit.org/show_bug.cgi?id=196697
     5        <rdar://problem/47477113>
     6
     7        Reviewed by Eric Carlson.
     8
     9        It is not thread safe to use m_backend in another thread than the main thread.
     10        It is not useful anymore to hop to the signaling thread to gather stats.
     11        No change of behavior.
     12
     13        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
     14        (WebCore::LibWebRTCMediaEndpoint::getStats):
     15        (WebCore::LibWebRTCMediaEndpoint::gatherStatsForLogging):
     16
    1172019-04-08  Antoine Quint  <graouts@apple.com>
    218
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp

    r243163 r244034  
    285285}
    286286
    287 void LibWebRTCMediaEndpoint::getStats(Ref<DeferredPromise>&& promise, WTF::Function<void(rtc::scoped_refptr<LibWebRTCStatsCollector>&&)>&& getStatsFunction)
    288 {
    289     auto collector = LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)]() mutable -> RefPtr<RTCStatsReport> {
     287rtc::scoped_refptr<LibWebRTCStatsCollector> LibWebRTCMediaEndpoint::createStatsCollector(Ref<DeferredPromise>&& promise)
     288{
     289    return LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)]() mutable -> RefPtr<RTCStatsReport> {
    290290        ASSERT(isMainThread());
    291291        if (protectedThis->isStopped())
     
    301301        return report;
    302302    });
    303     LibWebRTCProvider::callOnWebRTCSignalingThread([getStatsFunction = WTFMove(getStatsFunction), collector = WTFMove(collector)]() mutable {
    304         getStatsFunction(WTFMove(collector));
    305     });
    306303}
    307304
    308305void LibWebRTCMediaEndpoint::getStats(Ref<DeferredPromise>&& promise)
    309306{
    310     getStats(WTFMove(promise), [this](auto&& collector) {
    311         if (m_backend)
    312             m_backend->GetStats(WTFMove(collector));
    313     });
     307    if (m_backend)
     308        m_backend->GetStats(createStatsCollector(WTFMove(promise)));
    314309}
    315310
    316311void LibWebRTCMediaEndpoint::getStats(webrtc::RtpReceiverInterface& receiver, Ref<DeferredPromise>&& promise)
    317312{
    318     getStats(WTFMove(promise), [this, receiver = rtc::scoped_refptr<webrtc::RtpReceiverInterface>(&receiver)](auto&& collector) mutable {
    319         if (m_backend)
    320             m_backend->GetStats(WTFMove(receiver), WTFMove(collector));
    321     });
     313    if (m_backend)
     314        m_backend->GetStats(rtc::scoped_refptr<webrtc::RtpReceiverInterface>(&receiver), createStatsCollector(WTFMove(promise)));
    322315}
    323316
    324317void LibWebRTCMediaEndpoint::getStats(webrtc::RtpSenderInterface& sender, Ref<DeferredPromise>&& promise)
    325318{
    326     getStats(WTFMove(promise), [this, sender = rtc::scoped_refptr<webrtc::RtpSenderInterface>(&sender)](auto&& collector)  mutable {
    327         if (m_backend)
    328             m_backend->GetStats(WTFMove(sender), WTFMove(collector));
    329     });
     319    if (m_backend)
     320        m_backend->GetStats(rtc::scoped_refptr<webrtc::RtpSenderInterface>(&sender), createStatsCollector(WTFMove(promise)));
    330321}
    331322
     
    833824void LibWebRTCMediaEndpoint::gatherStatsForLogging()
    834825{
    835     LibWebRTCProvider::callOnWebRTCSignalingThread([protectedThis = makeRef(*this)] {
    836         if (protectedThis->m_backend)
    837             protectedThis->m_backend->GetStats(protectedThis.ptr());
    838     });
     826    m_backend->GetStats(this);
    839827}
    840828
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h

    r240152 r244034  
    154154    void stopLoggingStats();
    155155
    156     void getStats(Ref<DeferredPromise>&&, WTF::Function<void(rtc::scoped_refptr<LibWebRTCStatsCollector>&&)>&&);
     156    rtc::scoped_refptr<LibWebRTCStatsCollector> createStatsCollector(Ref<DeferredPromise>&&);
    157157
    158158    MediaStream& mediaStreamFromRTCStream(webrtc::MediaStreamInterface&);
Note: See TracChangeset for help on using the changeset viewer.