[GTK] Back/forward gesture snapshot always times out
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Apr 2019 16:58:09 +0000 (16:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Apr 2019 16:58:09 +0000 (16:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197233

Patch by Alexander Mikhaylenko <exalm7659@gmail.com> on 2019-04-25
Reviewed by Michael Catanzaro.

Delaying web process launch caused a regression where we create ViewGestureController when the
web process doesn't yet exist. The controller immediately tries to connect to it and fails,
and because of that never receives DidHitRenderTreeSizeThreshold() message, so navigation
snapshot always stays until timeout after performing the gesture.

To prevent this, create the controller in webkitWebViewBaseDidRelaunchWebProcess() instead of
webkitWebViewBaseCreateWebPage(). Additionally, since settings are now created earlier than
ViewGestureController, store the value of whether swipe gesture is enabled in WebKitWebViewBase
and immediately apply it when creating the controller.

* UIProcess/API/glib/WebKitWebView.cpp:
(enableBackForwardNavigationGesturesChanged):
Move the logic into webkitWebViewBaseSetEnableBackForwardNavigationGesture().
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseSetEnableBackForwardNavigationGesture): Added. In addition to what was in
WebKitWebViewBase::enableBackForwardNavigationGesturesChanged(), store the value in a field
for the case ViewGestureController doesn't exist yet.
(webkitWebViewBaseCreateWebPage): Stop creating ViewGestureController.
(webkitWebViewBaseDidRelaunchWebProcess): Move creating ViewGestureController here. Also
immediately call setSwipeGestureEnabled() with the stored value.
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h

index e32eb49..71a8022 100644 (file)
@@ -1,3 +1,32 @@
+2019-04-25  Alexander Mikhaylenko  <exalm7659@gmail.com>
+
+        [GTK] Back/forward gesture snapshot always times out
+        https://bugs.webkit.org/show_bug.cgi?id=197233
+
+        Reviewed by Michael Catanzaro.
+
+        Delaying web process launch caused a regression where we create ViewGestureController when the
+        web process doesn't yet exist. The controller immediately tries to connect to it and fails,
+        and because of that never receives DidHitRenderTreeSizeThreshold() message, so navigation
+        snapshot always stays until timeout after performing the gesture.
+
+        To prevent this, create the controller in webkitWebViewBaseDidRelaunchWebProcess() instead of
+        webkitWebViewBaseCreateWebPage(). Additionally, since settings are now created earlier than
+        ViewGestureController, store the value of whether swipe gesture is enabled in WebKitWebViewBase
+        and immediately apply it when creating the controller.
+
+        * UIProcess/API/glib/WebKitWebView.cpp:
+        (enableBackForwardNavigationGesturesChanged):
+        Move the logic into webkitWebViewBaseSetEnableBackForwardNavigationGesture().
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseSetEnableBackForwardNavigationGesture): Added. In addition to what was in
+        WebKitWebViewBase::enableBackForwardNavigationGesturesChanged(), store the value in a field
+        for the case ViewGestureController doesn't exist yet.
+        (webkitWebViewBaseCreateWebPage): Stop creating ViewGestureController.
+        (webkitWebViewBaseDidRelaunchWebProcess): Move creating ViewGestureController here. Also
+        immediately call setSwipeGestureEnabled() with the stored value.
+        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+
 2019-04-25  Youenn Fablet  <youenn@apple.com>
 
         [Mac iOS WK2] Layout Test http/wpt/cache-storage/cache-quota-after-restart.any.html is a flaky failure
index af10d68..887f7b3 100644 (file)
@@ -514,11 +514,7 @@ static void userAgentChanged(WebKitSettings* settings, GParamSpec*, WebKitWebVie
 static void enableBackForwardNavigationGesturesChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView)
 {
     gboolean enable = webkit_settings_get_enable_back_forward_navigation_gestures(settings);
-
-    ViewGestureController& controller = webkitWebViewBaseViewGestureController(WEBKIT_WEB_VIEW_BASE(webView));
-    controller.setSwipeGestureEnabled(enable);
-
-    getPage(webView).setShouldRecordNavigationSnapshots(enable);
+    webkitWebViewBaseSetEnableBackForwardNavigationGesture(WEBKIT_WEB_VIEW_BASE(webView), enable);
 }
 
 static void webkitWebViewUpdateFavicon(WebKitWebView* webView, cairo_surface_t* favicon)
