<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://blog.tingping.se/feed.xml" rel="self" type="application/atom+xml" /><link href="https://blog.tingping.se/" rel="alternate" type="text/html" /><updated>2025-01-02T12:12:03-05:00</updated><id>https://blog.tingping.se/feed.xml</id><title type="html">TingPing’s blog</title><subtitle>Development blog of TingPing</subtitle><author><name>Patrick Griffis</name></author><entry><title type="html">Introducing the WebKit Container SDK</title><link href="https://blog.tingping.se/2024/05/23/Introducing-WebKit-Container-SDK.html" rel="alternate" type="text/html" title="Introducing the WebKit Container SDK" /><published>2024-05-23T00:00:00-04:00</published><updated>2024-05-23T00:00:00-04:00</updated><id>https://blog.tingping.se/2024/05/23/Introducing-WebKit-Container-SDK</id><content type="html" xml:base="https://blog.tingping.se/2024/05/23/Introducing-WebKit-Container-SDK.html"><![CDATA[<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’s fairly complex C++ codebase which not all compiler versions handle well. To help with this we’ve made a new SDK to make it easier.</p>

<!--more-->

<h3 id="current-solutions">Current Solutions</h3>

<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 “supported”, you often had to build a large number of dependencies, and the end result wasn’t very reproducable for others.</p>

<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>

<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>

<h3 id="the-webkit-container-sdk">The WebKit Container SDK</h3>

<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’s intention is to be as simple as possible and not change traditional development workflows.</p>

<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>

<p>The main requirements is that this only works on Linux with podman 4.0+ installed. For example Ubuntu 23.10+.</p>

<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>

<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
wkdev-create <span class="nt">--create-home</span>
wkdev-enter
</code></pre></div></div>

<p>From there you can use WebKit’s 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>

<h3 id="advanced-usage">Advanced Usage</h3>

<h4 id="disposibility">Disposibility</h4>

<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>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>wkdev-create --name=playground1
wkdev-create --name=playground2

podman rm playground1 # You would stop first if running.
wkdev-enter --name=playground2
</code></pre></div></div>

<h4 id="working-on-dependencies">Working on Dependencies</h4>

<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’t new but works well with containers and is a simple solution to work on our core dependencies.</p>

<p>Here is an example workflow working on GLib:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>wkdev-create --name=glib
wkdev-enter --name=glib

# This will clone glib main, build, and install it for us. 
jhbuild build glib

# At this point you could simply test if a bug was fixed in a different versin of glib.
# We can also modify and debug glib directly. All of the projects are cloned into ~/checkout.
cd ~/checkout/glib

# Modify the source however you wish then install your new version.
jhbuild make
</code></pre></div></div>

<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>

<h3 id="to-be-continued">To Be Continued</h3>

<p>In the next blog post I’ll document how to use VSCode inside of the SDK for debugging and development.</p>]]></content><author><name>Patrick Griffis</name></author><category term="igalia" /><category term="webkit" /><summary type="html"><![CDATA[Developing WebKitGTK and WPE has always had challenges such as the amount of dependencies or it’s fairly complex C++ codebase which not all compiler versions handle well. To help with this we’ve made a new SDK to make it easier.]]></summary></entry><entry><title type="html">How GTK3 themes work in Flatpak</title><link href="https://blog.tingping.se/2023/04/20/Themes-and-Flatpak.html" rel="alternate" type="text/html" title="How GTK3 themes work in Flatpak" /><published>2023-04-20T00:00:00-04:00</published><updated>2023-04-20T00:00:00-04:00</updated><id>https://blog.tingping.se/2023/04/20/Themes-and-Flatpak</id><content type="html" xml:base="https://blog.tingping.se/2023/04/20/Themes-and-Flatpak.html"><![CDATA[<p>There seems to be a lot of misinformation and low quality content out there on how to use a theme with Flatpak. So I’m going to break down how it all works.</p>

<h3 id="clients">Clients</h3>

<p>Before we talk about Flatpak we have to talk about how GTK3 itself decides what theme you use.</p>

<h4 id="wayland">Wayland</h4>

<p>If you use Wayland this is very simple. It talks to <code class="language-plaintext highlighter-rouge">xdg-desktop-portal-gtk</code> to get your theme name from the host. The setting location on the host is in GSettings:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita-dark'
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">gnome-tweaks</code> sets this value for you, so I’d recommend just using it. Other desktop tools <em>may</em> set this value in their respective settings applications.</p>

<h4 id="x11">X11</h4>

<p>If you are on X11 it relies upon a standard known as <a href="https://www.freedesktop.org/wiki/Specifications/xsettings-spec/">XSettings</a>. How to configure this is less straightforward. On GNOME it uses <code class="language-plaintext highlighter-rouge">gsd-xsettings</code> as part of the <code class="language-plaintext highlighter-rouge">gnome-settings-daemon</code> project and it reads the GSettings value discussed above.</p>

<p>If you use a different daemon like <code class="language-plaintext highlighter-rouge">xsettingsd</code> you have to set <code class="language-plaintext highlighter-rouge">Net/ThemeName</code> in its configuration file. Other desktops may have their own daemon that need to be configured.</p>

<h3 id="getting-themes-inside-of-flatpak">Getting themes inside of Flatpak</h3>

<p>Now that your theme is actually configured properly you need to get the theme files inside of flatpak. You often can run a single command, <code class="language-plaintext highlighter-rouge">flatpak update</code> and everything will work now. It reads the GSetting discussed above and downloads a packaged theme.</p>

<h4 id="not-packaged-themes">Not packaged themes</h4>

<p>If no package for the theme was found a common direction people go in is modifying permissions to add folders to the sandbox. I don’t recommend this. Instead here is how you package your theme.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#!/bin/bash
DEFAULT_ARCH=`flatpak --default-arch`
THEME_NAME=`gsettings get org.gnome.desktop.interface gtk-theme | tr -d \'`
THEME_EXTENSION_DIR=~/.local/share/flatpak/extension/org.gtk.Gtk3theme.$THEME_NAME/$DEFAULT_ARCH/3.22

mkdir -p $THEME_EXTENSION_DIR

