Changeset 222045 in webkit


Ignore:
Timestamp:
Sep 14, 2017 12:45:31 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

RTCDataChannel connectivity issues in Safari 11
https://bugs.webkit.org/show_bug.cgi?id=173052
<rdar://problem/32712143>

Patch by Youenn Fablet <youenn@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:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r222040 r222045  
     12017-09-14  Youenn Fablet  <youenn@apple.com>
     2
     3        RTCDataChannel connectivity issues in Safari 11
     4        https://bugs.webkit.org/show_bug.cgi?id=173052
     5        <rdar://problem/32712143>
     6
     7        Reviewed by Alex Christensen.
     8
     9        * webrtc/datachannel/binary-expected.txt:
     10        * webrtc/datachannel/binary.html:
     11
    1122017-09-14  Antti Koivisto  <antti@apple.com>
    213
  • trunk/LayoutTests/webrtc/datachannel/binary-expected.txt

    r218774 r222045  
    11
    22PASS Basic binary data channel exchange from offerer to receiver
     3PASS test array buffer 1
     4PASS test array buffer 2
     5PASS test array buffer 3
     6PASS test array buffer 4
     7PASS test array buffer view 1
     8PASS test array buffer view 2
     9PASS test array buffer view 3
     10PASS test array buffer view 4
    311
  • trunk/LayoutTests/webrtc/datachannel/binary.html

    r218774 r222045  
    2727}
    2828
     29function createArrayBufferView(length)
     30{
     31    return createArrayBuffer(2 * length).subarray(length, 2 * length);
     32}
     33
    2934function checkArrayBuffer(array, length)
    3035{
     
    4045}
    4146
     47function checkArrayBufferView(array, length)
     48{
     49    if (array.byteLength !== length)
     50        return false;
     51
     52    var a = new Uint8Array(array);
     53    for (var cptr = 0; cptr < length; cptr++) {
     54        if (a[cptr] !== cptr + length + 1)
     55             return false;
     56    }
     57    return true;
     58}
     59
     60function testArrayBuffer(array, length)
     61{
     62    test(() => {
     63        assert_true(checkArrayBuffer(array, length));
     64    }, "test array buffer " + length);
     65}
     66
     67function testArrayBufferView(array, length)
     68{
     69    test(() => {
     70        assert_true(checkArrayBufferView(array, length));
     71    }, "test array buffer view " + length);
     72}
     73
    4274function receiveMessages(event) {
    4375    try {
    4476        if (++counter === 1)
    45             assert_true(checkArrayBuffer(event.data, 1));
     77            testArrayBuffer(event.data, 1);
    4678        else if (counter === 2)
    47             assert_true(checkArrayBuffer(event.data, 2));
     79            testArrayBuffer(event.data, 2);
    4880        else if (counter === 3)
    49             assert_true(checkArrayBuffer(event.data, 3));
    50         else if (counter === 4) {
    51             assert_true(checkArrayBuffer(event.data, 4));
     81            testArrayBuffer(event.data, 3);
     82        else if (counter === 4)
     83            testArrayBuffer(event.data, 4);
     84        else if (counter === 5)
     85            testArrayBufferView(event.data, 1);
     86        else if (counter === 6)
     87            testArrayBufferView(event.data, 2);
     88        else if (counter === 7)
     89            testArrayBufferView(event.data, 3);
     90        else if (counter === 8) {
     91            testArrayBufferView(event.data, 4);
    5292            closeDataChannels();
    5393            finishTest();
     
    65105    channel.send(createArrayBuffer(3));
    66106    channel.send(createArrayBuffer(4));
     107    channel.send(createArrayBufferView(1));
     108    channel.send(createArrayBufferView(2));
     109    channel.send(createArrayBufferView(3));
     110    channel.send(createArrayBufferView(4));
    67111}
    68112
  • trunk/Source/WebCore/ChangeLog

    r222040 r222045  
     12017-09-14  Youenn Fablet  <youenn@apple.com>
     2
     3        RTCDataChannel connectivity issues in Safari 11
     4        https://bugs.webkit.org/show_bug.cgi?id=173052
     5        <rdar://problem/32712143>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Covered by updated test.
     10
     11        Before the patch, when sending an ArrayBufferView, RTCDataChannel was sending the whole ArrayBuffer backing the ArrayBufferView.
     12        With this patch, RTCDataChannel will now send only the bytes the ArrayBufferView is exposing.
     13
     14        * Modules/mediastream/RTCDataChannel.cpp:
     15        (WebCore::RTCDataChannel::send): Correctly handling sending of ArrayBufferView.
     16        (WebCore::RTCDataChannel::sendRawData): Helper routine for raw data sending.
     17        * Modules/mediastream/RTCDataChannel.h:
     18
    1192017-09-14  Antti Koivisto  <antti@apple.com>
    220
  • trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.cpp

    r219856 r222045  
    106106ExceptionOr<void> RTCDataChannel::send(const String& data)
    107107{
    108     // FIXME: We should only throw in Connected state.
    109108    if (m_readyState != RTCDataChannelState::Open)
    110109        return Exception { InvalidStateError };
     
    118117}
    119118
    120 ExceptionOr<void> RTCDataChannel::send(ArrayBuffer& data)
    121 {
    122     // FIXME: We should only throw in Connected state.
     119ExceptionOr<void> RTCDataChannel::sendRawData(const char* data, size_t length)
     120{
    123121    if (m_readyState != RTCDataChannelState::Open)
    124122        return Exception { InvalidStateError };
    125123
    126     size_t dataLength = data.byteLength();
    127     if (!dataLength)
     124    if (!length)
    128125        return { };
    129126
    130     const char* dataPointer = static_cast<const char*>(data.data());
    131 
    132     if (!m_handler->sendRawData(dataPointer, dataLength)) {
     127    if (!m_handler->sendRawData(data, length)) {
    133128        // FIXME: Decide what the right exception here is.
    134129        return Exception { SyntaxError };
     
    138133}
    139134
     135
     136ExceptionOr<void> RTCDataChannel::send(ArrayBuffer& data)
     137{
     138    return sendRawData(static_cast<const char*>(data.data()), data.byteLength());
     139}
     140
    140141ExceptionOr<void> RTCDataChannel::send(ArrayBufferView& data)
    141142{
    142     // FIXME: We should only throw in Connected state.
    143     return send(*data.unsharedBuffer());
     143    return sendRawData(static_cast<const char*>(data.baseAddress()), data.byteLength());
    144144}
    145145
  • trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h

    r214627 r222045  
    8989    void derefEventTarget() final { deref(); }
    9090
     91    ExceptionOr<void> sendRawData(const char* data, size_t length);
     92
    9193    // ActiveDOMObject API
    9294    void stop() final;
Note: See TracChangeset for help on using the changeset viewer.