{"@attributes":{"version":"2.0"},"channel":{"title":"TingPing's blog","description":"Development blog of TingPing","link":"https:\/\/blog.tingping.se\/","pubDate":"Thu, 02 Jan 2025 12:12:03 -0500","lastBuildDate":"Thu, 02 Jan 2025 12:12:03 -0500","generator":"Jekyll v3.10.0","item":[{"title":"Introducing the WebKit Container SDK","description":"<p>Developing <a href=\"https:\/\/webkitgtk.org\">WebKitGTK<\/a> and <a href=\"https:\/\/wpewebkit.org\/\">WPE<\/a> has always had challenges such as the amount of dependencies or it\u2019s fairly complex C++ codebase which not all compiler versions handle well. To help with this we\u2019ve made a new SDK to make it easier.<\/p>\n\n<!--more-->\n\n<h3 id=\"current-solutions\">Current Solutions<\/h3>\n\n<p>There have always been multiple ways to build WebKit and its dependencies on your host however this was never a great developer experience. Only very specific hosts could be \u201csupported\u201d, you often had to build a large number of dependencies, and the end result wasn\u2019t very reproducable for others.<\/p>\n\n<p>The current solution used by default is a Flatpak based one. This was a big improvement for ease of use and excellent for reproducablity but it introduced many challenges doing development work. As it has a strict sandbox and provides read-only runtimes it was difficult to use complex tooling\/IDEs or develop third party libraries in it.<\/p>\n\n<p>The new SDK tries to take a middle ground between those two alternatives, isolating itself from the host to be somewhat reproducable, yet being a mutable environment to be flexible enough for a wide range of tools and workflows.<\/p>\n\n<h3 id=\"the-webkit-container-sdk\">The WebKit Container SDK<\/h3>\n\n<p>At the core it is an Ubuntu OCI image with all of the dependencies and tooling needed to work on WebKit. On top of this we added some scripts to run\/manage these containers with podman and aid in developing inside of the container. It\u2019s intention is to be as simple as possible and not change traditional development workflows.<\/p>\n\n<p>You can find the SDK and follow the quickstart guide on our GitHub: <a href=\"https:\/\/github.com\/Igalia\/webkit-container-sdk\">https:\/\/github.com\/Igalia\/webkit-container-sdk<\/a><\/p>\n\n<p>The main requirements is that this only works on Linux with podman 4.0+ installed. For example Ubuntu 23.10+.<\/p>\n\n<p>In the most simple case, once you clone <code class=\"language-plaintext highlighter-rouge\">https:\/\/github.com\/Igalia\/webkit-container-sdk.git<\/code>, using the SDK can be a few commands:<\/p>\n\n<div class=\"language-sh highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nb\">source<\/span> \/your\/path\/to\/webkit-container-sdk\/register-sdk-on-host.sh\nwkdev-create <span class=\"nt\">--create-home<\/span>\nwkdev-enter\n<\/code><\/pre><\/div><\/div>\n\n<p>From there you can use WebKit\u2019s build scripts (<code class=\"language-plaintext highlighter-rouge\">.\/Tools\/Scripts\/build-webkit --gtk<\/code>) or CMake. As mentioned before it is an Ubuntu installation so you can easily install your favorite tools directly like VSCode. We even provide a <code class=\"language-plaintext highlighter-rouge\">wkdev-setup-vscode<\/code> script to automate that.<\/p>\n\n<h3 id=\"advanced-usage\">Advanced Usage<\/h3>\n\n<h4 id=\"disposibility\">Disposibility<\/h4>\n\n<p>A workflow that some developers may not be familiar with is making use of entirely disposable development environments. Since these are isolated containers you can easily make two. This allows you to do work in parallel that would interfere with eachother while not worrying about it as well as being able to get back to a known good state easily:<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>wkdev-create --name=playground1\nwkdev-create --name=playground2\n\npodman rm playground1 # You would stop first if running.\nwkdev-enter --name=playground2\n<\/code><\/pre><\/div><\/div>\n\n<h4 id=\"working-on-dependencies\">Working on Dependencies<\/h4>\n\n<p>An important part of WebKit development is working on the dependencies of WebKit rather than itself, either for debugging or for new features. This can be difficult or error-prone with previous solutions. In order to make this easier we use a project called <a href=\"https:\/\/gnome.pages.gitlab.gnome.org\/jhbuild\/\">JHBuild<\/a> which isn\u2019t new but works well with containers and is a simple solution to work on our core dependencies.<\/p>\n\n<p>Here is an example workflow working on GLib:<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>wkdev-create --name=glib\nwkdev-enter --name=glib\n\n# This will clone glib main, build, and install it for us. \njhbuild build glib\n\n# At this point you could simply test if a bug was fixed in a different versin of glib.\n# We can also modify and debug glib directly. All of the projects are cloned into ~\/checkout.\ncd ~\/checkout\/glib\n\n# Modify the source however you wish then install your new version.\njhbuild make\n<\/code><\/pre><\/div><\/div>\n\n<p>Remember that containers are isoated from each other so you can even have two terminals open with different builds of glib. This can also be used to test projects like Epiphany against your build of WebKit if you install it into the JHBUILD_PREFIX.<\/p>\n\n<h3 id=\"to-be-continued\">To Be Continued<\/h3>\n\n<p>In the next blog post I\u2019ll document how to use VSCode inside of the SDK for debugging and development.<\/p>\n","pubDate":"Thu, 23 May 2024 00:00:00 -0400","link":"https:\/\/blog.tingping.se\/2024\/05\/23\/Introducing-WebKit-Container-SDK.html","guid":"https:\/\/blog.tingping.se\/2024\/05\/23\/Introducing-WebKit-Container-SDK.html","category":["igalia","webkit"]},{"title":"WebExtension Support in Epiphany","description":"<p>I\u2019m excited to help bring WebExtensions to <a href=\"https:\/\/wiki.gnome.org\/action\/show\/Apps\/Web\">Epiphany<\/a> (GNOME Web) thanks to investment from my employer <a href=\"https:\/\/igalia.com\">Igalia<\/a>. In this post, I\u2019ll go over a summary of how extensions work and give details on what Epiphany supports.<\/p>\n\n<!--more-->\n\n<p>Web browsers have supported extensions in some form for decades. They allow the creation of features that would otherwise be part of a browser but can be authored and experimented with more easily. They\u2019ve helped develop and popularize ideas like ad blocking, password management, and reader modes. Sometimes, as in very popular cases like these, browsers themselves then begin trying to apply lessons upstream.<\/p>\n\n<h2 id=\"toward-universal-support\">Toward universal support<\/h2>\n\n<p>For most of this history, web extensions have used incompatible browser-specific APIs. This began to change in 2015 with Firefox adopting an API similar to Chrome\u2019s. In 2020, Safari also followed suit. We now have the foundations of an ecosystem-wide solution.<\/p>\n\n<p>\u201cThe foundations of\u201d is an important thing to understand: There are still plenty of existing extensions built with browser-specific APIs and this doesn\u2019t magically make them all portable. It does, however, provide a way towards making portable extensions. In some cases, existing extensions might just need some porting. In other cases, they may utilize features that aren\u2019t entirely universal yet (or, may never be).<\/p>\n\n<h2 id=\"bringing-extensions-to-epiphany\">Bringing Extensions to Epiphany<\/h2>\n\n<p>With version 43.alpha Epiphany users can <em>begin<\/em> to take advantage of some of the same powerful and portable extensions described above. Note that there are quite a few APIs that power this and with this release we\u2019ve covered a meaningful segment of them but not all (details below). Over time our API coverage and interoperability will continue to grow.<\/p>\n\n<h2 id=\"what-webextensions-can-do-technical-details\">What WebExtensions can do: Technical Details<\/h2>\n\n<p>At a high level, WebExtensions allow a private privileged web page to run in the browser. This is an invisible <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/Add-ons\/WebExtensions\/manifest.json\/background\">Background Page<\/a> that has access to a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/Add-ons\/WebExtensions\/Browser_support_for_JavaScript_APIs\"><code class=\"language-plaintext highlighter-rouge\">browser<\/code><\/a> JavaScript API. This API, given permission, can interact with browser tabs, cookies, downloads, bookmarks, and more.<\/p>\n\n<p>Along with the invisible background page, it gives a few options to show a UI to the user. One such method is a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/Add-ons\/WebExtensions\/manifest.json\/browser_action\">Browser Action<\/a> which is shown as a button in the browser\u2019s toolbar that can popup an HTML view for the user to interact with. Another is an <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/Add-ons\/WebExtensions\/manifest.json\/options_ui\">Options Page<\/a> dedicated to configuring the extension.<\/p>\n\n<p>Lastly, an extension can inject JavaScript directly into any website it has permissions to via <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/Add-ons\/WebExtensions\/manifest.json\/content_scripts\">Content Scripts<\/a>. These scripts are given full access to the DOM of any web page they run in. However content scripts don\u2019t have access to the majority of the <code class=\"language-plaintext highlighter-rouge\">browser<\/code> API but, along with the above pages, it has the ability to send and receive custom JSON messages to all pages within an extension.<\/p>\n\n<h3 id=\"example-usage\">Example usage<\/h3>\n\n<p>For a real-world example, I use Bitwarden as my password manager which I\u2019ll simplify how it roughly functions. Firstly there is a Background Page that does account management for your user. It has a Popup that the user can trigger to interface with your account, passwords, and options. Finally, it also injects Content Scripts into every website you open.<\/p>\n\n<p>The Content Script can detect all input fields and then wait for a message to autofill information into them. The Popup can request the details of the active tab and, upon you selecting an account, send a message to the Content Script to fill this information. This flow does function in Epiphany now but there are still some issues to iron out for Bitwarden.<\/p>\n\n<h2 id=\"epiphanys-current-support\">Epiphany\u2019s current support<\/h2>\n\n<p>Epiphany 43.alpha supports the basic structure described above. We are currently modeling our behavior after Firefox\u2019s ManifestV2 API which includes compatibility with Chrome extensions where possible. Supporting ManifestV3 is planned alongside V2 in the future.<\/p>\n\n<p>As of today, we support the majority of:<\/p>\n\n<ul>\n  <li><code class=\"language-plaintext highlighter-rouge\">alarms<\/code> - Scheduling of events to trigger at specific dates or times.<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">commands<\/code> - Keyboard shortcuts.<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">cookies<\/code> - Management and querying of browser cookies.<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">downloads<\/code> - Ability to start and manage downloads.<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">menus<\/code> - Creation of context menu items.<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">notifications<\/code> - Ability to show desktop notifications.<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">storage<\/code> - Storage of extension private settings.<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">tabs<\/code> - Control and monitoring of browser tabs, including creating, closing, etc.<\/li>\n  <li><code class=\"language-plaintext highlighter-rouge\">windows<\/code> - Control and monitoring of browser windows.<\/li>\n<\/ul>\n\n<p>A notable missing API is <code class=\"language-plaintext highlighter-rouge\">webRequest<\/code> which is commonly used by blocking extensions such as uBlock Origin or Privacy Badger. I would like to implement this API at some point however it requires WebKitGTK improvements.<\/p>\n\n<p>For specific API details please see <a href=\"https:\/\/gitlab.gnome.org\/GNOME\/epiphany\/-\/blob\/master\/src\/webextension\/README.md\">Epiphany\u2019s documentation<\/a>.<\/p>\n\n<p>What this means today is that users of Epiphany can write powerful extensions using a well-documented and commonly used format and API. What this does not mean is that most extensions for other browsers will just work out of the box, at least not yet. Cross-browser extensions are possible but they will have to only require the subset of APIs and behaviors Epiphany currently supports.<\/p>\n\n<h2 id=\"how-to-install-extensions\">How to install extensions<\/h2>\n\n<p>This support is still considered experimental so do understand this may lead to crashes or other unwanted behavior. Also please report issues you find to Epiphany rather than to extensions.<\/p>\n\n<p>You can install the development release and test it like so:<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>flatpak remote-add --if-not-exists gnome-nightly https:\/\/nightly.gnome.org\/gnome-nightly.flatpakrepo\nflatpak install gnome-nightly org.gnome.Epiphany.Devel\nflatpak run --command=gsettings org.gnome.Epiphany.Devel set org.gnome.Epiphany.web:\/org\/gnome\/epiphany\/web\/ enable-webextensions true\n<\/code><\/pre><\/div><\/div>\n\n<p>You will now see <strong>Extensions<\/strong> in Epiphany\u2019s menu and if you run it from the terminal it will print out any message logged by extensions for debugging. You can download extensions most easily from <a href=\"https:\/\/addons.mozilla.org\/en-US\/firefox\/extensions\/\">Mozilla\u2019s website<\/a>.<\/p>\n","pubDate":"Wed, 29 Jun 2022 00:00:00 -0400","link":"https:\/\/blog.tingping.se\/2022\/06\/29\/WebExtensions-Epiphany.html","guid":"https:\/\/blog.tingping.se\/2022\/06\/29\/WebExtensions-Epiphany.html","category":["gnome","igalia","webkit"]},{"title":"HTTP\/2 in libsoup3, WebKitGTK, and Epiphany","description":"<p>The latest development release of libsoup 3, 2.99.8, now enables HTTP\/2 by default.\nSo lets look into what that means and how you can try it out.<\/p>\n\n<!--more-->\n\n<h2 id=\"performance\">Performance<\/h2>\n\n<p>In simple terms what HTTP\/2 provides for improved performance is more efficient network\nusage when requesting multiple files from a single host. It does this by avoiding making\nnew connections whenever possible and over that single connection allowing multiple\nrequests to happen at the same time.<\/p>\n\n<p>It is easy to imagine many workloads this would improve, such as <code class=\"language-plaintext highlighter-rouge\">flatpak<\/code> downloading\na lot of objects from a single server.<\/p>\n\n<p>Here are some examples in Epiphany:<\/p>\n\n<h4 id=\"gophertiles\">gophertiles<\/h4>\n\n<p>This is a benchmark made to directly test the best case for HTTP\/2. As you can see\nin the inspector (which has been improved to show more network information)\nyou can see HTTP\/2 creates a single connection and completes in 229ms. HTTP\/1 on the\nother-hand creates 6 connections taking 1.5 seconds. This all happens on a network which\nis a best case for HTTP\/1, a low latency wired gigabit connection; As network latency\nincreases HTTP\/2\u2019s lead grows dramatically.<\/p>\n\n<p><img src=\"\/images\/gophertiles-http2.png\" alt=\"browser screenshot using http2\" \/><\/p>\n\n<p><img src=\"\/images\/gophertiles-http1.png\" alt=\"browser screenshot using http1\" \/><\/p>\n\n<h4 id=\"youtube\">Youtube<\/h4>\n\n<p>For a more real world example Youtube is a great demo. It hosts a lot of files for a webpage\nbut it isn\u2019t a perfect benchmark as it still involves multiple hosts that don\u2019t share\nconnections. HTTP\/2 still has the slight lead, again versus HTTP\/1\u2019s best case.<\/p>\n\n<p><img src=\"\/images\/youtube-http2.png\" alt=\"inspector screenshot using http2\" \/><\/p>\n\n<p><img src=\"\/images\/youtube-http1.png\" alt=\"inspector screenshot using http1\" \/><\/p>\n\n<h2 id=\"testing\">Testing<\/h2>\n\n<p>This work is all new and we would really like some testing and feedback. The easiest\nway to run this yourself is with this custom <a href=\"https:\/\/dl.tingping.se\/flatpak\/epiphany-canary.flatpak\">Epiphany Flatpak<\/a> (sorry for the slow download server, and it will not\nwork with NVidia drivers).<\/p>\n\n<p>You can get useful debug output both through the WebKit inspector (ctrl+shift+i) and\nby running with <code class=\"language-plaintext highlighter-rouge\">--env='G_MESSAGES_DEBUG=libsoup-http2;nghttp2'<\/code>.<\/p>\n\n<p>Please report any bugs you find to <a href=\"https:\/\/gitlab.gnome.org\/gnome\/libsoup\/issues\">https:\/\/gitlab.gnome.org\/gnome\/libsoup\/issues<\/a>.<\/p>\n","pubDate":"Mon, 07 Jun 2021 00:00:00 -0400","link":"https:\/\/blog.tingping.se\/2021\/06\/07\/http2-in-libsoup.html","guid":"https:\/\/blog.tingping.se\/2021\/06\/07\/http2-in-libsoup.html","category":["gnome","igalia","webkit"]},{"title":"Future of libsoup","description":"<p>The libsoup library implements HTTP for the GNOME platform and is used by a wide range of projects\nincluding any web browser using <a href=\"https:\/\/webkitgtk.org\">WebKitGTK<\/a>. This past year we at <a href=\"https:\/\/igalia.com\">Igalia<\/a>\nhave been working on a new release to modernize the project and I\u2019d like to share some details and get some\nfeedback from the community.<\/p>\n\n<!--more-->\n\n<h2 id=\"history\">History<\/h2>\n\n<p>Before getting into what is changing I want to briefly give backstory to why these changes are happening.<\/p>\n\n<p>The library has a long history, that I won\u2019t cover all of, being created in 2000 by Helix Code, which became\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/Ximian\">Ximian<\/a>, where it was used in projects such as an email client (Evolution).<\/p>\n\n<p>While it has been maintained to some degree for all of this time it hasn\u2019t had a lot of momementum\nbehind it. The library has maintained its ABI for 13 years at this point with ad-hoc feature additions\nand fixes being often added on top. This has resulted in a library that has multiple APIs to accomplish\nthe same task, confusing APIs that don\u2019t follow any convention common within GNOME, and at times odd\ndefault behaviors that couldn\u2019t be changed.<\/p>\n\n<h2 id=\"whats-coming\">What\u2019s Coming<\/h2>\n\n<p>We are finally breaking ABI and making a new libsoup 3.0 release. The goal is to make it a smaller,\nmore simple, and focused library.<\/p>\n\n<p>Making the library smaller meant deleting a lot of duplicated and deprecated APIs, removing rarely used\nfeatures, leveraging additions to GLib in the past decades, and general code cleanup. As of today\nthe current codebase is roughly at 45,000 lines of C code compared to 57,000 lines in the last release\nwith over 20% of the project deleted.<\/p>\n\n<p>Along with reducing the size of the library I wanted to improve the quality of the codebase. We now\nhave improved CI which deploys documentation that has 100% coverage, reports code coverage for tests,\ntests against Clang\u2019s sanitizers, and the beginnings of automated code fuzzing.<\/p>\n\n<p>Lastly there is ongoing work to finally add HTTP\/2 support improving responsiveness for the whole\nplatform.<\/p>\n\n<p>There will be follow up blog posts going more into the technical details of each of these.<\/p>\n\n<h2 id=\"release-schedule\">Release Schedule<\/h2>\n\n<p>The plan is to release libsoup 3.0 with the GNOME 41 release in September. However we will be releasing\na preview build with the GNOME 40 release for developers to start testing against and porting to. All feedback\nwould be welcomed.<\/p>\n\n<p>Igalia plans on helping the platform move to 3.0 and will port GStreamer, GVFS, WebKitGTK and may help with some\napplications so we can have a smooth transition.<\/p>\n\n<p>For more details on WebKitGTK\u2019s release plans there is <a href=\"https:\/\/lists.webkit.org\/pipermail\/webkit-gtk\/2021-February\/003667.html\">a mailinglist thread over it<\/a>.<\/p>\n\n<p>The previous release libsoup 2.72 will continue to get bug fix releases for the forseable future but no new 2.7x\nreleases will happen.<\/p>\n\n<h2 id=\"how-to-help\">How to Help<\/h2>\n\n<p>You can build the current <a href=\"https:\/\/gitlab.gnome.org\/GNOME\/libsoup\">head of libsoup<\/a> to test now.<\/p>\n\n<p>Installing it does not conflict with version 2.x however GObject-Introspection based applications may accidentally import the wrong version (Python for example needs <code class=\"language-plaintext highlighter-rouge\">gi.require_version('Soup', '2.4')<\/code> and GJS needs <code class=\"language-plaintext highlighter-rouge\">imports.gi.versions.Soup = \"2.4\";<\/code> for the old API) and you cannot load both versions in the same process.<\/p>\n\n<p>A <a href=\"https:\/\/libsoup.org\/ch02.html\">migration guide<\/a> has been written to cover some of the common questions as well as improved documentation and guides in general.<\/p>\n\n<p>All bug reports and API discussions are welcomed on the <a href=\"https:\/\/gitlab.gnome.org\/GNOME\/libsoup\/-\/issues\">bug tracker<\/a>.<\/p>\n\n<p>You can also join the IRC channel for direct communication (be patient for timezones): <a href=\"ircs:\/\/irc.gimp.net\/libsoup\">ircs:\/\/irc.gimp.net\/libsoup<\/a>.<\/p>\n","pubDate":"Tue, 23 Feb 2021 00:00:00 -0500","link":"https:\/\/blog.tingping.se\/2021\/02\/23\/future-of-libsoup.html","guid":"https:\/\/blog.tingping.se\/2021\/02\/23\/future-of-libsoup.html","category":["gnome","igalia","webkit"]}]}}