- Revision
- 150015
- Author
- [email protected]
- Date
- 2013-05-13 08:29:01 -0700 (Mon, 13 May 2013)
Log Message
[CoordGfx] requestAnimationFrame performance issues
https://bugs.webkit.org/show_bug.cgi?id=112345
Patch by Noam Rosenthal <[email protected]> on 2013-05-13
Reviewed by Jocelyn Turcotte.
Source/WebCore:
Removed current requestAnimationFrame logic from CoordinatedGraphics. The new logic
is entirely in WebKit2 CoordinatedLayerTreeHost.
Covered by existing tests in fast/animations.
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
(WebCore::CoordinatedGraphicsScene::CoordinatedGraphicsScene):
(WebCore::CoordinatedGraphicsScene::paintToCurrentGLContext):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
(CoordinatedGraphicsScene):
Source/WebKit2:
Changed the logic of requestAnimationFrame in Coordinated Graphics.
We don't send any IPC messages for requestAnimationFrame. Instead, we do one of two things:
- If there is already a frame pending in the UI process, do nothing, as the animations would
be serviced when the frame is returned to the web process.
- If there is no frame pending, we schedule a flush, making sure that that flush occurs at
least 1/60 seconds after the last animation service, so that we don't get an infinite loop
of flushes.
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:
(WebKit::CoordinatedLayerTreeHostProxy::requestAnimationFrame):
* UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
(WebKit::CoordinatedLayerTreeHost::flushPendingLayerChanges):
(WebKit::CoordinatedLayerTreeHost::scheduleAnimation):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.messages.in:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (150014 => 150015)
--- trunk/Source/WebCore/ChangeLog 2013-05-13 15:14:46 UTC (rev 150014)
+++ trunk/Source/WebCore/ChangeLog 2013-05-13 15:29:01 UTC (rev 150015)
@@ -1,3 +1,21 @@
+2013-05-13 Noam Rosenthal <[email protected]>
+
+ [CoordGfx] requestAnimationFrame performance issues
+ https://bugs.webkit.org/show_bug.cgi?id=112345
+
+ Reviewed by Jocelyn Turcotte.
+
+ Removed current requestAnimationFrame logic from CoordinatedGraphics. The new logic
+ is entirely in WebKit2 CoordinatedLayerTreeHost.
+
+ Covered by existing tests in fast/animations.
+
+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp:
+ (WebCore::CoordinatedGraphicsScene::CoordinatedGraphicsScene):
+ (WebCore::CoordinatedGraphicsScene::paintToCurrentGLContext):
+ * platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h:
+ (CoordinatedGraphicsScene):
+
2013-05-13 Víctor Manuel Jáquez Leal <[email protected]>
[texmap][GStreamer] Composited Video support
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp (150014 => 150015)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp 2013-05-13 15:14:46 UTC (rev 150014)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.cpp 2013-05-13 15:29:01 UTC (rev 150015)
@@ -59,9 +59,6 @@
: m_client(client)
, m_isActive(false)
, m_rootLayerID(InvalidCoordinatedLayerID)
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- , m_animationFrameRequested(false)
-#endif
, m_backgroundColor(Color::white)
, m_setDrawsBackground(false)
{
@@ -116,29 +113,8 @@
if (layer->descendantsOrSelfHaveRunningAnimations())
dispatchOnMainThread(bind(&CoordinatedGraphicsScene::updateViewport, this));
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- if (m_animationFrameRequested) {
- m_animationFrameRequested = false;
- dispatchOnMainThread(bind(&CoordinatedGraphicsScene::animationFrameReady, this));
- }
-#endif
}
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-void CoordinatedGraphicsScene::animationFrameReady()
-{
- ASSERT(isMainThread());
- if (m_client)
- m_client->animationFrameReady();
-}
-
-void CoordinatedGraphicsScene::requestAnimationFrame()
-{
- m_animationFrameRequested = true;
-}
-#endif
-
void CoordinatedGraphicsScene::paintToGraphicsContext(PlatformGraphicsContext* platformContext)
{
if (!m_textureMapper)
Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h (150014 => 150015)
--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h 2013-05-13 15:14:46 UTC (rev 150014)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsScene.h 2013-05-13 15:29:01 UTC (rev 150015)
@@ -53,9 +53,6 @@
class CoordinatedGraphicsSceneClient {
public:
virtual ~CoordinatedGraphicsSceneClient() { }
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- virtual void animationFrameReady() = 0;
-#endif
virtual void purgeBackingStores() = 0;
virtual void renderNextFrame() = 0;
virtual void updateViewport() = 0;
@@ -101,10 +98,6 @@
void setBackgroundColor(const Color&);
void setDrawsBackground(bool enable) { m_setDrawsBackground = enable; }
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- void requestAnimationFrame();
-#endif
-
private:
void setRootLayerID(CoordinatedLayerID);
void setLayerState(CoordinatedLayerID, const CoordinatedGraphicsLayerState&);
@@ -137,9 +130,6 @@
void dispatchOnMainThread(const Function<void()>&);
void updateViewport();
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- void animationFrameReady();
-#endif
void renderNextFrame();
void purgeBackingStores();
@@ -194,9 +184,6 @@
CoordinatedLayerID m_rootLayerID;
FloatPoint m_scrollPosition;
FloatPoint m_renderedContentsScrollPosition;
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- bool m_animationFrameRequested;
-#endif
Color m_backgroundColor;
bool m_setDrawsBackground;
Modified: trunk/Source/WebKit2/ChangeLog (150014 => 150015)
--- trunk/Source/WebKit2/ChangeLog 2013-05-13 15:14:46 UTC (rev 150014)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-13 15:29:01 UTC (rev 150015)
@@ -1,3 +1,28 @@
+2013-05-13 Noam Rosenthal <[email protected]>
+
+ [CoordGfx] requestAnimationFrame performance issues
+ https://bugs.webkit.org/show_bug.cgi?id=112345
+
+ Reviewed by Jocelyn Turcotte.
+
+ Changed the logic of requestAnimationFrame in Coordinated Graphics.
+ We don't send any IPC messages for requestAnimationFrame. Instead, we do one of two things:
+ - If there is already a frame pending in the UI process, do nothing, as the animations would
+ be serviced when the frame is returned to the web process.
+ - If there is no frame pending, we schedule a flush, making sure that that flush occurs at
+ least 1/60 seconds after the last animation service, so that we don't get an infinite loop
+ of flushes.
+
+ * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp:
+ (WebKit::CoordinatedLayerTreeHostProxy::requestAnimationFrame):
+ * UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h:
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
+ (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
+ (WebKit::CoordinatedLayerTreeHost::flushPendingLayerChanges):
+ (WebKit::CoordinatedLayerTreeHost::scheduleAnimation):
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
+ * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.messages.in:
+
2013-05-13 Jesus Sanchez-Palencia <[email protected]>
[WK2][CoordinatedGraphics] WKView needs API for handling opacity
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp (150014 => 150015)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp 2013-05-13 15:14:46 UTC (rev 150014)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.cpp 2013-05-13 15:29:01 UTC (rev 150015)
@@ -140,19 +140,6 @@
m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID());
}
-#if ENABLE(REQUEST_ANIMATION_FRAME)
-void CoordinatedLayerTreeHostProxy::requestAnimationFrame()
-{
- dispatchUpdate(bind(&CoordinatedGraphicsScene::requestAnimationFrame, m_scene.get()));
- updateViewport();
-}
-
-void CoordinatedLayerTreeHostProxy::animationFrameReady()
-{
- m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::AnimationFrameReady(), m_drawingAreaProxy->page()->pageID());
-}
-#endif
-
void CoordinatedLayerTreeHostProxy::purgeBackingStores()
{
m_drawingAreaProxy->page()->process()->send(Messages::CoordinatedLayerTreeHost::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID());
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h (150014 => 150015)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h 2013-05-13 15:14:46 UTC (rev 150014)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.h 2013-05-13 15:29:01 UTC (rev 150015)
@@ -71,18 +71,11 @@
void commitCoordinatedGraphicsState(const WebCore::CoordinatedGraphicsState&);
void setAnimationsLocked(bool);
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- void requestAnimationFrame();
-#endif
void setBackgroundColor(const WebCore::Color&);
void setVisibleContentsRect(const WebCore::FloatRect&, const WebCore::FloatPoint& trajectoryVector);
WebCore::CoordinatedGraphicsScene* coordinatedGraphicsScene() const { return m_scene.get(); }
- // CoordinatedGraphicsSceneClient Methods.
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- virtual void animationFrameReady() OVERRIDE;
-#endif
virtual void updateViewport() OVERRIDE;
virtual void renderNextFrame() OVERRIDE;
virtual void purgeBackingStores() OVERRIDE;
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in (150014 => 150015)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in 2013-05-13 15:14:46 UTC (rev 150014)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedLayerTreeHostProxy.messages.in 2013-05-13 15:29:01 UTC (rev 150015)
@@ -35,11 +35,6 @@
UpdateImageBacking(uint64_t imageID, WebKit::WebCoordinatedSurface::Handle handle)
ClearImageBackingContents(uint64_t imageID)
RemoveImageBacking(uint64_t imageID)
-
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- RequestAnimationFrame()
-#endif
-
SetBackgroundColor(WebCore::Color color)
}
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp (150014 => 150015)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 2013-05-13 15:14:46 UTC (rev 150014)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp 2013-05-13 15:29:01 UTC (rev 150015)
@@ -94,6 +94,9 @@
, m_layerFlushSchedulingEnabled(true)
, m_forceRepaintAsyncCallbackID(0)
, m_animationsLocked(false)
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ , m_lastAnimationServiceTime(0)
+#endif
{
m_webPage->corePage()->settings()->setScrollingCoordinatorEnabled(true);
m_webPage->corePage()->settings()->setApplyDeviceScaleFactorInCompositor(true);
@@ -139,7 +142,7 @@
if (!m_layerFlushSchedulingEnabled)
return;
- if (!m_layerFlushTimer.isActive())
+ if (!m_layerFlushTimer.isActive() || m_layerFlushTimer.nextFireInterval() > 0)
m_layerFlushTimer.startOneShot(0);
}
@@ -429,7 +432,8 @@
{
#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_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(currentTime());
+ m_lastAnimationServiceTime = WTF::monotonicallyIncreasingTime();
+ m_webPage->corePage()->mainFrame()->view()->serviceScriptedAnimations(m_lastAnimationServiceTime);
#endif
m_webPage->layoutIfNeeded();
@@ -649,11 +653,15 @@
#if ENABLE(REQUEST_ANIMATION_FRAME)
void CoordinatedLayerTreeHost::scheduleAnimation()
{
- m_webPage->send(Messages::CoordinatedLayerTreeHostProxy::RequestAnimationFrame());
-}
+ if (m_waitingForUIProcess)
+ return;
-void CoordinatedLayerTreeHost::animationFrameReady()
-{
+ if (m_layerFlushTimer.isActive())
+ return;
+
+ // 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));
scheduleLayerFlush();
}
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h (150014 => 150015)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h 2013-05-13 15:14:46 UTC (rev 150014)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h 2013-05-13 15:29:01 UTC (rev 150015)
@@ -147,9 +147,6 @@
void layerFlushTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
void scheduleReleaseInactiveAtlases();
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- void animationFrameReady();
-#endif
void releaseInactiveAtlasesTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
@@ -202,6 +199,10 @@
bool m_layerFlushSchedulingEnabled;
uint64_t m_forceRepaintAsyncCallbackID;
bool m_animationsLocked;
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ double m_lastAnimationServiceTime;
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.messages.in (150014 => 150015)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.messages.in 2013-05-13 15:14:46 UTC (rev 150014)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.messages.in 2013-05-13 15:29:01 UTC (rev 150015)
@@ -24,9 +24,6 @@
SetVisibleContentsRect(WebCore::FloatRect visibleContentsRect, WebCore::FloatPoint trajectoryVectory)
RenderNextFrame()
PurgeBackingStores()
-#if ENABLE(REQUEST_ANIMATION_FRAME)
- AnimationFrameReady()
-#endif
CommitScrollOffset(uint32_t layerID, WebCore::IntSize offset)
}
#endif