Title: [182159] trunk/Source/WebCore
Revision
182159
Author
[email protected]
Date
2015-03-30 15:59:58 -0700 (Mon, 30 Mar 2015)

Log Message

[Threaded Compositor] Crash when animation changes frequently.
https://bugs.webkit.org/show_bug.cgi?id=143213

Reviewed by Simon Fraser.

CompositingCoordinator copies CoordinatedGraphicsLayerState when
flushing GraphicsLayer changes, and ThreadedCoordinatedCompositor passes
it to compositing thread.

To ensure thread-safety, we need to provide copy constructor to copy
Animation object in TextureMapperAnimation instead of referencing it.

Since TimingFunction and TransformOperation used by KeyframeValueList are
not ThreadSafeRefCounted, these should be cloned also.

No new tests needed.

* platform/graphics/GraphicsLayer.h:
(WebCore::AnimationValue::AnimationValue):
(WebCore::FloatAnimationValue::FloatAnimationValue):
(WebCore::TransformAnimationValue::TransformAnimationValue):
(WebCore::FilterAnimationValue::FilterAnimationValue):
Adds deep copy constructor.

* platform/graphics/texmap/TextureMapperAnimation.cpp:
(WebCore::TextureMapperAnimation::TextureMapperAnimation):
Because the name of the animation can be AtomicString, we need to create
isolated version of string to ensure thread safty.

* platform/graphics/texmap/TextureMapperAnimation.h:
* platform/graphics/transforms/IdentityTransformOperation.h:
* platform/graphics/transforms/Matrix3DTransformOperation.h:
* platform/graphics/transforms/MatrixTransformOperation.h:
* platform/graphics/transforms/PerspectiveTransformOperation.h:
* platform/graphics/transforms/RotateTransformOperation.h:
* platform/graphics/transforms/ScaleTransformOperation.h:
* platform/graphics/transforms/SkewTransformOperation.h:
* platform/graphics/transforms/TransformOperation.h:
* platform/graphics/transforms/TranslateTransformOperation.h:
Adds TransformOperation::clone() for threadsafety.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (182158 => 182159)


--- trunk/Source/WebCore/ChangeLog	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/ChangeLog	2015-03-30 22:59:58 UTC (rev 182159)
@@ -1,3 +1,46 @@
+2015-03-30  Gwang Yoon Hwang  <[email protected]>
+
+        [Threaded Compositor] Crash when animation changes frequently.
+        https://bugs.webkit.org/show_bug.cgi?id=143213
+
+        Reviewed by Simon Fraser.
+
+        CompositingCoordinator copies CoordinatedGraphicsLayerState when
+        flushing GraphicsLayer changes, and ThreadedCoordinatedCompositor passes
+        it to compositing thread.
+
+        To ensure thread-safety, we need to provide copy constructor to copy
+        Animation object in TextureMapperAnimation instead of referencing it.
+
+        Since TimingFunction and TransformOperation used by KeyframeValueList are
+        not ThreadSafeRefCounted, these should be cloned also.
+
+        No new tests needed.
+
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::AnimationValue::AnimationValue):
+        (WebCore::FloatAnimationValue::FloatAnimationValue):
+        (WebCore::TransformAnimationValue::TransformAnimationValue):
+        (WebCore::FilterAnimationValue::FilterAnimationValue):
+        Adds deep copy constructor.
+
+        * platform/graphics/texmap/TextureMapperAnimation.cpp:
+        (WebCore::TextureMapperAnimation::TextureMapperAnimation):
+        Because the name of the animation can be AtomicString, we need to create
+        isolated version of string to ensure thread safty.
+
+        * platform/graphics/texmap/TextureMapperAnimation.h:
+        * platform/graphics/transforms/IdentityTransformOperation.h:
+        * platform/graphics/transforms/Matrix3DTransformOperation.h:
+        * platform/graphics/transforms/MatrixTransformOperation.h:
+        * platform/graphics/transforms/PerspectiveTransformOperation.h:
+        * platform/graphics/transforms/RotateTransformOperation.h:
+        * platform/graphics/transforms/ScaleTransformOperation.h:
+        * platform/graphics/transforms/SkewTransformOperation.h:
+        * platform/graphics/transforms/TransformOperation.h:
+        * platform/graphics/transforms/TranslateTransformOperation.h:
+        Adds TransformOperation::clone() for threadsafety.
+
 2015-03-30  Chris Dumez  <[email protected]>
 
         Cached "Expires" header is not updated upon successful resource revalidation

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -75,6 +75,12 @@
     {
     }
 
