- Revision
- 222045
- Author
- commit-qu...@webkit.org
- Date
- 2017-09-14 12:45:31 -0700 (Thu, 14 Sep 2017)
Log Message
RTCDataChannel connectivity issues in Safari 11
https://bugs.webkit.org/show_bug.cgi?id=173052
<rdar://problem/32712143>
Patch by Youenn Fablet <you...@apple.com> on 2017-09-14
Reviewed by Alex Christensen.
Source/WebCore:
Covered by updated test.
Before the patch, when sending an ArrayBufferView, RTCDataChannel was sending the whole ArrayBuffer backing the ArrayBufferView.
With this patch, RTCDataChannel will now send only the bytes the ArrayBufferView is exposing.
* Modules/mediastream/RTCDataChannel.cpp:
(WebCore::RTCDataChannel::send): Correctly handling sending of ArrayBufferView.
(WebCore::RTCDataChannel::sendRawData): Helper routine for raw data sending.
* Modules/mediastream/RTCDataChannel.h:
LayoutTests:
* webrtc/datachannel/binary-expected.txt:
* webrtc/datachannel/binary.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (222044 => 222045)
--- trunk/LayoutTests/ChangeLog 2017-09-14 19:40:37 UTC (rev 222044)
+++ trunk/LayoutTests/ChangeLog 2017-09-14 19:45:31 UTC (rev 222045)
@@ -1,3 +1,14 @@
+2017-09-14 Youenn Fablet <you...@apple.com>
+
+ RTCDataChannel connectivity issues in Safari 11
+ https://bugs.webkit.org/show_bug.cgi?id=173052
+ <rdar://problem/32712143>
+
+ Reviewed by Alex Christensen.
+
+ * webrtc/datachannel/binary-expected.txt:
+ * webrtc/datachannel/binary.html:
+
2017-09-14 Antti Koivisto <an...@apple.com>
Computing animated style should not require renderers
Modified: trunk/LayoutTests/webrtc/datachannel/binary-expected.txt (222044 => 222045)
--- trunk/LayoutTests/webrtc/datachannel/binary-expected.txt 2017-09-14 19:40:37 UTC (rev 222044)
+++ trunk/LayoutTests/webrtc/datachannel/binary-expected.txt 2017-09-14 19:45:31 UTC (rev 222045)
@@ -1,3 +1,11 @@
PASS Basic binary data channel exchange from offerer to receiver
+PASS test array buffer 1
+PASS test array buffer 2
+PASS test array buffer 3
+PASS test array buffer 4
+PASS test array buffer view 1
+PASS test array buffer view 2
+PASS test array buffer view 3
+PASS test array buffer view 4
Modified: trunk/LayoutTests/webrtc/datachannel/binary.html (222044 => 222045)
--- trunk/LayoutTests/webrtc/datachannel/binary.html 2017-09-14 19:40:37 UTC (rev 222044)
+++ trunk/LayoutTests/webrtc/datachannel/binary.html 2017-09-14 19:45:31 UTC (rev 222045)
@@ -26,6 +26,11 @@
return array;
}
+function createArrayBufferView(length)
+{
+ return createArrayBuffer(2 * length).subarray(length, 2 * length);
+}
+
function checkArrayBuffer(array, length)
{
if (array.byteLength !== length)
@@ -39,16 +44,51 @@
return true;
}
+function checkArrayBufferView(array, length)
+{
+ if (array.byteLength !== length)
+ return false;
+
+ var a = new Uint8Array(array);
+ for (var cptr = 0; cptr < length; cptr++) {
+ if (a[cptr] !== cptr + length + 1)
+ return false;
+ }
+ return true;
+}
+
+function testArrayBuffer(array, length)
+{
+ test(() => {
+ assert_true(checkArrayBuffer(array, length));
+ }, "test array buffer " + length);
+}
+
+function testArrayBufferView(array, length)
+{
+ test(() => {
+ assert_true(checkArrayBufferView(array, length));
+ }, "test array buffer view " + length);
+}
+
function receiveMessages(event) {
try {
if (++counter === 1)
- assert_true(checkArrayBuffer(event.data, 1));
+ testArrayBuffer(event.data, 1);
else if (counter === 2)
- assert_true(checkArrayBuffer(event.data, 2));
+ testArrayBuffer(event.data, 2);
else if (counter === 3)
- assert_true(checkArrayBuffer(event.data, 3));
- else if (counter === 4) {
- assert_true(checkArrayBuffer(event.data, 4));
+ testArrayBuffer(event.data, 3);
+ else if (counter === 4)
+ testArrayBuffer(event.data, 4);
+ else if (counter === 5)
+ testArrayBufferView(event.data, 1);
+ else if (counter === 6)
+ testArrayBufferView(event.data, 2);
+ else if (counter === 7)
+ testArrayBufferView(event.data, 3);
+ else if (counter === 8) {
+ testArrayBufferView(event.data, 4);
closeDataChannels();
finishTest();
} else
@@ -64,6 +104,10 @@
channel.send(createArrayBuffer(2));
channel.send(createArrayBuffer(3));
channel.send(createArrayBuffer(4));
+ channel.send(createArrayBufferView(1));
+ channel.send(createArrayBufferView(2));
+ channel.send(createArrayBufferView(3));
+ channel.send(createArrayBufferView(4));
}
var finishTest;
Modified: trunk/Source/WebCore/ChangeLog (222044 => 222045)
--- trunk/Source/WebCore/ChangeLog 2017-09-14 19:40:37 UTC (rev 222044)
+++ trunk/Source/WebCore/ChangeLog 2017-09-14 19:45:31 UTC (rev 222045)
@@ -1,3 +1,21 @@
+2017-09-14 Youenn Fablet <you...@apple.com>
+
+ RTCDataChannel connectivity issues in Safari 11
+ https://bugs.webkit.org/show_bug.cgi?id=173052
+ <rdar://problem/32712143>
+
+ Reviewed by Alex Christensen.
+
+ Covered by updated test.
+
+ Before the patch, when sending an ArrayBufferView, RTCDataChannel was sending the whole ArrayBuffer backing the ArrayBufferView.
+ With this patch, RTCDataChannel will now send only the bytes the ArrayBufferView is exposing.
+
+ * Modules/mediastream/RTCDataChannel.cpp:
+ (WebCore::RTCDataChannel::send): Correctly handling sending of ArrayBufferView.
+ (WebCore::RTCDataChannel::sendRawData): Helper routine for raw data sending.
+ * Modules/mediastream/RTCDataChannel.h:
+
2017-09-14 Antti Koivisto <an...@apple.com>
Computing animated style should not require renderers
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp (222044 => 222045)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp 2017-09-14 19:40:37 UTC (rev 222044)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp 2017-09-14 19:45:31 UTC (rev 222045)
@@ -105,7 +105,6 @@
ExceptionOr<void> RTCDataChannel::send(const String& data)
{
- // FIXME: We should only throw in Connected state.
if (m_readyState != RTCDataChannelState::Open)
return Exception { InvalidStateError };
@@ -117,19 +116,15 @@
return { };
}
-ExceptionOr<void> RTCDataChannel::send(ArrayBuffer& data)
+ExceptionOr<void> RTCDataChannel::sendRawData(const char* data, size_t length)
{
- // FIXME: We should only throw in Connected state.
if (m_readyState != RTCDataChannelState::Open)
return Exception { InvalidStateError };
- size_t dataLength = data.byteLength();
- if (!dataLength)
+ if (!length)
return { };
- const char* dataPointer = static_cast<const char*>(data.data());
-
- if (!m_handler->sendRawData(dataPointer, dataLength)) {
+ if (!m_handler->sendRawData(data, length)) {
// FIXME: Decide what the right exception here is.
return Exception { SyntaxError };
}
@@ -137,10 +132,15 @@
return { };
}
+
+ExceptionOr<void> RTCDataChannel::send(ArrayBuffer& data)
+{
+ return sendRawData(static_cast<const char*>(data.data()), data.byteLength());
+}
+
ExceptionOr<void> RTCDataChannel::send(ArrayBufferView& data)
{
- // FIXME: We should only throw in Connected state.
- return send(*data.unsharedBuffer());
+ return sendRawData(static_cast<const char*>(data.baseAddress()), data.byteLength());
}
ExceptionOr<void> RTCDataChannel::send(Blob&)
Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h (222044 => 222045)
--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h 2017-09-14 19:40:37 UTC (rev 222044)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h 2017-09-14 19:45:31 UTC (rev 222045)
@@ -88,6 +88,8 @@
void refEventTarget() final { ref(); }
void derefEventTarget() final { deref(); }
+ ExceptionOr<void> sendRawData(const char* data, size_t length);
+
// ActiveDOMObject API
void stop() final;
const char* activeDOMObjectName() const final { return "RTCDataChannel"; }