Bug 50882

Summary: Each call to FilterEffect::effectContext() allocates a new m_effectBuffer
Product: WebKit Reporter: Simon Fraser (smfr) <simon.fraser>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WORKSFORME    
Severity: Normal CC: kbalazs, krit, simon.fraser, zherczeg, zimmermann
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   

Description Simon Fraser (smfr) 2010-12-11 19:20:38 PST
m_effectBuffer is allocated each time FilterEffect::effectContext() is called. Adding this assertion:


diff --git a/WebCore/platform/graphics/filters/FilterEffect.cpp b/WebCore/platform/graphics/filters/FilterEffect.cpp
index c228731..3f8f099 100644
--- a/WebCore/platform/graphics/filters/FilterEffect.cpp
+++ b/WebCore/platform/graphics/filters/FilterEffect.cpp
@@ -77,6 +77,8 @@ GraphicsContext* FilterEffect::effectContext()
     determineAbsolutePaintRect();
     if (m_absolutePaintRect.isEmpty())
         return 0;
+
+    ASSERT(!m_effectBuffer);
     m_effectBuffer = ImageBuffer::create(m_absolutePaintRect.size(), ColorSpaceLinearRGB);
     if (!m_effectBuffer)
         return 0;

shows that this indeed happens for at least one layout test:

svg/filters/feBlend-invalid-mode.xhtml -> crashed
ASSERTION FAILED: !m_effectBuffer
Comment 1 Balazs Kelemen 2010-12-12 05:25:12 PST
I don't know much about that code path but this is definitely not a leak
since m_effectBuffer is an OwnPtr.
Comment 2 Dirk Schulze 2010-12-12 08:18:02 PST
I'll also take a look at this later. Still a bit busy right now.
Comment 3 Simon Fraser (smfr) 2010-12-12 09:12:12 PST
Update title. The behavior still seems wrong.
Comment 4 Zoltan Herczeg 2010-12-12 10:00:47 PST
If I ever get an r+, this will be fixed in:
https://bugs.webkit.org/show_bug.cgi?id=49907
Comment 5 Dirk Schulze 2010-12-12 11:14:27 PST
(In reply to comment #4)
> If I ever get an r+, this will be fixed in:
> https://bugs.webkit.org/show_bug.cgi?id=49907

Ah, so it is because of the multiple apply() calls of an effect?
Comment 6 Zoltan Herczeg 2010-12-12 12:45:51 PST
> Ah, so it is because of the multiple apply() calls of an effect?

Exactly. Example:

  <feA result="a" />
  <feB in="a" result="b" />
  <feC in="a" result="c" />
  <feComposite in="b" in2="c">

In this case the apply() of feA was called twice, and the result was generated twice before. This is unnecessary (and usually costly).
Comment 7 Zoltan Herczeg 2010-12-13 02:47:22 PST
Fixed in r73894 ( https://bugs.webkit.org/show_bug.cgi?id=49907 ).