Backed out changeset ccdc2beb09ae (bug 865929) for mochitest and crashtest crashes.
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 25 Apr 2013 22:13:14 -0400
changeset 130018 7338d59869c3a6cd22b7b2bcad98566976ec8361
parent 130017 63f3e64b064aeed9778e750cbb202f2d063cb0d3
child 130019 9ab1119d459612a44b4c72eb8512b508eef39c11
push id1552
push userttaubert@mozilla.com
push dateSat, 27 Apr 2013 15:33:29 +0000
treeherderfx-team@40dafc376794 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs865929
milestone23.0a1
backs outccdc2beb09ae5908a209c11d19f85279307279c1
Backed out changeset ccdc2beb09ae (bug 865929) for mochitest and crashtest crashes. CLOSED TREE
b2g/app/b2g.js
content/canvas/src/CanvasImageCache.cpp
modules/libpref/src/init/all.js
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -23,17 +23,16 @@ pref("browser.cache.disk.smart_size.enab
 pref("browser.cache.disk.smart_size.first_run", false);
 
 pref("browser.cache.memory.enable", true);
 pref("browser.cache.memory.capacity", 1024); // kilobytes
 
 /* image cache prefs */
 pref("image.cache.size", 1048576); // bytes
 pref("image.high_quality_downscaling.enabled", false);
-pref("canvas.image.cache.limit", 10485760); // 10 MB
 
 /* offline cache prefs */
 pref("browser.offline-apps.notify", false);
 pref("browser.cache.offline.enable", true);
 pref("offline-apps.allow_by_default", true);
 
 /* protocol warning prefs */
 pref("network.protocol-handler.warn-external.tel", false);
--- a/content/canvas/src/CanvasImageCache.cpp
+++ b/content/canvas/src/CanvasImageCache.cpp
@@ -8,17 +8,16 @@
 #include "nsExpirationTracker.h"
 #include "imgIRequest.h"
 #include "gfxASurface.h"
 #include "gfxPoint.h"
 #include "mozilla/dom/Element.h"
 #include "nsTHashtable.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "nsContentUtils.h"
-#include "mozilla/Preferences.h"
 
 namespace mozilla {
 
 using namespace dom;
 
 struct ImageCacheKey {
   ImageCacheKey(Element* aImage, HTMLCanvasElement* aCanvas)
     : mImage(aImage), mCanvas(aCanvas) {}
@@ -38,18 +37,16 @@ struct ImageCacheEntryData {
   ImageCacheEntryData(const ImageCacheKey& aKey)
     : mImage(aKey.mImage)
     , mILC(nullptr)
     , mCanvas(aKey.mCanvas)
   {}
 
   nsExpirationState* GetExpirationState() { return &mState; }
 
-  size_t SizeInBytes() { return mSize.width * mSize.height * 4; }
-
   // Key
   nsRefPtr<Element> mImage;
   nsIImageLoadingContent* mILC;
   nsRefPtr<HTMLCanvasElement> mCanvas;
   // Value
   nsCOMPtr<imgIRequest> mRequest;
   nsRefPtr<gfxASurface> mSurface;
   gfxIntSize mSize;
@@ -77,98 +74,57 @@ public:
   {
     return HashGeneric(key->mImage, key->mCanvas);
   }
   enum { ALLOW_MEMMOVE = true };
 
   nsAutoPtr<ImageCacheEntryData> mData;
 };
 
-static bool sPrefsInitialized = false;
-static int32_t sCanvasImageCacheLimit = 0;
-
-class ImageCache MOZ_FINAL : public nsExpirationTracker<ImageCacheEntryData,4>,
-                             public nsIObserver {
+class ImageCache MOZ_FINAL : public nsExpirationTracker<ImageCacheEntryData,4> {
 public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIOBSERVER
-
   // We use 3 generations of 1 second each to get a 2-3 seconds timeout.
   enum { GENERATION_MS = 1000 };
   ImageCache()
     : nsExpirationTracker<ImageCacheEntryData,4>(GENERATION_MS)
-    , mSize(0)
   {
-    if (!sPrefsInitialized) {
-      sPrefsInitialized = true;
-      Preferences::AddIntVarCache(&sCanvasImageCacheLimit, "canvas.image.cache.limit", 0);
-    }
     mCache.Init();
   }
   ~ImageCache() {
     AgeAllGenerations();
   }
 
-  void AddObject(ImageCacheEntryData* aObject)
-  {
-    nsExpirationTracker<ImageCacheEntryData,4>::AddObject(aObject);
-    mSize += aObject->SizeInBytes();
-  }
-
-  void RemoveObject(ImageCacheEntryData* aObject)
-  {
-    nsExpirationTracker<ImageCacheEntryData,4>::RemoveObject(aObject);
-    mSize -= aObject->SizeInBytes();
-  }
-
   virtual void NotifyExpired(ImageCacheEntryData* aObject)
   {
     RemoveObject(aObject);
     // Deleting the entry will delete aObject since the entry owns aObject
     mCache.RemoveEntry(ImageCacheKey(aObject->mImage, aObject->mCanvas));
   }
 
   nsTHashtable<ImageCacheEntry> mCache;
-  size_t mSize;
 };
 
 static ImageCache* gImageCache = nullptr;
 
-NS_IMPL_ISUPPORTS1(ImageCache, nsIObserver)
-
-NS_IMETHODIMP
-ImageCache::Observe(nsISupports *aSubject,
-                    const char *aTopic,
-                    const PRUnichar *aData)
-{
-  if (strcmp(aTopic, "memory-pressure") == 0) {
-    AgeAllGenerations();
-  }
-  return NS_OK;
-}
-
 class CanvasImageCacheShutdownObserver MOZ_FINAL : public nsIObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
 };
 
 void
 CanvasImageCache::NotifyDrawImage(Element* aImage,
                                   HTMLCanvasElement* aCanvas,
                                   imgIRequest* aRequest,
                                   gfxASurface* aSurface,
                                   const gfxIntSize& aSize)
 {
   if (!gImageCache) {
     gImageCache = new ImageCache();
-    nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
-    if (os)
-      os->AddObserver(gImageCache, "memory-pressure", false);
     nsContentUtils::RegisterShutdownObserver(new CanvasImageCacheShutdownObserver());
   }
 
   ImageCacheEntry* entry = gImageCache->mCache.PutEntry(ImageCacheKey(aImage, aCanvas));
   if (entry) {
     if (entry->mData->mSurface) {
       // We are overwriting an existing entry.
       gImageCache->RemoveObject(entry->mData);
@@ -179,23 +135,16 @@ CanvasImageCache::NotifyDrawImage(Elemen
     if (ilc) {
       ilc->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
                       getter_AddRefs(entry->mData->mRequest));
     }
     entry->mData->mILC = ilc;
     entry->mData->mSurface = aSurface;
     entry->mData->mSize = aSize;
   }
-
-  if (!sCanvasImageCacheLimit)
-    return;
-
-  // Expire the image cache early if its larger than we want it to be.
-  while (gImageCache->mSize > size_t(sCanvasImageCacheLimit))
-    gImageCache->AgeOneGeneration();
 }
 
 gfxASurface*
 CanvasImageCache::Lookup(Element* aImage,
                          HTMLCanvasElement* aCanvas,
                          gfxIntSize* aSize)
 {
   if (!gImageCache)
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -3916,20 +3916,16 @@ pref("image.mem.max_decoded_image_kb", 5
 // Whether we decode images on multiple background threads rather than the
 // foreground thread.
 pref("image.multithreaded_decoding.enabled", true);
 
 // How many threads we'll use for multithreaded decoding. If < 0, will be
 // automatically determined based on the system's number of cores.
 pref("image.multithreaded_decoding.limit", -1);
 
-// Limit for the canvas image cache. 0 means we don't limit the size of the
-// cache.
-pref("canvas.image.cache.limit", 0);
-
 // WebGL prefs
 pref("gl.msaa-level", 2);
 pref("webgl.force-enabled", false);
 pref("webgl.disabled", false);
 pref("webgl.shader_validator", true);
 pref("webgl.prefer-native-gl", false);
 pref("webgl.min_capability_mode", false);
 pref("webgl.disable-extensions", false);