Changeset 197254 in webkit


Ignore:
Timestamp:
Feb 27, 2016 9:49:29 AM (8 years ago)
Author:
akling@apple.com
Message:

[iOS] Discard decoded image data on top-level navigation.
<https://webkit.org/b/154776>

Reviewed by Anders Carlsson.

Add a mechanism that destroys decoded data for all CachedImages and invoke it
when performing a top-level navigation on iOS.

This substantially reduces the ImageIO contribution to our peak memory footprint.

It would be even better if we could mark these images volatile during the transition
but we currently don't have framework support for such machinations.

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::commitProvisionalLoad):

  • loader/cache/MemoryCache.cpp:

(WebCore::MemoryCache::forEachResource):
(WebCore::MemoryCache::destroyDecodedDataForAllImages):

  • loader/cache/MemoryCache.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r197244 r197254  
     12016-02-27  Andreas Kling  <akling@apple.com>
     2
     3        [iOS] Discard decoded image data on top-level navigation.
     4        <https://webkit.org/b/154776>
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Add a mechanism that destroys decoded data for all CachedImages and invoke it
     9        when performing a top-level navigation on iOS.
     10
     11        This substantially reduces the ImageIO contribution to our peak memory footprint.
     12
     13        It would be even better if we could mark these images volatile during the transition
     14        but we currently don't have framework support for such machinations.
     15
     16        * loader/FrameLoader.cpp:
     17        (WebCore::FrameLoader::commitProvisionalLoad):
     18        * loader/cache/MemoryCache.cpp:
     19        (WebCore::MemoryCache::forEachResource):
     20        (WebCore::MemoryCache::destroyDecodedDataForAllImages):
     21        * loader/cache/MemoryCache.h:
     22
    1232016-02-26  Carlos Garcia Campos  <cgarcia@igalia.com>
    224
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r197244 r197254  
    17671767        // outweigh the cost of recompiling in the case of a future backwards navigation.
    17681768        GCController::singleton().deleteAllLinkedCode();
     1769
     1770        // Throw out decoded data for CachedImages when we are switching pages. The majority of it
     1771        // will not be used by the next page.
     1772        MemoryCache::singleton().destroyDecodedDataForAllImages();
    17691773#endif
    17701774    }
  • trunk/Source/WebCore/loader/cache/MemoryCache.cpp

    r196483 r197254  
    278278}
    279279
     280void MemoryCache::forEachResource(const std::function<void(CachedResource&)>& function)
     281{
     282    for (auto& lruList : m_allResources) {
     283        for (auto& resource : *lruList)
     284            function(*resource);
     285    }
     286}
     287
     288void MemoryCache::destroyDecodedDataForAllImages()
     289{
     290    MemoryCache::singleton().forEachResource([](CachedResource& resource) {
     291        if (resource.isImage())
     292            resource.destroyDecodedData();
     293    });
     294}
     295
    280296void MemoryCache::pruneLiveResourcesToSize(unsigned targetSize, bool shouldDestroyDecodedDataForAllLiveResources)
    281297{
  • trunk/Source/WebCore/loader/cache/MemoryCache.h

    r187706 r197254  
    102102    void revalidationSucceeded(CachedResource& revalidatingResource, const ResourceResponse&);
    103103    void revalidationFailed(CachedResource& revalidatingResource);
     104
     105    void forEachResource(const std::function<void(CachedResource&)>&);
     106    void destroyDecodedDataForAllImages();
    104107   
    105108    // Sets the cache's memory capacities, in bytes. These will hold only approximately,
Note: See TracChangeset for help on using the changeset viewer.