cp -r /usr/share/themes/$THEME_NAME/gtk-3.0/* $THEME_EXTENSION_DIR
</code></pre></div></div>

<p>This simply copies your theme into a private flatpak extension and everything should work fine as long as there aren’t weird symlinks in your theme.
Replace <code class="language-plaintext highlighter-rouge">/usr/share/themes</code> with a different directory like <code class="language-plaintext highlighter-rouge">~/.themes</code> if needed.</p>]]></content><author><name>Patrick Griffis</name></author><category term="gnome" /><category term="flatpak" /><summary type="html"><![CDATA[There seems to be a lot of misinformation and low quality content out there on how to use a theme with Flatpak. So I’m going to break down how it all works.]]></summary></entry><entry><title type="html">WebExtension Support in Epiphany</title><link href="https://blog.tingping.se/2022/06/29/WebExtensions-Epiphany.html" rel="alternate" type="text/html" title="WebExtension Support in Epiphany" /><published>2022-06-29T00:00:00-04:00</published><updated>2022-06-29T00:00:00-04:00</updated><id>https://blog.tingping.se/2022/06/29/WebExtensions-Epiphany</id><content type="html" xml:base="https://blog.tingping.se/2022/06/29/WebExtensions-Epiphany.html"><![CDATA[<p>I’m 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’ll go over a summary of how extensions work and give details on what Epiphany supports.</p>

<!--more-->

<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’ve 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>

<h2 id="toward-universal-support">Toward universal support</h2>

<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’s. In 2020, Safari also followed suit. We now have the foundations of an ecosystem-wide solution.</p>

<p>“The foundations of” is an important thing to understand: There are still plenty of existing extensions built with browser-specific APIs and this doesn’t 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’t entirely universal yet (or, may never be).</p>

<h2 id="bringing-extensions-to-epiphany">Bringing Extensions to Epiphany</h2>

<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’ve covered a meaningful segment of them but not all (details below). Over time our API coverage and interoperability will continue to grow.</p>

<h2 id="what-webextensions-can-do-technical-details">What WebExtensions can do: Technical Details</h2>

<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>

<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’s 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>

<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’t 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>

<h3 id="example-usage">Example usage</h3>

<p>For a real-world example, I use Bitwarden as my password manager which I’ll 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>

<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>

<h2 id="epiphanys-current-support">Epiphany’s current support</h2>

<p>Epiphany 43.alpha supports the basic structure described above. We are currently modeling our behavior after Firefox’s ManifestV2 API which includes compatibility with Chrome extensions where possible. Supporting ManifestV3 is planned alongside V2 in the future.</p>

<p>As of today, we support the majority of:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">alarms</code> - Scheduling of events to trigger at specific dates or times.</li>
  <li><code class="language-plaintext highlighter-rouge">commands</code> - Keyboard shortcuts.</li>
  <li><code class="language-plaintext highlighter-rouge">cookies</code> - Management and querying of browser cookies.</li>
  <li><code class="language-plaintext highlighter-rouge">downloads</code> - Ability to start and manage downloads.</li>
  <li><code class="language-plaintext highlighter-rouge">menus</code> - Creation of context menu items.</li>
  <li><code class="language-plaintext highlighter-rouge">notifications</code> - Ability to show desktop notifications.</li>
  <li><code class="language-plaintext highlighter-rouge">storage</code> - Storage of extension private settings.</li>
  <li><code class="language-plaintext highlighter-rouge">tabs</code> - Control and monitoring of browser tabs, including creating, closing, etc.</li>
  <li><code class="language-plaintext highlighter-rouge">windows</code> - Control and monitoring of browser windows.</li>
</ul>

<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>

<p>For specific API details please see <a href="https://gitlab.gnome.org/GNOME/epiphany/-/blob/master/src/webextension/README.md">Epiphany’s documentation</a>.</p>

<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>

<h2 id="how-to-install-extensions">How to install extensions</h2>

<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>

<p>You can install the development release and test it like so:</p>

<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
flatpak install gnome-nightly org.gnome.Epiphany.Devel
flatpak run --command=gsettings org.gnome.Epiphany.Devel set org.gnome.Epiphany.web:/org/gnome/epiphany/web/ enable-webextensions true
</code></pre></div></div>

<p>You will now see <strong>Extensions</strong> in Epiphany’s 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’s website</a>.</p>]]></content><author><name>Patrick Griffis</name></author><category term="gnome" /><category term="igalia" /><category term="webkit" /><summary type="html"><![CDATA[I’m excited to help bring WebExtensions to Epiphany (GNOME Web) thanks to investment from my employer Igalia. In this post, I’ll go over a summary of how extensions work and give details on what Epiphany supports.]]></summary></entry><entry><title type="html">HTTP/2 in libsoup3, WebKitGTK, and Epiphany</title><link href="https://blog.tingping.se/2021/06/07/http2-in-libsoup.html" rel="alternate" type="text/html" title="HTTP/2 in libsoup3, WebKitGTK, and Epiphany" /><published>2021-06-07T00:00:00-04:00</published><updated>2021-06-07T00:00:00-04:00</updated><id>https://blog.tingping.se/2021/06/07/http2-in-libsoup</id><content type="html" xml:base="https://blog.tingping.se/2021/06/07/http2-in-libsoup.html"><![CDATA[<p>The latest development release of libsoup 3, 2.99.8, now enables HTTP/2 by default.
So lets look into what that means and how you can try it out.</p>

<!--more-->

<h2 id="performance">Performance</h2>

<p>In simple terms what HTTP/2 provides for improved performance is more efficient network
usage when requesting multiple files from a single host. It does this by avoiding making
new connections whenever possible and over that single connection allowing multiple
requests to happen at the same time.</p>

<p>It is easy to imagine many workloads this would improve, such as <code class="language-plaintext highlighter-rouge">flatpak</code> downloading
a lot of objects from a single server.</p>

<p>Here are some examples in Epiphany:</p>

<h4 id="gophertiles">gophertiles</h4>

<p>This is a benchmark made to directly test the best case for HTTP/2. As you can see
in the inspector (which has been improved to show more network information)
you can see HTTP/2 creates a single connection and completes in 229ms. HTTP/1 on the
other-hand creates 6 connections taking 1.5 seconds. This all happens on a network which
is a best case for HTTP/1, a low latency wired gigabit connection; As network latency
increases HTTP/2’s lead grows dramatically.</p>

<p><img src="/images/gophertiles-http2.png" alt="browser screenshot using http2" /></p>

<p><img src="/images/gophertiles-http1.png" alt="browser screenshot using http1" /></p>

<h4 id="youtube">Youtube</h4>

<p>For a more real world example Youtube is a great demo. It hosts a lot of files for a webpage
but it isn’t a perfect benchmark as it still involves multiple hosts that don’t share
connections. HTTP/2 still has the slight lead, again versus HTTP/1’s best case.</p>

<p><img src="/images/youtube-http2.png" alt="inspector screenshot using http2" /></p>

<p><img src="/images/youtube-http1.png" alt="inspector screenshot using http1" /></p>

<h2 id="testing">Testing</h2>

<p>This work is all new and we would really like some testing and feedback. The easiest
way 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
work with NVidia drivers).</p>

<p>You can get useful debug output both through the WebKit inspector (ctrl+shift+i) and
by running with <code class="language-plaintext highlighter-rouge">--env='G_MESSAGES_DEBUG=libsoup-http2;nghttp2'</code>.</p>

<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>]]></content><author><name>Patrick Griffis</name></author><category term="gnome" /><category term="igalia" /><category term="webkit" /><summary type="html"><![CDATA[The latest development release of libsoup 3, 2.99.8, now enables HTTP/2 by default. So lets look into what that means and how you can try it out.]]></summary></entry><entry><title type="html">Future of libsoup</title><link href="https://blog.tingping.se/2021/02/23/future-of-libsoup.html" rel="alternate" type="text/html" title="Future of libsoup" /><published>2021-02-23T00:00:00-05:00</published><updated>2021-02-23T00:00:00-05:00</updated><id>https://blog.tingping.se/2021/02/23/future-of-libsoup</id><content type="html" xml:base="https://blog.tingping.se/2021/02/23/future-of-libsoup.html"><![CDATA[<p>The libsoup library implements HTTP for the GNOME platform and is used by a wide range of projects
including any web browser using <a href="https://webkitgtk.org">WebKitGTK</a>. This past year we at <a href="https://igalia.com">Igalia</a>
have been working on a new release to modernize the project and I’d like to share some details and get some
feedback from the community.</p>

<!--more-->

<h2 id="history">History</h2>

<p>Before getting into what is changing I want to briefly give backstory to why these changes are happening.</p>

<p>The library has a long history, that I won’t cover all of, being created in 2000 by Helix Code, which became
<a href="https://en.wikipedia.org/wiki/Ximian">Ximian</a>, where it was used in projects such as an email client (Evolution).</p>

<p>While it has been maintained to some degree for all of this time it hasn’t had a lot of momementum
behind it. The library has maintained its ABI for 13 years at this point with ad-hoc feature additions
and fixes being often added on top. This has resulted in a library that has multiple APIs to accomplish
the same task, confusing APIs that don’t follow any convention common within GNOME, and at times odd
default behaviors that couldn’t be changed.</p>

<h2 id="whats-coming">What’s Coming</h2>

<p>We are finally breaking ABI and making a new libsoup 3.0 release. The goal is to make it a smaller,
more simple, and focused library.</p>

<p>Making the library smaller meant deleting a lot of duplicated and deprecated APIs, removing rarely used
features, leveraging additions to GLib in the past decades, and general code cleanup. As of today
the current codebase is roughly at 45,000 lines of C code compared to 57,000 lines in the last release
with over 20% of the project deleted.</p>

<p>Along with reducing the size of the library I wanted to improve the quality of the codebase. We now
have improved CI which deploys documentation that has 100% coverage, reports code coverage for tests,
tests against Clang’s sanitizers, and the beginnings of automated code fuzzing.</p>

<p>Lastly there is ongoing work to finally add HTTP/2 support improving responsiveness for the whole
platform.</p>

<p>There will be follow up blog posts going more into the technical details of each of these.</p>

<h2 id="release-schedule">Release Schedule</h2>

<p>The plan is to release libsoup 3.0 with the GNOME 41 release in September. However we will be releasing
a preview build with the GNOME 40 release for developers to start testing against and porting to. All feedback
would be welcomed.</p>

<p>Igalia plans on helping the platform move to 3.0 and will port GStreamer, GVFS, WebKitGTK and may help with some
applications so we can have a smooth transition.</p>

<p>For more details on WebKitGTK’s release plans there is <a href="https://lists.webkit.org/pipermail/webkit-gtk/2021-February/003667.html">a mailinglist thread over it</a>.</p>

<p>The previous release libsoup 2.72 will continue to get bug fix releases for the forseable future but no new 2.7x
releases will happen.</p>

<h2 id="how-to-help">How to Help</h2>

<p>You can build the current <a href="https://gitlab.gnome.org/GNOME/libsoup">head of libsoup</a> to test now.</p>

<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>

<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>

<p>All bug reports and API discussions are welcomed on the <a href="https://gitlab.gnome.org/GNOME/libsoup/-/issues">bug tracker</a>.</p>

<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>]]></content><author><name>Patrick Griffis</name></author><category term="gnome" /><category term="igalia" /><category term="webkit" /><summary type="html"><![CDATA[The libsoup library implements HTTP for the GNOME platform and is used by a wide range of projects including any web browser using WebKitGTK. This past year we at Igalia have been working on a new release to modernize the project and I’d like to share some details and get some feedback from the community.]]></summary></entry><entry><title type="html">Hardening Flatpak Permissions Over Time</title><link href="https://blog.tingping.se/2019/10/06/hardening-flatpak-permissions.html" rel="alternate" type="text/html" title="Hardening Flatpak Permissions Over Time" /><published>2019-10-06T00:00:00-04:00</published><updated>2019-10-06T00:00:00-04:00</updated><id>https://blog.tingping.se/2019/10/06/hardening-flatpak-permissions</id><content type="html" xml:base="https://blog.tingping.se/2019/10/06/hardening-flatpak-permissions.html"><![CDATA[<p>One of the main goals of Flatpak is to sandbox applications but a common complaint is that
many packages add a lot of insecure permissions which is entirely valid. I’ll be showing an example
of how over time many permissions now have secure alternatives.</p>

<!--more-->

<p>For this example I’ll be using <a href="https://pithos.github.io">Pithos</a> which is an application I maintain.<br />
It is an online radio player for Pandora.com.</p>

<p>These are the Flatpak permissions used for the application 2 years ago:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="w">  </span><span class="nl">"finish-args"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
    </span><span class="s2">"--share=ipc"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--share=network"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--socket=x11"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--socket=wayland"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--socket=pulseaudio"</span><span class="p">,</span><span class="w">

    </span><span class="s2">"--env=DCONF_USER_CONFIG_DIR=.config/dconf"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--filesystem=xdg-run/dconf"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--filesystem=~/.config/dconf:ro"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--talk-name=ca.desrt.dconf"</span><span class="p">,</span><span class="w">

    </span><span class="s2">"--talk-name=org.freedesktop.secrets"</span><span class="p">,</span><span class="w">

    </span><span class="s2">"--talk-name=org.freedesktop.Notifications"</span><span class="p">,</span><span class="w">

    </span><span class="s2">"--talk-name=org.gnome.SettingsDaemon"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--talk-name=org.mate.SettingsDaemon"</span><span class="p">,</span><span class="w">

    </span><span class="s2">"--talk-name=org.gnome.ScreenSaver"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--talk-name=org.cinnamon.ScreenSaver"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--talk-name=org.freedesktop.ScreenSaver"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--talk-name=com.canonical.Unity.Session"</span><span class="p">,</span><span class="w">

    </span><span class="s2">"--talk-name=org.kde.StatusNotifierWatcher"</span><span class="p">,</span><span class="w">

    </span><span class="s2">"--own-name=org.mpris.MediaPlayer2.pithos"</span><span class="w">
  </span><span class="p">]</span><span class="w">
</span></code></pre></div></div>

<p>These are the possible* permissions today:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="w">  </span><span class="nl">"finish-args"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
    </span><span class="s2">"--share=ipc"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--share=network"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--socket=fallback-x11"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--socket=wayland"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--socket=pulseaudio"</span><span class="p">,</span><span class="w">

    </span><span class="s2">"--talk-name=org.gnome.SettingsDaemon.MediaKeys"</span><span class="p">,</span><span class="w">
    </span><span class="s2">"--talk-name=org.mate.SettingsDaemon"</span><span class="p">,</span><span class="w">

    </span><span class="s2">"--talk-name=org.kde.StatusNotifierWatcher"</span><span class="w">
</span></code></pre></div></div>

<hr />

<p>So lets go over each permission from the old manifest.</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="w">    </span><span class="s2">"--share=ipc"</span><span class="err">,</span><span class="w"> </span><span class="s2">"--share=network"</span><span class="err">,</span><span class="w"> </span><span class="s2">"--socket=x11"</span><span class="err">,</span><span class="w"> </span><span class="s2">"--socket=wayland"</span><span class="err">,</span><span class="w"> </span><span class="s2">"--socket=pulseaudio"</span><span class="w">
</span></code></pre></div></div>

<p>These are simply required for the application to function. The application will always require <code class="language-plaintext highlighter-rouge">network</code>
access and <code class="language-plaintext highlighter-rouge">wayland</code> access. We did replace <code class="language-plaintext highlighter-rouge">x11</code> with <code class="language-plaintext highlighter-rouge">fallback-x11</code> which means on Wayland X11 is blocked.
Eventually (hopefully within a year?) <code class="language-plaintext highlighter-rouge">pulseaudio</code> will have a similar solution for <code class="language-plaintext highlighter-rouge">pipewire</code> which will
be able to block things like being able to record audio.</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="w">    </span><span class="s2">"--filesystem=xdg-run/dconf"</span><span class="err">,</span><span class="w"> </span><span class="s2">"--filesystem=~/.config/dconf:ro"</span><span class="err">,</span><span class="w"> </span><span class="s2">"--talk-name=ca.desrt.dconf"</span><span class="w">
</span></code></pre></div></div>

<p>As of GLib 2.60.6+ this permission is simply removed and settings are stored locally. This prevents applications from
reading and writing settings for all software on the system.</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="w">    </span><span class="s2">"--talk-name=org.freedesktop.secrets"</span><span class="w">
</span></code></pre></div></div>

<p>In an upcoming <code class="language-plaintext highlighter-rouge">libsecret</code> release this will also store secrets locally preventing the application from being able to
read and write all stored secrets in the system keyring.</p>

<p>* This is not in a stable release <em>yet</em>.</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="w">    </span><span class="s2">"--talk-name=org.freedesktop.Notifications"</span><span class="w">
</span></code></pre></div></div>

<p>A portal for notifications have been supported for a long time and the application simply uses the <a href="https://developer.gnome.org/gio/stable/GNotification.html">GNotification</a> API
and just works.</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="w">    </span><span class="s2">"--talk-name=org.gnome.SettingsDaemon"</span><span class="err">,</span><span class="w"> </span><span class="s2">"--talk-name=org.mate.SettingsDaemon"</span><span class="w">
</span></code></pre></div></div>

<p>These permissions are required for GNOME (and forks of GNOME like MATE) to bind media keys. Granting talk access to everything
the settings daemon can do is not ideal and lets the application mess with system wide settings. Years ago <code class="language-plaintext highlighter-rouge">gnome-settings-daemon</code>
improved this by splitting the features into their own namespaces so you only need to expose <code class="language-plaintext highlighter-rouge">org.gnome.SettingsDaemon.MediaKeys</code>
which should be relatively safe to talk to. Hopefully this goes away entirely eventually with a host side solution using MPRIS.</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="w">    </span><span class="s2">"--talk-name=org.gnome.ScreenSaver"</span><span class="err">,</span><span class="w"> </span><span class="s2">"--talk-name=org.cinnamon.ScreenSaver"</span><span class="err">,</span><span class="w"> </span><span class="s2">"--talk-name=org.freedesktop.ScreenSaver"</span><span class="err">,</span><span class="w"> </span><span class="s2">"--talk-name=com.canonical.Unity.Session"</span><span class="w">
</span></code></pre></div></div>

<p>These were used to track the state of the screensaver to pause playback. This isn’t the most dangerous thing in the world
but it does allow applications to activate the screensaver. GTK now supports the <code class="language-plaintext highlighter-rouge">GtkApplication::screensaver-active</code> property
which lets an application monitor the state without having extra permissions.</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="w">    </span><span class="s2">"--own-name=org.mpris.MediaPlayer2.pithos"</span><span class="w">
</span></code></pre></div></div>

<p>This was never a dangerous permission but as of Flatpak 1.0.4 you implicitly have permission to own <code class="language-plaintext highlighter-rouge">org.mpris.MediaPlayer2.$app_id</code>
and subnames so that is now used for our name.</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="w">    </span><span class="s2">"--talk-name=org.kde.StatusNotifierWatcher"</span><span class="w">
</span></code></pre></div></div>

<p>Lastly we do not have an alternative to this permission which still isn’t ideal and could be used to spoof other applications
or exploit the host service which was likely never designed to handle untrusted data.</p>

<hr />

<p>In conclusion there is certainly progress being made and this isn’t the only application slowly tightening permissions. There
are of course still big holes where no alternative exists (most usage of <code class="language-plaintext highlighter-rouge">--filesystem</code>) but already today relatively secure
but still well integrated flatpak’d applications can and do exist.</p>]]></content><author><name>Patrick Griffis</name></author><category term="flatpak" /><summary type="html"><![CDATA[One of the main goals of Flatpak is to sandbox applications but a common complaint is that many packages add a lot of insecure permissions which is entirely valid. I’ll be showing an example of how over time many permissions now have secure alternatives.]]></summary></entry><entry><title type="html">How to design a status icon library in 2019</title><link href="https://blog.tingping.se/2019/09/07/how-to-design-a-modern-status-icon.html" rel="alternate" type="text/html" title="How to design a status icon library in 2019" /><published>2019-09-07T00:00:00-04:00</published><updated>2019-09-07T00:00:00-04:00</updated><id>https://blog.tingping.se/2019/09/07/how-to-design-a-modern-status-icon</id><content type="html" xml:base="https://blog.tingping.se/2019/09/07/how-to-design-a-modern-status-icon.html"><![CDATA[<p>So the year is 2019 and people still use system trays on their desktops. I’m not going to get into
if that is good or bad but lets discuss an implementation to sanely use them and what existing ones
get wrong. I hope this is somewhat informative to developers using or implementing status icons.</p>

<!--more-->

<p>Lets start with some high level goals:</p>

<ul>
  <li>
    <p>Don’t use X11</p>

    <p>I’ll start with this because its simple and everybody knows it by now. If you want to set a tray you can’t
 use X11 because not everybody uses X11. So you need a different solution and on Linux that is a DBus service
 that applications talk to.</p>
  </li>
  <li>
    <p>Safely handle and expose if the tray works</p>

    <p>There are always going to situations where the tray will not work such as using a desktop that doesn’t support
 it or bugs like the service crashing and going away. This should always be reported to the application as soon
 as possible as this avoids issues like an application having a hide window feature but no tray to show it.</p>
  </li>
  <li>
    <p>Be designed for a sandboxed future</p>

    <p>We are now at a point where desktop software is getting sandboxed so that means certain actions are limited such
 as reading/writing files on the host, talking to or owning arbitrary DBus names, having a PID that means anything
 to the host, etc. On top of that applications should expect a permission system where they are denied using a tray.</p>
  </li>
  <li>
    <p>Recommended features</p>

    <p>This is more opinionated but I’d say you need to support:</p>

    <ul>
      <li>Showing an icon and changing it (with scaling ideally)</li>
      <li>Reacting to clicks and maybe scrolling</li>
      <li>Exporting a menu to be shown</li>
    </ul>
  </li>
</ul>

<p>Ok I think that covers the basics lets look at the real world solutions:</p>

<h3 id="--gtkstatusicon-gtk">- GtkStatusIcon (GTK)</h3>

<ul>
  <li>❌ Uses X11</li>
  <li>✔️ It does expose if the tray is “embedded” or not (almost nobody listens to this).</li>
  <li>❌ Sandbox friendly (its X11)</li>
  <li>✔️ Features</li>
</ul>

<p>Nobody should use this API in new code if you want to target non-X11 but this is the classic API
  everybody has lived with for years and it got the job done. Since it no longer exists in GTK4
  due to not being portable a replacement had to come.</p>

<h3 id="--appindicator-canonical">- AppIndicator (Canonical)</h3>

<ul>
  <li>✔️ Uses DBus (but falls back to X11)</li>
  <li>❌ Failure not exposed by default</li>
  <li>❓ It is kinda sandbox friendly</li>
  <li>✔️ Features</li>
</ul>

<p>While nobody should be using the DBus service anymore many use the libappindciator library which behind the scenes uses StatusNotifier these days. It has a complete
  feature-set for the most part though menu handling is overly complex.</p>

<p>There are quite a few problems with this implementation however. It is designed to silently fail by default; It falls back to X11 automatically and unless you override
  the fallback handling XEmbed failing yourself (maybe literally nobody does) you will not know it did. It does tell if you if the DBus portion is connected but as long
  as it fallsback you don’t know what is going on.</p>

<p>It isn’t quite sandbox friendly because it does require talking to an insecure service and it allows referencing icons by path. However it doesn’t require bus
  name ownership which is a positive.</p>

<p>Lastly the library is entirely unmaintained for many years and libdbusmenu is just disgusting, so its not something I’d recommend in new code.</p>

<h3 id="--statusnotifier-kde">- StatusNotifier (KDE)</h3>

<ul>
  <li>✔️ Uses DBus</li>
  <li>✔️ You can detect failure if you try</li>
  <li>❌ Not sandbox friendly</li>
  <li>✔️ Features</li>
</ul>

<p>This is the de-facto standard at the moment that many people are using now. It has its positives and its negatives.</p>

<p>The biggest problem with this API is that it is clearly not designed with a sandbox in mind. Quoting the spec:</p>

<blockquote>
  <p>Each application can register an arbitrary number of Status Notifier Items by registering on the session bus the service org.kde.StatusNotifierItem-PID-ID,
where PID is the process id of the application and ID is an arbitrary numeric unique identifier between different instances registered by the same application.</p>
</blockquote>

<p>So this bad on a few levels. For one it requires name ownership in the KDE namespace which I personally do not understand why. Flatpak blocks all ownership except for your app-id.
  I’m not even sure a well-known name is required at all.</p>

<p>Secondly it requires putting your PID in the name which is a no-go for any PID namespace on Linux as they will almost always have the same values inside the sandbox.</p>

<p>Lastly it has the same issues AppIndicator exposed such as talking to an insecure service, referencing icons by path, etc. It also reuses the DBusMenu spec for exporting
  menus which is still completely awful and unmaintained.</p>

<p>I’d say it is the best solution we have but it needs improving.</p>

<h3 id="--statusicon-linux-mint">- StatusIcon (Linux Mint)</h3>

<ul>
  <li>✔️ Uses DBus (but falls back to X11)</li>
  <li>❌ Failure not exposed</li>
  <li>❌ Not sandbox friendly</li>
  <li>❌ Features</li>
</ul>

<p>So last comes Mint with a new interface which repeats the issues of the past.</p>

<p>Failure is not exposed at all so applications have no idea if it works.</p>

<p>It has all of the sandbox problems of StatusNotifier nearly copy paste. It requires name ownership, it uses your PID in said ownership, etc.</p>

<p>In the end it does not expose as many features as the previous solutions as you can only set an icon, label, and tooltip. I understand why to a degree
  for menus because libdbusmenu is seriously evil but they could have went a more minimal approach and reused GMenu in GLib which perfectly
  handles exporting a menu over DBus.</p>

<p>This announcement is clearly why I am writing this as I hope they will consider some of the sandboxing cases and better expose if a tray
  is working in the future. I just do not want to see past mistakes repeated and for adoption to happen before they are solved.</p>

<p>P.S. Don’t use the <code class="language-plaintext highlighter-rouge">org.x</code> namespace and don’t do blocking IO.</p>

<h3 id="--what-i-want-to-see-or-maybe-create">- What I want to see (or maybe create)</h3>

<ul>
  <li>Supports features mentioned above</li>
  <li>Backed by DBus service
    <ul>
      <li>This must be a robust service, validating the sent icon data in a sandbox
        <ul>
          <li>All icons must be sent as data or icon-names, no paths allowed</li>
        </ul>
      </li>
      <li>Not require well-known name ownership outside of app-id namespace
        <ul>
          <li>Uniqueness is up to the application already</li>
        </ul>
      </li>
      <li>Support more minimal menus than DBusMenu (via GMenu IMO, but anything similar)</li>
      <li>Be exposed by <code class="language-plaintext highlighter-rouge">xdg-desktop-portal</code> which handles permissions</li>
    </ul>
  </li>
  <li>Library that exposes if the tray is working or not
    <ul>
      <li>Also don’t fallback to XEmbed, at least not silently</li>
    </ul>
  </li>
</ul>]]></content><author><name>Patrick Griffis</name></author><category term="linux" /><summary type="html"><![CDATA[So the year is 2019 and people still use system trays on their desktops. I’m not going to get into if that is good or bad but lets discuss an implementation to sanely use them and what existing ones get wrong. I hope this is somewhat informative to developers using or implementing status icons.]]></summary></entry><entry><title type="html">How to force AMDGPU to use full RGB range</title><link href="https://blog.tingping.se/2018/12/01/amdgpu-fullrgb.html" rel="alternate" type="text/html" title="How to force AMDGPU to use full RGB range" /><published>2018-12-01T00:00:00-05:00</published><updated>2018-12-01T00:00:00-05:00</updated><id>https://blog.tingping.se/2018/12/01/amdgpu-fullrgb</id><content type="html" xml:base="https://blog.tingping.se/2018/12/01/amdgpu-fullrgb.html"><![CDATA[<p>I recently got an AMD GPU but sadly unlike i915 (Intel) and nvidia it doesn’t expose any way of setting the full RGB range which my monitor wants instead of limited. There are a dozen issues from the kernel, xorg, wayland compositors, etc to get this exposed somehow but
it still isn’t today.</p>

<p>Thankfully there is a hacky solution of using a custom <a href="https://en.wikipedia.org/wiki/Extended_Display_Identification_Data">EDID</a> and this solution works on Wayland as well as Xorg (it should work with other drivers also). I was not actually the one to figure this out so shout out to <a href="https://www.reddit.com/r/AMDHelp/comments/5e966r/ycbcr444_pixel_format_amdgpupro/">parkerlreed</a> on reddit. This post is just to make it more visible and I packaged the tool used to make this easier.</p>

<ol>
  <li>Find the <code class="language-plaintext highlighter-rouge">edid</code> file used by the connector: <code class="language-plaintext highlighter-rouge">find /sys/devices/pci*/ -name edid</code>
    <ul>
      <li>For convenience copy to home: <code class="language-plaintext highlighter-rouge">cp /sys/devices/.../edid ~/edid.bin</code></li>
    </ul>
  </li>
  <li>Install wxEDID: <code class="language-plaintext highlighter-rouge">flatpak install https://dl.tingping.se/flatpak/wxedid.flatpakref</code></li>
  <li>Open the found file in wxEDID and edit it to disable YCbCr support:
    <ul>
      <li>SPF: Supported features -&gt; change value of <code class="language-plaintext highlighter-rouge">vsig_format</code> to <code class="language-plaintext highlighter-rouge">0b00</code></li>
      <li>CHD: CEA-861 header -&gt; change the value of <code class="language-plaintext highlighter-rouge">YCbCr420</code> and <code class="language-plaintext highlighter-rouge">YCbCr444</code> to <code class="language-plaintext highlighter-rouge">0</code></li>
      <li>VSD: Vendor Specific Data Block -&gt; change the value of <code class="language-plaintext highlighter-rouge">DC_Y444</code> to <code class="language-plaintext highlighter-rouge">0</code></li>
    </ul>
  </li>
  <li>Use the modified EDID file:
    <ol>
      <li>Option -&gt; Recalc Checksum</li>
      <li>File -&gt; Save EDID Binary (to <code class="language-plaintext highlighter-rouge">~/modified_edid.bin</code> for example)</li>
      <li>Copy to firmware directory: <code class="language-plaintext highlighter-rouge">sudo install -Dm644 ~/modified_edid.bin /usr/lib/firmware/edid/modified_edid.bin</code></li>
      <li>Configure kernel to use it. For example on Fedora: <code class="language-plaintext highlighter-rouge">sudo grubby --args='drm.edid_firmware=edid/modified_edid.bin' --update-kernel=DEFAULT</code>
        <ul>
          <li>Note that this only changes the current kernel so you can boot into older kernels (or edit in the grub menu) if it fails and revert this with <code class="language-plaintext highlighter-rouge">grubby --remove-args</code></li>
        </ul>
      </li>
    </ol>
  </li>
  <li>Reboot</li>
