Changeset 178183 in webkit


Ignore:
Timestamp:
Jan 9, 2015 12:07:17 PM (9 years ago)
Author:
akling@apple.com
Message:

[Cocoa] Make decoded image data purgeable ASAP.
<https://webkit.org/b/140298>

Reviewed by Antti Koivisto.

Mark decoded images as "transient" which makes CoreGraphics mark
the backing stores as purgeable shortly after they're used.

The decoded representation will remain in CoreGraphics's caches
indefinitely unless the kernel gets starved and needs the pages.

Most resources will now reach a state where the encoded data is
mmap'ed from disk cache (once the entire resource is downloaded)
and the decoded data is purgeable.

This also has the side effect of making the MemoryCache more
palatial since the decoded data cost can be deducted for images,
allowing us to cache more resources.

Note that the worst case for this new behavior would be something
like hovering below 100% memory utilization and constantly having
to drop and re-decode images. While churny, it still beats
crashing the process, plus there's tiling to remove many of the
reasons we'd need the decoded data.

  • platform/graphics/cg/ImageSourceCG.cpp:

(WebCore::ImageSource::createFrameAtIndex):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r178182 r178183  
     12015-01-09  Andreas Kling  <akling@apple.com>
     2
     3        [Cocoa] Make decoded image data purgeable ASAP.
     4        <https://webkit.org/b/140298>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Mark decoded images as "transient" which makes CoreGraphics mark
     9        the backing stores as purgeable shortly after they're used.
     10
     11        The decoded representation will remain in CoreGraphics's caches
     12        indefinitely unless the kernel gets starved and needs the pages.
     13
     14        Most resources will now reach a state where the encoded data is
     15        mmap'ed from disk cache (once the entire resource is downloaded)
     16        and the decoded data is purgeable.
     17
     18        This also has the side effect of making the MemoryCache more
     19        palatial since the decoded data cost can be deducted for images,
     20        allowing us to cache more resources.
     21
     22        Note that the worst case for this new behavior would be something
     23        like hovering below 100% memory utilization and constantly having
     24        to drop and re-decode images. While churny, it still beats
     25        crashing the process, plus there's tiling to remove many of the
     26        reasons we'd need the decoded data.
     27
     28        * platform/graphics/cg/ImageSourceCG.cpp:
     29        (WebCore::ImageSource::createFrameAtIndex):
     30
    1312015-01-09  Gwang Yoon Hwang  <yoon@igalia.com>
    232
  • trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp

    r176140 r178183  
    348348    RetainPtr<CGImageRef> image = adoptCF(CGImageSourceCreateImageAtIndex(m_decoder, index, imageSourceOptions(subsamplingLevel).get()));
    349349
    350 #if PLATFORM(IOS)
    351     // <rdar://problem/7371198> - CoreGraphics changed the default caching behaviour in iOS 4.0 to kCGImageCachingTransient
    352     // which caused a performance regression for us since the images had to be resampled/recreated every time we called
    353     // CGContextDrawImage. We now tell CG to cache the drawn images. See also <rdar://problem/14366755> -
    354     // CoreGraphics needs to un-deprecate kCGImageCachingTemporary since it's still not the default.
    355 #if COMPILER(CLANG)
    356 #pragma clang diagnostic push
    357 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
    358 #endif
    359     CGImageSetCachingFlags(image.get(), kCGImageCachingTemporary);
    360 #if COMPILER(CLANG)
    361 #pragma clang diagnostic pop
    362 #endif
    363 #endif // PLATFORM(IOS)
     350    CGImageSetCachingFlags(image.get(), kCGImageCachingTransient);
    364351
    365352    CFStringRef imageUTI = CGImageSourceGetType(m_decoder);
     
    368355    if (!imageUTI)
    369356        return image.leakRef();
    370 
    371 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    372     if (CFEqual(imageUTI, kUTTypeGIF)) {
    373         CGImageSetCachingFlags(image.get(), kCGImageCachingTransient);
    374         return image.leakRef();
    375     }
    376 #endif
    377357
    378358    if (!CFEqual(imageUTI, xbmUTI))
Note: See TracChangeset for help on using the changeset viewer.