index 816f0fa..5e6f6f6 100644 (file)
@@ -206,6 +206,7 @@ struct _WebKitWebViewBasePrivate {
     std::unique_ptr<GestureController> gestureController;
 #endif
     std::unique_ptr<ViewGestureController> viewGestureController;
+    bool isBackForwardNavigationGestureEnabled { false };
 };
 
 WEBKIT_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
@@ -1189,6 +1190,18 @@ GestureController& webkitWebViewBaseGestureController(WebKitWebViewBase* webView
 }
 #endif
 
+void webkitWebViewBaseSetEnableBackForwardNavigationGesture(WebKitWebViewBase* webViewBase, bool enabled)
+{
+    WebKitWebViewBasePrivate* priv = webViewBase->priv;
+
+    priv->isBackForwardNavigationGestureEnabled = enabled;
+
+    if (priv->pageProxy->hasRunningProcess())
+        webViewBase->priv->viewGestureController->setSwipeGestureEnabled(enabled);
+
+    priv->pageProxy->setShouldRecordNavigationSnapshots(enabled);
+}
+
 ViewGestureController& webkitWebViewBaseViewGestureController(WebKitWebViewBase* webViewBase)
 {
     return *webViewBase->priv->viewGestureController;
@@ -1420,8 +1433,6 @@ void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, Ref<AP
     priv->pageProxy->setIntrinsicDeviceScaleFactor(gtk_widget_get_scale_factor(GTK_WIDGET(webkitWebViewBase)));
     g_signal_connect(webkitWebViewBase, "notify::scale-factor", G_CALLBACK(deviceScaleFactorChanged), nullptr);
 #endif
-
-    priv->viewGestureController = std::make_unique<WebKit::ViewGestureController>(*priv->pageProxy);
 }
 
 void webkitWebViewBaseSetTooltipText(WebKitWebViewBase* webViewBase, const char* tooltip)
@@ -1639,11 +1650,12 @@ void webkitWebViewBaseDidRelaunchWebProcess(WebKitWebViewBase* webkitWebViewBase
     // Queue a resize to ensure the new DrawingAreaProxy is resized.
     gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
 
+    WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
+
 #if PLATFORM(X11) && USE(TEXTURE_MAPPER_GL) && !USE(REDIRECTED_XCOMPOSITE_WINDOW)
     if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
         return;
 
-    WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
     auto* drawingArea = static_cast<DrawingAreaProxyCoordinatedGraphics*>(priv->pageProxy->drawingArea());
     ASSERT(drawingArea);
 
@@ -1655,6 +1667,9 @@ void webkitWebViewBaseDidRelaunchWebProcess(WebKitWebViewBase* webkitWebViewBase
 #else
     UNUSED_PARAM(webkitWebViewBase);
 #endif
+
+    priv->viewGestureController = std::make_unique<WebKit::ViewGestureController>(*priv->pageProxy);
+    priv->viewGestureController->setSwipeGestureEnabled(priv->isBackForwardNavigationGestureEnabled);
 }
 
 void webkitWebViewBasePageClosed(WebKitWebViewBase* webkitWebViewBase)
index 1360285..10df80b 100644 (file)
@@ -84,6 +84,7 @@ WebKit::GestureController& webkitWebViewBaseGestureController(WebKitWebViewBase*
 
 RefPtr<WebKit::ViewSnapshot> webkitWebViewBaseTakeViewSnapshot(WebKitWebViewBase*);
 
+void webkitWebViewBaseSetEnableBackForwardNavigationGesture(WebKitWebViewBase*, bool enabled);
 WebKit::ViewGestureController& webkitWebViewBaseViewGestureController(WebKitWebViewBase*);
 
 void webkitWebViewBaseDidStartProvisionalLoadForMainFrame(WebKitWebViewBase*);