- Revision
- 239064
- Author
- [email protected]
- Date
- 2018-12-10 19:43:38 -0800 (Mon, 10 Dec 2018)
Log Message
DataChannels created asynchronously never open and are unusable
https://bugs.webkit.org/show_bug.cgi?id=192566
Reviewed by Eric Carlson.
Source/WebCore:
For every new data channel (remote or local), we should check the underlying backend state.
This allows firing events if needed.
We were not always doing that which was prohibiting sending some open
events for data channels created after the SCTP connection is set up.
Covered by updated test.
* Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
(WebCore::LibWebRTCDataChannelHandler::channelEvent):
(WebCore::LibWebRTCDataChannelHandler::setClient):
(WebCore::LibWebRTCDataChannelHandler::OnStateChange):
(WebCore::LibWebRTCDataChannelHandler::checkState):
* Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h:
LayoutTests:
* webrtc/datachannel/basic-expected.txt:
* webrtc/datachannel/basic.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (239063 => 239064)
--- trunk/LayoutTests/ChangeLog 2018-12-11 03:05:28 UTC (rev 239063)
+++ trunk/LayoutTests/ChangeLog 2018-12-11 03:43:38 UTC (rev 239064)
@@ -1,3 +1,13 @@
+2018-12-10 Youenn Fablet <[email protected]>
+
+ DataChannels created asynchronously never open and are unusable
+ https://bugs.webkit.org/show_bug.cgi?id=192566
+
+ Reviewed by Eric Carlson.
+
+ * webrtc/datachannel/basic-expected.txt:
+ * webrtc/datachannel/basic.html:
+
2018-12-10 Rob Buis <[email protected]>
XMLHttpRequest removes spaces from content-types before processing
Modified: trunk/LayoutTests/webrtc/datachannel/basic-expected.txt (239063 => 239064)
--- trunk/LayoutTests/webrtc/datachannel/basic-expected.txt 2018-12-11 03:05:28 UTC (rev 239063)
+++ trunk/LayoutTests/webrtc/datachannel/basic-expected.txt 2018-12-11 03:43:38 UTC (rev 239064)
@@ -3,4 +3,5 @@
PASS Basic data channel exchange from receiver to offerer
PASS Basic data channel exchange from offerer to receiver using UDP only
PASS Basic data channel exchange from offerer to receiver
+PASS Create a second channel asynchronously and send messages
Modified: trunk/LayoutTests/webrtc/datachannel/basic.html (239063 => 239064)
--- trunk/LayoutTests/webrtc/datachannel/basic.html 2018-12-11 03:05:28 UTC (rev 239063)
+++ trunk/LayoutTests/webrtc/datachannel/basic.html 2018-12-11 03:43:38 UTC (rev 239064)
@@ -126,6 +126,40 @@
});
}, "Basic data channel exchange from offerer to receiver");
+promise_test(async (test) => {
+ await new Promise((resolve, reject) => {
+ finishTest = resolve;
+ createConnections((localConnection) => {
+ localChannel = localConnection.createDataChannel('sendDataChannel');
+ }, (remoteConnection) => {
+ remoteConnection._ondatachannel_ = resolve;
+ });
+ setTimeout(() => { reject("Test step 1 timed out"); }, 5000);
+ });
+ await waitFor(50);
+ let waitForLocalChannelOpening = new Promise((resolve) => {
+ localChannel = localConnection.createDataChannel('sendDataChannel2');
+ localChannel._onopen_ = resolve;
+ });
+
+ let waitForRemoteChannel = new Promise((resolve) => {
+ remoteConnection._ondatachannel_ = (event) => {
+ remoteChannel = event.channel;
+ resolve();
+ };
+ });
+
+ await Promise.all([waitForLocalChannelOpening, waitForRemoteChannel]);
+
+ counter = 0;
+ await new Promise((resolve, reject) => {
+ finishTest = resolve;
+ remoteChannel._onmessage_ = receiveMessages;
+ sendMessages(localChannel);
+ setTimeout(() => { reject("Test step 2 timed out"); }, 5000);
+ });
+}, "Create a second channel asynchronously and send messages");
+
</script>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (239063 => 239064)
--- trunk/Source/WebCore/ChangeLog 2018-12-11 03:05:28 UTC (rev 239063)
+++ trunk/Source/WebCore/ChangeLog 2018-12-11 03:43:38 UTC (rev 239064)
@@ -1,3 +1,24 @@
+2018-12-10 Youenn Fablet <[email protected]>
+
+ DataChannels created asynchronously never open and are unusable
+ https://bugs.webkit.org/show_bug.cgi?id=192566
+
+ Reviewed by Eric Carlson.
+
+ For every new data channel (remote or local), we should check the underlying backend state.
+ This allows firing events if needed.
+ We were not always doing that which was prohibiting sending some open
+ events for data channels created after the SCTP connection is set up.
+
+ Covered by updated test.
+
+ * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
+ (WebCore::LibWebRTCDataChannelHandler::channelEvent):
+ (WebCore::LibWebRTCDataChannelHandler::setClient):
+ (WebCore::LibWebRTCDataChannelHandler::OnStateChange):
+ (WebCore::LibWebRTCDataChannelHandler::checkState):
+ * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h:
+
2018-12-10 Ryosuke Niwa <[email protected]>
Use WeakPtr to refer to VTTCue in VTTCueBox
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp (239063 => 239064)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp 2018-12-11 03:05:28 UTC (rev 239063)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp 2018-12-11 03:43:38 UTC (rev 239064)
@@ -69,19 +69,9 @@
init.negotiated = dataChannel->negotiated();
init.id = dataChannel->id();
- bool isOpened = dataChannel->state() == webrtc::DataChannelInterface::kOpen;
-
auto handler = std::make_unique<LibWebRTCDataChannelHandler>(WTFMove(dataChannel));
auto channel = RTCDataChannel::create(context, WTFMove(handler), fromStdString(label), WTFMove(init));
- if (isOpened) {
- callOnMainThread([channel = channel.copyRef()] {
- // FIXME: We should be able to write channel->didChangeReadyState(...)
- RTCDataChannelHandlerClient& client = channel.get();
- client.didChangeReadyState(RTCDataChannelState::Open);
- });
- }
-
return RTCDataChannelEvent::create(eventNames().datachannelEvent, Event::CanBubble::No, Event::IsCancelable::No, WTFMove(channel));
}
@@ -96,6 +86,7 @@
ASSERT(!m_client);
m_client = &client;
m_channel->RegisterObserver(this);
+ checkState();
}
bool LibWebRTCDataChannelHandler::sendStringData(const String& text)
@@ -122,7 +113,11 @@
{
if (!m_client)
return;
+ checkState();
+}
+void LibWebRTCDataChannelHandler::checkState()
+{
RTCDataChannelState state;
switch (m_channel->state()) {
case webrtc::DataChannelInterface::kConnecting:
Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h (239063 => 239064)
--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h 2018-12-11 03:05:28 UTC (rev 239063)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h 2018-12-11 03:43:38 UTC (rev 239064)
@@ -57,6 +57,7 @@
private:
// RTCDataChannelHandler API
void setClient(RTCDataChannelHandlerClient&) final;
+ void checkState();
bool sendStringData(const String&) final;
bool sendRawData(const char*, size_t) final;
void close() final;