Changeset 256009 in webkit


Ignore:
Timestamp:
Feb 7, 2020 12:46:32 AM (4 years ago)
Author:
youenn@apple.com
Message:

Do not process newly gathered ICE candidates if document is suspended
https://bugs.webkit.org/show_bug.cgi?id=207326
<rdar://problem/57336453>

Reviewed by Alex Christensen.

Source/WebCore:

We should not register MDNS candidates for suspended documents.
For that reason, enqueue a task when receiving a new candidate.
If document is not suspended, it will be executed immediately.
Otherwise, we will wait until document gets unsuspended.

Add a mock endpoint that delays gathering of candidates until document is suspended.

Test: webrtc/peerconnection-new-candidate-page-cache.html

  • Modules/mediastream/PeerConnectionBackend.cpp:

(WebCore::PeerConnectionBackend::newICECandidate):

  • testing/MockLibWebRTCPeerConnection.cpp:

(WebCore::MockLibWebRTCPeerConnection::GetTransceivers const):
(WebCore::MockLibWebRTCPeerConnectionForIceCandidates::MockLibWebRTCPeerConnectionForIceCandidates):
(WebCore::MockLibWebRTCPeerConnectionForIceCandidates::gotLocalDescription):
(WebCore::MockLibWebRTCPeerConnectionForIceCandidates::sendCandidates):
(WebCore::MockLibWebRTCPeerConnectionFactory::CreatePeerConnection):

LayoutTests:

  • fast/history/resources/page-cache-helper-100ms.html: Added.
  • webrtc/peerconnection-new-candidate-page-cache-expected.txt: Added.
  • webrtc/peerconnection-new-candidate-page-cache.html: Added.
