REGRESSION (PSON): After swipe back, first few attempts to swipe forward not recogniz...
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jan 2019 20:20:17 +0000 (20:20 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jan 2019 20:20:17 +0000 (20:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193818
<rdar://problem/47456584>

Reviewed by Tim Horton.

We don't hit the RenderTreeSizeThreshold milestone to remove the snapshot and allow interaction because we request it
from a wrong process (the one we are leaving behind).

* UIProcess/Cocoa/ViewGestureController.cpp:
(WebKit::ViewGestureController::didStartProvisionalLoadForMainFrame):

Request the RenderTreeSizeThreshold notification when the load has started and we know the process to use.

(WebKit::ViewGestureController::SnapshotRemovalTracker::hasOutstandingEvent):
* UIProcess/Cocoa/ViewGestureController.h:
(WebKit::ViewGestureController::SnapshotRemovalTracker::renderTreeSizeThreshold const):
(WebKit::ViewGestureController::SnapshotRemovalTracker::setRenderTreeSizeThreshold):
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::endSwipeGesture):

Don't request immediately, save the threshold to SnapshotRemovalTracker.

(WebKit::ViewGestureController::requestRenderTreeSizeNotificationIfNeeded):

Do the request to the right process.

* WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
(WebKit::ViewGestureGeometryCollector::setRenderTreeSizeNotificationThreshold):

Ensure we send the notification even if we reached the threshold before it was requested.

(WebKit::ViewGestureGeometryCollector::sendDidHitRenderTreeSizeThresholdIfNeeded):
(WebKit::ViewGestureGeometryCollector::mainFrameDidLayout):
* WebProcess/WebPage/ViewGestureGeometryCollector.h:
(WebKit::ViewGestureGeometryCollector::setRenderTreeSizeNotificationThreshold): Deleted.

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp
Source/WebKit/UIProcess/Cocoa/ViewGestureController.h
Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm
Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.cpp
Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.h

index 3007228..696d894 100644 (file)
@@ -1,3 +1,42 @@
+2019-01-25  Antti Koivisto  <antti@apple.com>
+
+        REGRESSION (PSON): After swipe back, first few attempts to swipe forward not recognized as swipe gestures
+        https://bugs.webkit.org/show_bug.cgi?id=193818
+        <rdar://problem/47456584>
+
+        Reviewed by Tim Horton.
+
+        We don't hit the RenderTreeSizeThreshold milestone to remove the snapshot and allow interaction because we request it
+        from a wrong process (the one we are leaving behind).
+
+        * UIProcess/Cocoa/ViewGestureController.cpp:
+        (WebKit::ViewGestureController::didStartProvisionalLoadForMainFrame):
+
+        Request the RenderTreeSizeThreshold notification when the load has started and we know the process to use.
+
+        (WebKit::ViewGestureController::SnapshotRemovalTracker::hasOutstandingEvent):
+        * UIProcess/Cocoa/ViewGestureController.h:
+        (WebKit::ViewGestureController::SnapshotRemovalTracker::renderTreeSizeThreshold const):
+        (WebKit::ViewGestureController::SnapshotRemovalTracker::setRenderTreeSizeThreshold):
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::endSwipeGesture):
+
+        Don't request immediately, save the threshold to SnapshotRemovalTracker.
+
+        (WebKit::ViewGestureController::requestRenderTreeSizeNotificationIfNeeded):
+
+        Do the request to the right process.
+
+        * WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
+        (WebKit::ViewGestureGeometryCollector::setRenderTreeSizeNotificationThreshold):
+
+        Ensure we send the notification even if we reached the threshold before it was requested.
+
+        (WebKit::ViewGestureGeometryCollector::sendDidHitRenderTreeSizeThresholdIfNeeded):
+        (WebKit::ViewGestureGeometryCollector::mainFrameDidLayout):
+        * WebProcess/WebPage/ViewGestureGeometryCollector.h:
+        (WebKit::ViewGestureGeometryCollector::setRenderTreeSizeNotificationThreshold): Deleted.
+
 2019-01-25  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS] Rename some WebKit-internal functions and variables that reference "data interaction"
