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




commit 2fabdefaba6115a65d61715fc9fc50ae2adb6972
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.

 embed/ephy-web-view.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index acafd5977..f1d01b698 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,31 @@ 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 +3855,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]