Title: [215901] trunk/Source/WebCore
Revision
215901
Author
[email protected]
Date
2017-04-27 15:58:44 -0700 (Thu, 27 Apr 2017)

Log Message

LayoutTest webrtc/datachannel/datachannel-event.html is a flaky crash
https://bugs.webkit.org/show_bug.cgi?id=171092
<rdar://problem/31748066>

Patch by Youenn Fablet <[email protected]> on 2017-04-27
Reviewed by Eric Carlson.

Covered by manual testing on iterating on the crashing tests.
With the patch, they appear to no longer crash.

The current RTCPeerConnection/RTCController was expecting that peer connections would be stopped before the controller.
This assumption is sometimes wrong.
Adding clean-up on both sides so that if controller goes away, it notifies its peer connections that they are unregistered.

* Modules/mediastream/RTCController.cpp:
(WebCore::RTCController::~RTCController):
* Modules/mediastream/RTCController.h:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::create):
(WebCore::RTCPeerConnection::~RTCPeerConnection):
(WebCore::RTCPeerConnection::doStop):
(WebCore::RTCPeerConnection::registerToController):
(WebCore::RTCPeerConnection::unregisterFromController):
(WebCore::RTCPeerConnection::rtcController): Deleted.
* Modules/mediastream/RTCPeerConnection.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (215900 => 215901)


--- trunk/Source/WebCore/ChangeLog	2017-04-27 22:57:32 UTC (rev 215900)
+++ trunk/Source/WebCore/ChangeLog	2017-04-27 22:58:44 UTC (rev 215901)
@@ -1,3 +1,30 @@
+2017-04-27  Youenn Fablet  <[email protected]>
+
+        LayoutTest webrtc/datachannel/datachannel-event.html is a flaky crash
+        https://bugs.webkit.org/show_bug.cgi?id=171092
+        <rdar://problem/31748066>
+
+        Reviewed by Eric Carlson.
+
+        Covered by manual testing on iterating on the crashing tests.
+        With the patch, they appear to no longer crash.
+
+        The current RTCPeerConnection/RTCController was expecting that peer connections would be stopped before the controller.
+        This assumption is sometimes wrong.
+        Adding clean-up on both sides so that if controller goes away, it notifies its peer connections that they are unregistered.
+
+        * Modules/mediastream/RTCController.cpp:
+        (WebCore::RTCController::~RTCController):
+        * Modules/mediastream/RTCController.h:
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::create):
+        (WebCore::RTCPeerConnection::~RTCPeerConnection):
+        (WebCore::RTCPeerConnection::doStop):
+        (WebCore::RTCPeerConnection::registerToController):
+        (WebCore::RTCPeerConnection::unregisterFromController):
+        (WebCore::RTCPeerConnection::rtcController): Deleted.
+        * Modules/mediastream/RTCPeerConnection.h:
+
 2017-04-27  Said Abou-Hallawa  <[email protected]>
 
         REGRESSION(r213764): Async decoding of animated images is disabled for ImageDocument

Modified: trunk/Source/WebCore/Modules/mediastream/RTCController.cpp (215900 => 215901)


--- trunk/Source/WebCore/Modules/mediastream/RTCController.cpp	2017-04-27 22:57:32 UTC (rev 215900)
+++ trunk/Source/WebCore/Modules/mediastream/RTCController.cpp	2017-04-27 22:58:44 UTC (rev 215901)
@@ -32,6 +32,12 @@
 
 namespace WebCore {
 
+RTCController::~RTCController()
+{
+    for (RTCPeerConnection& connection : m_peerConnections)
+        connection.clearController();
+}
+
 void RTCController::remove(RTCPeerConnection& connection)
 {
     m_peerConnections.removeFirstMatching([&connection](auto item) {

Modified: trunk/Source/WebCore/Modules/mediastream/RTCController.h (215900 => 215901)


--- trunk/Source/WebCore/Modules/mediastream/RTCController.h	2017-04-27 22:57:32 UTC (rev 215900)
+++ trunk/Source/WebCore/Modules/mediastream/RTCController.h	2017-04-27 22:58:44 UTC (rev 215901)
@@ -35,6 +35,8 @@
     RTCController() = default;
 
 #if ENABLE(WEB_RTC)
+    ~RTCController();
+
     void add(RTCPeerConnection&);
     void remove(RTCPeerConnection&);
 

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (215900 => 215901)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-04-27 22:57:32 UTC (rev 215900)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-04-27 22:58:44 UTC (rev 215901)
@@ -67,7 +67,9 @@
     // Let's make it uncollectable until the pc is closed by JS or the page stops it.
     if (!peerConnection->isClosed()) {
         peerConnection->setPendingActivity(peerConnection.ptr());
-        peerConnection->registerToController();
+
+        auto* page = downcast<Document>(context).page();
+        peerConnection->registerToController(page->rtcController());
     }
     return peerConnection;
 }
@@ -82,6 +84,7 @@
 
 RTCPeerConnection::~RTCPeerConnection()
 {
+    unregisterFromController();
     stop();
 }
 
@@ -398,26 +401,19 @@
 
     m_backend->stop();
 
-    unregisterFromController();
     unsetPendingActivity(this);
 }
 
-RTCController& RTCPeerConnection::rtcController()
+void RTCPeerConnection::registerToController(RTCController& controller)
 {
-    ASSERT(scriptExecutionContext());
-    ASSERT(scriptExecutionContext()->isDocument());
-    auto* page = static_cast<Document*>(scriptExecutionContext())->page();
-    return page->rtcController();
+    m_controller = &controller;
+    m_controller->add(*this);
 }
 
-void RTCPeerConnection::registerToController()
-{
-    rtcController().add(*this);
-}
-
 void RTCPeerConnection::unregisterFromController()
 {
-    rtcController().remove(*this);
+    if (m_controller)
+        m_controller->remove(*this);
 }
 
 const char* RTCPeerConnection::activeDOMObjectName() const

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (215900 => 215901)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2017-04-27 22:57:32 UTC (rev 215900)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2017-04-27 22:58:44 UTC (rev 215901)
@@ -145,13 +145,14 @@
 
     void enqueueReplaceTrackTask(RTCRtpSender&, Ref<MediaStreamTrack>&&, DOMPromise<void>&&);
 
+    void clearController() { m_controller = nullptr; }
+
 private:
     RTCPeerConnection(ScriptExecutionContext&);
 
     Ref<RTCRtpTransceiver> completeAddTransceiver(Ref<RTCRtpSender>&&, const RTCRtpTransceiverInit&, const String& trackId, const String& trackKind);
 
-    RTCController& rtcController();
-    void registerToController();
+    void registerToController(RTCController&);
     void unregisterFromController();
 
     // EventTarget implementation.
@@ -183,6 +184,7 @@
     std::unique_ptr<PeerConnectionBackend> m_backend;
 
     RTCConfiguration m_configuration;
+    RTCController* m_controller { nullptr };
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to