Changeset 171154 in webkit
- Timestamp:
- Jul 16, 2014 3:26:56 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r171146 r171154 1 2014-07-16 Benjamin Poulain <bpoulain@apple.com> 2 3 [iOS][WK2] Synchronize the dynamic viewport updates with their layer tree commit 4 https://bugs.webkit.org/show_bug.cgi?id=134965 5 Related to <rdar://problem/17082607> 6 7 Reviewed by Tim Horton. 8 9 Dynamic viewport update relies on the _resizeAnimationTransformAdjustments being applied 10 to the page at the new size during the transition. 11 12 Because of the races between the LayerTree Commit and DynamicViewportSizeUpdate, the transform 13 can be applied to the wrong set of tiles. 14 This is mostly a problem for unresponsive WebProcess or when the synchronization is done 15 immediately. 16 17 There is at least one more case that is not handled: if synchronizeDynamicViewportUpdate() 18 completely fails to get the new page, the UIProcess is in a somewhat messy state. 19 I will look into that separately than the layer tree synchronization. 20 21 * UIProcess/API/Cocoa/WKWebView.mm: 22 (-[WKWebView _didCommitLayerTree:]): 23 (-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:nextValidLayerTreeTransactionID:]): 24 (-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:]): Deleted. 25 * UIProcess/API/Cocoa/WKWebViewInternal.h: 26 * UIProcess/PageClient.h: 27 * UIProcess/WebPageProxy.cpp: 28 (WebKit::WebPageProxy::WebPageProxy): 29 (WebKit::WebPageProxy::resetState): 30 * UIProcess/WebPageProxy.h: 31 * UIProcess/ios/PageClientImplIOS.h: 32 * UIProcess/ios/PageClientImplIOS.mm: 33 (WebKit::PageClientImpl::dynamicViewportUpdateChangedTarget): 34 * UIProcess/ios/WebPageProxyIOS.mm: 35 (WebKit::WebPageProxy::dynamicViewportSizeUpdate): 36 (WebKit::WebPageProxy::synchronizeDynamicViewportUpdate): 37 (WebKit::WebPageProxy::didCommitLayerTree): 38 (WebKit::WebPageProxy::dynamicViewportUpdateChangedTarget): 39 * WebProcess/WebPage/WebPage.cpp: 40 (WebKit::WebPage::WebPage): 41 (WebKit::WebPage::didCommitLoad): 42 * WebProcess/WebPage/WebPage.h: 43 * WebProcess/WebPage/WebPage.messages.in: 44 * WebProcess/WebPage/ios/WebPageIOS.mm: 45 (WebKit::WebPage::synchronizeDynamicViewportUpdate): 46 (WebKit::WebPage::updateVisibleContentRects): 47 * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h: 48 (WebKit::RemoteLayerTreeDrawingArea::nextTransactionID): 49 (WebKit::RemoteLayerTreeDrawingArea::currentTransactionID): Deleted. 50 1 51 2014-07-16 Dan Bernstein <mitz@apple.com> 2 52 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r171135 r171154 171 171 BOOL _isAnimatingResize; 172 172 CATransform3D _resizeAnimationTransformAdjustments; 173 uint64_t _resizeAnimationTransformTransactionID; 173 174 RetainPtr<UIView> _resizeAnimationView; 174 175 CGFloat _lastAdjustmentForScroller; … … 805 806 806 807 if (_isAnimatingResize) { 807 [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments; 808 if (layerTreeTransaction.transactionID() >= _resizeAnimationTransformTransactionID) 809 [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments; 808 810 return; 809 811 } … … 866 868 } 867 869 868 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition 870 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID 869 871 { 870 872 if (_isAnimatingResize) { … … 879 881 _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / animatingScaleTarget; 880 882 _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / animatingScaleTarget; 883 _resizeAnimationTransformTransactionID = nextValidLayerTreeTransactionID; 881 884 } 882 885 } -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
r170974 r171154 75 75 - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction; 76 76 77 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition ;77 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID; 78 78 - (void)_restorePageStateToExposedRect:(WebCore::FloatRect)exposedRect scale:(double)scale; 79 79 - (void)_restorePageStateToUnobscuredCenter:(WebCore::FloatPoint)center scale:(double)scale; -
trunk/Source/WebKit2/UIProcess/PageClient.h
r171045 r171154 254 254 255 255 virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&) = 0; 256 virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition ) = 0;256 virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) = 0; 257 257 virtual void restorePageState(const WebCore::FloatRect&, double) = 0; 258 258 virtual void restorePageCenterAndScale(const WebCore::FloatPoint&, double) = 0; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r171045 r171154 275 275 #if PLATFORM(IOS) 276 276 , m_deviceOrientation(0) 277 , m_dynamicViewportSizeUpdateInProgress(false) 277 , m_dynamicViewportSizeUpdateWaitingForTarget(false) 278 , m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit(false) 279 , m_dynamicViewportSizeUpdateLayerTreeTransactionID(0) 278 280 #endif 279 281 , m_geolocationPermissionRequestManager(*this) … … 4345 4347 4346 4348 m_lastVisibleContentRectUpdate = VisibleContentRectUpdateInfo(); 4347 m_dynamicViewportSizeUpdateInProgress = false; 4349 m_dynamicViewportSizeUpdateWaitingForTarget = false; 4350 m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false; 4351 m_dynamicViewportSizeUpdateLayerTreeTransactionID = 0; 4348 4352 #endif 4349 4353 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r171124 r171154 1323 1323 VisibleContentRectUpdateInfo m_lastVisibleContentRectUpdate; 1324 1324 int32_t m_deviceOrientation; 1325 bool m_dynamicViewportSizeUpdateInProgress; 1325 bool m_dynamicViewportSizeUpdateWaitingForTarget; 1326 bool m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit; 1327 uint64_t m_dynamicViewportSizeUpdateLayerTreeTransactionID; 1326 1328 #endif 1327 1329 -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
r171045 r171154 114 114 115 115 virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&) override; 116 virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition ) override;116 virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) override; 117 117 virtual void restorePageState(const WebCore::FloatRect&, double) override; 118 118 virtual void restorePageCenterAndScale(const WebCore::FloatPoint&, double) override; -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
r171045 r171154 497 497 } 498 498 499 void PageClientImpl::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition )500 { 501 [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition ];499 void PageClientImpl::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t nextValidLayerTreeTransactionID) 500 { 501 [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition nextValidLayerTreeTransactionID:nextValidLayerTreeTransactionID]; 502 502 } 503 503 -
trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
r171124 r171154 251 251 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) 252 252 { 253 m_dynamicViewportSizeUpdateInProgress = true; 253 m_dynamicViewportSizeUpdateWaitingForTarget = true; 254 m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = true; 254 255 m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(minimumLayoutSize, minimumLayoutSizeForMinimalUI, maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, targetUnobscuredRectInScrollViewCoordinates, targetScale, deviceOrientation), m_pageID); 255 256 } … … 257 258 void WebPageProxy::synchronizeDynamicViewportUpdate() 258 259 { 259 if (m_dynamicViewportSizeUpdate InProgress) {260 if (m_dynamicViewportSizeUpdateWaitingForTarget) { 260 261 // We do not want the UIProcess to finish animated resize with the old content size, scale, etc. 261 262 // If that happens, the UIProcess would start pushing new VisibleContentRectUpdateInfo to the WebProcess with … … 269 270 // The following is a workaround to have the UIProcess in a consistent state. 270 271 // Instead of handling nested resize, we block the UIProcess until the animated resize finishes. 271 m_dynamicViewportSizeUpdateInProgress = false;272 272 double newScale; 273 273 FloatPoint newScrollPosition; 274 if (m_process->sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition), m_pageID, std::chrono::seconds(2))) { 275 m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition); 276 277 m_process->connection()->waitForAndDispatchImmediately<Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree>(m_pageID, std::chrono::seconds(1)); 274 uint64_t nextValidLayerTreeTransactionID; 275 if (m_process->sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition, nextValidLayerTreeTransactionID), m_pageID, std::chrono::seconds(2))) { 276 m_dynamicViewportSizeUpdateWaitingForTarget = false; 277 m_dynamicViewportSizeUpdateLayerTreeTransactionID = nextValidLayerTreeTransactionID; 278 m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, nextValidLayerTreeTransactionID); 278 279 } 279 } 280 281 } 282 283 // If m_dynamicViewportSizeUpdateWaitingForTarget is false, we are waiting for the next valid frame with the hope it is the one for the new target. 284 // If m_dynamicViewportSizeUpdateWaitingForTarget is still true, this is a desesperate attempt to get the valid frame before finishing the animation. 285 if (m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit) 286 m_process->connection()->waitForAndDispatchImmediately<Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree>(m_pageID, std::chrono::seconds(1), IPC::InterruptWaitingIfSyncMessageArrives); 287 288 m_dynamicViewportSizeUpdateWaitingForTarget = false; 289 m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false; 280 290 } 281 291 … … 308 318 m_pageExtendedBackgroundColor = layerTreeTransaction.pageExtendedBackgroundColor(); 309 319 320 if (!m_dynamicViewportSizeUpdateWaitingForTarget && m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit) { 321 if (layerTreeTransaction.transactionID() >= m_dynamicViewportSizeUpdateLayerTreeTransactionID) 322 m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false; 323 } 324 310 325 m_pageClient.didCommitLayerTree(layerTreeTransaction); 311 326 } … … 617 632 void WebPageProxy::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition) 618 633 { 619 if (m_dynamicViewportSizeUpdateInProgress) { 620 m_dynamicViewportSizeUpdateInProgress = false; 621 m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition); 634 if (m_dynamicViewportSizeUpdateWaitingForTarget) { 635 m_dynamicViewportSizeUpdateLayerTreeTransactionID = toRemoteLayerTreeDrawingAreaProxy(drawingArea())->nextLayerTreeTransactionID(); 636 m_dynamicViewportSizeUpdateWaitingForTarget = false; 637 m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, m_dynamicViewportSizeUpdateLayerTreeTransactionID); 622 638 } 623 639 } -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r171057 r171154 297 297 #endif 298 298 #if PLATFORM(IOS) 299 , m_ lastLayerTreeTransactionIDBeforeDidCommitLoad(0)299 , m_firstLayerTreeTransactionIDAfterDidCommitLoad(0) 300 300 , m_hasReceivedVisibleContentRectsAfterDidCommitLoad(false) 301 301 , m_scaleWasSetByUIProcess(false) … … 4448 4448 m_hasReceivedVisibleContentRectsAfterDidCommitLoad = false; 4449 4449 m_scaleWasSetByUIProcess = false; 4450 m_ lastLayerTreeTransactionIDBeforeDidCommitLoad = toRemoteLayerTreeDrawingArea(*m_drawingArea).currentTransactionID();4450 m_firstLayerTreeTransactionIDAfterDidCommitLoad = toRemoteLayerTreeDrawingArea(*m_drawingArea).nextTransactionID(); 4451 4451 m_userHasChangedPageScaleFactor = false; 4452 4452 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r171057 r171154 748 748 void setDeviceOrientation(int32_t); 749 749 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); 750 void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition );750 void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID); 751 751 void updateVisibleContentRects(const VisibleContentRectUpdateInfo&); 752 752 bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; } … … 1226 1226 1227 1227 WebCore::ViewportConfiguration m_viewportConfiguration; 1228 uint64_t m_ lastLayerTreeTransactionIDBeforeDidCommitLoad;1228 uint64_t m_firstLayerTreeTransactionIDAfterDidCommitLoad; 1229 1229 bool m_hasReceivedVisibleContentRectsAfterDidCommitLoad; 1230 1230 bool m_scaleWasSetByUIProcess; -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r170981 r171154 49 49 SetDeviceOrientation(int32_t deviceOrientation) 50 50 DynamicViewportSizeUpdate(WebCore::FloatSize minimumLayoutSize, WebCore::FloatSize minimumLayoutSizeForMinimalUI, WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, double scale, int32_t deviceOrientation) 51 SynchronizeDynamicViewportUpdate() -> (double newTargetScale, WebCore::FloatPoint newScrollPosition )51 SynchronizeDynamicViewportUpdate() -> (double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t nextValidLayerTreeTransactionID) 52 52 53 53 HandleTap(WebCore::IntPoint point) -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r171101 r171154 38 38 #import "InteractionInformationAtPosition.h" 39 39 #import "PluginView.h" 40 #import "RemoteLayerTreeDrawingArea.h" 40 41 #import "VisibleContentRectUpdateInfo.h" 41 42 #import "WKAccessibilityWebPageObjectIOS.h" … … 2325 2326 } 2326 2327 2327 void WebPage::synchronizeDynamicViewportUpdate(double& newTargetScale, FloatPoint& newScrollPosition )2328 void WebPage::synchronizeDynamicViewportUpdate(double& newTargetScale, FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID) 2328 2329 { 2329 2330 newTargetScale = pageScaleFactor(); 2330 2331 newScrollPosition = m_page->mainFrame().view()->scrollPosition(); 2332 nextValidLayerTreeTransactionID = toRemoteLayerTreeDrawingArea(*m_drawingArea).nextTransactionID(); 2331 2333 } 2332 2334 … … 2438 2440 { 2439 2441 // Skip any VisibleContentRectUpdate that have been queued before DidCommitLoad suppresses the updates in the UIProcess. 2440 if (visibleContentRectUpdateInfo.lastLayerTreeTransactionID() <= m_ lastLayerTreeTransactionIDBeforeDidCommitLoad)2442 if (visibleContentRectUpdateInfo.lastLayerTreeTransactionID() <= m_firstLayerTreeTransactionIDAfterDidCommitLoad) 2441 2443 return; 2442 2444 -
trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h
r170787 r171154 55 55 virtual ~RemoteLayerTreeDrawingArea(); 56 56 57 uint64_t currentTransactionID() const { return m_currentTransactionID; }57 uint64_t nextTransactionID() const { return m_currentTransactionID + 1; } 58 58 59 59 private:
Note: See TracChangeset
for help on using the changeset viewer.