Changeset 232802 in webkit


Ignore:
Timestamp:
Jun 13, 2018, 12:10:16 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

TileFirstPaint strategy for async image decoding should be disabled for non root RenderLayers
https://bugs.webkit.org/show_bug.cgi?id=186336
<rdar://problem/40808099>

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2018-06-13
Reviewed by Simon Fraser.

Source/WebCore:

When showing a composited RenderLayer for the first time, the images in
this layer have to be decoded synchronously to avoid unwanted flashing.

To create a layout test for this patch, FrameDecodingDurationForTesting
needs to be generalized for large and animated images. The decoding thread
now forces the decoding time to be at least equal to
FrameDecodingDurationForTesting.

Test: fast/images/async-image-composited-show.html

  • platform/graphics/BitmapImage.cpp:

(WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages const):
(WebCore::BitmapImage::internalStartAnimation):
(WebCore::BitmapImage::advanceAnimation):

  • platform/graphics/BitmapImage.h:
  • platform/graphics/ImageSource.cpp:

(WebCore::ImageSource::startAsyncDecodingQueue):

  • platform/graphics/ImageSource.h:

(WebCore::ImageSource::setFrameDecodingDurationForTesting):
(WebCore::ImageSource::frameDecodingDurationForTesting const):

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::paintLayerContents):

