Title: [198248] branches/safari-601.1.46-branch/Source/WebCore

Diff

Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (198247 => 198248)


--- branches/safari-601.1.46-branch/Source/WebCore/ChangeLog	2016-03-16 00:22:05 UTC (rev 198247)
+++ branches/safari-601.1.46-branch/Source/WebCore/ChangeLog	2016-03-16 00:22:08 UTC (rev 198248)
@@ -1,5 +1,55 @@
 2016-03-14  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r197125. rdar://problem/24860685
+
+    2016-02-25  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+            REGRESSION (r196268): Many assertion failures and crashes on SVG path animation tests when JS garbage collection happens quickly
+            https://bugs.webkit.org/show_bug.cgi?id=154331
+
+            Reviewed by Darin Adler.
+
+            This is not an actual regression. The bug did exist before r196268 but
+            the whole document was leaking once an SVGAnimatedProperty was created
+            so there was no way to produce this bug. After fixing the leak, one crash
+            and one assert got uncovered. Both of them happen because of the fact:
+            "if an SVGAnimatedProperty is not referenced it will be deleted."
+
+            * svg/SVGPathElement.cpp:
+            (WebCore::SVGPathElement::lookupOrCreateDWrapper):
+            The code in this function was assuming that the wrapper will be created
+            only once which happens when SVGAnimatedProperty::lookupOrCreateWrapper()
+            is called. Before making this single call, lookupOrCreateDWrapper() was
+            building an initial SVGPathSegList from byte stream. But now
+            SVGAnimatedProperty::lookupWrapper() can return false even after creating
+            the SVGAnimatedProperty because it was deleted later. Calling
+            buildSVGPathSegListFromByteStream() more than once was causing
+            SVGAnimatedListPropertyTearOff::animationStarted() to fire the assertion
+            ASSERT(m_values.size() == m_wrappers.size()) because the path segments were
+            appended twice to m_values which is in fact SVGPathElement::m_pathSegList.value.
+            The fix is to build the initial SVGPathSegList only once which should happen
+            when m_pathSegList.value.isEmpty().
+
+            (WebCore::SVGPathElement::animatedPropertyWillBeDeleted):
+            * svg/SVGPathElement.h:
+            * svg/properties/SVGAnimatedPathSegListPropertyTearOff.h:
+            (WebCore::SVGAnimatedPathSegListPropertyTearOff::~SVGAnimatedPathSegListPropertyTearOff):
+            SVGPathElement is assuming the following equivalence relation:
+            m_pathSegList.shouldSynchronize ~ SVGAnimatedProperty_is_created_and_not_null.
+            SVGPathElement::animatedPathSegList() and animatedNormalizedPathSegList()
+            set m_pathSegList.shouldSynchronize to true when SVGAnimatedProperty is
+            created but nothing sets m_pathSegList.shouldSynchronize back to false.
+            This was not a problem when the SVGAnimatedProperty was leaking but after
+            ensuring it is deleted when it is not referenced this equivalence relation
+            becomes untrue sometimes. This caused SVGPathElement::svgAttributeChanged()
+            to crash when we check m_pathSegList.shouldSynchronize and if it is true we
+            assume that SVGAnimatedProperty::lookupWrapper() will return a non-null pointer
+            and therefore we deference this pointer and call SVGAnimatedProperty::isAnimating().
+            To fix this crash we need to set m_pathSegList.shouldSynchronize back to false
+            when the associated SVGAnimatedProperty is deleted.
+
+2016-03-14  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r196670. rdar://problem/24860681
 
     2016-02-16  Said Abou-Hallawa  <sabouhall...@apple.com>

Modified: branches/safari-601.1.46-branch/Source/WebCore/svg/SVGPathElement.cpp (198247 => 198248)


--- branches/safari-601.1.46-branch/Source/WebCore/svg/SVGPathElement.cpp	2016-03-16 00:22:05 UTC (rev 198247)
+++ branches/safari-601.1.46-branch/Source/WebCore/svg/SVGPathElement.cpp	2016-03-16 00:22:08 UTC (rev 198248)
@@ -309,8 +309,8 @@
     if (auto property = SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff>(&ownerType, dPropertyInfo()))
         return *property;
 
