[gnome-builder] webkit: disable unneeded WebKit features



commit 0067e07b416795f704ebe8c37c2a42250b9b148d
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun May 31 09:27:31 2015 -0500

    webkit: disable unneeded WebKit features
    
    This is partially a workaround for WebKit bug #143245, where the
    inspector process pool and default process pool (the default web
    context) access the HTML5 local storage database at the same time from
    different threads. In theory, that's an SQLite bug, but it doesn't
    really matter because GNOME Builder is not a web browser and it doesn't
    need HTML5 local storage. Let's avoid the issue altogether by disabling
    it.
    
    This probably won't stop Builder from accessing the local storage
    database altogether, because it won't affect the inspector web context,
    but now it should only happen from one thread at a time. WebKit master
    is smart enough to not create the inspector web context unless it's
    actually needed, so going forward that shouldn't be an issue anymore
    (since Builder does not enable the web inspector).
    
    Note: it would probably be a bit better to disable these settings before
    creating the web view, rather than after. But I'm not sure how to do
    that with the web views living in .ui files, and they seem happy there.
    There might be a teensy race left open, but it's a WebKit or SQLite bug
    rather than a Builder bug, and nobody will ever hit it, knock on wood.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750163

 src/Makefile.am               |    2 ++
 src/devhelp/gb-devhelp-view.c |    4 ++++
 src/html/gb-html-view.c       |    4 ++++
 src/util/gb-webkit.c          |   33 +++++++++++++++++++++++++++++++++
 src/util/gb-webkit.h          |   30 ++++++++++++++++++++++++++++++
 5 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index b9e539e..ebb37fc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -149,6 +149,8 @@ libgnome_builder_la_SOURCES = \
        util/gb-rgba.h \
        util/gb-string.c \
        util/gb-string.h \
+       util/gb-webkit.c \
+       util/gb-webkit.h \
        util/gb-widget.c \
        util/gb-widget.h \
        views/gb-view-grid.c \
diff --git a/src/devhelp/gb-devhelp-view.c b/src/devhelp/gb-devhelp-view.c
index 0f3d582..0aee130 100644
--- a/src/devhelp/gb-devhelp-view.c
+++ b/src/devhelp/gb-devhelp-view.c
@@ -22,6 +22,7 @@
 #include <webkit2/webkit2.h>
 
 #include "gb-devhelp-view.h"
+#include "gb-webkit.h"
 #include "gb-widget.h"
 
 struct _GbDevhelpView
@@ -253,4 +254,7 @@ static void
 gb_devhelp_view_init (GbDevhelpView *self)
 {
   gtk_widget_init_template (GTK_WIDGET (self));
+
+  gb_webkit_web_view_apply_settings (self->web_view1);
+  gb_webkit_web_view_apply_settings (self->web_view2);
 }
diff --git a/src/html/gb-html-view.c b/src/html/gb-html-view.c
index 3e2338c..43b8d0d 100644
--- a/src/html/gb-html-view.c
+++ b/src/html/gb-html-view.c
@@ -26,6 +26,7 @@
 #include "gb-editor-document.h"
 #include "gb-html-document.h"
 #include "gb-html-view.h"
+#include "gb-webkit.h"
 #include "gb-widget.h"
 
 struct _GbHtmlView
@@ -342,6 +343,9 @@ gb_html_view_init (GbHtmlView *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
+  gb_webkit_web_view_apply_settings (self->web_view1);
+  gb_webkit_web_view_apply_settings (self->web_view2);
+
   controls = gb_view_get_controls (GB_VIEW (self));
 
   actions = g_simple_action_group_new ();
diff --git a/src/util/gb-webkit.c b/src/util/gb-webkit.c
new file mode 100644
index 0000000..050a521
--- /dev/null
+++ b/src/util/gb-webkit.c
@@ -0,0 +1,33 @@
+/* gb-webkit.c
+ *
+ * Copyright (C) 2015 Michael Catanzaro <mcatanzaro igalia com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gb-webkit.h"
+
+void
+gb_webkit_web_view_apply_settings (WebKitWebView *view)
+{
+  /*
+   * TODO: Consider whether HTML5 local storage should be enabled. It could only
+   * possibly be useful for complex web sites, but if you're building a web site
+   * with Builder then it might be useful to have. But leave disabled until
+   * https://bugs.webkit.org/show_bug.cgi?id=143245 has been fixed.
+   */
+  g_object_set (webkit_web_view_get_settings (view),
+                "enable-html5-local-storage", FALSE,
+                NULL);
+}
diff --git a/src/util/gb-webkit.h b/src/util/gb-webkit.h
new file mode 100644
index 0000000..f8acfc1
--- /dev/null
+++ b/src/util/gb-webkit.h
@@ -0,0 +1,30 @@
+/* gb-webkit.h
+ *
+ * Copyright (C) 2015 Michael Catanzaro <mcatanzaro igalia com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GB_WEBKIT_H
+#define GB_WEBKIT_H
+
+#include <webkit2/webkit2.h>
+
+G_BEGIN_DECLS
+
+void gb_webkit_web_view_apply_settings (WebKitWebView *view);
+
+G_END_DECLS
+
+#endif /* GB_WEBKIT_H */


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