[evolution] Bug 773316 - Better error message when web process crashes



commit 86ee1f87fd30cad13db6a6dad833e0c8c38a4227
Author: Milan Crha <mcrha redhat com>
Date:   Wed Dec 14 19:19:14 2016 +0100

    Bug 773316 - Better error message when web process crashes

 src/addressbook/addressbook.error.xml             |    5 +++
 src/addressbook/gui/widgets/eab-contact-display.c |   19 +++++++++++
 src/calendar/calendar.error.xml                   |   15 ++++++++
 src/calendar/gui/e-cal-component-preview.c        |   34 +++++++++++++++++++
 src/composer/mail-composer.error.xml              |    4 ++
 src/e-util/e-mail-signature-preview.c             |   22 ++++++++++++
 src/e-util/e-system.error.xml                     |    4 ++
 src/mail/e-mail-display.c                         |   19 +++++++++++
 src/mail/mail.error.xml                           |   11 ++++++
 src/modules/webkit-editor/CMakeLists.txt          |    4 ++-
 src/modules/webkit-editor/e-webkit-editor.c       |   37 ++++++++++++++++++--
 src/shell/e-shell-utils.c                         |   25 ++++++++++++++
 src/shell/e-shell-utils.h                         |    2 +
 13 files changed, 196 insertions(+), 5 deletions(-)
---
diff --git a/src/addressbook/addressbook.error.xml b/src/addressbook/addressbook.error.xml
index 01ff67e..da88d0a 100644
--- a/src/addressbook/addressbook.error.xml
+++ b/src/addressbook/addressbook.error.xml
@@ -136,4 +136,9 @@
     <_secondary>Cannot save a contact to the address book “{0}”, because it is still opening. Either wait 
till it’s opened, or select a different address book.</_secondary>
   </error>
 
+  <error id="webkit-web-process-crashed" type="error">
+    <_primary>Something has gone wrong when displaying the contact</_primary>
+    <_secondary>A WebKitWebProcess crashed when displaying the contact. You can try again by moving to 
another contact and back. If the issue persists, please file a bug report in the GNOME bugzilla.</_secondary>
+  </error>
+
 </error-list>
diff --git a/src/addressbook/gui/widgets/eab-contact-display.c 
b/src/addressbook/gui/widgets/eab-contact-display.c
index 28cb9e9..de972ff 100644
--- a/src/addressbook/gui/widgets/eab-contact-display.c
+++ b/src/addressbook/gui/widgets/eab-contact-display.c
@@ -28,6 +28,8 @@
 
 #include <webkit2/webkit2.h>
 
+#include "shell/e-shell-utils.h"
+
 #include "e-contact-map.h"
 #include "eab-contact-formatter.h"
 #include "eab-gui-util.h"
@@ -378,6 +380,19 @@ contact_display_update_actions (EWebView *web_view)
 }
 
 static void
+contact_display_web_process_crashed_cb (EABContactDisplay *display)
+{
+       EAlertSink *alert_sink;
+
+       g_return_if_fail (EAB_IS_CONTACT_DISPLAY (display));
+
+       /* Cannot use the EWebView, because it places the alerts inside itself */
+       alert_sink = e_shell_utils_find_alternate_alert_sink (GTK_WIDGET (display));
+       if (alert_sink)
+               e_alert_submit (alert_sink, "addressbook:webkit-web-process-crashed", NULL);
+}
+
+static void
 eab_contact_display_class_init (EABContactDisplayClass *class)
 {
        GObjectClass *object_class;
@@ -453,6 +468,10 @@ eab_contact_display_init (EABContactDisplay *display)
        web_view = E_WEB_VIEW (display);
        ui_manager = e_web_view_get_ui_manager (web_view);
 
+       g_signal_connect (
+               display, "web-process-crashed",
+               G_CALLBACK (contact_display_web_process_crashed_cb), NULL);
+
        e_signal_connect_notify (
                web_view, "notify::load-changed",
                G_CALLBACK (contact_display_load_changed), NULL);
diff --git a/src/calendar/calendar.error.xml b/src/calendar/calendar.error.xml
index ecf2fb4..b6f043b 100644
--- a/src/calendar/calendar.error.xml
+++ b/src/calendar/calendar.error.xml
@@ -567,4 +567,19 @@
     <secondary>{1}</secondary>
   </error>
 
+  <error id="webkit-web-process-crashed-event" type="error">
+    <_primary>Something has gone wrong when displaying the event</_primary>
+    <_secondary>A WebKitWebProcess crashed when displaying the event. You can try again by moving to another 
event and back. If the issue persists, please file a bug report in the GNOME bugzilla.</_secondary>
+  </error>
+
+  <error id="webkit-web-process-crashed-memo" type="error">
+    <_primary>Something has gone wrong when displaying the memo</_primary>
+    <_secondary>A WebKitWebProcess crashed when displaying the memo. You can try again by moving to another 
memo and back. If the issue persists, please file a bug report in the GNOME bugzilla.</_secondary>
+  </error>
+
+  <error id="webkit-web-process-crashed-task" type="error">
+    <_primary>Something has gone wrong when displaying the task</_primary>
+    <_secondary>A WebKitWebProcess crashed when displaying the task. You can try again by moving to another 
task and back. If the issue persists, please file a bug report in the GNOME bugzilla.</_secondary>
+  </error>
+
 </error-list>
diff --git a/src/calendar/gui/e-cal-component-preview.c b/src/calendar/gui/e-cal-component-preview.c
index d185251..67e5690 100644
--- a/src/calendar/gui/e-cal-component-preview.c
+++ b/src/calendar/gui/e-cal-component-preview.c
@@ -30,6 +30,8 @@
 #include <glib/gi18n.h>
 #include <camel/camel.h>
 
+#include "shell/e-shell-utils.h"
+
 #define E_CAL_COMPONENT_PREVIEW_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
        ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewPrivate))