</ol>]]></content><author><name>Patrick Griffis</name></author><category term="linux" /><summary type="html"><![CDATA[I recently got an AMD GPU but sadly unlike i915 (Intel) and nvidia it doesn’t expose any way of setting the full RGB range which my monitor wants instead of limited. There are a dozen issues from the kernel, xorg, wayland compositors, etc to get this exposed somehow but it still isn’t today.]]></summary></entry><entry><title type="html">LAS 2018</title><link href="https://blog.tingping.se/2018/09/23/las-2018.html" rel="alternate" type="text/html" title="LAS 2018" /><published>2018-09-23T00:00:00-04:00</published><updated>2018-09-23T00:00:00-04:00</updated><id>https://blog.tingping.se/2018/09/23/las-2018</id><content type="html" xml:base="https://blog.tingping.se/2018/09/23/las-2018.html"><![CDATA[<p>This month I was at my second <a href="https://las.gnome.org">Libre Application Summit</a> in Denver.
A smaller event than GUADEC but personally was my favorite conference so far.</p>

<!--more-->

<p>One of the main goals of LAS has been to be a place for multiple platforms to discuss the desktop space
and not just be a GNOME event. This year two KDE members, @aleixpol and Albert Astals Cid, who spoke about
release cycle of <a href="https://twitter.com/LASGNOME/status/1038204872678629376">KDE Applications</a>, Plasma, and the <a href="https://twitter.com/LASGNOME/status/1038084533206372352">history of Qt</a>.
It is always interesting to see how another project solves the same problems and where there is overlap.</p>

