Changeset 234497 in webkit


Ignore:
Timestamp:
Aug 2, 2018 2:23:42 AM (6 years ago)
Author:
cturner@igalia.com
Message:

[GStreamer] Stop pushing buffers when seeking status changes
https://bugs.webkit.org/show_bug.cgi?id=188193

Reviewed by Xabier Rodriguez-Calvar.

After switching to splitting buffers into smaller block sizes in

https://bugs.webkit.org/show_bug.cgi?id=182829

It was found that during the individual buffer pushes, the seeking
status could change behind our backs from another thread. When
this happens, buffers from incorrect offsets would find their way
into appsrc and eventually the demuxer itself, which would start
parsing from a random place and at best give a confusing error
message.

The solution here is break from pushing buffers when the seeking
status has been has changed. Flushes will clear out what we've
already delivered into the appsrc, then we must make sure to not
continue sending buffers in there after the flush.

No new tests since this is a timing bug.

  • platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:

(CachedResourceStreamingClient::dataReceived):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r234493 r234497  
     12018-08-02  Charlie Turner  <cturner@igalia.com>
     2
     3        [GStreamer] Stop pushing buffers when seeking status changes
     4        https://bugs.webkit.org/show_bug.cgi?id=188193
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        After switching to splitting buffers into smaller block sizes in
     9
     10            https://bugs.webkit.org/show_bug.cgi?id=182829
     11
     12        It was found that during the individual buffer pushes, the seeking
     13        status could change behind our backs from another thread. When
     14        this happens, buffers from incorrect offsets would find their way
     15        into appsrc and eventually the demuxer itself, which would start
     16        parsing from a random place and at best give a confusing error
     17        message.
     18
     19        The solution here is break from pushing buffers when the seeking
     20        status has been has changed. Flushes will clear out what we've
     21        already delivered into the appsrc, then we must make sure to not
     22        continue sending buffers in there after the flush.
     23
     24        No new tests since this is a timing bug.
     25
     26        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
     27        (CachedResourceStreamingClient::dataReceived):
     28
    1292018-08-01  Yusuke Suzuki  <utatane.tea@gmail.com>
    230
  • trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp

    r230625 r234497  
    898898    // to push buffers that are too large, otherwise incorrect buffering messages can be sent from the
    899899    // pipeline.
    900     uint64_t bufferSize = gst_buffer_get_size(priv->buffer.get());
    901     uint64_t blockSize = static_cast<uint64_t>(GST_BASE_SRC_CAST(priv->appsrc)->blocksize);
    902     ASSERT(blockSize);
     900    uint64_t bufferSize = static_cast<uint64_t>(length);
     901    // FIXME: Implement adaptive block resizing
     902    uint64_t blockSize = static_cast<uint64_t>(gst_base_src_get_blocksize(GST_BASE_SRC_CAST(priv->appsrc)));
    903903    GST_LOG_OBJECT(src, "Splitting the received buffer into %" PRIu64 " blocks", bufferSize / blockSize);
    904904    for (uint64_t currentOffset = 0; currentOffset < bufferSize; currentOffset += blockSize) {
     
    906906        uint64_t currentOffsetSize = std::min(blockSize, bufferSize - currentOffset);
    907907
    908         GST_TRACE_OBJECT(src, "Create sub-buffer from [%" PRIu64 ", %" PRIu64 "]", currentOffset, currentOffset + currentOffsetSize);
    909908        GstBuffer* subBuffer = gst_buffer_copy_region(priv->buffer.get(), GST_BUFFER_COPY_ALL, currentOffset, currentOffsetSize);
    910909        if (UNLIKELY(!subBuffer)) {
     
    913912        }
    914913
     914        GST_TRACE_OBJECT(src, "Sub-buffer bounds: %" PRIu64 " -- %" PRIu64, subBufferOffset, subBufferOffset + currentOffsetSize);
    915915        GST_BUFFER_OFFSET(subBuffer) = subBufferOffset;
    916916        GST_BUFFER_OFFSET_END(subBuffer) = subBufferOffset + currentOffsetSize;
    917         GST_TRACE_OBJECT(src, "Set sub-buffer offset bounds [%" PRIu64 ", %" PRIu64 "]", GST_BUFFER_OFFSET(subBuffer), GST_BUFFER_OFFSET_END(subBuffer));
    918 
    919         GST_TRACE_OBJECT(src, "Pushing buffer of size %" G_GSIZE_FORMAT " bytes", gst_buffer_get_size(subBuffer));
     917
     918        if (priv->isSeeking) {
     919            GST_TRACE_OBJECT(src, "Stopping buffer appends due to seek");
     920            // A seek has happened in the middle of us breaking the
     921            // incoming data up from a previous request. Stop pushing
     922            // buffers that are now from the incorrect offset.
     923            break;
     924        }
     925
     926        // It may be tempting to use a GstBufferList here, but note
     927        // that there is a race condition in GstDownloadBuffer during
     928        // seek flushes that can cause decoders to read at incorrect
     929        // offsets.
    920930        GstFlowReturn ret = gst_app_src_push_buffer(priv->appsrc, subBuffer);
    921931
Note: See TracChangeset for help on using the changeset viewer.