[epiphany/mcatanzaro/unresponsive-process-timeout: 3/3] web-view: wait 10 seconds before killing unresponsive process




commit f23857fa6880d499ecec129e5d19aa087156ad17
Author: Michael Catanzaro <mcatanzaro redhat com>
Date:   Fri Aug 6 16:03:39 2021 -0500

    web-view: wait 10 seconds before killing unresponsive process
    
    WebKit determines that the web process is hung when it has been more
    than three seconds since it has responded to a ping from the UI process.
    Turns out, this timeout is too low in practice because websites
    routinely run JavaScript for longer than this. So let's wait 10 seconds
    after the process is determined to be unresponsive, for 13 seconds
    total, before we kill anything. My hope is that this makes the
    unresponsive process killer less painful in practice.
    
    We might still want to ask users before killing anything, #1561, but
    this might suffice for now. Maybe.
    
    Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/994>

 embed/ephy-web-view.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index acafd5977..af3830941 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -127,6 +127,8 @@ struct _EphyWebView {
 
   EphyWebViewErrorPage error_page;
 
+  guint unresponsive_process_timeout_id;
+
   guint64 uid;
 };
 
@@ -842,15 +844,30 @@ process_terminated_cb (EphyWebView                       *web_view,
   }
 }
 
+static gboolean
+unresponsive_process_timeout_cb (gpointer user_data)
+{
+  EphyWebView *web_view = EPHY_WEB_VIEW (user_data);
+
+  webkit_web_view_terminate_web_process (WEBKIT_WEB_VIEW (web_view));
+
+  web_view->unresponsive_process_timeout_id = 0;
+
+  return G_SOURCE_REMOVE;
+}
+
 static void
 is_web_process_responsive_changed_cb (EphyWebView *web_view,
                                       GParamSpec  *pspec,
                                       gpointer     user_data)
 {
-  WebKitWebView *view = WEBKIT_WEB_VIEW (web_view);
+  g_clear_handle_id (&web_view->unresponsive_process_timeout_id, g_source_remove);
 
-  if (!webkit_web_view_get_is_web_process_responsive (view))
-    webkit_web_view_terminate_web_process (view);
+  if (!webkit_web_view_get_is_web_process_responsive (WEBKIT_WEB_VIEW (web_view))) {
+    web_view->unresponsive_process_timeout_id = g_timeout_add_seconds (10,
+                                                                       
(GSourceFunc)unresponsive_process_timeout_cb,
+                                                                       web_view);
+  }
 }
 
 static gboolean
@@ -3837,6 +3854,7 @@ ephy_web_view_dispose (GObject *object)
 
   g_clear_handle_id (&view->snapshot_timeout_id, g_source_remove);
   g_clear_handle_id (&view->reader_js_timeout, g_source_remove);
+  g_clear_handle_id (&view->unresponsive_process_timeout_id, g_source_remove);
 
   G_OBJECT_CLASS (ephy_web_view_parent_class)->dispose (object);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]