@@ -402,6 +404,34 @@ load_comp (ECalComponentPreview *preview)
 }
 
 static void
+cal_component_preview_web_process_crashed_cb (ECalComponentPreview *preview)
+{
+       EAlertSink *alert_sink;
+       const gchar *tagid;
+
+       g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview));
+
+       tagid = "system:webkit-web-process-crashed";
+
+       if (preview->priv->comp) {
+               ECalComponentVType vtype;
+
+               vtype = e_cal_component_get_vtype (preview->priv->comp);
+               if (vtype == E_CAL_COMPONENT_EVENT)
+                       tagid = "calendar:webkit-web-process-crashed-event";
+               else if (vtype == E_CAL_COMPONENT_TODO)
+                       tagid = "calendar:webkit-web-process-crashed-task";
+               else if (vtype == E_CAL_COMPONENT_JOURNAL)
+                       tagid = "calendar:webkit-web-process-crashed-memo";
+       }
+
+       /* Cannot use the EWebView, because it places the alerts inside itself */
+       alert_sink = e_shell_utils_find_alternate_alert_sink (GTK_WIDGET (preview));
+       if (alert_sink)
+               e_alert_submit (alert_sink, tagid, NULL);
+}
+
+static void
 cal_component_preview_finalize (GObject *object)
 {
        clear_comp_info (E_CAL_COMPONENT_PREVIEW (object));
@@ -429,6 +459,10 @@ e_cal_component_preview_init (ECalComponentPreview *preview)
        g_signal_connect (
                preview, "style-updated",
                G_CALLBACK (load_comp), NULL);
+
+       g_signal_connect (
+               preview, "web-process-crashed",
+               G_CALLBACK (cal_component_preview_web_process_crashed_cb), NULL);
 }
 
 GtkWidget *
diff --git a/src/composer/mail-composer.error.xml b/src/composer/mail-composer.error.xml
index b6943fc..4f1c0d4 100644
--- a/src/composer/mail-composer.error.xml
+++ b/src/composer/mail-composer.error.xml
@@ -135,4 +135,8 @@
   <button _label="Convert to _Message" response="GTK_RESPONSE_YES"/>
  </error>
 
+ <error id="webkit-web-process-crashed" type="error">
+   <_primary>Something has gone wrong when editing the message</_primary>
+   <_secondary>A WebKitWebProcess crashed when editing the message. You can try again by closing the 
composer window and opening a new one. If the issue persists, please file a bug report in the GNOME 
bugzilla.</_secondary>
+ </error>
 </error-list>
