Diff
Modified: trunk/LayoutTests/ChangeLog (132741 => 132742)
--- trunk/LayoutTests/ChangeLog 2012-10-28 01:31:06 UTC (rev 132741)
+++ trunk/LayoutTests/ChangeLog 2012-10-28 01:32:58 UTC (rev 132742)
@@ -1,3 +1,16 @@
+2012-10-27 Noam Rosenthal <[email protected]>
+
+ Coordinated Graphics: Animation jerkiness when rAF is enabled
+ https://bugs.webkit.org/show_bug.cgi?id=100536
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Added a test to make sure we don't respond too eagerly to requestAnimationFrame.
+
+ * fast/animation/request-animation-frame-too-rapid-expected.txt: Added.
+ * fast/animation/request-animation-frame-too-rapid.html: Added.
+ * fast/animation/script-tests/request-animation-frame-too-rapid.js: Added.
+
2012-10-27 David Barton <[email protected]>
[MathML] Improve some addChild methods
Added: trunk/LayoutTests/fast/animation/request-animation-frame-too-rapid-expected.txt (0 => 132742)
--- trunk/LayoutTests/fast/animation/request-animation-frame-too-rapid-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/animation/request-animation-frame-too-rapid-expected.txt 2012-10-28 01:32:58 UTC (rev 132742)
@@ -0,0 +1,10 @@
+Tests that requestAnimationFrame callbacks aren't called too rapidly (above 1000FPS)
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS 100 is >= numCallbacks
+
Added: trunk/LayoutTests/fast/animation/request-animation-frame-too-rapid.html (0 => 132742)
--- trunk/LayoutTests/fast/animation/request-animation-frame-too-rapid.html (rev 0)
+++ trunk/LayoutTests/fast/animation/request-animation-frame-too-rapid.html 2012-10-28 01:32:58 UTC (rev 132742)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<span id="e"></span>
+<span id="f"></span>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/animation/script-tests/request-animation-frame-too-rapid.js (0 => 132742)
--- trunk/LayoutTests/fast/animation/script-tests/request-animation-frame-too-rapid.js (rev 0)
+++ trunk/LayoutTests/fast/animation/script-tests/request-animation-frame-too-rapid.js 2012-10-28 01:32:58 UTC (rev 132742)
@@ -0,0 +1,26 @@
+description("Tests that requestAnimationFrame callbacks aren't called too rapidly (above 1000FPS)");
+
+var numCallbacks = 0;
+var e = document.getElementById("e");
+
+function next() {
+ window.requestAnimationFrame(function () {
+ numCallbacks++;
+ next();
+ }, e);
+}
+
+next();
+
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+// Set the timeout after the first callback.
+setTimeout(function() {
+ isSuccessfullyParsed();
+ shouldBeGreaterThanOrEqual("100", "numCallbacks");
+ if (window.testRunner)
+ window.testRunner.notifyDone();
+}, 100);
+
+
Modified: trunk/Source/WebKit2/ChangeLog (132741 => 132742)
--- trunk/Source/WebKit2/ChangeLog 2012-10-28 01:31:06 UTC (rev 132741)
+++ trunk/Source/WebKit2/ChangeLog 2012-10-28 01:32:58 UTC (rev 132742)
@@ -1,3 +1,46 @@
+2012-10-27 Noam Rosenthal <[email protected]>
+
+ Coordinated Graphics: Animation jerkiness when rAF is enabled
+ https://bugs.webkit.org/show_bug.cgi?id=100536
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ The jerkiness comes from the fact that we schedule animations excessively; That's because
+ the previous patch broke requestAnimationFrame behavior during CSS animations, since the
+ frame returns right away instead of waiting till the previous frame is actually rendered.
+
+ This patch makes sure that when animations are scheduled, they're only serviced after the
+ UI process has actually painted the previous frame. We do so by sending a
+ RequestAnimationFrame message to the UI process, which responds with AnimationFrameReady
+ after the UI process paints.
+
+ New test: fast/animations/request-animation-frame-too-rapid.html
+ Tests that we don't receive an unreasonably high number of callbacks from
+ requestAnimationFrame (> 1000FPS).
+
+ * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp:
+ (WebKit):
+ (WebKit::LayerTreeCoordinatorProxy::requestAnimationFrame):
+ (WebKit::LayerTreeCoordinatorProxy::animationFrameReady):
+ * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h:
+ (LayerTreeCoordinatorProxy):
+ * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in:
+ * UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp:
+ (WebKit::LayerTreeRenderer::LayerTreeRenderer):
+ (WebKit::LayerTreeRenderer::paintToCurrentGLContext):
+ (WebKit):
+ (WebKit::LayerTreeRenderer::animationFrameReady):
+ (WebKit::LayerTreeRenderer::requestAnimationFrame):
+ * UIProcess/CoordinatedGraphics/LayerTreeRenderer.h:
+ (LayerTreeRenderer):
+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp:
+ (WebKit):
+ (WebKit::LayerTreeCoordinator::scheduleAnimation):
+ (WebKit::LayerTreeCoordinator::animationFrameReady):
+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h:
+ (LayerTreeCoordinator):
+ * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.messages.in:
+
2012-10-27 Sam Weinig <[email protected]>
Yet more MessageReceivering
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp (132741 => 132742)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp 2012-10-28 01:31:06 UTC (rev 132741)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp 2012-10-28 01:32:58 UTC (rev 132742)
@@ -175,6 +175,19 @@
m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::RenderNextFrame(), m_drawingAreaProxy->page()->pageID());
}
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+void LayerTreeCoordinatorProxy::requestAnimationFrame()
+{
+ dispatchUpdate(bind(&LayerTreeRenderer::requestAnimationFrame, m_renderer.get()));
+ updateViewport();
+}
+
+void LayerTreeCoordinatorProxy::animationFrameReady()
+{
+ m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::AnimationFrameReady(), m_drawingAreaProxy->page()->pageID());
+}
+#endif
+
void LayerTreeCoordinatorProxy::didChangeScrollPosition(const IntPoint& position)
{
dispatchUpdate(bind(&LayerTreeRenderer::didChangeScrollPosition, m_renderer.get(), position));
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h (132741 => 132742)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h 2012-10-28 01:31:06 UTC (rev 132741)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h 2012-10-28 01:32:58 UTC (rev 132742)
@@ -83,6 +83,10 @@
LayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); }
void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&);
void setAnimationsLocked(bool);
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ void requestAnimationFrame();
+ void animationFrameReady();
+#endif
protected:
void dispatchUpdate(const Function<void()>&);
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in (132741 => 132742)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in 2012-10-28 01:31:06 UTC (rev 132741)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in 2012-10-28 01:32:58 UTC (rev 132742)
@@ -36,6 +36,10 @@
SetLayerAnimations(uint32_t id, WebCore::GraphicsLayerAnimations animations)
SetAnimationsLocked(bool locked)
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ RequestAnimationFrame()
+#endif
+
#if USE(GRAPHICS_SURFACE)
SyncCanvas(uint32_t id, WebCore::IntSize canvasSize, WebCore::GraphicsSurfaceToken token, uint32_t frontBuffer)
#endif
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp (132741 => 132742)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp 2012-10-28 01:31:06 UTC (rev 132741)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp 2012-10-28 01:32:58 UTC (rev 132742)
@@ -89,6 +89,9 @@
, m_rootLayerID(InvalidWebLayerID)
, m_isActive(false)
, m_animationsLocked(false)
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ , m_animationFrameRequested(false)
+#endif
{
}
@@ -138,8 +141,28 @@
if (layer->descendantsOrSelfHaveRunningAnimations())
dispatchOnMainThread(bind(&LayerTreeRenderer::updateViewport, this));
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ if (m_animationFrameRequested) {
+ m_animationFrameRequested = false;
+ dispatchOnMainThread(bind(&LayerTreeRenderer::animationFrameReady, this));
+ }
+#endif
}
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+void LayerTreeRenderer::animationFrameReady()
+{
+ if (m_layerTreeCoordinatorProxy)
+ m_layerTreeCoordinatorProxy->animationFrameReady();
+}
+
+void LayerTreeRenderer::requestAnimationFrame()
+{
+ m_animationFrameRequested = true;
+}
+#endif
+
void LayerTreeRenderer::paintToGraphicsContext(BackingStore::PlatformGraphicsContext painter)
{
if (!m_textureMapper)
Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h (132741 => 132742)
--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h 2012-10-28 01:31:06 UTC (rev 132741)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h 2012-10-28 01:32:58 UTC (rev 132742)
@@ -95,6 +95,12 @@
void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&);
void setAnimationsLocked(bool);
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ void requestAnimationFrame();
+ void animationFrameReady();
+#endif
+
private:
PassOwnPtr<WebCore::GraphicsLayer> createLayer(WebLayerID);
@@ -148,6 +154,9 @@
WebCore::IntPoint m_pendingRenderedContentsScrollPosition;
bool m_isActive;
bool m_animationsLocked;
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ bool m_animationFrameRequested;
+#endif
};
};
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp (132741 => 132742)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp 2012-10-28 01:31:06 UTC (rev 132741)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp 2012-10-28 01:32:58 UTC (rev 132742)
@@ -651,10 +651,17 @@
return this;
}
+#if ENABLE(REQUEST_ANIMATION_FRAME)
void LayerTreeCoordinator::scheduleAnimation()
{
+ m_webPage->send(Messages::LayerTreeCoordinatorProxy::RequestAnimationFrame());
+}
+
+void LayerTreeCoordinator::animationFrameReady()
+{
scheduleLayerFlush();
}
+#endif
void LayerTreeCoordinator::renderNextFrame()
{
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h (132741 => 132742)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h 2012-10-28 01:31:06 UTC (rev 132741)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h 2012-10-28 01:32:58 UTC (rev 132742)
@@ -96,7 +96,10 @@
virtual void syncFixedLayers();
virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&);
+
+#if ENABLE(REQUEST_ANIMATION_FRAME)
virtual void scheduleAnimation() OVERRIDE;
+#endif
protected:
explicit LayerTreeCoordinator(WebPage*);
@@ -126,6 +129,10 @@
void layerFlushTimerFired(WebCore::Timer<LayerTreeCoordinator>*);
void scheduleReleaseInactiveAtlases();
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ void animationFrameReady();
+#endif
+
void releaseInactiveAtlasesTimerFired(WebCore::Timer<LayerTreeCoordinator>*);
OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.messages.in (132741 => 132742)
--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.messages.in 2012-10-28 01:31:06 UTC (rev 132741)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.messages.in 2012-10-28 01:32:58 UTC (rev 132742)
@@ -23,5 +23,8 @@
SetVisibleContentsRect(WebCore::IntRect visibleContentsRect, float scale, WebCore::FloatPoint trajectoryVectory)
RenderNextFrame()
PurgeBackingStores()
+#if ENABLE(REQUEST_ANIMATION_FRAME)
+ AnimationFrameReady()
+#endif
}
#endif