Title: [196483] trunk/Source/WebCore
Revision
196483
Author
[email protected]
Date
2016-02-12 10:34:57 -0800 (Fri, 12 Feb 2016)

Log Message

[Mac] BitmapImage::decodedDataIsPurgeable() is telling lies and causing massive memory usage.
<https://webkit.org/b/154172>

Reviewed by Antti Koivisto.

The underlying mechanism in CoreAnimation that made this work is no longer in place.

Instead of keeping purgeable frames and juggling volatility bits, we were simply caching
every single frame of large GIF animations, sometimes leading to monstrous memory usage.

Remove the code from WebCore since it's not doing at all what it means to.

Now iOS and Mac will behave the same again, and frame caching decisions will be
made by WebKit, based on total pixel byte size.

* loader/cache/CachedImage.h:
* loader/cache/CachedResource.h:
(WebCore::CachedResource::decodedDataIsPurgeable): Deleted.
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::pruneLiveResourcesToSize): Deleted.
* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::decodedDataIsPurgeable): Deleted.
(WebCore::BitmapImage::destroyDecodedDataIfNecessary): Deleted.
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
(WebCore::Image::decodedDataIsPurgeable): Deleted.
* platform/graphics/cg/BitmapImageCG.cpp:
(WebCore::BitmapImage::decodedDataIsPurgeable): Deleted.
* platform/graphics/cg/ImageSourceCG.cpp:
(WebCore::ImageSource::createFrameAtIndex): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (196482 => 196483)


--- trunk/Source/WebCore/ChangeLog	2016-02-12 18:30:43 UTC (rev 196482)
+++ trunk/Source/WebCore/ChangeLog	2016-02-12 18:34:57 UTC (rev 196483)
@@ -1,3 +1,36 @@
+2016-02-12  Andreas Kling  <[email protected]>
+
+        [Mac] BitmapImage::decodedDataIsPurgeable() is telling lies and causing massive memory usage.
+        <https://webkit.org/b/154172>
+
+        Reviewed by Antti Koivisto.
+
+        The underlying mechanism in CoreAnimation that made this work is no longer in place.
+
+        Instead of keeping purgeable frames and juggling volatility bits, we were simply caching
+        every single frame of large GIF animations, sometimes leading to monstrous memory usage.
+
+        Remove the code from WebCore since it's not doing at all what it means to.
+
+        Now iOS and Mac will behave the same again, and frame caching decisions will be
+        made by WebKit, based on total pixel byte size.
+
+        * loader/cache/CachedImage.h:
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::decodedDataIsPurgeable): Deleted.
+        * loader/cache/MemoryCache.cpp:
+        (WebCore::MemoryCache::pruneLiveResourcesToSize): Deleted.
+        * platform/graphics/BitmapImage.cpp:
+        (WebCore::BitmapImage::decodedDataIsPurgeable): Deleted.
+        (WebCore::BitmapImage::destroyDecodedDataIfNecessary): Deleted.
+        * platform/graphics/BitmapImage.h:
+        * platform/graphics/Image.h:
+        (WebCore::Image::decodedDataIsPurgeable): Deleted.
+        * platform/graphics/cg/BitmapImageCG.cpp:
+        (WebCore::BitmapImage::decodedDataIsPurgeable): Deleted.
+        * platform/graphics/cg/ImageSourceCG.cpp:
+        (WebCore::ImageSource::createFrameAtIndex): Deleted.
+
 2016-02-12  Brady Eidson  <[email protected]>
 
         Modern IDB: Ref cycle between IDBObjectStore and IDBIndex.

Modified: trunk/Source/WebCore/loader/cache/CachedImage.h (196482 => 196483)


--- trunk/Source/WebCore/loader/cache/CachedImage.h	2016-02-12 18:30:43 UTC (rev 196482)
+++ trunk/Source/WebCore/loader/cache/CachedImage.h	2016-02-12 18:34:57 UTC (rev 196483)
@@ -116,8 +116,6 @@
 
     virtual bool stillNeedsLoad() const override { return !errorOccurred() && status() == Unknown && !isLoading(); }
 
-    virtual bool decodedDataIsPurgeable() const override { return m_image && m_image->decodedDataIsPurgeable(); }
-
     // ImageObserver
     virtual void decodedSizeChanged(const Image*, int delta) override;
     virtual void didDraw(const Image*) override;

Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (196482 => 196483)


--- trunk/Source/WebCore/loader/cache/CachedResource.h	2016-02-12 18:30:43 UTC (rev 196482)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h	2016-02-12 18:34:57 UTC (rev 196483)
@@ -147,8 +147,6 @@
     unsigned encodedSize() const { return m_encodedSize; }
     unsigned decodedSize() const { return m_decodedSize; }
     unsigned overheadSize() const;
