Title: [251907] trunk/Source/WebKit
Revision
251907
Author
cdu...@apple.com
Date
2019-10-31 21:07:37 -0700 (Thu, 31 Oct 2019)

Log Message

Take down the gesture snapshot early when the back/forward cache is not leveraged
https://bugs.webkit.org/show_bug.cgi?id=203713
<rdar://problem/56803910>

Reviewed by Tim Horton.

Take down the gesture snapshot as soon as the gesture is done when the back/forward cache
is not leveraged. Otherwise, the snapshot may stay up for a long time (while we load, parse
and restore scroll position) and it would look to the user as if the view was unresponsive.
Showing the page slowly loading in such cases is less confusing as the user knows what's
going on and is even able to interact with the partially loaded page.

* Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::hasCachedWebPage const):
* Shared/WebBackForwardListItem.h:
* UIProcess/ViewGestureController.cpp:
(WebKit::ViewGestureController::endSwipeGesture):
* UIProcess/ViewGestureController.h:
* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::makeSnapshotBlank):
(WebKit::ViewGestureController::endSwipeGesture):
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::makeSnapshotBlank):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (251906 => 251907)


--- trunk/Source/WebKit/ChangeLog	2019-11-01 04:00:32 UTC (rev 251906)
+++ trunk/Source/WebKit/ChangeLog	2019-11-01 04:07:37 UTC (rev 251907)
@@ -1,3 +1,29 @@
+2019-10-31  Chris Dumez  <cdu...@apple.com>
+
+        Take down the gesture snapshot early when the back/forward cache is not leveraged
+        https://bugs.webkit.org/show_bug.cgi?id=203713
+        <rdar://problem/56803910>
+
+        Reviewed by Tim Horton.
+
+        Take down the gesture snapshot as soon as the gesture is done when the back/forward cache
+        is not leveraged. Otherwise, the snapshot may stay up for a long time (while we load, parse
+        and restore scroll position) and it would look to the user as if the view was unresponsive.
+        Showing the page slowly loading in such cases is less confusing as the user knows what's
+        going on and is even able to interact with the partially loaded page.
+
+        * Shared/WebBackForwardListItem.cpp:
+        (WebKit::WebBackForwardListItem::hasCachedWebPage const):
+        * Shared/WebBackForwardListItem.h:
+        * UIProcess/ViewGestureController.cpp:
+        (WebKit::ViewGestureController::endSwipeGesture):
+        * UIProcess/ViewGestureController.h:
+        * UIProcess/ios/ViewGestureControllerIOS.mm:
+        (WebKit::ViewGestureController::makeSnapshotBlank):
+        (WebKit::ViewGestureController::endSwipeGesture):
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::makeSnapshotBlank):
+
 2019-10-31  Per Arne Vollan  <pvol...@apple.com>
 
         [iOS] Fix mach lookup sandbox violations in the Mail app

Modified: trunk/Source/WebKit/Shared/WebBackForwardListItem.cpp (251906 => 251907)


--- trunk/Source/WebKit/Shared/WebBackForwardListItem.cpp	2019-11-01 04:00:32 UTC (rev 251906)
+++ trunk/Source/WebKit/Shared/WebBackForwardListItem.cpp	2019-11-01 04:07:37 UTC (rev 251907)
@@ -182,6 +182,16 @@
     return m_backForwardCacheEntry ? m_backForwardCacheEntry->suspendedPage() : nullptr;
 }
 
+bool WebBackForwardListItem::hasCachedWebPage() const
+{
+    if (!m_backForwardCacheEntry)
+        return false;
+    if (!m_backForwardCacheEntry->suspendedPage())
+        return true; // In-process cached page without suspended page proxy.
+    // Make sure the suspended page proxy has an associated WebPage.
+    return !m_backForwardCacheEntry->suspendedPage()->pageIsClosedOrClosing();
+}
+
 #if !LOG_DISABLED
 const char* WebBackForwardListItem::loggingString()
 {

Modified: trunk/Source/WebKit/Shared/WebBackForwardListItem.h (251906 => 251907)


--- trunk/Source/WebKit/Shared/WebBackForwardListItem.h	2019-11-01 04:00:32 UTC (rev 251906)
+++ trunk/Source/WebKit/Shared/WebBackForwardListItem.h	2019-11-01 04:07:37 UTC (rev 251907)
@@ -82,6 +82,7 @@
 
     void wasRemovedFromBackForwardList();
 
+    bool hasCachedWebPage() const;
     WebBackForwardCacheEntry* backForwardCacheEntry() const { return m_backForwardCacheEntry.get(); }
     SuspendedPageProxy* suspendedPage() const;
 

Modified: trunk/Source/WebKit/UIProcess/ViewGestureController.cpp (251906 => 251907)


--- trunk/Source/WebKit/UIProcess/ViewGestureController.cpp	2019-11-01 04:00:32 UTC (rev 251906)
+++ trunk/Source/WebKit/UIProcess/ViewGestureController.cpp	2019-11-01 04:07:37 UTC (rev 251907)
@@ -590,10 +590,16 @@
         return;
     }
 