diff --git a/src/e-util/e-mail-signature-preview.c b/src/e-util/e-mail-signature-preview.c
index d8e4553..bce4988 100644
--- a/src/e-util/e-mail-signature-preview.c
+++ b/src/e-util/e-mail-signature-preview.c
@@ -35,6 +35,7 @@ struct _EMailSignaturePreviewPrivate {
        ESourceRegistry *registry;
        GCancellable *cancellable;
        gchar *source_uid;
+       gboolean webprocess_crashed;
 };
 
 enum {
@@ -111,6 +112,22 @@ mail_signature_preview_load_cb (ESource *source,
 }
 
 static void
+mail_signature_preview_web_process_crashed_cb (EMailSignaturePreview *preview)
+{
+       g_return_if_fail (E_IS_MAIL_SIGNATURE_PREVIEW (preview));
+
+       if (preview->priv->webprocess_crashed)
+               return;
+
+       preview->priv->webprocess_crashed = TRUE;
+
+       /* Should not use the EWebView, because it places the alerts inside itself,
+          but no better place here. Thus show the error only once, to avoid endless
+          repeating. */
+       e_alert_submit (E_ALERT_SINK (preview), "mail:webkit-web-process-crashed-signature", NULL);
+}
+
+static void
 mail_signature_preview_set_registry (EMailSignaturePreview *preview,
                                      ESourceRegistry *registry)
 {
@@ -304,6 +321,11 @@ static void
 e_mail_signature_preview_init (EMailSignaturePreview *preview)
 {
        preview->priv = E_MAIL_SIGNATURE_PREVIEW_GET_PRIVATE (preview);
+       preview->priv->webprocess_crashed = FALSE;
+
+       g_signal_connect (
+               preview, "web-process-crashed",
+               G_CALLBACK (mail_signature_preview_web_process_crashed_cb), NULL);
 }
 
 GtkWidget *
diff --git a/src/e-util/e-system.error.xml b/src/e-util/e-system.error.xml
index 14705ed..bb88067 100644
--- a/src/e-util/e-system.error.xml
+++ b/src/e-util/e-system.error.xml
@@ -85,4 +85,8 @@
   <_secondary>The reported error was “{1}”.</_secondary>
  </error>
 
+ <error id="webkit-web-process-crashed" type="error">
+   <_primary>Something has gone wrong</_primary>
+   <_secondary>A WebKitWebProcess crashed when displaying the content. You can try again by reopening the 
window. If the issue persists, please file a bug report in the GNOME bugzilla.</_secondary>
+ </error>
 </error-list>
diff --git a/src/mail/e-mail-display.c b/src/mail/e-mail-display.c
index 79324bc..27d1f3c 100644
--- a/src/mail/e-mail-display.c
+++ b/src/mail/e-mail-display.c
@@ -33,6 +33,8 @@
 #include <em-format/e-mail-part-attachment.h>
 #include <em-format/e-mail-part-utils.h>
 
+#include "shell/e-shell-utils.h"
+
 #include "e-cid-request.h"
 #include "e-http-request.h"
 #include "e-mail-display-popup-extension.h"
@@ -1818,6 +1820,19 @@ e_mail_display_test_change_and_update_fonts_cb (EMailDisplay *mail_display,
 }
 
 static void
+mail_display_web_process_crashed_cb (EMailDisplay *display)
+{
+       EAlertSink *alert_sink;
+
+       g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+       /* Cannot use the EWebView, because it places the alerts inside itself */
+       alert_sink = e_shell_utils_find_alternate_alert_sink (GTK_WIDGET (display));
+       if (alert_sink)
+               e_alert_submit (alert_sink, "mail:webkit-web-process-crashed", NULL);
+}
+
+static void
 e_mail_display_class_init (EMailDisplayClass *class)
 {
        GObjectClass *object_class;
@@ -1964,6 +1979,10 @@ e_mail_display_init (EMailDisplay *display)
        display->priv->scheduled_reload = 0;
 
        g_signal_connect (
+               display, "web-process-crashed",
+               G_CALLBACK (mail_display_web_process_crashed_cb), NULL);
+
+       g_signal_connect (
                display, "decide-policy",
                G_CALLBACK (decide_policy_cb), NULL);
 
diff --git a/src/mail/mail.error.xml b/src/mail/mail.error.xml
index 5468c69..d9a5e6b 100644
--- a/src/mail/mail.error.xml
+++ b/src/mail/mail.error.xml
@@ -633,4 +633,15 @@ in the folder will be available in offline mode.</_secondary>
     <_primary>Failed to store message note in folder “{0}”</_primary>
     <secondary>{1}</secondary>
   </error>
+
+  <error id="webkit-web-process-crashed" type="error">
+    <_primary>Something has gone wrong when displaying the message</_primary>
+    <_secondary>A WebKitWebProcess crashed when displaying the message. You can try again by moving to 
another message and back. If the issue persists, please file a bug report in the GNOME bugzilla.</_secondary>
+  </error>
+
+  <error id="webkit-web-process-crashed-signature" type="error">
+    <_primary>Something has gone wrong when displaying the signature</_primary>
+    <_secondary>A WebKitWebProcess crashed when displaying the signature. You can try again by moving to 
another signature and back. If the issue persists, please file a bug report in the GNOME 
bugzilla.</_secondary>
+  </error>
+
 </error-list>
diff --git a/src/modules/webkit-editor/CMakeLists.txt b/src/modules/webkit-editor/CMakeLists.txt
index e04f48e..d974218 100644
--- a/src/modules/webkit-editor/CMakeLists.txt
+++ b/src/modules/webkit-editor/CMakeLists.txt
@@ -1,4 +1,6 @@
-set(extra_deps)
+set(extra_deps
+       evolution-mail-composer
+)
 set(sources
        evolution-module-webkit-editor.c
        e-webkit-editor-extension.c
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 7f35ffc..331782b 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -20,7 +20,9 @@
 
 #include "web-extension/e-editor-web-extension-names.h"
 
-#include <e-util/e-util.h>
+#include "e-util/e-util.h"
+#include "composer/e-msg-composer.h"
+
 #include <string.h>
 
 #define E_WEBKIT_EDITOR_GET_PRIVATE(obj) \
@@ -5770,9 +5772,36 @@ webkit_editor_drag_end_cb (EWebKitEditor *wk_editor,
 static void
 webkit_editor_web_process_crashed_cb (EWebKitEditor *wk_editor)
 {
-       g_warning (
-               "WebKitWebProcess (page id %ld) for EWebKitEditor crashed",
-               webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (wk_editor)));
+       GtkWidget *widget;
+
+       g_return_if_fail (E_IS_WEBKIT_EDITOR (wk_editor));
+
+       widget = GTK_WIDGET (wk_editor);
+       while (widget) {
+               if (E_IS_ALERT_SINK (widget)) {
+                       e_alert_submit (E_ALERT_SINK (widget), "mail-composer:webkit-web-process-crashed", 
NULL);
+                       break;
+               }
+
+               if (E_IS_MSG_COMPOSER (widget)) {
+                       EHTMLEditor *html_editor;
+
+                       html_editor = e_msg_composer_get_editor (E_MSG_COMPOSER (widget));
+                       if (html_editor) {
+                               e_alert_submit (E_ALERT_SINK (html_editor), 
"mail-composer:webkit-web-process-crashed", NULL);
+                               break;
+                       }
+               }
+
+               widget = gtk_widget_get_parent (widget);
+       }
+
+       /* No suitable EAlertSink found as the parent widget */
+       if (!widget) {
+               g_warning (
+                       "WebKitWebProcess (page id %ld) for EWebKitEditor crashed",
+                       webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (wk_editor)));
+       }
 }
 
 static void
diff --git a/src/shell/e-shell-utils.c b/src/shell/e-shell-utils.c
index 0028017..01724c1 100644
--- a/src/shell/e-shell-utils.c
+++ b/src/shell/e-shell-utils.c
@@ -448,3 +448,28 @@ e_shell_utils_run_help_contents (EShell *shell)
        e_display_help (window, NULL);
 #endif
 }
+
+/**
+ * e_shell_utils_find_alternate_alert_sink:
+ * @widget: a #GtkWidget for which to do the search
+ *
+ * Search an alternate #EAlertSink in the widget hierarchy up-wards
+ * from the @widget (skipping the @widget itself).
+ *
+ * Returns: (nullable) (transfer none): an alert sink, different than @widget,
+ *    or %NULL, when none found
+ *
+ * Since: 3.24
+ **/
+EAlertSink *
+e_shell_utils_find_alternate_alert_sink (GtkWidget *widget)
+{
+       g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+       while (widget = gtk_widget_get_parent (widget), widget) {
+               if (E_IS_ALERT_SINK (widget))
+                       return E_ALERT_SINK (widget);
+       }
+
+       return NULL;
+}
diff --git a/src/shell/e-shell-utils.h b/src/shell/e-shell-utils.h
index c3cc640..5cfe98a 100644
--- a/src/shell/e-shell-utils.h
+++ b/src/shell/e-shell-utils.h
@@ -47,6 +47,8 @@ void          e_shell_utils_run_quick_reference
                                                (EShell *shell);
 void           e_shell_utils_run_help_about    (EShell *shell);
 void           e_shell_utils_run_help_contents (EShell *shell);
+EAlertSink *   e_shell_utils_find_alternate_alert_sink
+                                               (GtkWidget *widget);
 
 G_END_DECLS
 


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