Diff
Modified: trunk/LayoutTests/ChangeLog (214507 => 214508)
--- trunk/LayoutTests/ChangeLog 2017-03-28 23:53:28 UTC (rev 214507)
+++ trunk/LayoutTests/ChangeLog 2017-03-29 00:06:11 UTC (rev 214508)
@@ -1,3 +1,13 @@
+2017-03-28 Youenn Fablet <you...@apple.com>
+
+ Stop RTCDataChannel when closing page
+ https://bugs.webkit.org/show_bug.cgi?id=170166
+
+ Reviewed by Eric Carlson.
+
+ * webrtc/datachannel/datachannel-gc-expected.txt: Added.
+ * webrtc/datachannel/datachannel-gc.html: Added.
+
2017-03-28 Myles C. Maxfield <mmaxfi...@apple.com>
Ranges for variation font properties are not enforced
Added: trunk/LayoutTests/webrtc/datachannel/datachannel-gc-expected.txt (0 => 214508)
--- trunk/LayoutTests/webrtc/datachannel/datachannel-gc-expected.txt (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/datachannel-gc-expected.txt 2017-03-29 00:06:11 UTC (rev 214508)
@@ -0,0 +1,3 @@
+
+PASS Losing local channel reference and closing it on the other side should still allow emitting the close event
+
Added: trunk/LayoutTests/webrtc/datachannel/datachannel-gc.html (0 => 214508)
--- trunk/LayoutTests/webrtc/datachannel/datachannel-gc.html (rev 0)
+++ trunk/LayoutTests/webrtc/datachannel/datachannel-gc.html 2017-03-29 00:06:11 UTC (rev 214508)
@@ -0,0 +1,35 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Testing basic data channel and garbage collection</title>
+ <script src=""
+ <script src=""
+ </head>
+ <body>
+ <script src =""
+ <script>
+var finishTest;
+promise_test((test) => {
+ counter = 0;
+ return new Promise((resolve, reject) => {
+ if (window.internals)
+ internals.useMockRTCPeerConnectionFactory("TwoRealPeerConnections");
+
+ createConnections((localConnection) => {
+ localConnection.createDataChannel('sendDataChannel')._onclose_ = resolve;
+ }, (remoteConnection) => {
+ remoteConnection._ondatachannel_ = (event) => {
+ var remoteChannel = event.channel;
+ remoteChannel.close();
+ };
+ });
+ if (window.GCController)
+ return GCController.collect();
+ }).then(() => {
+ closeConnections();
+ });
+}, "Losing local channel reference and closing it on the other side should still allow emitting the close event");
+ </script>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (214507 => 214508)
--- trunk/Source/WebCore/ChangeLog 2017-03-28 23:53:28 UTC (rev 214507)
+++ trunk/Source/WebCore/ChangeLog 2017-03-29 00:06:11 UTC (rev 214508)
@@ -1,3 +1,24 @@
+2017-03-28 Youenn Fablet <you...@apple.com>
+
+ Stop RTCDataChannel when closing page
+ https://bugs.webkit.org/show_bug.cgi?id=170166
+
+ Reviewed by Eric Carlson.
+
+ Test: webrtc/datachannel/datachannel-gc.html
+
+ Making RTCDataChannel an ActiveDOMObject.
+ Closing the data channel backend and freeing upon close and stop.
+
+ * Modules/mediastream/RTCDataChannel.cpp:
+ (WebCore::RTCDataChannel::create):
+ (WebCore::RTCDataChannel::RTCDataChannel):
+ (WebCore::RTCDataChannel::close):
+ (WebCore::RTCDataChannel::stop):
+ * Modules/mediastream/RTCDataChannel.h:
+ * Modules/mediastream/RTCDataChannel.idl:
+ * Modules/mediastream/RTCPeerConnection.h:
+
2017-03-28 Myles C. Maxfield <mmaxfi...@apple.com>
Ranges for variation font properties are not enforced
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp (214507 => 214508)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp 2017-03-28 23:53:28 UTC (rev 214507)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp 2017-03-29 00:06:11 UTC (rev 214508)
@@ -56,12 +56,14 @@
{
ASSERT(handler);
auto channel = adoptRef(*new RTCDataChannel(context, WTFMove(handler), WTFMove(label), WTFMove(options)));
- channel->m_handler->setClient(&channel.get());
+ channel->suspendIfNeeded();
+ channel->m_handler->setClient(channel.ptr());
+ channel->setPendingActivity(channel.ptr());
return channel;
}
RTCDataChannel::RTCDataChannel(ScriptExecutionContext& context, std::unique_ptr<RTCDataChannelHandler>&& handler, String&& label, RTCDataChannelInit&& options)
- : m_scriptExecutionContext(&context)
+ : ActiveDOMObject(&context)
, m_handler(WTFMove(handler))
, m_scheduledEventTimer(*this, &RTCDataChannel::scheduledEventTimerFired)
, m_label(WTFMove(label))
@@ -168,7 +170,13 @@
if (m_stopped)
return;
+ m_stopped = true;
+ m_readyState = ReadyStateClosed;
+
m_handler->close();
+ m_handler->setClient(nullptr);
+ m_handler = nullptr;
+ unsetPendingActivity(this);
}
void RTCDataChannel::didChangeReadyState(ReadyState newState)
@@ -234,10 +242,7 @@
void RTCDataChannel::stop()
{
- m_stopped = true;
- m_readyState = ReadyStateClosed;
- m_handler->setClient(nullptr);
- m_scriptExecutionContext = nullptr;
+ close();
}
void RTCDataChannel::scheduleDispatchEvent(Ref<Event>&& event)
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h (214507 => 214508)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h 2017-03-28 23:53:28 UTC (rev 214507)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h 2017-03-29 00:06:11 UTC (rev 214508)
@@ -26,6 +26,7 @@
#if ENABLE(WEB_RTC)
+#include "ActiveDOMObject.h"
#include "Event.h"
#include "EventTarget.h"
#include "ExceptionOr.h"
@@ -44,7 +45,7 @@
class Blob;
class RTCPeerConnectionHandler;
-class RTCDataChannel final : public RTCDataChannelHandlerClient, public EventTargetWithInlineData {
+class RTCDataChannel final : public ActiveDOMObject, public RTCDataChannelHandlerClient, public EventTargetWithInlineData {
public:
static Ref<RTCDataChannel> create(ScriptExecutionContext&, std::unique_ptr<RTCDataChannelHandler>&&, String&&, RTCDataChannelInit&&);
@@ -71,8 +72,6 @@
void close();
- void stop();
-
using RTCDataChannelHandlerClient::ref;
using RTCDataChannelHandlerClient::deref;
@@ -88,7 +87,10 @@
void refEventTarget() final { ref(); }
void derefEventTarget() final { deref(); }
- ScriptExecutionContext* m_scriptExecutionContext;
+ // ActiveDOMObject API
+ void stop() final;
+ const char* activeDOMObjectName() const final { return "RTCDataChannel"; }
+ bool canSuspendForDocumentSuspension() const final { return m_readyState == ReadyStateClosed; }
// RTCDataChannelHandlerClient API
void didChangeReadyState(ReadyState) final;
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl (214507 => 214508)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl 2017-03-28 23:53:28 UTC (rev 214507)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl 2017-03-29 00:06:11 UTC (rev 214508)
@@ -23,6 +23,7 @@
*/
[
+ ActiveDOMObject,
Conditional=WEB_RTC,
NoInterfaceObject,
] interface RTCDataChannel : EventTarget {
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (214507 => 214508)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h 2017-03-28 23:53:28 UTC (rev 214507)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h 2017-03-29 00:06:11 UTC (rev 214508)
@@ -178,8 +178,6 @@
std::unique_ptr<RtpTransceiverSet> m_transceiverSet { std::unique_ptr<RtpTransceiverSet>(new RtpTransceiverSet()) };
- Vector<RefPtr<RTCDataChannel>> m_dataChannels;
-
std::unique_ptr<PeerConnectionBackend> m_backend;
RTCConfiguration m_configuration;