{"id":902,"date":"2017-03-20T16:19:15","date_gmt":"2017-03-20T15:19:15","guid":{"rendered":"http:\/\/blogs.igalia.com\/carlosgc\/?p=902"},"modified":"2017-03-20T16:19:15","modified_gmt":"2017-03-20T15:19:15","slug":"webkitgtk-2-16","status":"publish","type":"post","link":"https:\/\/blogs.igalia.com\/carlosgc\/2017\/03\/20\/webkitgtk-2-16\/","title":{"rendered":"WebKitGTK+ 2.16"},"content":{"rendered":"<p>The <a href=\"https:\/\/www.igalia.com\/\">Igalia<\/a> WebKit team is happy to announce <a href=\"https:\/\/lists.webkit.org\/pipermail\/webkit-gtk\/2017-March\/002971.html\">WebKitGTK+ 2.16<\/a>. This new release drastically improves the memory consumption, adds new API as required by applications, includes new debugging tools, and of course fixes a lot of bugs.<\/p>\n<h2>Memory consumption<\/h2>\n<p>After <a href=\"https:\/\/blogs.igalia.com\/carlosgc\/2016\/09\/20\/webkitgtk-2-14\/\">WebKitGTK+ 2.14<\/a> was released, several Epiphany users started to complain about high memory usage of WebKitGTK+ when Epiphany had a lot of tabs open. As we already explained in a <a href=\"https:\/\/blogs.igalia.com\/carlosgc\/2017\/02\/10\/accelerated-compositing-in-webkitgtk-2-14-4\/\">previous post<\/a>, this was because of the switch to the threaded compositor, that made hardware acceleration always enabled. To fix this, we decided to make hardware acceleration optional again, enabled only when websites require it, but still using the threaded compositor. This is by far the major improvement in the memory consumption, but not the only one. Even when in accelerated compositing mode, we managed to reduce the memory required by GL contexts when using GLX, by using OpenGL version 3.2 (core profile) if available. In mesa based drivers that means that software rasterizer fallback is never required, so the context doesn&#8217;t need to create the software rasterization part. And finally, an important bug was fixed in the JavaScript garbage collector timers that prevented the garbage collection to happen in some cases.<\/p>\n<h2>CSS Grid Layout<\/h2>\n<p>Yes, the future here and now available by default in all WebKitGTK+ based browsers and web applications. This is the result of several years of great work by the <a href=\"https:\/\/www.igalia.com\/\">Igalia<\/a> web platform team in collaboration with bloomberg. If you are interested, you have all the details in <a href=\"https:\/\/blogs.igalia.com\/mrego\/2017\/03\/16\/css-grid-layout-is-here-to-stay\/\">Manuel&#8217;s blog<\/a>.<\/p>\n<h2>New API<\/h2>\n<p>The WebKitGTK+ API is quite complete now, but there&#8217;s always new things required by our users.<\/p>\n<p><b>Hardware acceleration policy<\/b><\/p>\n<p>Hardware acceleration is now enabled on demand again, when a website requires to use accelerated compositing, the hardware acceleration is enabled automatically. WebKitGTK+ has environment variables to change this behavior, WEBKIT_DISABLE_COMPOSITING_MODE to never enable hardware acceleration and WEBKIT_FORCE_COMPOSITING_MODE to always enabled it. However, those variables were never meant to be used by applications, but only for developers to test the different code paths. The main problem of those variables is that they apply to all web views of the application. Not all of the WebKitGTK+ applications are web browsers, so it can happen that an application knows it will never need hardware acceleration for a particular web view, like for example the evolution composer, while other applications, especially in the embedded world, always want hardware acceleration enabled and don&#8217;t want to waste time and resources with the switch between modes. For those cases a new WebKitSetting <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitSettings.html#WebKitSettings--hardware-acceleration-policy\">hardware-acceleration-policy<\/a> has been added. We encourage everybody to use this setting instead of the environment variables when upgrading to WebKitGTk+ 2.16.<\/p>\n<p><b>Network proxy settings<\/b><\/p>\n<p>Since the switch to WebKit2, where the SoupSession is no longer available from the API, it hasn&#8217;t been possible to change the network proxy settings from the API. WebKitGTK+ has always used the default proxy resolver when creating the soup context, and that just works for most of our users. But there are some corner cases in which applications that don&#8217;t run under a GNOME environment want to provide their own proxy settings instead of using the proxy environment variables. For those cases WebKitGTK+ 2.16 includes a new <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitNetworkProxySettings.html\">UI process API<\/a> to configure all proxy settings available in GProxyResolver API.<\/p>\n<p><b>Private browsing<\/b><\/p>\n<p>WebKitGTK+ has always had a WebKitSetting to enable or disable the private browsing mode, but it has never worked really well. For that reason, applications like Epiphany has always implemented their own private browsing mode just by using a different profile directory in tmp to write all persistent data. This approach has several issues, for example if the UI process crashes, the profile directory is leaked in tmp with all the personal data there. WebKitGTK+ 2.16 adds a new API that allows to create <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitWebView.html#WebKitWebView--is-ephemeral\">ephemeral web views<\/a> which never write any persistent data to disk. It&#8217;s possible to create ephemeral web views individually, or create <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitWebContext.html#webkit-web-context-new-ephemeral\">ephemeral web contexts <\/a>where all web views associated to it will be ephemeral automatically.<\/p>\n<p><b>Website data<\/b><\/p>\n<p><a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitWebsiteDataManager.html\">WebKitWebsiteDataManager<\/a> was added in 2.10 to configure the default paths on which website data should be stored for a web context. In WebKitGTK+ 2.16 the API has been expanded to include methods to <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitWebsiteDataManager.html#webkit-website-data-manager-fetch\">retrieve<\/a> and <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitWebsiteDataManager.html#webkit-website-data-manager-remove\">remove<\/a> the <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitWebsiteData.html\">website data<\/a> stored on the client side. Not only persistent data like HTTP disk cache, cookies or databases, but also non-persistent data like the memory cache and session cookies. This API is already used by Epiphany to implement the new personal data dialog.<\/p>\n<p><b>Dynamically added forms<\/b><\/p>\n<p>Web browsers normally implement the remember passwords functionality by searching in the DOM tree for authentication form fields when the <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitWebPage.html#WebKitWebPage-document-loaded\">document loaded<\/a> signal is emitted. However, some websites add the authentication form fields dynamically after the document has been loaded. In those cases web browsers couldn&#8217;t find any form fields to autocomplete. In WebKitGTk+ 2.16 the web extensions API includes <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitWebPage.html#WebKitWebPage-form-controls-associated\">a new signal<\/a> to notify when new forms are added to the DOM. Applications can connect to it, instead of document-loaded to start searching for authentication form fields.<\/p>\n<p><b>Custom print settings<\/b><\/p>\n<p>The GTK+ print dialog allows the user to add a new tab embedding a custom widget, so that applications can include their own print settings UI. Evolution used to do this, but the functionality was lost with the switch to WebKit2. In WebKitGTK+ 2.16 a <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitPrintCustomWidget.html\">similar API to the GTK+ one<\/a> has been added to recover that functionality in evolution.<\/p>\n<p><b>Notification improvements<\/b><\/p>\n<p>Applications can now set the <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitWebContext.html#webkit-web-context-initialize-notification-permissions\">initial notification permissions<\/a> on the web context to avoid having to ask the user everytime. It&#8217;s also possible to <a href=\"https:\/\/webkitgtk.org\/reference\/webkit2gtk\/unstable\/WebKitNotification.html#webkit-notification-get-tag\">get the tag identifier <\/a>of a WebKitNotification.<\/p>\n<h2>Debugging tools<\/h2>\n<p>Two new debugged tools are now available in WebKitGTk+ 2.16. The memory sampler and the resource usage overlay.<\/p>\n<p><b>Memory sampler<\/b><\/p>\n<p>This tool allows to monitor the memory consumption of the WebKit processes. It can be enabled by defining the environment variable WEBKIT_SMAPLE_MEMORY. When enabled, the UI process and all web process will automatically take samples of memory usage every second. For every sample a detailed report of the memory used by the process is generated and written to a file in the temp directory.<\/p>\n<pre>\n$ WEBKIT_SAMPLE_MEMORY=1 MiniBrowser \nStarted memory sampler for process MiniBrowser 32499; Sampler log file stored at: \/tmp\/MiniBrowser7ff2246e-406e-4798-bc83-6e525987aace\nStarted memory sampler for process WebKitWebProces 32512; Sampler log file stored at: \/tmp\/WebKitWebProces93a10a0f-84bb-4e3c-b257-44528eb8f036\n<\/pre>\n<p>The files contain a list of sample reports like this one:<\/p>\n<pre>\nTimestamp                          1490004807\nTotal Program Bytes                1960214528\nResident Set Bytes                 84127744\nResident Shared Bytes              68661248\nText Bytes                         4096\nLibrary Bytes                      0\nData + Stack Bytes                 87068672\nDirty Bytes                        0\nFast Malloc In Use                 86466560\nFast Malloc Committed Memory       86466560\nJavaScript Heap In Use             0\nJavaScript Heap Committed Memory   49152\nJavaScript Stack Bytes             2472\nJavaScript JIT Bytes               8192\nTotal Memory In Use                86477224\nTotal Committed Memory             86526376\nSystem Total Bytes                 16729788416\nAvailable Bytes                    5788946432\nShared Bytes                       1037447168\nBuffer Bytes                       844214272\nTotal Swap Bytes                   1996484608\nAvailable Swap Bytes               1991532544\n<\/pre>\n<p><b>Resource usage overlay<\/b><\/p>\n<p>The resource usage overlay is only available in Linux systems when WebKitGTK+ is built with ENABLE_DEVELOPER_MODE. It allows to show an overlay with information about resources currently in use by the web process like CPU usage, total memory consumption, JavaScript memory and JavaScript garbage collector timers information. The overlay can be shown\/hidden by pressing CTRL+Shit+G.<\/p>\n<p><a href=\"http:\/\/blogs.igalia.com\/carlosgc\/files\/2017\/03\/minibrowser-resources-overlay.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blogs.igalia.com\/carlosgc\/files\/2017\/03\/minibrowser-resources-overlay.png\" alt=\"\" width=\"800\" height=\"636\" class=\"aligncenter size-full wp-image-903\" \/><\/a><\/p>\n<p>We plan to add more information to the overlay in the future like memory cache status.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Igalia WebKit team is happy to announce WebKitGTK+ 2.16. This new release drastically improves the memory consumption, adds new API as required by applications, includes new debugging tools, and of course fixes a lot of bugs. Memory consumption After &hellip; <a href=\"https:\/\/blogs.igalia.com\/carlosgc\/2017\/03\/20\/webkitgtk-2-16\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6,7,8],"tags":[22],"class_list":["post-902","post","type-post","status-publish","format-standard","hentry","category-free-software","category-gnome","category-igalia","category-webkit","tag-webkit"],"_links":{"self":[{"href":"https:\/\/blogs.igalia.com\/carlosgc\/wp-json\/wp\/v2\/posts\/902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.igalia.com\/carlosgc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.igalia.com\/carlosgc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/carlosgc\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/carlosgc\/wp-json\/wp\/v2\/comments?post=902"}],"version-history":[{"count":11,"href":"https:\/\/blogs.igalia.com\/carlosgc\/wp-json\/wp\/v2\/posts\/902\/revisions"}],"predecessor-version":[{"id":914,"href":"https:\/\/blogs.igalia.com\/carlosgc\/wp-json\/wp\/v2\/posts\/902\/revisions\/914"}],"wp:attachment":[{"href":"https:\/\/blogs.igalia.com\/carlosgc\/wp-json\/wp\/v2\/media?parent=902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.igalia.com\/carlosgc\/wp-json\/wp\/v2\/categories?post=902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.igalia.com\/carlosgc\/wp-json\/wp\/v2\/tags?post=902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}