[webkit-changes] [WebKit/WebKit] 93ee37: [Filters] Limit the memory cost of FilterResults t...

Said Abou-Hallawa noreply at github.com
Thu Jun 1 14:47:48 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 93ee37d3063287725be2d54acbaf38fade9dd4d5
      https://github.com/WebKit/WebKit/commit/93ee37d3063287725be2d54acbaf38fade9dd4d5
  Author: Said Abou-Hallawa <said at apple.com>
  Date:   2023-06-01 (Thu, 01 Jun 2023)

  Changed paths:
    A LayoutTests/svg/filters/repeated-drop-shadow-effects-expected.svg
    A LayoutTests/svg/filters/repeated-drop-shadow-effects.svg
    M Source/WebCore/platform/graphics/coreimage/FilterImageCoreImage.mm
    M Source/WebCore/platform/graphics/filters/FilterImage.cpp
    M Source/WebCore/platform/graphics/filters/FilterImage.h
    M Source/WebCore/platform/graphics/filters/FilterResults.cpp
    M Source/WebCore/platform/graphics/filters/FilterResults.h
    M Source/WebCore/svg/graphics/filters/SVGFilter.cpp

  Log Message:
  -----------
  [Filters] Limit the memory cost of FilterResults to 100MB
https://bugs.webkit.org/show_bug.cgi?id=245230

Reviewed by Cameron McCormack.

The SVGFilter is completely discarded if the number of unique effects is more
than 100 or the number of children of any effect is more than 200. This is a
naive way to limit the memory used for caching the results because it does not
consider the size of the FilterImage. Moreover this limitation prevents displaying
the sourceImage itself. So we end up with a blank rectangle.

A better approach is to allow caching the FilterImages up to 100MB per filter.
All FilterImages which are generated after that limit will be discarded after
they are used. Any subsequent filter applying will regenerate these FilterImages.

* LayoutTests/svg/filters/repeated-drop-shadow-effects-expected.svg: Added.
* LayoutTests/svg/filters/repeated-drop-shadow-effects.svg: Added.
* Source/WebCore/platform/graphics/coreimage/FilterImageCoreImage.mm:
(WebCore::FilterImage::memoryCostOfCIImage const):
* Source/WebCore/platform/graphics/filters/FilterImage.cpp:
(WebCore::FilterImage::memoryCost const):
* Source/WebCore/platform/graphics/filters/FilterImage.h:
* Source/WebCore/platform/graphics/filters/FilterResults.cpp:
(WebCore::FilterResults::memoryCost const):
(WebCore::FilterResults::canCacheResult const):
(WebCore::FilterResults::setEffectResult):
* Source/WebCore/platform/graphics/filters/FilterResults.h:
* Source/WebCore/svg/graphics/filters/SVGFilter.cpp:
(WebCore::SVGFilter::buildExpression):

Canonical link: https://commits.webkit.org/264807@main




More information about the webkit-changes mailing list