-
-    virtual bool decodedDataIsPurgeable() const { return false; }
     
     bool isLoaded() const { return !m_loading; } // FIXME. Method name is inaccurate. Loading might not have started yet.
 

Modified: trunk/Source/WebCore/loader/cache/MemoryCache.cpp (196482 => 196483)


--- trunk/Source/WebCore/loader/cache/MemoryCache.cpp	2016-02-12 18:30:43 UTC (rev 196482)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.cpp	2016-02-12 18:34:57 UTC (rev 196483)
@@ -314,9 +314,6 @@
             if (!shouldDestroyDecodedDataForAllLiveResources && elapsedTime < cMinDelayBeforeLiveDecodedPrune)
                 return;
 
-            if (current->decodedDataIsPurgeable())
-                continue;
-
             // Destroy our decoded data. This will remove us from m_liveDecodedResources, and possibly move us
             // to a different LRU list in m_allResources.
             current->destroyDecodedData();

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.cpp (196482 => 196483)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2016-02-12 18:30:43 UTC (rev 196482)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.cpp	2016-02-12 18:34:57 UTC (rev 196483)
@@ -96,13 +96,6 @@
     m_frameTimer->startOneShot(delay);
 }
 
-#if !USE(CG)
-bool BitmapImage::decodedDataIsPurgeable() const
-{
-    return false;
-}
-#endif
-
 bool BitmapImage::haveFrameAtIndex(size_t index)
 {
     if (index >= frameCount())
@@ -150,11 +143,6 @@
     const unsigned largeAnimationCutoff = 5242880;
 #endif
 
-    // If decoded data is purgeable, the operating system will
-    // take care of throwing it away when the system is under pressure.
-    if (decodedDataIsPurgeable())
-        return;
-
     // If we have decoded frames but there is no encoded data, we shouldn't destroy
     // the decoded image since we won't be able to reconstruct it later.
     if (!data() && m_frames.size())

Modified: trunk/Source/WebCore/platform/graphics/BitmapImage.h (196482 => 196483)


--- trunk/Source/WebCore/platform/graphics/BitmapImage.h	2016-02-12 18:30:43 UTC (rev 196482)
+++ trunk/Source/WebCore/platform/graphics/BitmapImage.h	2016-02-12 18:34:57 UTC (rev 196483)
@@ -288,7 +288,6 @@
 #endif
 
 private:
-    virtual bool decodedDataIsPurgeable() const override;
     void clearTimer();
     void startTimer(double delay);
 

Modified: trunk/Source/WebCore/platform/graphics/Image.h (196482 => 196483)


--- trunk/Source/WebCore/platform/graphics/Image.h	2016-02-12 18:30:43 UTC (rev 196482)
+++ trunk/Source/WebCore/platform/graphics/Image.h	2016-02-12 18:34:57 UTC (rev 196483)
@@ -119,7 +119,6 @@
     virtual String filenameExtension() const { return String(); } // null string if unknown
 
     virtual void destroyDecodedData(bool destroyAll = true) = 0;
-    virtual bool decodedDataIsPurgeable() const { return false; }
 
     SharedBuffer* data() { return m_encodedImageData.get(); }
 

Modified: trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp (196482 => 196483)


--- trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp	2016-02-12 18:30:43 UTC (rev 196482)
+++ trunk/Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp	2016-02-12 18:34:57 UTC (rev 196483)
@@ -265,13 +265,6 @@
     return m_source.createFrameAtIndex(index);
 }
 
-bool BitmapImage::decodedDataIsPurgeable() const
-{
-    return m_frames.size() >= 1
-        && m_frames[0].m_frame
-        && CGImageGetCachingFlags(m_frames[0].m_frame) & kCGImageCachingTransient;
 }
 
-}
-
 #endif // USE(CG)

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp (196482 => 196483)


--- trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp	2016-02-12 18:30:43 UTC (rev 196482)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageSourceCG.cpp	2016-02-12 18:34:57 UTC (rev 196483)
@@ -368,13 +368,6 @@
     if (!imageUTI)
         return image.leakRef();
 
-#if PLATFORM(MAC)
-    if (CFEqual(imageUTI, kUTTypeGIF)) {
-        CGImageSetCachingFlags(image.get(), kCGImageCachingTransient);
-        return image.leakRef();
-    }
-#endif
-
     if (!CFEqual(imageUTI, xbmUTI))
         return image.leakRef();
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to