Location:
trunk
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r256001 r256009  
     12020-02-07  youenn fablet  <youenn@apple.com>
     2
     3        Do not process newly gathered ICE candidates if document is suspended
     4        https://bugs.webkit.org/show_bug.cgi?id=207326
     5        <rdar://problem/57336453>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * fast/history/resources/page-cache-helper-100ms.html: Added.
     10        * webrtc/peerconnection-new-candidate-page-cache-expected.txt: Added.
     11        * webrtc/peerconnection-new-candidate-page-cache.html: Added.
     12
    1132020-02-06  Jiewen Tan  <jiewen_tan@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r256008 r256009  
     12020-02-07  youenn fablet  <youenn@apple.com>
     2
     3        Do not process newly gathered ICE candidates if document is suspended
     4        https://bugs.webkit.org/show_bug.cgi?id=207326
     5        <rdar://problem/57336453>
     6
     7        Reviewed by Alex Christensen.
     8
     9        We should not register MDNS candidates for suspended documents.
     10        For that reason, enqueue a task when receiving a new candidate.
     11        If document is not suspended, it will be executed immediately.
     12        Otherwise, we will wait until document gets unsuspended.
     13
     14        Add a mock endpoint that delays gathering of candidates until document is suspended.
     15
     16        Test: webrtc/peerconnection-new-candidate-page-cache.html
     17
     18        * Modules/mediastream/PeerConnectionBackend.cpp:
     19        (WebCore::PeerConnectionBackend::newICECandidate):
     20        * testing/MockLibWebRTCPeerConnection.cpp:
     21        (WebCore::MockLibWebRTCPeerConnection::GetTransceivers const):
     22        (WebCore::MockLibWebRTCPeerConnectionForIceCandidates::MockLibWebRTCPeerConnectionForIceCandidates):
     23        (WebCore::MockLibWebRTCPeerConnectionForIceCandidates::gotLocalDescription):
     24        (WebCore::MockLibWebRTCPeerConnectionForIceCandidates::sendCandidates):
     25        (WebCore::MockLibWebRTCPeerConnectionFactory::CreatePeerConnection):
     26
    1272020-02-06  Myles C. Maxfield  <mmaxfield@apple.com>
    228
  • trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp

    r254007 r256009  
    438438void PeerConnectionBackend::newICECandidate(String&& sdp, String&& mid, unsigned short sdpMLineIndex, String&& serverURL)
    439439{
    440     ALWAYS_LOG(LOGIDENTIFIER, "Gathered ice candidate:", sdp);
    441     m_finishedGatheringCandidates = false;
    442 
    443     if (!m_shouldFilterICECandidates) {
    444         fireICECandidateEvent(RTCIceCandidate::create(WTFMove(sdp), WTFMove(mid), sdpMLineIndex), WTFMove(serverURL));
    445         return;
    446     }
    447     if (sdp.find(" host ", 0) != notFound) {
    448         // FIXME: We might need to clear all pending candidates when setting again local description.
    449         m_pendingICECandidates.append(PendingICECandidate { String { sdp }, WTFMove(mid), sdpMLineIndex, WTFMove(serverURL) });
    450         if (RuntimeEnabledFeatures::sharedFeatures().webRTCMDNSICECandidatesEnabled()) {
    451             auto ipAddress = extractIPAddres(sdp);
    452             // We restrict to IPv4 candidates for now.
    453             if (ipAddress.contains('.'))
    454                 registerMDNSName(ipAddress);
     440    m_peerConnection.doTask([logSiteIdentifier = LOGIDENTIFIER, this, sdp = WTFMove(sdp), mid = WTFMove(mid), sdpMLineIndex, serverURL = WTFMove(serverURL)]() mutable {
     441        UNUSED_PARAM(logSiteIdentifier);
     442        ALWAYS_LOG(logSiteIdentifier, "Gathered ice candidate:", sdp);
     443        m_finishedGatheringCandidates = false;
     444
     445        if (!m_shouldFilterICECandidates) {
     446            fireICECandidateEvent(RTCIceCandidate::create(WTFMove(sdp), WTFMove(mid), sdpMLineIndex), WTFMove(serverURL));
     447            return;
    455448        }
    456         return;
    457     }
    458     fireICECandidateEvent(RTCIceCandidate::create(filterICECandidate(WTFMove(sdp)), WTFMove(mid), sdpMLineIndex), WTFMove(serverURL));
     449        if (sdp.find(" host ", 0) != notFound) {
     450            // FIXME: We might need to clear all pending candidates when setting again local description.
     451            m_pendingICECandidates.append(PendingICECandidate { String { sdp }, WTFMove(mid), sdpMLineIndex, WTFMove(serverURL) });
     452            if (RuntimeEnabledFeatures::sharedFeatures().webRTCMDNSICECandidatesEnabled()) {
     453                auto ipAddress = extractIPAddres(sdp);
     454                // We restrict to IPv4 candidates for now.
     455                if (ipAddress.contains('.'))
     456                    registerMDNSName(ipAddress);
     457            }
     458            return;
     459        }
     460        fireICECandidateEvent(RTCIceCandidate::create(filterICECandidate(WTFMove(sdp)), WTFMove(mid), sdpMLineIndex), WTFMove(serverURL));
     461    });
    459462}
    460463
  • trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp

    r252472 r256009  
    8787class MockLibWebRTCPeerConnectionForIceCandidates : public MockLibWebRTCPeerConnection {
    8888public:
    89     explicit MockLibWebRTCPeerConnectionForIceCandidates(webrtc::PeerConnectionObserver& observer) : MockLibWebRTCPeerConnection(observer) { }
     89    explicit MockLibWebRTCPeerConnectionForIceCandidates(webrtc::PeerConnectionObserver&, unsigned delayCount = 0);
    9090    virtual ~MockLibWebRTCPeerConnectionForIceCandidates() = default;
    9191private:
    9292    void gotLocalDescription() final;
     93    void sendCandidates();
     94
     95    unsigned m_delayCount { 0 };
    9396};
    9497
     98MockLibWebRTCPeerConnectionForIceCandidates::MockLibWebRTCPeerConnectionForIceCandidates(webrtc::PeerConnectionObserver& observer, unsigned delayCount)
     99    : MockLibWebRTCPeerConnection(observer)
     100    , m_delayCount(delayCount)
     101{
     102}
     103
    95104void MockLibWebRTCPeerConnectionForIceCandidates::gotLocalDescription()
    96105{
     106    AddRef();
     107    sendCandidates();
     108}
     109
     110void MockLibWebRTCPeerConnectionForIceCandidates::sendCandidates()
     111{
     112    if (m_delayCount > 0) {
     113        m_delayCount--;
     114        callOnMainThread([this] {
     115            LibWebRTCProvider::callOnWebRTCNetworkThread([this] {
     116                sendCandidates();
     117            });
     118        });
     119        return;
     120    }
     121
    97122    // Let's gather candidates
    98123    LibWebRTCProvider::callOnWebRTCSignalingThread([this]() {
     
    100125        m_observer.OnIceCandidate(&candidate);
    101126    });
     127
    102128    LibWebRTCProvider::callOnWebRTCSignalingThread([this]() {
    103129        MockLibWebRTCIceCandidate candidate("1019216383 1 tcp 1019216384 192.168.0.100 9 typ host tcptype passive generation 0", "1");
    104130        m_observer.OnIceCandidate(&candidate);
    105131    });
     132
    106133    LibWebRTCProvider::callOnWebRTCSignalingThread([this]() {
    107134        MockLibWebRTCIceCandidate candidate("1677722111 1 tcp 1677722112 172.18.0.1 47989 typ srflx raddr 192.168.0.100 rport 47989 generation 0", "1");
    108135        m_observer.OnIceCandidate(&candidate);
    109136    });
     137
    110138    LibWebRTCProvider::callOnWebRTCSignalingThread([this]() {
    111139        m_observer.OnIceGatheringChange(webrtc::PeerConnectionInterface::kIceGatheringComplete);
    112140    });
     141
     142    Release();
    113143}
    114144
     
    190220    if (m_testCase == "ICECandidates")
    191221        return new rtc::RefCountedObject<MockLibWebRTCPeerConnectionForIceCandidates>(*dependencies.observer);
     222
     223    if (m_testCase == "ICECandidatesWithDelay")
     224        return new rtc::RefCountedObject<MockLibWebRTCPeerConnectionForIceCandidates>(*dependencies.observer, 1000);
    192225
    193226    if (m_testCase == "ICEConnectionState")
Note: See TracChangeset for help on using the changeset viewer.