Changeset 222836 in webkit


Ignore:
Timestamp:
Oct 4, 2017 2:09:00 AM (7 years ago)
Author:
magomez@igalia.com
Message:

[GTK][WPE] Fix playback of GIFs
https://bugs.webkit.org/show_bug.cgi?id=176089

Reviewed by Carlos Garcia Campos.

Allow GIFImageReader to decode again already decoded frames. Thanks to this, we don't
need to delete the GIFImageReader when GIFImageDecoder::clearFrameBufferCache() is
called, and the we don't need the lock to avoid crashes in that situation.

Covered by existent tests.

  • platform/image-decoders/gif/GIFImageDecoder.cpp:

(WebCore::GIFImageDecoder::clearFrameBufferCache):
(WebCore::GIFImageDecoder::decode):

  • platform/image-decoders/gif/GIFImageDecoder.h:
  • platform/image-decoders/gif/GIFImageReader.cpp:

(GIFImageReader::decode):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r222835 r222836  
     12017-10-04  Miguel Gomez  <magomez@igalia.com>
     2
     3        [GTK][WPE] Fix playback of GIFs
     4        https://bugs.webkit.org/show_bug.cgi?id=176089
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Allow GIFImageReader to decode again already decoded frames. Thanks to this, we don't
     9        need to delete the GIFImageReader when GIFImageDecoder::clearFrameBufferCache() is
     10        called, and the we don't need the lock to avoid crashes in that situation.
     11
     12        Covered by existent tests.
     13
     14        * platform/image-decoders/gif/GIFImageDecoder.cpp:
     15        (WebCore::GIFImageDecoder::clearFrameBufferCache):
     16        (WebCore::GIFImageDecoder::decode):
     17        * platform/image-decoders/gif/GIFImageDecoder.h:
     18        * platform/image-decoders/gif/GIFImageReader.cpp:
     19        (GIFImageReader::decode):
     20
    1212017-10-04  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
    222
  • trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp

    r222196 r222836  
    126126        return; // Nothing to do.
    127127
    128     // Lock the decodelock here, as we are going to destroy the GIFImageReader and doing so while
    129     // there's an ongoing decode will cause a crash.
    130     LockHolder locker(m_decodeLock);
    131 
    132128    // The "-1" here is tricky.  It does not mean that |clearBeforeFrame| is the
    133129    // last frame we wish to preserve, but rather that we never want to clear
     
    171167            j->clear();
    172168    }
    173 
    174     // When some frames are cleared, the reader is out of sync, since the caller might ask for any frame not
    175     // necessarily in the order expected by the reader. See https://bugs.webkit.org/show_bug.cgi?id=159089.
    176     m_reader = nullptr;
    177169}
    178170
     
    303295        return;
    304296
    305     LockHolder locker(m_decodeLock);
    306297    if (!m_reader) {
    307298        m_reader = std::make_unique<GIFImageReader>(this);
  • trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.h

    r222151 r222836  
    8181    mutable RepetitionCount m_repetitionCount { RepetitionCountOnce };
    8282    std::unique_ptr<GIFImageReader> m_reader;
    83     Lock m_decodeLock;
    8483};
    8584
  • trunk/Source/WebCore/platform/image-decoders/gif/GIFImageReader.cpp

    r206481 r222836  
    364364        return true;
    365365
     366    // Already decoded frames can be deleted from the cache and then they require to be decoded again, so
     367    // the haltAtFrame value we receive here may be lower than m_currentDecodingFrame. In this case
     368    // we position m_currentDecodingFrame to haltAtFrame and decode from there.
     369    // See bug https://bugs.webkit.org/show_bug.cgi?id=176089.
     370    m_currentDecodingFrame = std::min(m_currentDecodingFrame, static_cast<size_t>(haltAtFrame));
     371
    366372    while (m_currentDecodingFrame < std::min(m_frames.size(), static_cast<size_t>(haltAtFrame))) {
    367373        bool frameDecoded = false;
Note: See TracChangeset for help on using the changeset viewer.