+    AnimationValue(const AnimationValue& other)
+        : m_keyTime(other.m_keyTime)
+        , m_timingFunction(other.m_timingFunction ? other.m_timingFunction->clone() : nullptr)
+    {
+    }
+
 private:
     double m_keyTime;
     RefPtr<TimingFunction> m_timingFunction;
@@ -95,6 +101,12 @@
         return std::make_unique<FloatAnimationValue>(*this);
     }
 
+    FloatAnimationValue(const FloatAnimationValue& other)
+        : AnimationValue(other)
+        , m_value(other.m_value)
+    {
+    }
+
     float value() const { return m_value; }
 
 private:
@@ -116,6 +128,13 @@
         return std::make_unique<TransformAnimationValue>(*this);
     }
 
+    TransformAnimationValue(const TransformAnimationValue& other)
+        : AnimationValue(other)
+    {
+        for (size_t i = 0; i < other.m_value.operations().size(); ++i)
+            m_value.operations().append(other.m_value.operations()[i]->clone());
+    }
+
     const TransformOperations& value() const { return m_value; }
 
 private:
@@ -137,6 +156,13 @@
         return std::make_unique<FilterAnimationValue>(*this);
     }
 
+    FilterAnimationValue(const FilterAnimationValue& other)
+        : AnimationValue(other)
+    {
+        for (size_t i = 0; i < other.m_value.operations().size(); ++i)
+            m_value.operations().append(other.m_value.operations()[i]->clone());
+    }
+
     const FilterOperations& value() const { return m_value; }
 
 private:

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp	2015-03-30 22:59:58 UTC (rev 182159)
@@ -213,7 +213,7 @@
     : m_keyframes(keyframes)
     , m_boxSize(boxSize)
     , m_animation(Animation::create(*animation))
-    , m_name(name)
+    , m_name(name.isSafeToSendToAnotherThread() ? name : name.isolatedCopy())
     , m_listsMatch(listsMatch)
     , m_startTime(startTime)
     , m_pauseTime(0)
@@ -223,6 +223,20 @@
 {
 }
 
+TextureMapperAnimation::TextureMapperAnimation(const TextureMapperAnimation& other)
+    : m_keyframes(other.keyframes())
+    , m_boxSize(other.boxSize())
+    , m_animation(Animation::create(*other.animation()))
+    , m_name(other.name().isSafeToSendToAnotherThread() ? other.name() : other.name().isolatedCopy())
+    , m_listsMatch(other.listsMatch())
+    , m_startTime(other.startTime())
+    , m_pauseTime(other.pauseTime())
+    , m_totalRunningTime(other.m_totalRunningTime)
+    , m_lastRefreshedTime(other.m_lastRefreshedTime)
+    , m_state(other.state())
+{
+}
+
 void TextureMapperAnimation::applyInternal(Client* client, const AnimationValue& from, const AnimationValue& to, float progress)
 {
     switch (m_keyframes.property()) {

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -41,6 +41,7 @@
         : m_keyframes(AnimatedPropertyInvalid)
     { }
     TextureMapperAnimation(const String&, const KeyframeValueList&, const FloatSize&, const Animation*, double, bool);
+    TextureMapperAnimation(const TextureMapperAnimation&);
     void apply(Client*);
     void pause(double);
     void resume();

Modified: trunk/Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -35,7 +35,12 @@
     {
         return adoptRef(new IdentityTransformOperation());
     }
-        
+
+    virtual PassRefPtr<TransformOperation> clone() const override
+    {
+        return create();
+    }
+
 private:
     virtual bool isIdentity() const override { return true; }
     virtual OperationType type() const override { return IDENTITY; }

Modified: trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -37,6 +37,11 @@
         return adoptRef(new Matrix3DTransformOperation(matrix));
     }
 
+    virtual PassRefPtr<TransformOperation> clone() const override
+    {
+        return adoptRef(new Matrix3DTransformOperation(m_matrix));
+    }
+
     TransformationMatrix matrix() const {return m_matrix; }
 
 private:    

Modified: trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -42,6 +42,11 @@
         return adoptRef(new MatrixTransformOperation(t));
     }
 
+    virtual PassRefPtr<TransformOperation> clone() const override
+    {
+        return adoptRef(new MatrixTransformOperation(matrix()));
+    }
+
     TransformationMatrix matrix() const { return TransformationMatrix(m_a, m_b, m_c, m_d, m_e, m_f); }
 
 private:

Modified: trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -39,6 +39,11 @@
         return adoptRef(new PerspectiveTransformOperation(p));
     }
 
+    virtual PassRefPtr<TransformOperation> clone() const override
+    {
+        return adoptRef(new PerspectiveTransformOperation(m_p));
+    }
+
     Length perspective() const { return m_p; }
     
 private:

Modified: trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -41,6 +41,11 @@
         return adoptRef(new RotateTransformOperation(x, y, z, angle, type));
     }
 
+    virtual PassRefPtr<TransformOperation> clone() const override
+    {
+        return adoptRef(new RotateTransformOperation(m_x, m_y, m_z, m_angle, m_type));
+    }
+
     double x() const { return m_x; }
     double y() const { return m_y; }
     double z() const { return m_z; }

Modified: trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -41,6 +41,11 @@
         return adoptRef(new ScaleTransformOperation(sx, sy, sz, type));
     }
 
+    virtual PassRefPtr<TransformOperation> clone() const override
+    {
+        return adoptRef(new ScaleTransformOperation(m_x, m_y, m_z, m_type));
+    }
+
     double x() const { return m_x; }
     double y() const { return m_y; }
     double z() const { return m_z; }

Modified: trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -36,6 +36,11 @@
         return adoptRef(new SkewTransformOperation(angleX, angleY, type));
     }
 
+    virtual PassRefPtr<TransformOperation> clone() const override
+    {
+        return adoptRef(new SkewTransformOperation(m_angleX, m_angleY, m_type));
+    }
+
     double angleX() const { return m_angleX; }
     double angleY() const { return m_angleY; }
 

Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -54,6 +54,8 @@
 
     virtual ~TransformOperation() { }
 
+    virtual PassRefPtr<TransformOperation> clone() const = 0;
+
     virtual bool operator==(const TransformOperation&) const = 0;
     bool operator!=(const TransformOperation& o) const { return !(*this == o); }
 

Modified: trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h (182158 => 182159)


--- trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h	2015-03-30 22:58:22 UTC (rev 182158)
+++ trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h	2015-03-30 22:59:58 UTC (rev 182159)
@@ -43,6 +43,11 @@
         return adoptRef(new TranslateTransformOperation(tx, ty, tz, type));
     }
 
+    virtual PassRefPtr<TransformOperation> clone() const override
+    {
+        return adoptRef(new TranslateTransformOperation(m_x, m_y, m_z, m_type));
+    }
+
     double x(const FloatSize& borderBoxSize) const { return floatValueForLength(m_x, borderBoxSize.width()); }
     double y(const FloatSize& borderBoxSize) const { return floatValueForLength(m_y, borderBoxSize.height()); }
     double z(const FloatSize&) const { return floatValueForLength(m_z, 1); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to