<p>The elementary folks were there since this is @cassidyjames home turf who had a great <a href="https://twitter.com/LASGNOME/status/1038158404328607744">“It’s Not Always Techincal”</a> talk as well as a talk with @danrabbit about <a href="https://twitter.com/LASGNOME/status/1038177696071774208">AppCenter</a> which are both very important areas the GNOME Project needs to improve
in. I also enjoyed meeting a few other community members such as @Philip-Scott and
talk about their use of elementary’s platform.</p>

<p>Heather from Purism spoke about the <a href="https://twitter.com/LASGNOME/status/1038536036501086209">Librem 5 status</a>
which I’m excited for but has a way to go. It was great to get an opportunity to meet her since we’ve spoken
online about their interest in Flatpak and GNOME-Builder.</p>

<p>There were some fantastic talks discussing FOSS usage at a broader level:</p>

<ul>
  <li><a href="https://twitter.com/LASGNOME/status/1038098083102580739">“FreeHive: An Open-Source Creative Agency”</a> and <a href="https://twitter.com/LASGNOME/status/1038163877333266434">“Developers, Developers, Developers—How About Creatives?”</a> - Ryan Gorely</li>
  <li><a href="https://twitter.com/LASGNOME/status/1038113840037289984">“How Can You Make Your Open Source Project Attractive to Students?”</a> - Heidi Ellis and Gregory Hislop</li>
  <li><a href="https://twitter.com/LASGNOME/status/1038551786511101953">“Research Science and Libre Computing”</a> - Britt Yazel</li>
</ul>

<p>As always there was a big Flatpak presense and throughout we had the opportunity to discuss things like
<a href="https://gitlab.com/freedesktop-sdk/freedesktop-sdk/issues/356">adding Qt to fdo</a>, <a href="https://github.com/tingping/flatpak-cve-checker">tracking runtime CVEs</a>, sandboxing WebKitGTK, etc. We also had a <a href="https://github.com/flatpak/flatpak/wiki/LAS-GNOME-Flatpak-BoF">Flatpak BoF</a> on the last day
discussing things like possibilty of selling apps and infrastructure improvements.</p>

<p>I really enjoyed the event overall and look forward to future LASes. Next week I will be in <a href="https://en.wikipedia.org/wiki/A_Coru%C3%B1a">A Coruña, Spain,</a>
for the <a href="https://webengineshackfest.org/2018/">webengine hackfest</a>.</p>

<div style="text-align:center">
  <p><img src="https://wiki.gnome.org/Travel/Policy?action=AttachFile&amp;do=get&amp;target=sponsored-by-foundation-round.png" alt="GNOME Foundation Sponsored Badge" /></p>
</div>]]></content><author><name>Patrick Griffis</name></author><category term="gnome" /><summary type="html"><![CDATA[This month I was at my second Libre Application Summit in Denver. A smaller event than GUADEC but personally was my favorite conference so far.]]></summary></entry><entry><title type="html">Using host Nvidia driver with Flatpak</title><link href="https://blog.tingping.se/2018/08/26/flatpak-host-extensions.html" rel="alternate" type="text/html" title="Using host Nvidia driver with Flatpak" /><published>2018-08-26T00:00:00-04:00</published><updated>2018-08-26T00:00:00-04:00</updated><id>https://blog.tingping.se/2018/08/26/flatpak-host-extensions</id><content type="html" xml:base="https://blog.tingping.se/2018/08/26/flatpak-host-extensions.html"><![CDATA[<p>This post is going to be a bit of a deep dive into how GL driver extensions work on
Flatpak, why they work the way they do, and how we can best use them moving forward.
Some of this information is useful for distro packagers and of course just anybody
interested in Flatpak details.</p>

<!-- more -->

<p>Just as a quick recap Flatpak <em>does not use host libraries</em>. This is required to be
portable and reproducable on nearly any Linux distro. This even applies to very
important libraries like libgl but this is rarely a problem as Mesa supports a wide
range of hardware. The exception to this is properietary drivers which for desktop
users means Nvidia. This isn’t necessarily a problem since we can just package more
drivers but Nvidia’s userspace drivers must be the same version as the kernel driver
which becomes a bit of a packaging nightmare because then we have to package every
version that is in use.</p>

<p>The logical solution to this is for the Flatpak GL driver to come from the same place
that your host GL driver did. Flatpak supports “unmanaged extensions” allowing loading
extensions installed externally into <code class="language-plaintext highlighter-rouge">/var/lib/flatpak/extension</code> and
<code class="language-plaintext highlighter-rouge">$XDG_DATA_HOME/flatpak/extension</code>. This does make my previous paragraph a lie but
it places trust in the host to be responsable and understand how ABI works to keep
things portable which we will get into later.</p>

<p>Before we get into packaging the Nvidia driver on the host for this lets look at how
the GL driver extension point specifically works. This extension point is <a href="https://gitlab.com/freedesktop-sdk/freedesktop-sdk/blob/18.08/elements/flatpak-images/platform.bst#L21-31">defined</a>
as such:</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="s1">'</span><span class="s">Extension</span><span class="nv"> </span><span class="s">org.freedesktop.Platform.GL'</span><span class="err">:</span>
    <span class="na">versions</span><span class="pi">:</span> <span class="s2">"</span><span class="s">18.08;1.4"</span>
    <span class="na">version</span><span class="pi">:</span> <span class="s2">"</span><span class="s">1.4"</span>
    <span class="na">directory</span><span class="pi">:</span> <span class="s2">"</span><span class="s">%{lib}/GL"</span>
    <span class="na">subdirectories</span><span class="pi">:</span> <span class="s2">"</span><span class="s">true"</span>
    <span class="na">no-autodownload</span><span class="pi">:</span> <span class="s2">"</span><span class="s">true"</span>
    <span class="na">autodelete</span><span class="pi">:</span> <span class="s2">"</span><span class="s">false"</span>
    <span class="na">add-ld-path</span><span class="pi">:</span> <span class="s2">"</span><span class="s">lib"</span>
    <span class="na">merge-dirs</span><span class="pi">:</span> <span class="s2">"</span><span class="s">vulkan/icd.d;glvnd/egl_vendor.d"</span>
    <span class="na">download-if</span><span class="pi">:</span> <span class="s2">"</span><span class="s">active-gl-driver"</span>
    <span class="na">enable-if</span><span class="pi">:</span> <span class="s2">"</span><span class="s">active-gl-driver"</span>
</code></pre></div></div>

<p>I will point out the important parts of this later but I will just cover what
<code class="language-plaintext highlighter-rouge">active-gl-driver</code> means really quick. The <code class="language-plaintext highlighter-rouge">-if</code> properties run custom checks within
<code class="language-plaintext highlighter-rouge">flatpak</code> to know if an extension should be downloaded or enabled. This check specifically
looks up your nvidia version from the kernel and maps that to a string e.g. <code class="language-plaintext highlighter-rouge">nvidia-396-54</code>.
What your current version is can be checked with <code class="language-plaintext highlighter-rouge">flatpak --gl-drivers</code> where you will notice
<code class="language-plaintext highlighter-rouge">host</code> and <code class="language-plaintext highlighter-rouge">default</code> are always inserted. This value can also be overriden with the env var 
<code class="language-plaintext highlighter-rouge">FLATPAK_GL_DRIVERS</code>.</p>

<p>So here is a real world example of me packaging this on Fedora: <a href="https://github.com/negativo17/nvidia-driver/pull/57">negativo17/nvidia-driver</a>.
The path it ends up installed into is: <code class="language-plaintext highlighter-rouge">…/org.freedesktop.Platform.GL.host/x86_64/1.4</code>.
As you can see <code class="language-plaintext highlighter-rouge">host</code> is used here because it is always in the default driver list and thus will always get used first.
The <code class="language-plaintext highlighter-rouge">1.4</code> version might also be confusing since the <code class="language-plaintext highlighter-rouge">1.4</code> runtime is ancient and nobody uses it. The reason this is used
is because the Nvidia driver has no ABI requirements outside of libc basically and will run on every freedesktop runtime
that exists so far. That guarentee does not exist for all drivers and must be used cautiously. The layout of files
ends up being this because of <code class="language-plaintext highlighter-rouge">merge-dirs</code> and <code class="language-plaintext highlighter-rouge">add-ld-path</code> shown above:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>├── glvnd
│   └── egl_vendor.d
│       └── 10_nvidia.json
├── lib
│   ├── libGLX_nvidia.so.396.54
│   └── All libs omitted for brevity…
├── OpenCL
│   └── vendors
│       └── nvidia.icd
└── vulkan
    └── icd.d
        └── nvidia_icd.json
</code></pre></div></div>

<p>That should cover all the details for host extensions but this extension point is
also still very useful for normal flatpaked extensions. There is a <a href="https://gitlab.com/freedesktop-sdk/freedesktop-sdk/merge_requests/458">MR for mesa-git</a>
that would end up being used by setting <code class="language-plaintext highlighter-rouge">FLATPAK_GL_DRIVERS=mesa-git</code> to try out
newer versions.</p>

<p>If you are a distro packager I do believe it makes sense to start making a nvidia
package for the Flatpak extension especially for beta versions. This should probably
not be used to package host versions of Mesa though because they link to host
libraries outside of libc. There is some work done to make this possible but most
distro packages are not acceptable for this usage and there is rarely an upside as
fdo 18.08 might even have newer Mesa versions than some distros and can get updates.</p>]]></content><author><name>Patrick Griffis</name></author><category term="flatpak" /><summary type="html"><![CDATA[This post is going to be a bit of a deep dive into how GL driver extensions work on Flatpak, why they work the way they do, and how we can best use them moving forward. Some of this information is useful for distro packagers and of course just anybody interested in Flatpak details.]]></summary></entry></feed>