<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[171154] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/171154">171154</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-07-16 15:26:56 -0700 (Wed, 16 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS][WK2] Synchronize the dynamic viewport updates with their layer tree commit
https://bugs.webkit.org/show_bug.cgi?id=134965
Related to &lt;rdar://problem/17082607&gt;

Patch by Benjamin Poulain &lt;bpoulain@apple.com&gt; on 2014-07-16
Reviewed by Tim Horton.

Dynamic viewport update relies on the _resizeAnimationTransformAdjustments being applied
to the page at the new size during the transition.

Because of the races between the LayerTree Commit and DynamicViewportSizeUpdate, the transform
can be applied to the wrong set of tiles.
This is mostly a problem for unresponsive WebProcess or when the synchronization is done
immediately.

There is at least one more case that is not handled: if synchronizeDynamicViewportUpdate()
completely fails to get the new page, the UIProcess is in a somewhat messy state.
I will look into that separately than the layer tree synchronization.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didCommitLayerTree:]):
(-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:nextValidLayerTreeTransactionID:]):
(-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::resetState):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::dynamicViewportUpdateChangedTarget):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::dynamicViewportSizeUpdate):
(WebKit::WebPageProxy::synchronizeDynamicViewportUpdate):
(WebKit::WebPageProxy::didCommitLayerTree):
(WebKit::WebPageProxy::dynamicViewportUpdateChangedTarget):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::didCommitLoad):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::synchronizeDynamicViewportUpdate):
(WebKit::WebPage::updateVisibleContentRects):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
(WebKit::RemoteLayerTreeDrawingArea::nextTransactionID):
(WebKit::RemoteLayerTreeDrawingArea::currentTransactionID): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSh">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreah">trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/ChangeLog        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -1,3 +1,53 @@
</span><ins>+2014-07-16  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
+        [iOS][WK2] Synchronize the dynamic viewport updates with their layer tree commit
+        https://bugs.webkit.org/show_bug.cgi?id=134965
+        Related to &lt;rdar://problem/17082607&gt;
+
+        Reviewed by Tim Horton.
+
+        Dynamic viewport update relies on the _resizeAnimationTransformAdjustments being applied
+        to the page at the new size during the transition.
+
+        Because of the races between the LayerTree Commit and DynamicViewportSizeUpdate, the transform
+        can be applied to the wrong set of tiles.
+        This is mostly a problem for unresponsive WebProcess or when the synchronization is done
+        immediately.
+
+        There is at least one more case that is not handled: if synchronizeDynamicViewportUpdate()
+        completely fails to get the new page, the UIProcess is in a somewhat messy state.
+        I will look into that separately than the layer tree synchronization.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _didCommitLayerTree:]):
+        (-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:nextValidLayerTreeTransactionID:]):
+        (-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:]): Deleted.
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::resetState):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::dynamicViewportUpdateChangedTarget):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::dynamicViewportSizeUpdate):
+        (WebKit::WebPageProxy::synchronizeDynamicViewportUpdate):
+        (WebKit::WebPageProxy::didCommitLayerTree):
+        (WebKit::WebPageProxy::dynamicViewportUpdateChangedTarget):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        (WebKit::WebPage::didCommitLoad):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::synchronizeDynamicViewportUpdate):
+        (WebKit::WebPage::updateVisibleContentRects):
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
+        (WebKit::RemoteLayerTreeDrawingArea::nextTransactionID):
+        (WebKit::RemoteLayerTreeDrawingArea::currentTransactionID): Deleted.
+
</ins><span class="cx"> 2014-07-16  Dan Bernstein  &lt;mitz@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r170653): Web Content service’s Info.plist has wrong format
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -170,6 +170,7 @@
</span><span class="cx">     uint64_t _firstPaintAfterCommitLoadTransactionID;
</span><span class="cx">     BOOL _isAnimatingResize;
</span><span class="cx">     CATransform3D _resizeAnimationTransformAdjustments;
</span><ins>+    uint64_t _resizeAnimationTransformTransactionID;
</ins><span class="cx">     RetainPtr&lt;UIView&gt; _resizeAnimationView;
</span><span class="cx">     CGFloat _lastAdjustmentForScroller;
</span><span class="cx"> 
</span><span class="lines">@@ -804,7 +805,8 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (_isAnimatingResize) {
</span><del>-        [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments;
</del><ins>+        if (layerTreeTransaction.transactionID() &gt;= _resizeAnimationTransformTransactionID)
+            [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments;
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -865,7 +867,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition
</del><ins>+- (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID
</ins><span class="cx"> {
</span><span class="cx">     if (_isAnimatingResize) {
</span><span class="cx">         CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11;
</span><span class="lines">@@ -878,6 +880,7 @@
</span><span class="cx"> 
</span><span class="cx">         _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / animatingScaleTarget;
</span><span class="cx">         _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / animatingScaleTarget;
</span><ins>+        _resizeAnimationTransformTransactionID = nextValidLayerTreeTransactionID;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx"> - (void)_didCommitLoadForMainFrame;
</span><span class="cx"> - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&amp;)layerTreeTransaction;
</span><span class="cx"> 
</span><del>-- (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition;
</del><ins>+- (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID;
</ins><span class="cx"> - (void)_restorePageStateToExposedRect:(WebCore::FloatRect)exposedRect scale:(double)scale;
</span><span class="cx"> - (void)_restorePageStateToUnobscuredCenter:(WebCore::FloatPoint)center scale:(double)scale;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -253,7 +253,7 @@
</span><span class="cx">     virtual void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color&amp;, const Vector&lt;WebCore::FloatQuad&gt;&amp; highlightedQuads, const WebCore::IntSize&amp; topLeftRadius, const WebCore::IntSize&amp; topRightRadius, const WebCore::IntSize&amp; bottomLeftRadius, const WebCore::IntSize&amp; bottomRightRadius) = 0;
</span><span class="cx"> 
</span><span class="cx">     virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&amp;) = 0;
</span><del>-    virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint&amp; newScrollPosition) = 0;
</del><ins>+    virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint&amp; newScrollPosition, uint64_t transactionID) = 0;
</ins><span class="cx">     virtual void restorePageState(const WebCore::FloatRect&amp;, double) = 0;
</span><span class="cx">     virtual void restorePageCenterAndScale(const WebCore::FloatPoint&amp;, double) = 0;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -274,7 +274,9 @@
</span><span class="cx">     , m_userAgent(standardUserAgent())
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     , m_deviceOrientation(0)
</span><del>-    , m_dynamicViewportSizeUpdateInProgress(false)
</del><ins>+    , m_dynamicViewportSizeUpdateWaitingForTarget(false)
+    , m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit(false)
+    , m_dynamicViewportSizeUpdateLayerTreeTransactionID(0)
</ins><span class="cx"> #endif
</span><span class="cx">     , m_geolocationPermissionRequestManager(*this)
</span><span class="cx">     , m_notificationPermissionRequestManager(*this)
</span><span class="lines">@@ -4344,7 +4346,9 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_lastVisibleContentRectUpdate = VisibleContentRectUpdateInfo();
</span><del>-    m_dynamicViewportSizeUpdateInProgress = false;
</del><ins>+    m_dynamicViewportSizeUpdateWaitingForTarget = false;
+    m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;
+    m_dynamicViewportSizeUpdateLayerTreeTransactionID = 0;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     CallbackBase::Error error;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -1322,7 +1322,9 @@
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenManagerProxy&gt; m_videoFullscreenManager;
</span><span class="cx">     VisibleContentRectUpdateInfo m_lastVisibleContentRectUpdate;
</span><span class="cx">     int32_t m_deviceOrientation;
</span><del>-    bool m_dynamicViewportSizeUpdateInProgress;
</del><ins>+    bool m_dynamicViewportSizeUpdateWaitingForTarget;
+    bool m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit;
+    uint64_t m_dynamicViewportSizeUpdateLayerTreeTransactionID;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIBRATION)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -113,7 +113,7 @@
</span><span class="cx">     virtual void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color&amp;, const Vector&lt;WebCore::FloatQuad&gt;&amp; highlightedQuads, const WebCore::IntSize&amp; topLeftRadius, const WebCore::IntSize&amp; topRightRadius, const WebCore::IntSize&amp; bottomLeftRadius, const WebCore::IntSize&amp; bottomRightRadius) override;
</span><span class="cx"> 
</span><span class="cx">     virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&amp;) override;
</span><del>-    virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint&amp; newScrollPosition) override;
</del><ins>+    virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint&amp; newScrollPosition, uint64_t transactionID) override;
</ins><span class="cx">     virtual void restorePageState(const WebCore::FloatRect&amp;, double) override;
</span><span class="cx">     virtual void restorePageCenterAndScale(const WebCore::FloatPoint&amp;, double) override;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -496,9 +496,9 @@
</span><span class="cx">     [m_contentView _didCommitLayerTree:layerTreeTransaction];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PageClientImpl::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint&amp; newScrollPosition)
</del><ins>+void PageClientImpl::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint&amp; newScrollPosition, uint64_t nextValidLayerTreeTransactionID)
</ins><span class="cx"> {
</span><del>-    [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition];
</del><ins>+    [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition nextValidLayerTreeTransactionID:nextValidLayerTreeTransactionID];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::restorePageState(const WebCore::FloatRect&amp; exposedRect, double scale)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -250,13 +250,14 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::dynamicViewportSizeUpdate(const FloatSize&amp; minimumLayoutSize, const WebCore::FloatSize&amp; minimumLayoutSizeForMinimalUI, const WebCore::FloatSize&amp; maximumUnobscuredSize, const FloatRect&amp; targetExposedContentRect, const FloatRect&amp; targetUnobscuredRect, const FloatRect&amp; targetUnobscuredRectInScrollViewCoordinates,  double targetScale, int32_t deviceOrientation)
</span><span class="cx"> {
</span><del>-    m_dynamicViewportSizeUpdateInProgress = true;
</del><ins>+    m_dynamicViewportSizeUpdateWaitingForTarget = true;
+    m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = true;
</ins><span class="cx">     m_process-&gt;send(Messages::WebPage::DynamicViewportSizeUpdate(minimumLayoutSize, minimumLayoutSizeForMinimalUI, maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, targetUnobscuredRectInScrollViewCoordinates, targetScale, deviceOrientation), m_pageID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::synchronizeDynamicViewportUpdate()
</span><span class="cx"> {
</span><del>-    if (m_dynamicViewportSizeUpdateInProgress) {
</del><ins>+    if (m_dynamicViewportSizeUpdateWaitingForTarget) {
</ins><span class="cx">         // We do not want the UIProcess to finish animated resize with the old content size, scale, etc.
</span><span class="cx">         // If that happens, the UIProcess would start pushing new VisibleContentRectUpdateInfo to the WebProcess with
</span><span class="cx">         // invalid informations.
</span><span class="lines">@@ -268,15 +269,24 @@
</span><span class="cx">         //
</span><span class="cx">         // The following is a workaround to have the UIProcess in a consistent state.
</span><span class="cx">         // Instead of handling nested resize, we block the UIProcess until the animated resize finishes.
</span><del>-        m_dynamicViewportSizeUpdateInProgress = false;
</del><span class="cx">         double newScale;
</span><span class="cx">         FloatPoint newScrollPosition;
</span><del>-        if (m_process-&gt;sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition), m_pageID, std::chrono::seconds(2))) {
-            m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition);
</del><ins>+        uint64_t nextValidLayerTreeTransactionID;
+        if (m_process-&gt;sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition, nextValidLayerTreeTransactionID), m_pageID, std::chrono::seconds(2))) {
+            m_dynamicViewportSizeUpdateWaitingForTarget = false;
+            m_dynamicViewportSizeUpdateLayerTreeTransactionID = nextValidLayerTreeTransactionID;
+            m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, nextValidLayerTreeTransactionID);
+        }
</ins><span class="cx"> 
</span><del>-            m_process-&gt;connection()-&gt;waitForAndDispatchImmediately&lt;Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree&gt;(m_pageID, std::chrono::seconds(1));
-        }
</del><span class="cx">     }
</span><ins>+
+    // If m_dynamicViewportSizeUpdateWaitingForTarget is false, we are waiting for the next valid frame with the hope it is the one for the new target.
+    // If m_dynamicViewportSizeUpdateWaitingForTarget is still true, this is a desesperate attempt to get the valid frame before finishing the animation.
+    if (m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit)
+        m_process-&gt;connection()-&gt;waitForAndDispatchImmediately&lt;Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree&gt;(m_pageID, std::chrono::seconds(1), IPC::InterruptWaitingIfSyncMessageArrives);
+
+    m_dynamicViewportSizeUpdateWaitingForTarget = false;
+    m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize&amp; size)
</span><span class="lines">@@ -307,6 +317,11 @@
</span><span class="cx"> {
</span><span class="cx">     m_pageExtendedBackgroundColor = layerTreeTransaction.pageExtendedBackgroundColor();
</span><span class="cx"> 
</span><ins>+    if (!m_dynamicViewportSizeUpdateWaitingForTarget &amp;&amp; m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit) {
+        if (layerTreeTransaction.transactionID() &gt;= m_dynamicViewportSizeUpdateLayerTreeTransactionID)
+            m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;
+    }
+
</ins><span class="cx">     m_pageClient.didCommitLayerTree(layerTreeTransaction);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -616,9 +631,10 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint&amp; newScrollPosition)
</span><span class="cx"> {
</span><del>-    if (m_dynamicViewportSizeUpdateInProgress) {
-        m_dynamicViewportSizeUpdateInProgress = false;
-        m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition);
</del><ins>+    if (m_dynamicViewportSizeUpdateWaitingForTarget) {
+        m_dynamicViewportSizeUpdateLayerTreeTransactionID = toRemoteLayerTreeDrawingAreaProxy(drawingArea())-&gt;nextLayerTreeTransactionID();
+        m_dynamicViewportSizeUpdateWaitingForTarget = false;
+        m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, m_dynamicViewportSizeUpdateLayerTreeTransactionID);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -296,7 +296,7 @@
</span><span class="cx">     , m_isShowingContextMenu(false)
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-    , m_lastLayerTreeTransactionIDBeforeDidCommitLoad(0)
</del><ins>+    , m_firstLayerTreeTransactionIDAfterDidCommitLoad(0)
</ins><span class="cx">     , m_hasReceivedVisibleContentRectsAfterDidCommitLoad(false)
</span><span class="cx">     , m_scaleWasSetByUIProcess(false)
</span><span class="cx">     , m_userHasChangedPageScaleFactor(false)
</span><span class="lines">@@ -4447,7 +4447,7 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     m_hasReceivedVisibleContentRectsAfterDidCommitLoad = false;
</span><span class="cx">     m_scaleWasSetByUIProcess = false;
</span><del>-    m_lastLayerTreeTransactionIDBeforeDidCommitLoad = toRemoteLayerTreeDrawingArea(*m_drawingArea).currentTransactionID();
</del><ins>+    m_firstLayerTreeTransactionIDAfterDidCommitLoad = toRemoteLayerTreeDrawingArea(*m_drawingArea).nextTransactionID();
</ins><span class="cx">     m_userHasChangedPageScaleFactor = false;
</span><span class="cx"> 
</span><span class="cx">     WebProcess::shared().eventDispatcher().clearQueuedTouchEventsForPage(*this);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -747,7 +747,7 @@
</span><span class="cx">     void setMaximumUnobscuredSize(const WebCore::FloatSize&amp;);
</span><span class="cx">     void setDeviceOrientation(int32_t);
</span><span class="cx">     void dynamicViewportSizeUpdate(const WebCore::FloatSize&amp; minimumLayoutSize, const WebCore::FloatSize&amp; minimumLayoutSizeForMinimalUI, const WebCore::FloatSize&amp; maximumUnobscuredSize, const WebCore::FloatRect&amp; targetExposedContentRect, const WebCore::FloatRect&amp; targetUnobscuredRect, const WebCore::FloatRect&amp; targetUnobscuredRectInScrollViewCoordinates, double scale, int32_t deviceOrientation);
</span><del>-    void synchronizeDynamicViewportUpdate(double&amp; newTargetScale, WebCore::FloatPoint&amp; newScrollPosition);
</del><ins>+    void synchronizeDynamicViewportUpdate(double&amp; newTargetScale, WebCore::FloatPoint&amp; newScrollPosition, uint64_t&amp; nextValidLayerTreeTransactionID);
</ins><span class="cx">     void updateVisibleContentRects(const VisibleContentRectUpdateInfo&amp;);
</span><span class="cx">     bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
</span><span class="cx">     void willStartUserTriggeredZooming();
</span><span class="lines">@@ -1225,7 +1225,7 @@
</span><span class="cx">     WebCore::FloatPoint m_potentialTapLocation;
</span><span class="cx"> 
</span><span class="cx">     WebCore::ViewportConfiguration m_viewportConfiguration;
</span><del>-    uint64_t m_lastLayerTreeTransactionIDBeforeDidCommitLoad;
</del><ins>+    uint64_t m_firstLayerTreeTransactionIDAfterDidCommitLoad;
</ins><span class="cx">     bool m_hasReceivedVisibleContentRectsAfterDidCommitLoad;
</span><span class="cx">     bool m_scaleWasSetByUIProcess;
</span><span class="cx">     bool m_userHasChangedPageScaleFactor;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx">     SetMaximumUnobscuredSize(WebCore::FloatSize size)
</span><span class="cx">     SetDeviceOrientation(int32_t deviceOrientation)
</span><span class="cx">     DynamicViewportSizeUpdate(WebCore::FloatSize minimumLayoutSize, WebCore::FloatSize minimumLayoutSizeForMinimalUI,  WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, double scale, int32_t deviceOrientation)
</span><del>-    SynchronizeDynamicViewportUpdate() -&gt; (double newTargetScale, WebCore::FloatPoint newScrollPosition)
</del><ins>+    SynchronizeDynamicViewportUpdate() -&gt; (double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t nextValidLayerTreeTransactionID)
</ins><span class="cx"> 
</span><span class="cx">     HandleTap(WebCore::IntPoint point)
</span><span class="cx">     PotentialTapAtPosition(uint64_t requestID, WebCore::FloatPoint point)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #import &quot;InjectedBundleUserMessageCoders.h&quot;
</span><span class="cx"> #import &quot;InteractionInformationAtPosition.h&quot;
</span><span class="cx"> #import &quot;PluginView.h&quot;
</span><ins>+#import &quot;RemoteLayerTreeDrawingArea.h&quot;
</ins><span class="cx"> #import &quot;VisibleContentRectUpdateInfo.h&quot;
</span><span class="cx"> #import &quot;WKAccessibilityWebPageObjectIOS.h&quot;
</span><span class="cx"> #import &quot;WebChromeClient.h&quot;
</span><span class="lines">@@ -2324,10 +2325,11 @@
</span><span class="cx">     send(Messages::WebPageProxy::DynamicViewportUpdateChangedTarget(pageScaleFactor(), frameView.scrollPosition()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPage::synchronizeDynamicViewportUpdate(double&amp; newTargetScale, FloatPoint&amp; newScrollPosition)
</del><ins>+void WebPage::synchronizeDynamicViewportUpdate(double&amp; newTargetScale, FloatPoint&amp; newScrollPosition, uint64_t&amp; nextValidLayerTreeTransactionID)
</ins><span class="cx"> {
</span><span class="cx">     newTargetScale = pageScaleFactor();
</span><span class="cx">     newScrollPosition = m_page-&gt;mainFrame().view()-&gt;scrollPosition();
</span><ins>+    nextValidLayerTreeTransactionID = toRemoteLayerTreeDrawingArea(*m_drawingArea).nextTransactionID();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::resetViewportDefaultConfiguration(WebFrame* frame)
</span><span class="lines">@@ -2437,7 +2439,7 @@
</span><span class="cx"> void WebPage::updateVisibleContentRects(const VisibleContentRectUpdateInfo&amp; visibleContentRectUpdateInfo)
</span><span class="cx"> {
</span><span class="cx">     // Skip any VisibleContentRectUpdate that have been queued before DidCommitLoad suppresses the updates in the UIProcess.
</span><del>-    if (visibleContentRectUpdateInfo.lastLayerTreeTransactionID() &lt;= m_lastLayerTreeTransactionIDBeforeDidCommitLoad)
</del><ins>+    if (visibleContentRectUpdateInfo.lastLayerTreeTransactionID() &lt;= m_firstLayerTreeTransactionIDAfterDidCommitLoad)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_hasReceivedVisibleContentRectsAfterDidCommitLoad = true;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h (171153 => 171154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h        2014-07-16 21:33:05 UTC (rev 171153)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h        2014-07-16 22:26:56 UTC (rev 171154)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx">     RemoteLayerTreeDrawingArea(WebPage&amp;, const WebPageCreationParameters&amp;);
</span><span class="cx">     virtual ~RemoteLayerTreeDrawingArea();
</span><span class="cx"> 
</span><del>-    uint64_t currentTransactionID() const { return m_currentTransactionID; }
</del><ins>+    uint64_t nextTransactionID() const { return m_currentTransactionID + 1; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     // DrawingArea
</span></span></pre>
</div>
</div>

</body>
</html>