Fix the animation performance issue
authorHurnjoo Lee <hurnjoo.lee@samsung.com>
Mon, 24 Jun 2013 00:51:00 +0000 (09:51 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Wed, 2 Oct 2013 08:32:24 +0000 (08:32 +0000)
[Title] Fix the animation performance issue
[Issue#] N/A
[Problem] Slider Puzzle: Performance is poor, app is keep stucking on any random steps even sometimes unable to start.
[Cause] Regression(http://slp-info.sec.samsung.net/gerrit/#/c/225669/)
[Solution] This issue can be resolved by r150015, but cherry-picking is hard because the current our
           local branch is different from webkit-org and there is a regression on the EFL.
           So we applied part of r150015(http://trac.webkit.org/changeset/150015)
           (refer to:https://bugs.webkit.org/show_bug.cgi?id=112345)

Conflicts:
Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp
Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h

Change-Id: Ieface03402b46e28c23ccf5dc2af0830ace8465e

Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp
Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h

index 8f6d427..0a62420 100644 (file)
@@ -106,6 +106,9 @@ LayerTreeCoordinator::LayerTreeCoordinator(WebPage* webPage)
     , m_isGLAccelerationMode(true)
 #endif
     , m_animationsLocked(false)
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    , m_lastAnimationServiceTime(0)
+#endif
 {
     // Create a root layer.
     m_rootLayer = GraphicsLayer::create(this);
@@ -492,6 +495,7 @@ void LayerTreeCoordinator::performScheduledLayerFlush()
 
 #if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER) && !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
     // Make sure that any previously registered animation callbacks are being executed before we flush the layers.
+    m_lastAnimationServiceTime = WTF::monotonicallyIncreasingTime();
     m_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(convertSecondsToDOMTimeStamp(currentTime()));
 #endif
 
@@ -724,7 +728,20 @@ void LayerTreeCoordinator::setVisibleContentsRect(const IntRect& rect, float sca
 #if USE(UI_SIDE_COMPOSITING)
 void LayerTreeCoordinator::scheduleAnimation()
 {
-    scheduleLayerFlush();
+    if (m_waitingForUIProcess)
+        return;
+
+    if (m_layerFlushTimer.isActive())
+        return;
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+     // According to the requestAnimationFrame spec, rAF callbacks should not be faster than 60FPS.
+     static const double MinimalTimeoutForAnimations = 1. / 60.;
+     m_layerFlushTimer.startOneShot(std::max<double>(0., MinimalTimeoutForAnimations - WTF::monotonicallyIncreasingTime() + m_lastAnimationServiceTime));
+#else
+     static const double cAnimationTimerDelay = 0.015;
+     m_layerFlushTimer.startOneShot(cAnimationTimerDelay);
+#endif
+     scheduleLayerFlush();
 }
 #endif
 
index ce8de42..f15853a 100644 (file)
@@ -220,6 +220,9 @@ private:
 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
     WebCore::IntRect m_fixedVisibleContentRect;
 #endif
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+    double m_lastAnimationServiceTime;
+#endif
 };
 
 }