Changeset 238642 in webkit


Ignore:
Timestamp:
Nov 28, 2018 2:12:32 PM (5 years ago)
Author:
youenn@apple.com
Message:

imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-transceivers.https.html is flaky on iOS simulator
https://bugs.webkit.org/show_bug.cgi?id=192037

Reviewed by Eric Carlson.

The stats report JS map should be created when resolving the stats promise with WebCore RTCStatsReport.
But resolving the promise might fail in case of a page being suspended.
In that case, no JSRTCStatsReport is created and there is no backing map.
Update the code to reflect that.
Covered by existing test.

  • Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:

(WebCore::LibWebRTCMediaEndpoint::getStats):

  • Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:

(WebCore::LibWebRTCStatsCollector::~LibWebRTCStatsCollector):
(WebCore::LibWebRTCStatsCollector::OnStatsDelivered):

  • Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r238639 r238642  
     12018-11-28  Youenn Fablet  <youenn@apple.com>
     2
     3        imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-transceivers.https.html is flaky on iOS simulator
     4        https://bugs.webkit.org/show_bug.cgi?id=192037
     5
     6        Reviewed by Eric Carlson.
     7
     8        The stats report JS map should be created when resolving the stats promise with WebCore RTCStatsReport.
     9        But resolving the promise might fail in case of a page being suspended.
     10        In that case, no JSRTCStatsReport is created and there is no backing map.
     11        Update the code to reflect that.
     12        Covered by existing test.
     13
     14        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
     15        (WebCore::LibWebRTCMediaEndpoint::getStats):
     16        * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
     17        (WebCore::LibWebRTCStatsCollector::~LibWebRTCStatsCollector):
     18        (WebCore::LibWebRTCStatsCollector::OnStatsDelivered):
     19        * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h:
     20
    1212018-11-28  Keith Rollin  <krollin@apple.com>
    222
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp

    r238601 r238642  
    286286void LibWebRTCMediaEndpoint::getStats(Ref<DeferredPromise>&& promise, WTF::Function<void(rtc::scoped_refptr<LibWebRTCStatsCollector>&&)>&& getStatsFunction)
    287287{
    288     auto collector = LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)](auto&& report) mutable {
     288    auto collector = LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)]() mutable -> RefPtr<RTCStatsReport> {
    289289        ASSERT(isMainThread());
    290         if (protectedThis->isStopped() || !report)
    291             return false;
    292 
    293         promise->resolve<IDLInterface<RTCStatsReport>>(report.releaseNonNull());
    294         return true;
     290        if (protectedThis->isStopped())
     291            return nullptr;
     292
     293        auto report = RTCStatsReport::create();
     294
     295        promise->resolve<IDLInterface<RTCStatsReport>>(report.copyRef());
     296
     297        // The promise resolution might fail in which case no backing map will be created.
     298        if (!report->backingMap())
     299            return nullptr;
     300        return WTFMove(report);
    295301    });
    296302    LibWebRTCProvider::callOnWebRTCSignalingThread([getStatsFunction = WTFMove(getStatsFunction), collector = WTFMove(collector)]() mutable {
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp

    r238171 r238642  
    4545
    4646    callOnMainThread([callback = WTFMove(m_callback)]() mutable {
    47         callback({ });
     47        callback();
    4848    });
    4949}
     
    385385{
    386386    callOnMainThread([protectedThis = rtc::scoped_refptr<LibWebRTCStatsCollector>(this), rtcReport] {
    387         auto report = RTCStatsReport::create();
    388         if (!protectedThis->m_callback(report.copyRef()))
     387        auto report = protectedThis->m_callback();
     388        if (!report)
    389389            return;
    390390
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h

    r235935 r238642  
    4343class LibWebRTCStatsCollector : public webrtc::RTCStatsCollectorCallback {
    4444public:
    45     using CollectorCallback = WTF::CompletionHandler<bool(RefPtr<RTCStatsReport>&&)>;
     45    using CollectorCallback = CompletionHandler<RefPtr<RTCStatsReport>()>;
    4646    static rtc::scoped_refptr<LibWebRTCStatsCollector> create(CollectorCallback&& callback) { return new rtc::RefCountedObject<LibWebRTCStatsCollector>(WTFMove(callback)); }
    4747
Note: See TracChangeset for help on using the changeset viewer.