[iOS][WK2] Synchronize the dynamic viewport updates with their layer tree commit
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jul 2014 22:26:56 +0000 (22:26 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Jul 2014 22:26:56 +0000 (22:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134965
Related to <rdar://problem/17082607>

Patch by Benjamin Poulain <bpoulain@apple.com> 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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@171154 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h

index ab33575..d6eb55a 100644 (file)
@@ -1,3 +1,53 @@
+2014-07-16  Benjamin Poulain  <bpoulain@apple.com>
+
+        [iOS][WK2] Synchronize the dynamic viewport updates with their layer tree commit
+        https://bugs.webkit.org/show_bug.cgi?id=134965
+        Related to <rdar://problem/17082607>
+
+        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.
+
 2014-07-16  Dan Bernstein  <mitz@apple.com>
 
         REGRESSION (r170653): Web Content service‚Äôs Info.plist has wrong format
index 48c2472..c596fa1 100644 (file)
@@ -170,6 +170,7 @@ WKWebView* fromWebPageProxy(WebKit::WebPageProxy& page)
     uint64_t _firstPaintAfterCommitLoadTransactionID;
     BOOL _isAnimatingResize;
     CATransform3D _resizeAnimationTransformAdjustments;
+    uint64_t _resizeAnimationTransformTransactionID;
     RetainPtr<UIView> _resizeAnimationView;
     CGFloat _lastAdjustmentForScroller;
 
@@ -804,7 +805,8 @@ static inline bool withinEpsilon(TypeA a, TypeB b)
         return;
 
     if (_isAnimatingResize) {
-        [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments;
+        if (layerTreeTransaction.transactionID() >= _resizeAnimationTransformTransactionID)
+            [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments;
         return;
     }
 
@@ -865,7 +867,7 @@ static inline bool withinEpsilon(TypeA a, TypeB b)
     }
 }
 
-- (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition
+- (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID
 {
     if (_isAnimatingResize) {
         CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11;
@@ -878,6 +880,7 @@ static inline bool withinEpsilon(TypeA a, TypeB b)
 
         _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / animatingScaleTarget;
         _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / animatingScaleTarget;
+        _resizeAnimationTransformTransactionID = nextValidLayerTreeTransactionID;
     }
 }
 
index 4aa9797..1efa185 100644 (file)
@@ -74,7 +74,7 @@ struct PrintInfo;
 - (void)_didCommitLoadForMainFrame;
 - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction;
 
-- (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition;
+- (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID;
 - (void)_restorePageStateToExposedRect:(WebCore::FloatRect)exposedRect scale:(double)scale;
 - (void)_restorePageStateToUnobscuredCenter:(WebCore::FloatPoint)center scale:(double)scale;
 
index cf16c9f..68c13f0 100644 (file)
@@ -253,7 +253,7 @@ public:
     virtual void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color&, const Vector<WebCore::FloatQuad>& highlightedQuads, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius) = 0;
 
     virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&) = 0;
-    virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition) = 0;
+    virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) = 0;
     virtual void restorePageState(const WebCore::FloatRect&, double) = 0;
     virtual void restorePageCenterAndScale(const WebCore::FloatPoint&, double) = 0;
 
index 54c3e95..208e117 100644 (file)
@@ -274,7 +274,9 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
     , m_userAgent(standardUserAgent())
 #if PLATFORM(IOS)
     , m_deviceOrientation(0)
-    , m_dynamicViewportSizeUpdateInProgress(false)
+    , m_dynamicViewportSizeUpdateWaitingForTarget(false)
+    , m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit(false)
+    , m_dynamicViewportSizeUpdateLayerTreeTransactionID(0)
 #endif
     , m_geolocationPermissionRequestManager(*this)
     , m_notificationPermissionRequestManager(*this)
@@ -4344,7 +4346,9 @@ void WebPageProxy::resetState(ResetStateReason resetStateReason)
     }
 
     m_lastVisibleContentRectUpdate = VisibleContentRectUpdateInfo();
-    m_dynamicViewportSizeUpdateInProgress = false;
+    m_dynamicViewportSizeUpdateWaitingForTarget = false;
+    m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;
+    m_dynamicViewportSizeUpdateLayerTreeTransactionID = 0;
 #endif
 
     CallbackBase::Error error;
index c23d564..498df30 100644 (file)
@@ -1322,7 +1322,9 @@ private:
     RefPtr<WebVideoFullscreenManagerProxy> m_videoFullscreenManager;
     VisibleContentRectUpdateInfo m_lastVisibleContentRectUpdate;
     int32_t m_deviceOrientation;
-    bool m_dynamicViewportSizeUpdateInProgress;
+    bool m_dynamicViewportSizeUpdateWaitingForTarget;
+    bool m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit;
+    uint64_t m_dynamicViewportSizeUpdateLayerTreeTransactionID;
 #endif
 
 #if ENABLE(VIBRATION)
index d04bac5..18ef1f4 100644 (file)
@@ -113,7 +113,7 @@ private:
     virtual void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color&, const Vector<WebCore::FloatQuad>& highlightedQuads, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius) override;
 
     virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&) override;
-    virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition) override;
+    virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) override;
     virtual void restorePageState(const WebCore::FloatRect&, double) override;
     virtual void restorePageCenterAndScale(const WebCore::FloatPoint&, double) override;
 
index ba95af8..20a3553 100644 (file)
@@ -496,9 +496,9 @@ void PageClientImpl::didCommitLayerTree(const RemoteLayerTreeTransaction& layerT
     [m_contentView _didCommitLayerTree:layerTreeTransaction];
 }
 
-void PageClientImpl::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition)
+void PageClientImpl::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t nextValidLayerTreeTransactionID)
 {
-    [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition];
+    [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition nextValidLayerTreeTransactionID:nextValidLayerTreeTransactionID];
 }
 
 void PageClientImpl::restorePageState(const WebCore::FloatRect& exposedRect, double scale)
index 6a9e6f1..879842c 100644 (file)
@@ -250,13 +250,14 @@ void WebPageProxy::overflowScrollViewDidScroll()
 
 void WebPageProxy::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, const WebCore::FloatSize& minimumLayoutSizeForMinimalUI, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const FloatRect& targetUnobscuredRectInScrollViewCoordinates,  double targetScale, int32_t deviceOrientation)
 {
-    m_dynamicViewportSizeUpdateInProgress = true;
+    m_dynamicViewportSizeUpdateWaitingForTarget = true;
+    m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = true;
     m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(minimumLayoutSize, minimumLayoutSizeForMinimalUI, maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, targetUnobscuredRectInScrollViewCoordinates, targetScale, deviceOrientation), m_pageID);
 }
 
 void WebPageProxy::synchronizeDynamicViewportUpdate()
 {
-    if (m_dynamicViewportSizeUpdateInProgress) {
+    if (m_dynamicViewportSizeUpdateWaitingForTarget) {
         // We do not want the UIProcess to finish animated resize with the old content size, scale, etc.
         // If that happens, the UIProcess would start pushing new VisibleContentRectUpdateInfo to the WebProcess with
         // invalid informations.
@@ -268,15 +269,24 @@ void WebPageProxy::synchronizeDynamicViewportUpdate()
         //
         // The following is a workaround to have the UIProcess in a consistent state.
         // Instead of handling nested resize, we block the UIProcess until the animated resize finishes.
-        m_dynamicViewportSizeUpdateInProgress = false;
         double newScale;
         FloatPoint newScrollPosition;
-        if (m_process->sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition), m_pageID, std::chrono::seconds(2))) {
-            m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition);
-
-            m_process->connection()->waitForAndDispatchImmediately<Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree>(m_pageID, std::chrono::seconds(1));
+        uint64_t nextValidLayerTreeTransactionID;
+        if (m_process->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);
         }
+
     }
+
+    // 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->connection()->waitForAndDispatchImmediately<Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree>(m_pageID, std::chrono::seconds(1), IPC::InterruptWaitingIfSyncMessageArrives);
+
+    m_dynamicViewportSizeUpdateWaitingForTarget = false;
+    m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;
 }
 
 void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::FloatSize& size)
@@ -307,6 +317,11 @@ void WebPageProxy::didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction&
 {
     m_pageExtendedBackgroundColor = layerTreeTransaction.pageExtendedBackgroundColor();
 
+    if (!m_dynamicViewportSizeUpdateWaitingForTarget && m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit) {
+        if (layerTreeTransaction.transactionID() >= m_dynamicViewportSizeUpdateLayerTreeTransactionID)
+            m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;
+    }
+
     m_pageClient.didCommitLayerTree(layerTreeTransaction);
 }
 
@@ -616,9 +631,10 @@ float WebPageProxy::textAutosizingWidth()
 
 void WebPageProxy::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition)
 {
-    if (m_dynamicViewportSizeUpdateInProgress) {
-        m_dynamicViewportSizeUpdateInProgress = false;
-        m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition);
+    if (m_dynamicViewportSizeUpdateWaitingForTarget) {
+        m_dynamicViewportSizeUpdateLayerTreeTransactionID = toRemoteLayerTreeDrawingAreaProxy(drawingArea())->nextLayerTreeTransactionID();
+        m_dynamicViewportSizeUpdateWaitingForTarget = false;
+        m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, m_dynamicViewportSizeUpdateLayerTreeTransactionID);
     }
 }
 
index f788c3d..f73680e 100644 (file)
@@ -296,7 +296,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
     , m_isShowingContextMenu(false)
 #endif
 #if PLATFORM(IOS)
-    , m_lastLayerTreeTransactionIDBeforeDidCommitLoad(0)
+    , m_firstLayerTreeTransactionIDAfterDidCommitLoad(0)
     , m_hasReceivedVisibleContentRectsAfterDidCommitLoad(false)
     , m_scaleWasSetByUIProcess(false)
     , m_userHasChangedPageScaleFactor(false)
@@ -4447,7 +4447,7 @@ void WebPage::didCommitLoad(WebFrame* frame)
 #if PLATFORM(IOS)
     m_hasReceivedVisibleContentRectsAfterDidCommitLoad = false;
     m_scaleWasSetByUIProcess = false;
