[CoordGfx] requestAnimationFrame performance issues

https://bugs.webkit.org/show_bug.cgi?id=112345

Patch by Noam Rosenthal <noam@webkit.org> 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:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150015 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fd07aca1
2013-05-13 Noam Rosenthal <noam@webkit.org>
[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 <vjaquez@igalia.com>
[texmap][GStreamer] Composited Video support
......
......@@ -59,9 +59,6 @@ CoordinatedGraphicsScene::CoordinatedGraphicsScene(CoordinatedGraphicsSceneClien
: 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 @@ void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatri
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)
......
......@@ -53,9 +53,6 @@ class CustomFilterProgramInfo;
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 @@ public:
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 @@ private:
void dispatchOnMainThread(const Function<void()>&);
void updateViewport();
#if ENABLE(REQUEST_ANIMATION_FRAME)
void animationFrameReady();
#endif
void renderNextFrame();
void purgeBackingStores();
......@@ -194,9 +184,6 @@ private:
CoordinatedLayerID m_rootLayerID;
FloatPoint m_scrollPosition;
FloatPoint m_renderedContentsScrollPosition;
#if ENABLE(REQUEST_ANIMATION_FRAME)
bool m_animationFrameRequested;
#endif
Color m_backgroundColor;
bool m_setDrawsBackground;
......
2013-05-13 Noam Rosenthal <noam@webkit.org>
[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 <jesus.palencia@openbossa.org>
[WK2][CoordinatedGraphics] WKView needs API for handling opacity
......
......@@ -140,19 +140,6 @@ void CoordinatedLayerTreeHostProxy::renderNextFrame()
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());
......
......@@ -71,18 +71,11 @@ public:
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;
......
......@@ -35,11 +35,6 @@ messages -> CoordinatedLayerTreeHostProxy {
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
......@@ -94,6 +94,9 @@ CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
, 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 @@ void CoordinatedLayerTreeHost::scheduleLayerFlush()
if (!m_layerFlushSchedulingEnabled)
return;
if (!m_layerFlushTimer.isActive())
if (!m_layerFlushTimer.isActive() || m_layerFlushTimer.nextFireInterval() > 0)
m_layerFlushTimer.startOneShot(0);
}
......@@ -429,7 +432,8 @@ void CoordinatedLayerTreeHost::syncDisplayState()
{
#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 @@ GraphicsLayerFactory* CoordinatedLayerTreeHost::graphicsLayerFactory()
#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
......
......@@ -147,9 +147,6 @@ private:
void layerFlushTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
void scheduleReleaseInactiveAtlases();
#if ENABLE(REQUEST_ANIMATION_FRAME)
void animationFrameReady();
#endif
void releaseInactiveAtlasesTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
......@@ -202,6 +199,10 @@ private:
bool m_layerFlushSchedulingEnabled;
uint64_t m_forceRepaintAsyncCallbackID;
bool m_animationsLocked;
#if ENABLE(REQUEST_ANIMATION_FRAME)
double m_lastAnimationServiceTime;
#endif
};
} // namespace WebKit
......
......@@ -24,9 +24,6 @@ messages -> CoordinatedLayerTreeHost LegacyReceiver {
SetVisibleContentsRect(WebCore::FloatRect visibleContentsRect, WebCore::FloatPoint trajectoryVectory)
RenderNextFrame()
PurgeBackingStores()
#if ENABLE(REQUEST_ANIMATION_FRAME)
AnimationFrameReady()
#endif
CommitScrollOffset(uint32_t layerID, WebCore::IntSize offset)
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment