Title: [253146] trunk
Revision
253146
Author
[email protected]
Date
2019-12-05 04:56:19 -0800 (Thu, 05 Dec 2019)

Log Message

getStats() promise never rejects nor resolves when peer connection state is closed.
https://bugs.webkit.org/show_bug.cgi?id=204842
<rdar://problem/57617107>

Reviewed by Eric Carlson.

Source/WebCore:

Instead of closing and nulling the backend when closing the peer connection,
we only close it. This allows calling getStats to retrieve the last gathered stats from the backend.
Covered by updated test.

* Modules/mediastream/PeerConnectionBackend.h:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::close):
(WebCore::RTCPeerConnection::stop):
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::close):
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::LibWebRTCPeerConnectionBackend::close):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:

LayoutTests:

* webrtc/video-stats-expected.txt:
* webrtc/video-stats.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253145 => 253146)


--- trunk/LayoutTests/ChangeLog	2019-12-05 07:17:34 UTC (rev 253145)
+++ trunk/LayoutTests/ChangeLog	2019-12-05 12:56:19 UTC (rev 253146)
@@ -1,3 +1,14 @@
+2019-12-05  youenn fablet  <[email protected]>
+
+        getStats() promise never rejects nor resolves when peer connection state is closed.
+        https://bugs.webkit.org/show_bug.cgi?id=204842
+        <rdar://problem/57617107>
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/video-stats-expected.txt:
+        * webrtc/video-stats.html:
+
 2019-12-04  Jack Lee  <[email protected]>
 
         Nullptr crash in RenderLayoutState::pageLogicalHeight const via RenderGrid::computeIntrinsicLogicalWidths inside RenderMarquee::updateMarqueePosition

Modified: trunk/LayoutTests/webrtc/video-stats-expected.txt (253145 => 253146)


--- trunk/LayoutTests/webrtc/video-stats-expected.txt	2019-12-05 07:17:34 UTC (rev 253145)
+++ trunk/LayoutTests/webrtc/video-stats-expected.txt	2019-12-05 12:56:19 UTC (rev 253146)
@@ -3,4 +3,5 @@
 PASS Sender stats 
 PASS Receiver stats 
 PASS Check ssrc is not changing in inbound rtp stats 
+PASS Stats after pc close 
 

Modified: trunk/LayoutTests/webrtc/video-stats.html (253145 => 253146)


--- trunk/LayoutTests/webrtc/video-stats.html	2019-12-05 07:17:34 UTC (rev 253145)
+++ trunk/LayoutTests/webrtc/video-stats.html	2019-12-05 12:56:19 UTC (rev 253146)
@@ -187,6 +187,12 @@
     });
     assert_equals(instats1.ssrc, instats2.ssrc);
 }, "Check ssrc is not changing in inbound rtp stats");
+
+promise_test(async (test) => {
+    const pc = new RTCPeerConnection();
+    pc.close();
+    return pc.getStats();
+}, "Stats after pc close");
         </script>
     </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (253145 => 253146)


--- trunk/Source/WebCore/ChangeLog	2019-12-05 07:17:34 UTC (rev 253145)
+++ trunk/Source/WebCore/ChangeLog	2019-12-05 12:56:19 UTC (rev 253146)
@@ -1,3 +1,26 @@
+2019-12-05  youenn fablet  <[email protected]>
+
+        getStats() promise never rejects nor resolves when peer connection state is closed.
+        https://bugs.webkit.org/show_bug.cgi?id=204842
+        <rdar://problem/57617107>
+
+        Reviewed by Eric Carlson.
+
+        Instead of closing and nulling the backend when closing the peer connection,
+        we only close it. This allows calling getStats to retrieve the last gathered stats from the backend.
+        Covered by updated test.
+
+        * Modules/mediastream/PeerConnectionBackend.h:
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::close):
+        (WebCore::RTCPeerConnection::stop):
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::close):
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::LibWebRTCPeerConnectionBackend::close):
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+
 2019-12-04  Ryosuke Niwa  <[email protected]>
 
         Remove DocumentEventQueue and WorkerEventQueue

Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h (253145 => 253146)


--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h	2019-12-05 07:17:34 UTC (rev 253145)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h	2019-12-05 12:56:19 UTC (rev 253146)
@@ -99,6 +99,8 @@
 
     void stop();
 
+    virtual void close() = 0;
+
     virtual RefPtr<RTCSessionDescription> localDescription() const = 0;
     virtual RefPtr<RTCSessionDescription> currentLocalDescription() const = 0;
     virtual RefPtr<RTCSessionDescription> pendingLocalDescription() const = 0;

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (253145 => 253146)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2019-12-05 07:17:34 UTC (rev 253145)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2019-12-05 12:56:19 UTC (rev 253146)
@@ -455,7 +455,7 @@
 
     updateConnectionState();
     ASSERT(isClosed());
-    doStop();
+    m_backend->close();
 }
 
 void RTCPeerConnection::emulatePlatformEvent(const String& action)
@@ -465,9 +465,7 @@
 
 void RTCPeerConnection::stop()
 {
-    if (!doClose())
-        return;
-
+    doClose();
     doStop();
 }
 
@@ -477,8 +475,8 @@
         return;
 
     m_isStopped = true;
-
-    m_backend->stop();
+    if (m_backend)
+        m_backend->stop();
 }
 
 void RTCPeerConnection::registerToController(RTCController& controller)

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


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2019-12-05 07:17:34 UTC (rev 253145)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2019-12-05 12:56:19 UTC (rev 253146)
@@ -642,6 +642,12 @@
     });
 }
 
+void LibWebRTCMediaEndpoint::close()
+{
+    m_backend->Close();
+    stopLoggingStats();
+}
+
 void LibWebRTCMediaEndpoint::stop()
 {
     if (!m_backend)

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


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2019-12-05 07:17:34 UTC (rev 253145)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2019-12-05 12:56:19 UTC (rev 253146)
@@ -88,6 +88,7 @@
     std::unique_ptr<RTCDataChannelHandler> createDataChannel(const String&, const RTCDataChannelInit&);
     bool addIceCandidate(webrtc::IceCandidateInterface& candidate) { return m_backend->AddIceCandidate(&candidate); }
 
+    void close();
     void stop();
     bool isStopped() const { return !m_backend; }
 

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp (253145 => 253146)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2019-12-05 07:17:34 UTC (rev 253145)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2019-12-05 12:56:19 UTC (rev 253146)
@@ -251,6 +251,11 @@
     m_endpoint->doCreateAnswer();
 }
 
+void LibWebRTCPeerConnectionBackend::close()
+{
+    m_endpoint->close();
+}
+
 void LibWebRTCPeerConnectionBackend::doStop()
 {
     m_endpoint->stop();

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h (253145 => 253146)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h	2019-12-05 07:17:34 UTC (rev 253145)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h	2019-12-05 12:56:19 UTC (rev 253146)
@@ -58,6 +58,7 @@
     void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&);
 
 private:
+    void close() final;
     void doCreateOffer(RTCOfferOptions&&) final;
     void doCreateAnswer(RTCAnswerOptions&&) final;
     void doSetLocalDescription(RTCSessionDescription&) final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to