-    // Build initial SVGPathSegList.
-    buildSVGPathSegListFromByteStream(ownerType.m_pathByteStream.get(), &ownerType, ownerType.m_pathSegList.value, UnalteredParsing);
+    if (ownerType.m_pathSegList.value.isEmpty())
+        buildSVGPathSegListFromByteStream(ownerType.m_pathByteStream.get(), &ownerType, ownerType.m_pathSegList.value, UnalteredParsing);
 
     return SVGAnimatedProperty::lookupOrCreateWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff, SVGPathSegList>
         (&ownerType, dPropertyInfo(), ownerType.m_pathSegList.value);
@@ -325,6 +325,15 @@
     ownerType.m_pathSegList.synchronize(&ownerType, dPropertyInfo()->attributeName, ownerType.m_pathSegList.value.valueAsString());
 }
 
+void SVGPathElement::animatedPropertyWillBeDeleted()
+{
+    // m_pathSegList.shouldSynchronize is set to true when the 'd' wrapper for m_pathSegList
+    // is created and cached. We need to reset it back to false when this wrapper is deleted
+    // so we can be sure if shouldSynchronize is true, SVGAnimatedProperty::lookupWrapper()
+    // will return a valid cached 'd' wrapper for the m_pathSegList.
+    m_pathSegList.shouldSynchronize = false;
+}
+
 RefPtr<SVGPathSegListPropertyTearOff> SVGPathElement::pathSegList()
 {
     m_pathSegList.shouldSynchronize = true;

Modified: branches/safari-601.1.46-branch/Source/WebCore/svg/SVGPathElement.h (198247 => 198248)


--- branches/safari-601.1.46-branch/Source/WebCore/svg/SVGPathElement.h	2016-03-16 00:22:05 UTC (rev 198247)
+++ branches/safari-601.1.46-branch/Source/WebCore/svg/SVGPathElement.h	2016-03-16 00:22:08 UTC (rev 198248)
@@ -97,6 +97,8 @@
 
     bool isAnimValObserved() const { return m_isAnimValObserved; }
 
+    void animatedPropertyWillBeDeleted();
+
 private:
     SVGPathElement(const QualifiedName&, Document&);
 

Modified: branches/safari-601.1.46-branch/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h (198247 => 198248)


--- branches/safari-601.1.46-branch/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h	2016-03-16 00:22:05 UTC (rev 198247)
+++ branches/safari-601.1.46-branch/Source/WebCore/svg/properties/SVGAnimatedPathSegListPropertyTearOff.h	2016-03-16 00:22:08 UTC (rev 198248)
@@ -38,7 +38,7 @@
 
         auto property = SVGPathSegListPropertyTearOff::create(this, BaseValRole, PathSegUnalteredRole, m_values, m_wrappers);
         m_baseVal = property.ptr();
-        return WTFMove(property);
+        return WTF::move(property);
     }
 
     virtual RefPtr<ListProperty> animVal() override
@@ -48,7 +48,7 @@
 
         auto property = SVGPathSegListPropertyTearOff::create(this, AnimValRole, PathSegUnalteredRole, m_values, m_wrappers);
         m_animVal = property.ptr();
-        return WTFMove(property);
+        return WTF::move(property);
     }
 
     int findItem(const RefPtr<SVGPathSeg>& segment)
@@ -112,8 +112,15 @@
         : SVGAnimatedListPropertyTearOff<SVGPathSegList>(contextElement, attributeName, animatedPropertyType, values)
         , m_animatedPathByteStream(nullptr)
     {
+        ASSERT(contextElement);
+        ASSERT(is<SVGPathElement>(contextElement));
     }
 
+    virtual ~SVGAnimatedPathSegListPropertyTearOff()
+    {
+        downcast<SVGPathElement>(contextElement())->animatedPropertyWillBeDeleted();
+    }
+
     SVGPathByteStream* m_animatedPathByteStream;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to