-    m_lastLayerTreeTransactionIDBeforeDidCommitLoad = toRemoteLayerTreeDrawingArea(*m_drawingArea).currentTransactionID();
+    m_firstLayerTreeTransactionIDAfterDidCommitLoad = toRemoteLayerTreeDrawingArea(*m_drawingArea).nextTransactionID();
     m_userHasChangedPageScaleFactor = false;
 
     WebProcess::shared().eventDispatcher().clearQueuedTouchEventsForPage(*this);
index e16220f..436ecb0 100644 (file)
@@ -747,7 +747,7 @@ public:
     void setMaximumUnobscuredSize(const WebCore::FloatSize&);
     void setDeviceOrientation(int32_t);
     void dynamicViewportSizeUpdate(const WebCore::FloatSize& minimumLayoutSize, const WebCore::FloatSize& minimumLayoutSizeForMinimalUI, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, double scale, int32_t deviceOrientation);
-    void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition);
+    void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID);
     void updateVisibleContentRects(const VisibleContentRectUpdateInfo&);
     bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
     void willStartUserTriggeredZooming();
@@ -1225,7 +1225,7 @@ private:
     WebCore::FloatPoint m_potentialTapLocation;
 
     WebCore::ViewportConfiguration m_viewportConfiguration;
-    uint64_t m_lastLayerTreeTransactionIDBeforeDidCommitLoad;
+    uint64_t m_firstLayerTreeTransactionIDAfterDidCommitLoad;
     bool m_hasReceivedVisibleContentRectsAfterDidCommitLoad;
     bool m_scaleWasSetByUIProcess;
     bool m_userHasChangedPageScaleFactor;
index fc6c09f..3170d81 100644 (file)
@@ -48,7 +48,7 @@ messages -> WebPage LegacyReceiver {
     SetMaximumUnobscuredSize(WebCore::FloatSize size)
     SetDeviceOrientation(int32_t deviceOrientation)
     DynamicViewportSizeUpdate(WebCore::FloatSize minimumLayoutSize, WebCore::FloatSize minimumLayoutSizeForMinimalUI,  WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, double scale, int32_t deviceOrientation)
-    SynchronizeDynamicViewportUpdate() -> (double newTargetScale, WebCore::FloatPoint newScrollPosition)
+    SynchronizeDynamicViewportUpdate() -> (double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t nextValidLayerTreeTransactionID)
 
     HandleTap(WebCore::IntPoint point)
     PotentialTapAtPosition(uint64_t requestID, WebCore::FloatPoint point)
index 87fa039..2dc5e36 100644 (file)
@@ -37,6 +37,7 @@
 #import "InjectedBundleUserMessageCoders.h"
 #import "InteractionInformationAtPosition.h"
 #import "PluginView.h"
+#import "RemoteLayerTreeDrawingArea.h"
 #import "VisibleContentRectUpdateInfo.h"
 #import "WKAccessibilityWebPageObjectIOS.h"
 #import "WebChromeClient.h"
@@ -2324,10 +2325,11 @@ void WebPage::dynamicViewportSizeUpdate(const FloatSize& minimumLayoutSize, cons
     send(Messages::WebPageProxy::DynamicViewportUpdateChangedTarget(pageScaleFactor(), frameView.scrollPosition()));
 }
 
-void WebPage::synchronizeDynamicViewportUpdate(double& newTargetScale, FloatPoint& newScrollPosition)
+void WebPage::synchronizeDynamicViewportUpdate(double& newTargetScale, FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID)
 {
     newTargetScale = pageScaleFactor();
     newScrollPosition = m_page->mainFrame().view()->scrollPosition();
+    nextValidLayerTreeTransactionID = toRemoteLayerTreeDrawingArea(*m_drawingArea).nextTransactionID();
 }
 
 void WebPage::resetViewportDefaultConfiguration(WebFrame* frame)
@@ -2437,7 +2439,7 @@ static inline FloatRect adjustExposedRectForBoundedScale(const FloatRect& expose
 void WebPage::updateVisibleContentRects(const VisibleContentRectUpdateInfo& visibleContentRectUpdateInfo)
 {
     // Skip any VisibleContentRectUpdate that have been queued before DidCommitLoad suppresses the updates in the UIProcess.
-    if (visibleContentRectUpdateInfo.lastLayerTreeTransactionID() <= m_lastLayerTreeTransactionIDBeforeDidCommitLoad)
+    if (visibleContentRectUpdateInfo.lastLayerTreeTransactionID() <= m_firstLayerTreeTransactionIDAfterDidCommitLoad)
         return;
 
     m_hasReceivedVisibleContentRectsAfterDidCommitLoad = true;
index f2646b3..011ca98 100644 (file)
@@ -54,7 +54,7 @@ public:
     RemoteLayerTreeDrawingArea(WebPage&, const WebPageCreationParameters&);
     virtual ~RemoteLayerTreeDrawingArea();
 
-    uint64_t currentTransactionID() const { return m_currentTransactionID; }
+    uint64_t nextTransactionID() const { return m_currentTransactionID + 1; }
 
 private:
     // DrawingArea