LayoutTests:

  • fast/images/async-image-composited-show-expected.html: Added.
  • fast/images/async-image-composited-show.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r232797 r232802  
     12018-06-13  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        TileFirstPaint strategy for async image decoding should be disabled for non root RenderLayers
     4        https://bugs.webkit.org/show_bug.cgi?id=186336
     5        <rdar://problem/40808099>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * fast/images/async-image-composited-show-expected.html: Added.
     10        * fast/images/async-image-composited-show.html: Added.
     11
    1122018-06-13  Carlos Alberto Lopez Perez  <clopez@igalia.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r232799 r232802  
     12018-06-13  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        TileFirstPaint strategy for async image decoding should be disabled for non root RenderLayers
     4        https://bugs.webkit.org/show_bug.cgi?id=186336
     5        <rdar://problem/40808099>
     6
     7        Reviewed by Simon Fraser.
     8
     9        When showing a composited RenderLayer for the first time, the images in
     10        this layer have to be decoded synchronously to avoid unwanted flashing.
     11
     12        To create a layout test for this patch, FrameDecodingDurationForTesting
     13        needs to be generalized for large and animated images. The decoding thread
     14        now forces the decoding time to be at least equal to
     15        FrameDecodingDurationForTesting.
     16
     17        Test: fast/images/async-image-composited-show.html
     18
     19        * platform/graphics/BitmapImage.cpp:
     20        (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages const):
     21        (WebCore::BitmapImage::internalStartAnimation):
     22        (WebCore::BitmapImage::advanceAnimation):
     23        * platform/graphics/BitmapImage.h:
     24        * platform/graphics/ImageSource.cpp:
     25        (WebCore::ImageSource::startAsyncDecodingQueue):
     26        * platform/graphics/ImageSource.h:
     27        (WebCore::ImageSource::setFrameDecodingDurationForTesting):
     28        (WebCore::ImageSource::frameDecodingDurationForTesting const):
     29        * rendering/RenderLayer.cpp:
     30        (WebCore::RenderLayer::paintLayerContents):
     31
    1322018-06-13  Wenson Hsieh  <wenson_hsieh@apple.com>
    233
  • trunk/Source/WebCore/platform/graphics/BitmapImage.cpp

    r229209 r232802  
    341341bool BitmapImage::shouldUseAsyncDecodingForAnimatedImages() const
    342342{
    343     return canAnimate() && m_allowAnimatedImageAsyncDecoding && (shouldUseAsyncDecodingForAnimatedImagesForTesting() || m_source->canUseAsyncDecoding());
     343    return canAnimate() && m_allowAnimatedImageAsyncDecoding && (shouldUseAsyncDecodingForTesting() || m_source->canUseAsyncDecoding());
    344344}
    345345
     
    450450        }
    451451
    452         m_desiredFrameDecodeTimeForTesting = time + std::max(m_frameDecodingDurationForTesting, 0_s);
    453452        if (m_clearDecoderAfterAsyncFrameRequestForTesting)
    454453            m_source->resetData(data());
     
    463462{
    464463    clearTimer();
    465 
    466     // Pretend as if decoding nextFrame has taken m_frameDecodingDurationForTesting from
    467     // the time this decoding was requested.
    468     if (shouldUseAsyncDecodingForAnimatedImagesForTesting()) {
    469         MonotonicTime time = MonotonicTime::now();
    470         // Start a timer with the remaining time from now till the m_desiredFrameDecodeTime.
    471         if (m_desiredFrameDecodeTimeForTesting > std::max(time, m_desiredFrameStartTime)) {
    472             startTimer(m_desiredFrameDecodeTimeForTesting - time);
    473             return;
    474         }
    475     }
    476464
    477465    // Don't advance to nextFrame unless its decoding has finished or was not required.
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r230334 r232802  
    103103    bool canAnimate() const;
    104104
    105     bool shouldUseAsyncDecodingForAnimatedImagesForTesting() const { return m_frameDecodingDurationForTesting > 0_s; }
    106     void setFrameDecodingDurationForTesting(Seconds duration) { m_frameDecodingDurationForTesting = duration; }
     105    bool shouldUseAsyncDecodingForTesting() const { return m_source->frameDecodingDurationForTesting() > 0_s; }
     106    void setFrameDecodingDurationForTesting(Seconds duration) { m_source->setFrameDecodingDurationForTesting(duration); }
    107107    bool canUseAsyncDecodingForLargeImages() const;
    108108    bool shouldUseAsyncDecodingForAnimatedImages() const;
     
    217217
    218218    std::unique_ptr<Vector<Function<void()>, 1>> m_decodingCallbacks;
    219     Seconds m_frameDecodingDurationForTesting;
    220     MonotonicTime m_desiredFrameDecodeTimeForTesting;
    221219
    222220    bool m_animationFinished { false };
  • trunk/Source/WebCore/platform/graphics/ImageSource.cpp

    r230334 r232802  
    326326    decodingQueue().dispatch([protectedThis = makeRef(*this), protectedDecodingQueue = makeRef(decodingQueue()), protectedFrameRequestQueue = makeRef(frameRequestQueue()), protectedDecoder = makeRef(*m_decoder), sourceURL = sourceURL().string().isolatedCopy()] {
    327327        ImageFrameRequest frameRequest;
     328        Seconds minDecodingDuration = protectedThis->frameDecodingDurationForTesting();
    328329
    329330        while (protectedFrameRequestQueue->dequeue(frameRequest)) {
    330331            TraceScope tracingScope(AsyncImageDecodeStart, AsyncImageDecodeEnd);
     332
     333            MonotonicTime startingTime;
     334            if (minDecodingDuration > 0_s)
     335                startingTime = MonotonicTime::now();
    331336
    332337            // Get the frame NativeImage on the decoding thread.
     
    338343                continue;
    339344            }
     345
     346            // Pretend as if the decoding takes minDecodingDuration.
     347            if (minDecodingDuration > 0_s)
     348                sleep(minDecodingDuration - (MonotonicTime::now() - startingTime));
    340349
    341350            // Update the cached frames on the main thread to avoid updating the MemoryCache from a different thread.
  • trunk/Source/WebCore/platform/graphics/ImageSource.h

    r230334 r232802  
    8282    bool hasAsyncDecodingQueue() const { return m_decodingQueue; }
    8383    bool isAsyncDecodingQueueIdle() const;
     84    void setFrameDecodingDurationForTesting(Seconds duration) { m_frameDecodingDurationForTesting = duration; }
     85    Seconds frameDecodingDurationForTesting() const { return m_frameDecodingDurationForTesting; }
    8486
    8587    // Image metadata which is calculated either by the ImageDecoder or directly
     
    182184    FrameCommitQueue m_frameCommitQueue;
    183185    RefPtr<WorkQueue> m_decodingQueue;
     186    Seconds m_frameDecodingDurationForTesting;
    184187
    185188    // Image metadata.
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r232246 r232802  
    43514351            paintBehavior |= PaintBehaviorSnapshotting;
    43524352       
    4353         if (paintingInfo.paintBehavior & PaintBehaviorTileFirstPaint)
     4353        if ((paintingInfo.paintBehavior & PaintBehaviorTileFirstPaint) && isRenderViewLayer())
    43544354            paintBehavior |= PaintBehaviorTileFirstPaint;
    43554355
Note: See TracChangeset for help on using the changeset viewer.