[epiphany/mcatanzaro/#1447] web-view: fix reloading crashed pages




commit 7862a5156b7aff3d4bc38246ec498554b22b9748
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Tue Feb 16 10:17:43 2021 -0600

    web-view: fix reloading crashed pages
    
    When the web process crashes, we generate an error page that reloads the
    view's current URI when the reload button is pressed. Unfortunately,
    since WebKit r268097, the current URI is now an empty string at the time
    of crash because the web process termination signal is dispatched
    asynchronously after WebKit has already updated the view to contain an
    empty page. This means we have to manually keep track of the previous
    value of the URI. Arguably, this is a bug in WebKit, but it seems tough
    to fix there and we need a workaround for now.
    
    Note that the web process termination signal is currently only being
    sent when running under flatpak. Outside flatpak, the signal is not sent
    at all. That is a separate issue (WebKit#221489) that we will not fix
    here.
    
    Fixes #1447

 embed/ephy-web-view.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 4bf68f174..77150bdfa 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -88,6 +88,7 @@ struct _EphyWebView {
   char *display_address;
   char *typed_address;
   char *last_committed_address;
+  char *last_nonempty_address;
   char *loading_message;
   char *link_message;
   GdkPixbuf *icon;
@@ -784,6 +785,11 @@ ephy_web_view_set_address (EphyWebView *view,
   if (!was_empty && ephy_web_view_is_loading (view) && view->typed_address != NULL)
     ephy_web_view_set_typed_address (view, NULL);
 
+  if (g_strcmp0 (address, "")) {
+    g_free (view->last_nonempty_address);
+    view->last_nonempty_address = g_strdup (address);
+  }
+
   g_object_notify_by_pspec (object, obj_properties[PROP_ADDRESS]);
   g_object_notify_by_pspec (object, obj_properties[PROP_DISPLAY_ADDRESS]);
 }
@@ -829,7 +835,7 @@ process_terminated_cb (EphyWebView                       *web_view,
   }
 
   if (!ephy_embed_has_load_pending (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view))) {
-    ephy_web_view_load_error_page (web_view, ephy_web_view_get_address (web_view),
+    ephy_web_view_load_error_page (web_view, web_view->last_nonempty_address,
                                    EPHY_WEB_VIEW_ERROR_PROCESS_CRASH, NULL, NULL);
   }
 }
@@ -3753,6 +3759,7 @@ ephy_web_view_finalize (GObject *object)
   g_free (view->display_address);
   g_free (view->typed_address);
   g_free (view->last_committed_address);
+  g_free (view->last_nonempty_address);
   g_free (view->link_message);
   g_free (view->loading_message);
   g_free (view->tls_error_failing_uri);


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