Changeset 215900 in webkit


Ignore:
Timestamp:
Apr 27, 2017 3:57:32 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

REGRESSION(r213764): Async decoding of animated images is disabled for ImageDocument
https://bugs.webkit.org/show_bug.cgi?id=170333

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2017-04-27
Reviewed by Simon Fraser.

Source/WebCore:

The way the image drawing settings are transfered from the Settings to
BitmapImage is problematic. The drawing settings are retrieved from the
CachedImageObserver which store them in the constructor only if the
CachedImage as a loader. In the case of ImageDocument, there isn't loader
set in CachedImage so the settings of ImageDocument are not set. Also
the CachedImage can be used after loading by another document which may
have a different drawing settings.

The fix is to make BitmapImage reads the drawing settings every time it
is drawn as a foreground or background image in a RenderElement.

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::drawImage):

  • loader/cache/CachedImage.cpp:

(WebCore::CachedImage::CachedImageObserver::CachedImageObserver):

  • loader/cache/CachedImage.h:
  • platform/graphics/BitmapImage.cpp:

(WebCore::BitmapImage::setDrawingSettings):
(WebCore::BitmapImage::draw):
(WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImages): I was
trying to disable the async image decoding temporarily but this way will
even prevent testing it until it is enabled. Disable it through WK1 and
WK2 preferences.
(WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages):
(WebCore::BitmapImage::advanceAnimation):

  • platform/graphics/BitmapImage.h:
  • platform/graphics/ImageObserver.h:
  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::paintFillLayerExtended):

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::paintIntoRect):

Source/WebKit/mac:

Disbale the async decoding for large images for now.

  • WebView/WebView.mm:

(-[WebView _preferencesChanged:]):

Source/WebKit2:

Disbale the async decoding for large images for now.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::updatePreferences):

Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r215893 r215900  
     12017-04-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        REGRESSION(r213764): Async decoding of animated images is disabled for ImageDocument
     4        https://bugs.webkit.org/show_bug.cgi?id=170333
     5
     6        Reviewed by Simon Fraser.
     7
     8        The way the image drawing settings are transfered from the Settings to
     9        BitmapImage is problematic. The drawing settings are retrieved from the
     10        CachedImageObserver which store them in the constructor only if the
     11        CachedImage as a loader. In the case of ImageDocument, there isn't loader
     12        set in CachedImage so the settings of ImageDocument are not set. Also
     13        the CachedImage can be used after loading by another document which may
     14        have a different drawing settings.
     15
     16        The fix is to make BitmapImage reads the drawing settings every time it
     17        is drawn as a foreground or background image in a RenderElement.
     18
     19        * html/canvas/CanvasRenderingContext2D.cpp:
     20        (WebCore::CanvasRenderingContext2D::drawImage):
     21        * loader/cache/CachedImage.cpp:
     22        (WebCore::CachedImage::CachedImageObserver::CachedImageObserver):
     23        * loader/cache/CachedImage.h:
     24        * platform/graphics/BitmapImage.cpp:
     25        (WebCore::BitmapImage::setDrawingSettings):
     26        (WebCore::BitmapImage::draw):
     27        (WebCore::BitmapImage::shouldUseAsyncDecodingForLargeImages): I was
     28        trying to disable the async image decoding temporarily but this way will
     29        even prevent testing it until it is enabled. Disable it through WK1 and
     30        WK2 preferences.
     31        (WebCore::BitmapImage::shouldUseAsyncDecodingForAnimatedImages):
     32        (WebCore::BitmapImage::advanceAnimation):
     33        * platform/graphics/BitmapImage.h:
     34        * platform/graphics/ImageObserver.h:
     35        * rendering/RenderBoxModelObject.cpp:
     36        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
     37        * rendering/RenderImage.cpp:
     38        (WebCore::RenderImage::paintIntoRect):
     39
    1402017-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
    241
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r215632 r215900  
    14321432    }
    14331433
     1434    if (image->isBitmapImage())
     1435        downcast<BitmapImage>(*image).updateFromSettings(imageElement.document().settings());
     1436
    14341437    if (rectContainsCanvas(normalizedDstRect)) {
    14351438        c->drawImage(*image, normalizedDstRect, normalizedSrcRect, ImagePaintingOptions(op, blendMode));
  • trunk/Source/WebCore/loader/cache/CachedImage.cpp

    r215829 r215900  
    353353    m_cachedImages.reserveInitialCapacity(1);
    354354    m_cachedImages.append(&image);
    355     if (auto* loader = image.loader()) {
    356         m_allowSubsampling = loader->frameLoader()->frame().settings().imageSubsamplingEnabled();
    357         m_allowLargeImageAsyncDecoding = loader->frameLoader()->frame().settings().largeImageAsyncDecodingEnabled();
    358         m_allowAnimatedImageAsyncDecoding = loader->frameLoader()->frame().settings().animatedImageAsyncDecodingEnabled();
    359         m_showDebugBackground = loader->frameLoader()->frame().settings().showDebugBorders();
    360     }
    361355}
    362356
  • trunk/Source/WebCore/loader/cache/CachedImage.h

    r215829 r215900  
    129129        // ImageObserver API
    130130        URL sourceUrl() const override { return m_cachedImages[0]->url(); }
    131         bool allowSubsampling() const final { return m_allowSubsampling; }
    132         bool allowLargeImageAsyncDecoding() const override { return m_allowLargeImageAsyncDecoding; }
    133         bool allowAnimatedImageAsyncDecoding() const override { return m_allowAnimatedImageAsyncDecoding; }
    134         bool showDebugBackground() const final { return m_showDebugBackground; }
    135131        void decodedSizeChanged(const Image*, long long delta) final;
    136132        void didDraw(const Image*) final;
     
    140136
    141137        Vector<CachedImage*> m_cachedImages;
    142         // The default value of m_allowSubsampling should be the same as defaultImageSubsamplingEnabled in Settings.cpp
    143 #if PLATFORM(IOS)
    144         bool m_allowSubsampling { true };
    145 #else
    146         bool m_allowSubsampling { false };
    147 #endif
    148         bool m_allowLargeImageAsyncDecoding { false };
    149         bool m_allowAnimatedImageAsyncDecoding { false };
    150         bool m_showDebugBackground { false };
    151138    };
    152139
  • trunk/Source/WebCore/platform/graphics/BitmapImage.cpp

    r215804 r215900  
    3434#include "IntRect.h"
    3535#include "Logging.h"
     36#include "Settings.h"
    3637#include "TextStream.h"
    3738#include "Timer.h"
     
    6263    invalidatePlatformData();
    6364    stopAnimation();
     65}
     66
     67void BitmapImage::updateFromSettings(const Settings& settings)
     68{
     69    m_allowSubsampling = settings.imageSubsamplingEnabled();
     70    m_allowLargeImageAsyncDecoding = settings.largeImageAsyncDecodingEnabled();
     71    m_allowAnimatedImageAsyncDecoding = settings.animatedImageAsyncDecodingEnabled();
     72    m_showDebugBackground = settings.showDebugBorders();
    6473}
    6574
     
    167176    IntSize sizeForDrawing = expandedIntSize(size() * scaleFactorForDrawing);
    168177   
    169     m_currentSubsamplingLevel = allowSubsampling() ? m_source.subsamplingLevelForScaleFactor(context, scaleFactorForDrawing) : SubsamplingLevel::Default;
     178    m_currentSubsamplingLevel = m_allowSubsampling ? m_source.subsamplingLevelForScaleFactor(context, scaleFactorForDrawing) : SubsamplingLevel::Default;
    170179    LOG(Images, "BitmapImage::%s - %p - url: %s [subsamplingLevel = %d scaleFactorForDrawing = (%.4f, %.4f)]", __FUNCTION__, this, sourceURL().string().utf8().data(), static_cast<int>(m_currentSubsamplingLevel), scaleFactorForDrawing.width(), scaleFactorForDrawing.height());
    171180
     
    181190
    182191        if (!frameHasDecodedNativeImageCompatibleWithOptionsAtIndex(m_currentFrame, m_currentSubsamplingLevel, DecodingMode::Asynchronous)) {
    183             if (showDebugBackground())
     192            if (m_showDebugBackground)
    184193                fillWithSolidColor(context, destRect, Color(Color::yellow).colorWithAlpha(0.5), op);
    185194            return;
     
    192201        ASSERT_IMPLIES(status == StartAnimationStatus::DecodingActive, frameHasFullSizeNativeImageAtIndex(m_currentFrame, m_currentSubsamplingLevel));
    193202
    194         if (status == StartAnimationStatus::DecodingActive && showDebugBackground()) {
     203        if (status == StartAnimationStatus::DecodingActive && m_showDebugBackground) {
    195204            fillWithSolidColor(context, destRect, Color(Color::yellow).colorWithAlpha(0.5), op);
    196205            return;
     
    199208        if (frameIsBeingDecodedAndIsCompatibleWithOptionsAtIndex(m_currentFrame, DecodingMode::Asynchronous)) {
    200209            // FIXME: instead of showing the yellow rectangle and returning we need to wait for this the frame to finish decoding.
    201             if (showDebugBackground()) {
     210            if (m_showDebugBackground) {
    202211                fillWithSolidColor(context, destRect, Color(Color::yellow).colorWithAlpha(0.5), op);
    203212                LOG(Images, "BitmapImage::%s - %p - url: %s [waiting for async decoding to finish]", __FUNCTION__, this, sourceURL().string().utf8().data());
     
    274283bool BitmapImage::shouldUseAsyncDecodingForLargeImages()
    275284{
    276     // FIXME: enable async image decoding after the flickering bug wk170640 is fixed.
    277     // return !canAnimate() && allowLargeImageAsyncDecoding() && m_source.shouldUseAsyncDecoding();
    278     return false;
     285    return !canAnimate() && m_allowLargeImageAsyncDecoding && m_source.shouldUseAsyncDecoding();
    279286}
    280287
    281288bool BitmapImage::shouldUseAsyncDecodingForAnimatedImages()
    282289{
    283     return canAnimate() && allowAnimatedImageAsyncDecoding() && (shouldUseAsyncDecodingForAnimatedImagesForTesting() || m_source.shouldUseAsyncDecoding());
     290    return canAnimate() && m_allowAnimatedImageAsyncDecoding && (shouldUseAsyncDecodingForAnimatedImagesForTesting() || m_source.shouldUseAsyncDecoding());
    284291}
    285292
     
    391398    else {
    392399        // Force repaint if showDebugBackground() is on.
    393         if (showDebugBackground())
     400        if (m_showDebugBackground)
    394401            imageObserver()->changedInRect(this);
    395402        LOG(Images, "BitmapImage::%s - %p - url: %s [lateFrameCount = %ld nextFrame = %ld]", __FUNCTION__, this, sourceURL().string().utf8().data(), ++m_lateFrameCount, nextFrame);
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r215710 r215900  
    5050namespace WebCore {
    5151
     52class Settings;
    5253class Timer;
    5354
     
    6667#endif
    6768    virtual ~BitmapImage();
    68    
     69
     70    void updateFromSettings(const Settings&);
     71
    6972    bool hasSingleSecurityOrigin() const override { return true; }
    7073
     
    137140    NativeImagePtr frameImageAtIndex(size_t index) { return m_source.frameImageAtIndex(index); }
    138141    NativeImagePtr frameImageAtIndexCacheIfNeeded(size_t, SubsamplingLevel = SubsamplingLevel::Default, const GraphicsContext* = nullptr);
    139 
    140     bool allowSubsampling() const { return imageObserver() && imageObserver()->allowSubsampling(); }
    141     bool allowLargeImageAsyncDecoding() const { return imageObserver() && imageObserver()->allowLargeImageAsyncDecoding(); }
    142     bool allowAnimatedImageAsyncDecoding() const { return imageObserver() && imageObserver()->allowAnimatedImageAsyncDecoding(); }
    143     bool showDebugBackground() const { return imageObserver() && imageObserver()->showDebugBackground(); }
    144142
    145143    // Called to invalidate cached data. When |destroyAll| is true, we wipe out
     
    206204    RepetitionCount m_repetitionsComplete { RepetitionCountNone }; // How many repetitions we've finished.
    207205    MonotonicTime m_desiredFrameStartTime; // The system time at which we hope to see the next call to startAnimation().
    208     bool m_animationFinished { false };
    209206
    210207    Seconds m_frameDecodingDurationForTesting;
    211208    MonotonicTime m_desiredFrameDecodeTimeForTesting;
     209
     210    bool m_animationFinished { false };
     211
     212    // The default value of m_allowSubsampling should be the same as defaultImageSubsamplingEnabled in Settings.cpp
     213#if PLATFORM(IOS)
     214    bool m_allowSubsampling { true };
     215#else
     216    bool m_allowSubsampling { false };
     217#endif
     218    bool m_allowLargeImageAsyncDecoding { false };
     219    bool m_allowAnimatedImageAsyncDecoding { false };
     220    bool m_showDebugBackground { false };
     221
    212222    bool m_clearDecoderAfterAsyncFrameRequestForTesting { false };
     223
    213224#if !LOG_DISABLED
    214225    size_t m_lateFrameCount { 0 };
  • trunk/Source/WebCore/platform/graphics/ImageObserver.h

    r213563 r215900  
    4040public:
    4141    virtual URL sourceUrl() const = 0;
    42     virtual bool allowSubsampling() const = 0;
    43     virtual bool allowLargeImageAsyncDecoding() const = 0;
    44     virtual bool allowAnimatedImageAsyncDecoding() const = 0;
    45     virtual bool showDebugBackground() const = 0;
    4642    virtual void decodedSizeChanged(const Image*, long long delta) = 0;
    4743
     
    4945
    5046    virtual void animationAdvanced(const Image*) = 0;
    51 
    5247    virtual void changedInRect(const Image*, const IntRect* changeRect = nullptr) = 0;
    5348};
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r215613 r215900  
    2727#include "RenderBoxModelObject.h"
    2828
     29#include "BitmapImage.h"
    2930#include "BorderEdge.h"
    3031#include "FloatRoundedRect.h"
     
    878879            context.setDrawLuminanceMask(bgLayer.maskSourceType() == MaskLuminance);
    879880
     881            if (is<BitmapImage>(image.get()))
     882                downcast<BitmapImage>(*image).updateFromSettings(settings());
     883
    880884            auto interpolation = chooseInterpolationQuality(context, *image, &bgLayer, geometry.tileSize());
    881885            context.drawTiledImage(*image, geometry.destRect(), toLayoutPoint(geometry.relativePhase()), geometry.tileSize(), geometry.spaceSize(), ImagePaintingOptions(compositeOp, bgLayer.blendMode(), DecodingMode::Asynchronous, ImageOrientationDescription(), interpolation));
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r214450 r215900  
    581581#endif
    582582
     583    if (is<BitmapImage>(image))
     584        downcast<BitmapImage>(*image).updateFromSettings(settings());
     585
    583586    ImageOrientationDescription orientationDescription(shouldRespectImageOrientation(), style().imageOrientation());
    584587    context.drawImage(*img, rect, ImagePaintingOptions(compositeOperator, BlendModeNormal, DecodingMode::Asynchronous, orientationDescription, interpolation));
  • trunk/Source/WebKit/mac/ChangeLog

    r215872 r215900  
     12017-04-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        REGRESSION(r213764): Async decoding of animated images is disabled for ImageDocument
     4        https://bugs.webkit.org/show_bug.cgi?id=170333
     5
     6        Reviewed by Simon Fraser.
     7
     8        Disbale the async decoding for large images for now.
     9
     10        * WebView/WebView.mm:
     11        (-[WebView _preferencesChanged:]):
     12
    1132017-04-27  Alex Christensen  <achristensen@webkit.org>
    214
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r215866 r215900  
    30853085    settings.setShouldConvertInvalidURLsToBlank(shouldConvertInvalidURLsToBlank());
    30863086
    3087     settings.setLargeImageAsyncDecodingEnabled([preferences largeImageAsyncDecodingEnabled]);
     3087    // FIXME: enable async image decoding after the flickering bug wk170640 is fixed.
     3088    // settings.setLargeImageAsyncDecodingEnabled([preferences largeImageAsyncDecodingEnabled]);
     3089    settings.setLargeImageAsyncDecodingEnabled(false);
    30883090    settings.setAnimatedImageAsyncDecodingEnabled([preferences animatedImageAsyncDecodingEnabled]);
    30893091}
  • trunk/Source/WebKit2/ChangeLog

    r215899 r215900  
     12017-04-27  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        REGRESSION(r213764): Async decoding of animated images is disabled for ImageDocument
     4        https://bugs.webkit.org/show_bug.cgi?id=170333
     5
     6        Reviewed by Simon Fraser.
     7
     8        Disbale the async decoding for large images for now.
     9
     10        * WebProcess/WebPage/WebPage.cpp:
     11        (WebKit::WebPage::updatePreferences):
     12
    1132017-04-27  Brent Fulgham  <bfulgham@apple.com>
    214
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r215872 r215900  
    33653365    setForceAlwaysUserScalable(m_forceAlwaysUserScalable || store.getBoolValueForKey(WebPreferencesKey::forceAlwaysUserScalableKey()));
    33663366#endif
    3367     settings.setLargeImageAsyncDecodingEnabled(store.getBoolValueForKey(WebPreferencesKey::largeImageAsyncDecodingEnabledKey()));
     3367    // FIXME: enable async image decoding after the flickering bug wk170640 is fixed.
     3368    // settings.setLargeImageAsyncDecodingEnabled(store.getBoolValueForKey(WebPreferencesKey::largeImageAsyncDecodingEnabledKey()));
     3369    settings.setLargeImageAsyncDecodingEnabled(false);
    33683370    settings.setAnimatedImageAsyncDecodingEnabled(store.getBoolValueForKey(WebPreferencesKey::animatedImageAsyncDecodingEnabledKey()));
    33693371    settings.setShouldSuppressKeyboardInputDuringProvisionalNavigation(store.getBoolValueForKey(WebPreferencesKey::shouldSuppressKeyboardInputDuringProvisionalNavigationKey()));
Note: See TracChangeset for help on using the changeset viewer.