-    SnapshotRemovalTracker::Events desiredEvents = SnapshotRemovalTracker::VisuallyNonEmptyLayout
+    SnapshotRemovalTracker::Events desiredEvents;
+    if (targetItem->hasCachedWebPage()) {
+        desiredEvents = SnapshotRemovalTracker::VisuallyNonEmptyLayout
         | SnapshotRemovalTracker::MainFrameLoad
         | SnapshotRemovalTracker::SubresourceLoads
         | SnapshotRemovalTracker::ScrollPositionRestoration;
+    } else {
+        desiredEvents = SnapshotRemovalTracker::VisuallyNonEmptyLayout;
+        makeSnapshotBlank();
+    }
 
     if (renderTreeSizeThreshold) {
         desiredEvents |= SnapshotRemovalTracker::RenderTreeSizeThreshold;

Modified: trunk/Source/WebKit/UIProcess/ViewGestureController.h (251906 => 251907)


--- trunk/Source/WebKit/UIProcess/ViewGestureController.h	2019-11-01 04:00:32 UTC (rev 251906)
+++ trunk/Source/WebKit/UIProcess/ViewGestureController.h	2019-11-01 04:07:37 UTC (rev 251907)
@@ -310,6 +310,8 @@
     GRefPtr<GtkStyleContext> createStyleContext(const char*);
 #endif
 
+    void makeSnapshotBlank();
+
     WebPageProxy& m_webPageProxy;
     ViewGestureType m_activeGestureType { ViewGestureType::None };
 

Modified: trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp (251906 => 251907)


--- trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp	2019-11-01 04:00:32 UTC (rev 251906)
+++ trunk/Source/WebKit/UIProcess/gtk/ViewGestureControllerGtk.cpp	2019-11-01 04:07:37 UTC (rev 251907)
@@ -570,4 +570,8 @@
     return true;
 }
 
+void ViewGestureController::makeSnapshotBlank()
+{
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm (251906 => 251907)


--- trunk/Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm	2019-11-01 04:00:32 UTC (rev 251906)
+++ trunk/Source/WebKit/UIProcess/ios/ViewGestureControllerIOS.mm	2019-11-01 04:07:37 UTC (rev 251907)
@@ -267,6 +267,11 @@
     [transition startInteractiveTransition:m_swipeTransitionContext.get()];
 }
 
+void ViewGestureController::makeSnapshotBlank()
+{
+    [m_snapshotView layer].contents = nil;
+}
+
 void ViewGestureController::endSwipeGesture(WebBackForwardListItem* targetItem, _UIViewControllerTransitionContext *context, bool cancelled)
 {
     [context _setTransitionIsInFlight:NO];
@@ -312,12 +317,20 @@
         return;
     }
 
+    SnapshotRemovalTracker::Events desiredEvents;
+    if (targetItem->hasCachedWebPage()) {
+        desiredEvents = SnapshotRemovalTracker::RenderTreeSizeThreshold
+            | SnapshotRemovalTracker::RepaintAfterNavigation
+            | SnapshotRemovalTracker::MainFrameLoad
+            | SnapshotRemovalTracker::SubresourceLoads
+            | SnapshotRemovalTracker::ScrollPositionRestoration;
+    } else {
+        desiredEvents = SnapshotRemovalTracker::VisuallyNonEmptyLayout;
+        makeSnapshotBlank();
+    }
+
     // FIXME: Should we wait for VisuallyNonEmptyLayout like we do on Mac?
-    m_snapshotRemovalTracker.start(SnapshotRemovalTracker::RenderTreeSizeThreshold
-        | SnapshotRemovalTracker::RepaintAfterNavigation
-        | SnapshotRemovalTracker::MainFrameLoad
-        | SnapshotRemovalTracker::SubresourceLoads
-        | SnapshotRemovalTracker::ScrollPositionRestoration, [this] {
+    m_snapshotRemovalTracker.start(desiredEvents, [this] {
             this->removeSwipeSnapshot();
     });
 

Modified: trunk/Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm (251906 => 251907)


--- trunk/Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm	2019-11-01 04:00:32 UTC (rev 251906)
+++ trunk/Source/WebKit/UIProcess/mac/ViewGestureControllerMac.mm	2019-11-01 04:07:37 UTC (rev 251907)
@@ -173,6 +173,11 @@
         endMagnificationGesture();
 }
 
+void ViewGestureController::makeSnapshotBlank()
+{
+    [m_swipeSnapshotLayer setContents:nil];
+}
+
 void ViewGestureController::endMagnificationGesture()
 {
     if (m_activeGestureType != ViewGestureType::Magnification)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to