⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 273513 in webkit


Ignore:
Timestamp:
Feb 25, 2021, 2:14:59 PM (6 years ago)
Author:
jer.noble@apple.com
Message:

[Cocoa] Appending a partial segment of a WebM audio file results in no additional samples
​https://bugs.webkit.org/show_bug.cgi?id=222407
<rdar://74610383>

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/media-source/media-source-webm-vorbis-partial.html

When appending a partial WebM segment, it can occur that the parser is mid-way through
parsing a Block or SimpleBlock, and is waiting for enough data to be appended to construct a
full sample. However, previous appends are not accounted for when calculated the amount of
data to be requested from the reader, which both results in too much data read and a
miscalculation of the bytesRemaining out-param. This causes all subsequent appends to
generate no samples, leading to an apparent stall in playback.

Add a new ivar to track the number of partial bytes read, and use that value to calculate
the number of bytes yet to be parsed.

  • platform/graphics/cocoa/SourceBufferParserWebM.cpp:

(WebCore::SourceBufferParserWebM::VideoTrackData::createSampleBuffer):

  • platform/graphics/cocoa/SourceBufferParserWebM.h:

LayoutTests:

  • platform/mac-bigsur/media/media-source/content/test-48kHz-vorbis-manifest.json: Added.
  • platform/mac-bigsur/media/media-source/content/test-48kHz-vorbis.webm: Added.
  • platform/mac-bigsur/media/media-source/media-source-webm-vorbis-partial-expected.txt: Added.
  • platform/mac-bigsur/media/media-source/media-source-webm-vorbis-partial.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r273512 r273513  
     12021-02-25  Jer Noble  <jer.noble@apple.com>
     2
     3        [Cocoa] Appending a partial segment of a WebM audio file results in no additional samples
     4        https://bugs.webkit.org/show_bug.cgi?id=222407
     5        <rdar://74610383>
     6
     7        Reviewed by Eric Carlson.
     8
     9        * platform/mac-bigsur/media/media-source/content/test-48kHz-vorbis-manifest.json: Added.
     10        * platform/mac-bigsur/media/media-source/content/test-48kHz-vorbis.webm: Added.
     11        * platform/mac-bigsur/media/media-source/media-source-webm-vorbis-partial-expected.txt: Added.
     12        * platform/mac-bigsur/media/media-source/media-source-webm-vorbis-partial.html: Added.
     13
    1142021-02-25  Myles C. Maxfield  <mmaxfield@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r273512 r273513  
     12021-02-25  Jer Noble  <jer.noble@apple.com>
     2
     3        [Cocoa] Appending a partial segment of a WebM audio file results in no additional samples
     4        https://bugs.webkit.org/show_bug.cgi?id=222407
     5        <rdar://74610383>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Test: media/media-source/media-source-webm-vorbis-partial.html
     10
     11        When appending a partial WebM segment, it can occur that the parser is mid-way through
     12        parsing a Block or SimpleBlock, and is waiting for enough data to be appended to construct a
     13        full sample. However, previous appends are not accounted for when calculated the amount of
     14        data to be requested from the reader, which both results in too much data read and a
     15        miscalculation of the `bytesRemaining` out-param. This causes all subsequent appends to
     16        generate no samples, leading to an apparent stall in playback.
     17
     18        Add a new ivar to track the number of partial bytes read, and use that value to calculate
     19        the number of bytes yet to be parsed.
     20
     21        * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
     22        (WebCore::SourceBufferParserWebM::VideoTrackData::createSampleBuffer):
     23        * platform/graphics/cocoa/SourceBufferParserWebM.h:
     24
    1252021-02-25  Myles C. Maxfield  <mmaxfield@apple.com>
    226
  • trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp

    r273501 r273513  
    12271227    m_packetData.resize(m_packetBytesRead + metadata.size);
    12281228    size_t packetDataOffset = m_packetBytesRead;
     1229
     1230    ASSERT(m_partialBytesRead < metadata.size);
    12291231    size_t bytesToRead = metadata.size;
     1232    if (m_partialBytesRead && m_partialBytesRead < bytesToRead)
     1233        bytesToRead -= m_partialBytesRead;
    12301234    while (bytesToRead) {
    12311235        uint64_t bytesRead;
    … …  
    12361240
    12371241        // FIXME: We can't yet handle parsing a Frame that doesn't have all its memory available.
    1238         if (status.code == webm::Status::kOkPartial || status.code == webm::Status::kWouldBlock)
     1242        if (status.code == webm::Status::kOkPartial || status.code == webm::Status::kWouldBlock) {
     1243            m_partialBytesRead += bytesRead;
    12391244            return status;
     1245        }
     1246
     1247        m_partialBytesRead = 0;
    12401248    }
    12411249
  • trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h

    r273089 r273513  
    216216        size_t m_packetBytesRead { 0 };
    217217        size_t m_byteOffset { 0 };
     218        size_t m_partialBytesRead { 0 };
    218219        Vector<AudioStreamPacketDescription> m_packetDescriptions;
    219220
Note: See TracChangeset for help on using the changeset viewer.