index 0fffd9a..6fb5fbe 100644 (file)
@@ -148,6 +148,9 @@ bool ViewGestureController::canSwipeInDirection(SwipeDirection direction) const
 void ViewGestureController::didStartProvisionalLoadForMainFrame()
 {
     m_snapshotRemovalTracker.resume();
+#if PLATFORM(MAC)
+    requestRenderTreeSizeNotificationIfNeeded();
+#endif
 
     if (auto provisionalLoadCallback = WTFMove(m_provisionalLoadCallback))
         provisionalLoadCallback();
@@ -199,6 +202,9 @@ void ViewGestureController::didReachMainFrameLoadTerminalState()
 void ViewGestureController::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
 {
     m_snapshotRemovalTracker.resume();
+#if PLATFORM(MAC)
+    requestRenderTreeSizeNotificationIfNeeded();
+#endif
 
     bool cancelledOutstandingEvent = false;
 
@@ -325,6 +331,11 @@ bool ViewGestureController::SnapshotRemovalTracker::cancelOutstandingEvent(Event
     return stopWaitingForEvent(event, "wait for event cancelled: ");
 }
 
+bool ViewGestureController::SnapshotRemovalTracker::hasOutstandingEvent(Event event)
+{
+    return m_outstandingEvents & event;
+}
+
 void ViewGestureController::SnapshotRemovalTracker::fireRemovalCallbackIfPossible()
 {
     if (m_outstandingEvents) {
index 3fd2994..5b5d92d 100644 (file)
@@ -61,6 +61,7 @@ namespace WebKit {
 class ViewSnapshot;
 class WebBackForwardListItem;
 class WebPageProxy;
+class WebProcessProxy;
 
 class ViewGestureController : private IPC::MessageReceiver {
     WTF_MAKE_NONCOPYABLE(ViewGestureController);
@@ -179,9 +180,13 @@ private:
 
         bool eventOccurred(Events);
         bool cancelOutstandingEvent(Events);
+        bool hasOutstandingEvent(Event);
 
         void startWatchdog(Seconds);
 
+        uint64_t renderTreeSizeThreshold() const { return m_renderTreeSizeThreshold; }
+        void setRenderTreeSizeThreshold(uint64_t threshold) { m_renderTreeSizeThreshold = threshold; }
+
     private:
         static String eventsDescription(Events);
         void log(const String&) const;
@@ -196,6 +201,8 @@ private:
         WTF::Function<void()> m_removalCallback;
         MonotonicTime m_startTime;
 
+        uint64_t m_renderTreeSizeThreshold { 0 };
+
         RunLoop::Timer<SnapshotRemovalTracker> m_watchdogTimer;
         
         bool m_paused { true };
@@ -224,6 +231,8 @@ private:
 
     void forceRepaintIfNeeded();
 
+    void requestRenderTreeSizeNotificationIfNeeded();
+
     class PendingSwipeTracker {
     public:
         PendingSwipeTracker(WebPageProxy&, ViewGestureController&);
index 6405ecd..401f6e7 100644 (file)
@@ -33,6 +33,7 @@
 #import "FrameLoadState.h"
 #import "Logging.h"
 #import "NativeWebWheelEvent.h"
+#import "ProvisionalPageProxy.h"
 #import "ViewGestureControllerMessages.h"
 #import "ViewGestureGeometryCollectorMessages.h"
 #import "ViewSnapshotStore.h"
@@ -737,8 +738,7 @@ void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem,
     uint64_t renderTreeSize = 0;
     if (ViewSnapshot* snapshot = targetItem->snapshot())
         renderTreeSize = snapshot->renderTreeSize();
-
-    m_webPageProxy.process().send(Messages::ViewGestureGeometryCollector::SetRenderTreeSizeNotificationThreshold(renderTreeSize * swipeSnapshotRemovalRenderTreeSizeTargetFraction), m_webPageProxy.pageID());
+    auto renderTreeSizeThreshold = renderTreeSize * swipeSnapshotRemovalRenderTreeSizeTargetFraction;
 
     m_webPageProxy.navigationGestureDidEnd(true, *targetItem);
     m_webPageProxy.goToBackForwardItem(*targetItem);
@@ -754,8 +754,12 @@ void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem,
         | SnapshotRemovalTracker::MainFrameLoad
         | SnapshotRemovalTracker::SubresourceLoads
         | SnapshotRemovalTracker::ScrollPositionRestoration;
-    if (renderTreeSize)
+
+    if (renderTreeSizeThreshold) {
         desiredEvents |= SnapshotRemovalTracker::RenderTreeSizeThreshold;
+        m_snapshotRemovalTracker.setRenderTreeSizeThreshold(renderTreeSizeThreshold);
+    }
+
     m_snapshotRemovalTracker.start(desiredEvents, [this] { this->forceRepaintIfNeeded(); });
 
     // FIXME: Like on iOS, we should ensure that even if one of the timeouts fires,
@@ -840,6 +844,17 @@ bool ViewGestureController::completeSimulatedSwipeInDirectionForTesting(SwipeDir
     return false;
 }
 
+void ViewGestureController::requestRenderTreeSizeNotificationIfNeeded()
+{
+    if (!m_snapshotRemovalTracker.hasOutstandingEvent(SnapshotRemovalTracker::RenderTreeSizeThreshold))
+        return;
+
+    auto& process = m_webPageProxy.provisionalPageProxy() ? m_webPageProxy.provisionalPageProxy()->process() : m_webPageProxy.process();
+    auto threshold = m_snapshotRemovalTracker.renderTreeSizeThreshold();
+
+    process.send(Messages::ViewGestureGeometryCollector::SetRenderTreeSizeNotificationThreshold(threshold), m_webPageProxy.pageID());
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(MAC)
index c3a7978..cf1968e 100644 (file)
@@ -253,6 +253,20 @@ void ViewGestureGeometryCollector::collectGeometryForMagnificationGesture()
     bool frameHandlesMagnificationGesture = m_webPage.mainWebFrame()->handlesPageScaleGesture();
     m_webPage.send(Messages::ViewGestureController::DidCollectGeometryForMagnificationGesture(visibleContentRect, frameHandlesMagnificationGesture));
 }
+
+void ViewGestureGeometryCollector::setRenderTreeSizeNotificationThreshold(uint64_t size)
+{
+    m_renderTreeSizeNotificationThreshold = size;
+    sendDidHitRenderTreeSizeThresholdIfNeeded();
+}
+
+void ViewGestureGeometryCollector::sendDidHitRenderTreeSizeThresholdIfNeeded()
+{
+    if (m_renderTreeSizeNotificationThreshold && m_webPage.renderTreeSize() >= m_renderTreeSizeNotificationThreshold) {
+        m_webPage.send(Messages::ViewGestureController::DidHitRenderTreeSizeThreshold());
+        m_renderTreeSizeNotificationThreshold = 0;
+    }
+}
 #endif
 
 void ViewGestureGeometryCollector::mainFrameDidLayout()
@@ -261,10 +275,7 @@ void ViewGestureGeometryCollector::mainFrameDidLayout()
     m_cachedTextLegibilityScales.reset();
 #endif
 #if PLATFORM(MAC)
-    if (m_renderTreeSizeNotificationThreshold && m_webPage.renderTreeSize() >= m_renderTreeSizeNotificationThreshold) {
-        m_webPage.send(Messages::ViewGestureController::DidHitRenderTreeSizeThreshold());
-        m_renderTreeSizeNotificationThreshold = 0;
-    }
+    sendDidHitRenderTreeSizeThresholdIfNeeded();
 #endif
 }
 
index 6fb4566..2ac498d 100644 (file)
@@ -55,9 +55,8 @@ private:
 
 #if PLATFORM(MAC)
     void collectGeometryForMagnificationGesture();
-    void setRenderTreeSizeNotificationThreshold(uint64_t size) { m_renderTreeSizeNotificationThreshold = size; }
-
-    void renderTreeSizeNotificationTimerFired();
+    void setRenderTreeSizeNotificationThreshold(uint64_t);
+    void sendDidHitRenderTreeSizeThresholdIfNeeded();
 #endif
 
     void dispatchDidCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect targetRect, WebCore::FloatRect visibleContentRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale);