summaryrefslogtreecommitdiffstats
path: root/image
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2017-06-28 21:49:03 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-02-04 00:07:05 +0100
commitfeeb4327304db5af1c4aa7f77c082bb6527eef5b (patch)
tree6df08048816d276b7463126180030854c42e9d49 /image
parentde11930c3fecac13bc06da4f8b7818178c63f20e (diff)
downloadUXP-feeb4327304db5af1c4aa7f77c082bb6527eef5b.tar
UXP-feeb4327304db5af1c4aa7f77c082bb6527eef5b.tar.gz
UXP-feeb4327304db5af1c4aa7f77c082bb6527eef5b.tar.lz
UXP-feeb4327304db5af1c4aa7f77c082bb6527eef5b.tar.xz
UXP-feeb4327304db5af1c4aa7f77c082bb6527eef5b.zip
Don't cache vector images in the surface cache if they are too large.
A dimension of 3000 largest size x or y should cover all common caching cases for SVG icons and web app elements, but not caching large vector rasters that would exhaust the cache. This limit is a royal 36MB/element (3000x3000x4) as cap (if the SVG is square). This avoids performance regressions when repeatedly scaling large vector images, but also allows for large SVG backgrounds to be cached. It allows for the bad practice of slapping a large SVG on a site as html background, considering they are likely, even when using large sizes for "responsive" layout, not going to exceed 3000 px in the largest dimension (and if they do, the web designer needs to be slapped with a big trout).
Diffstat (limited to 'image')
-rw-r--r--image/VectorImage.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/image/VectorImage.cpp b/image/VectorImage.cpp
index 6e3928362..2976f5243 100644
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -931,12 +931,21 @@ VectorImage::CreateSurfaceAndShow(const SVGDrawingParameters& aParams, BackendTy
RefPtr<gfxDrawable> svgDrawable =
new gfxCallbackDrawable(cb, aParams.size);
+ // We take an early exit without using the surface cache if
+ // x or y > maxDimension, because for vector images this can cause bad perf
+ // issues if large sizes are scaled repeatedly (a rather common scenario)
+ // that can quickly exhaust the cache.
+ uint32_t maxDimension = 3000;
+
bool bypassCache = bool(aParams.flags & FLAG_BYPASS_SURFACE_CACHE) ||
// Refuse to cache animated images:
// XXX(seth): We may remove this restriction in bug 922893.
mHaveAnimations ||
// The image is too big to fit in the cache:
- !SurfaceCache::CanHold(aParams.size);
+ !SurfaceCache::CanHold(aParams.size) ||
+ // Image x or y is larger than our cache cap:
+ aParams.size.width > maxDimension ||
+ aParams.size.height > maxDimension;
if (bypassCache) {
return Show(svgDrawable, aParams);
}