{"id":67,"date":"2016-11-14T12:42:32","date_gmt":"2016-11-14T16:42:32","guid":{"rendered":"http:\/\/blogs.igalia.com\/tonikitoo\/?p=67"},"modified":"2016-11-14T16:04:59","modified_gmt":"2016-11-14T20:04:59","slug":"chromium-ozone-wayland-and-beyond","status":"publish","type":"post","link":"https:\/\/blogs.igalia.com\/tonikitoo\/2016\/11\/14\/chromium-ozone-wayland-and-beyond\/","title":{"rendered":"Chromium, ozone, wayland and beyond"},"content":{"rendered":"<p style=\"text-align: justify\">Over the past 2 months my fellow Igalian Fr\u00e9d\u00e9ric Wang and I have been working on improving the Wayland support in Chromium. I will be detailing on this post some of the progresses we&#8217;ve made and what our next steps are.<\/p>\n<h4 style=\"text-align: justify\">Background<\/h4>\n<p style=\"text-align: justify\">The more <a href=\"https:\/\/wayland.freedesktop.org\/\">Wayland<\/a>\u00a0evolved as a mature alternative to the traditional X11-based environments, the more the Chromium community realized efforts were needed to run Chrome natively and flawlessly on such environments. On that context, the <a href=\"https:\/\/chromium.googlesource.com\/chromium\/src\/+\/master\/docs\/ozone_overview.md\">Ozone project<\/a> began back in 2013 with the main goal of making\u00a0porting Chrome to different graphics systems easier.<\/p>\n<blockquote>\n<pre style=\"text-align: justify\">Ozone consists in a set of C++ classes for abstracting different window systems on Linux.\r\nIt provides abstraction for the construction of accelerated surfaces underlying Aura UI framework,\u00a0input devices assignment and event handling.<\/pre>\n<\/blockquote>\n<p style=\"text-align: justify\">Yet\u00a0in 2013, <a href=\"https:\/\/groups.google.com\/a\/chromium.org\/forum\/#!topic\/blink-dev\/KjewL-MKDN4\">Intel presented an Ozone\/Wayland backend<\/a>\u00a0to the Chromium community. Although project\u00a0progressed really well, after some time of active development,\u00a0it\u00a0got stalled:\u00a0<a href=\"http:\/\/github.com\/01org\/ozone-wayland.git\">its most\u00a0recent update is compatible with Chromium m49, from December\/2015<\/a>.<\/p>\n<p style=\"text-align: justify\">Leaping forward to 2016, a Wayland backend <a href=\"https:\/\/codereview.chromium.org\/1610683003\">was added to Chromium upstream<\/a>\u00a0by Michael Forney. The\u00a0implementation is\u00a0not as feature complete as Intel&#8217;s (for example, drag n&#8217; drop support is not implemented, and it only works with specific build\u00a0configurations\u00a0of Chrome), but it\u00a0is\u00a0definitively a good starting point.<\/p>\n<p style=\"text-align: justify\">In July, <a href=\"https:\/\/blogs.igalia.com\/tonikitoo\/2016\/05\/18\/chromium-content_shell-running-on-wayland-desktop-weston-compositor\/\">I experimented a bit this existing Wayland backend in Chromium<\/a>.\u00a0In summary, I took the <a href=\"https:\/\/cs.chromium.org\/chromium\/src\/ui\/ozone\/platform\/wayland\/\">existing wayland<\/a> support upstream, and &#8220;ported&#8221; the minimal patches from Intel&#8217;s 01.org repository, being able\u00a0to get\u00a0ContentShell running with\u00a0Wayland. However, given how\u00a0the\u00a0Wayland\u00a0backend in Chromium upstream is\u00a0designed and implemented, the GPU process failed to start, and\u00a0HW rendering path was not functional.<\/p>\n<p style=\"text-align: justify\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-69\" src=\"http:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/Weston_Wayland_Chromium-1-580x378.png\" alt=\"weston_wayland_chromium\" width=\"580\" height=\"378\" srcset=\"https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/Weston_Wayland_Chromium-1-580x378.png 580w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/Weston_Wayland_Chromium-1-768x501.png 768w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/Weston_Wayland_Chromium-1-940x613.png 940w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/Weston_Wayland_Chromium-1.png 1023w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/p>\n<h4 style=\"text-align: justify\">Communication with Google<\/h4>\n<p style=\"text-align: justify\">Our main goal was to make Chrome capable of running natively on a Wayland-based environment, with hardware accelerated rendering enabled through the GPU process. After the investigation phase, the natural follow up step for us at Igalia was to contact Chrome hackers at Google, share\u00a0our plans\u00a0to Chromium\/Wayland, and gather\u00a0feedback. We reached out to @forney and @rjkroege, and once we heard back, we could understand why &#8220;porting&#8221; the missing bits from Intel&#8217;s original Ozone\/Wayland implementation could not be the best choice on the long run.<\/p>\n<p style=\"text-align: justify\">Basically, the Ozone\/Wayland backend present in Chromium upstream is\u00a0designed in accordance to the original\u00a0<a href=\"https:\/\/www.chromium.org\/developers\/mus-ash\">Mus+Ash Project&#8217;s<\/a>\u00a0architecture:\u00a0the <strong>UI and GPU components would live in the same process<\/strong>. This way, the\u00a0Wayland connection and other objects, that belong to the <em>UI component<\/em>, would be accessible to the GPU component and accelerated HW rendering could be implemented without any IPC.<\/p>\n<p style=\"text-align: justify\">This differs from Intel&#8217;s original implementation, where the GPU process owns the Wayland connections and objects, and the legacy Chromium IPC system is\u00a0used to\u00a0pass Wayland data from\u00a0the GPU process to the Browser process.<\/p>\n<blockquote>\n<pre id=\"magicdomid2\"><span class=\"author-a-z73ztqz90zz90zz75zvtpz83zz72znz68zad4\">The latest big Chromium refactor, since the Content API modularization, is the so called Mus+Ash (read \"mustash\") effort. In an over-summarized definition, it consists of factoring out specific parts of Chromium out of Chrome into \"services\", each featuring well defined interfaces for communication via Mojo IPC subsystem.<\/span><\/pre>\n<\/blockquote>\n<p style=\"text-align: justify\">It was also pointed\u00a0to us that eventually <a href=\"https:\/\/bugs.chromium.org\/p\/chromium\/issues\/detail?id=620927\">the UI and GPU components will be split<\/a> into different processes. At that\u00a0point,\u00a0the <a href=\"https:\/\/codereview.chromium.org\/2088533002\">same<\/a>\u00a0<a href=\"https:\/\/codereview.chromium.org\/2071163002\">approach<\/a> as\u00a0<a href=\"https:\/\/codereview.chromium.org\/2096763005\">the one<\/a>\u00a0<a href=\"https:\/\/codereview.chromium.org\/2079233003\">done\u00a0for<\/a> the\u00a0<a href=\"https:\/\/cs.chromium.org\/chromium\/src\/ui\/ozone\/platform\/drm\/?q=drm&amp;sq=package:chromium&amp;dr=CSs\">DRM\/GBM\u00a0Ozone backend<\/a> was\u00a0advised in order to implement communication between UI and GPU\u00a0components.<\/p>\n<h4 style=\"text-align: justify\">Igalia improvements<\/h4>\n<p style=\"text-align: justify\">Given that &#8220;ash&#8221; is a ChromeOS-oriented UI component, it seems logical to say that\u00a0&#8220;mus+ash&#8221; project&#8217;s primarily focus is on the ChromeOS platform.\u00a0Well, with that in mind,\u00a0we thought we just needed to: (1) make a ChromeOS\/Ozone\/Wayland build of Chrome; (2)\u00a0run &#8216;chrome &#8211;mash &#8211;ozone-platform=wayland&#8217;; (c)\u00a0<em>voil\u00e0<\/em>, all should work.<\/p>\n<p style=\"padding-left: 30px;text-align: justify\"><strong>WRONG!<\/strong><\/p>\n<p style=\"text-align: justify\">When Fred and I\u00a0started on this project two months ago, the situation was:<\/p>\n<ul style=\"text-align: justify\">\n<li>Chrome\/Ozone\/Wayland configuration was only build-able\u00a0on ChromeOS and failed to run by default.<\/li>\n<li>The Ozone project documentation was out of date (e.g. it referred to GYP and the obsolete Intel Ozone\/Wayland code)<\/li>\n<li>The Wayland code path was not tested by any buildbots, and could break without being noticed at this time.<\/li>\n<\/ul>\n<p style=\"text-align: justify\">After <a href=\"https:\/\/codereview.chromium.org\/2297743003\/\">various<\/a> <a href=\"https:\/\/codereview.chromium.org\/2313353003\/\">code<\/a> <a href=\"https:\/\/codereview.chromium.org\/2312763002\/\">clean-ups<\/a>\u00a0and <a href=\"https:\/\/codereview.chromium.org\/2341773004\/\">build<\/a> <a href=\"https:\/\/codereview.chromium.org\/2431383002\/\">fixes<\/a>, we could finally\u00a0launch\u00a0Chrome off of a\u00a0ChromeOS\/Mash\/Ozone\/<strong>X11<\/strong> build.<\/p>\n<p style=\"text-align: justify\">With further investigation, we verified that\u00a0<em>ChromeOS\/Mash\/Ozone\/<strong>Wayland<\/strong>\u00a0<\/em>worked in m52 (when hardware accelerated rendering support was added\u00a0to the Wayland backend), m53 and m54 checkouts, but not in m55. We bisected\u00a0commits\u00a0between m54 and m55, identified the regressions, and\u00a0fixed them in\u00a0<a href=\"https:\/\/codereview.chromium.org\/2387063002\/\">issues 2387063002<\/a>\u00a0and\u00a0<a href=\"https:\/\/codereview.chromium.org\/2389053003\/\">2389053003<\/a>. Finally,\u00a0<em>chrome &#8211;mash &#8211;ozone-platform=wayland<\/em>\u00a0was running with hardware accelerated\u00a0rendering enabled on &#8220;off-device&#8221; ChromeOS builds.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-80\" src=\"http:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/Screenshot-from-2016-11-14-00-51-02-580x435.png\" alt=\"screenshot-from-2016-11-14-00-51-02\" width=\"580\" height=\"435\" srcset=\"https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/Screenshot-from-2016-11-14-00-51-02-580x435.png 580w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/Screenshot-from-2016-11-14-00-51-02-768x575.png 768w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/Screenshot-from-2016-11-14-00-51-02-940x704.png 940w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/Screenshot-from-2016-11-14-00-51-02.png 1025w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h5>Linux desktop builds<\/h5>\n<p style=\"text-align: justify\">Our next goal at this point of the collaboration was to make it possible to build and run <em>chrome &#8211;mash\u00a0<\/em><strong>off of a regular Linux desktop build<\/strong>, through Ozone\/Wayland backend.<\/p>\n<p style=\"text-align: justify\">After <a href=\"https:\/\/groups.google.com\/a\/chromium.org\/forum\/\\#!topic\/ozone-dev\/dAsxca9fd5Y\">discussing about it<\/a> on the\u00a0ozone-dev mailing, we <a href=\"https:\/\/codereview.chromium.org\/2454743002\/\">submitted<\/a>\u00a0and\u00a0<a href=\"https:\/\/codereview.chromium.org\/2457443004\/\">upstreamed<\/a>\u00a0<a href=\"https:\/\/codereview.chromium.org\/2452063002\/\">various<\/a> <a href=\"https:\/\/codereview.chromium.org\/2462423002\/\">patches<\/a>, <a href=\"https:\/\/codereview.chromium.org\/2449103004\/\">converging<\/a> to a <a href=\"https:\/\/codereview.chromium.org\/2483783004\/\">point<\/a> where <a href=\"https:\/\/codereview.chromium.org\/2408803002\/\">a preliminary\u00a0version of Chrome\/mash\/Ozone\/Wayland was functional<\/a>\u00a0on a non-chromeos build, as shown\u00a0below.<\/p>\n<p style=\"text-align: justify\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-83\" src=\"http:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/chrome_mash_ozone_wayland_non-chromeos-oct10-580x435.png\" alt=\"chrome_mash_ozone_wayland_non-chromeos-oct10\" width=\"580\" height=\"435\" srcset=\"https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/chrome_mash_ozone_wayland_non-chromeos-oct10-580x435.png 580w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/chrome_mash_ozone_wayland_non-chromeos-oct10-768x576.png 768w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/chrome_mash_ozone_wayland_non-chromeos-oct10-940x705.png 940w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/chrome_mash_ozone_wayland_non-chromeos-oct10.png 1024w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/p>\n<p style=\"text-align: justify\">Note that this version of Chrome is stated above as &#8220;preliminary&#8221; because although\u00a0it launches off of\u00a0a regular desktop Linux build, it still runs with UI components from\u00a0the ChromeOS UI environment, including a yellow bottom tray, and other items part of the\u00a0so called &#8220;<a href=\"https:\/\/www.chromium.org\/developers\/mus-ash\">ash<\/a>&#8221; Desktop environment.<\/p>\n<h5 style=\"text-align: justify\">Improving developers&#8217; ecosystem<\/h5>\n<p>As mentioned, when we started on this collaboration, the Ozone project\u00a0featured an <strong>out of date documentation<\/strong>, <strong>compilation\u00a0and execution failures<\/strong>, and was\u00a0mostly <strong>not integrated to Chromium&#8217;s continuous testing system<\/strong> (buildbots, etc).\u00a0However, given that Ozone is the\u00a0abstraction layer we would work on in order to get a Wayland backend up and running\u00a0for Chrome, we found it sensible to improve this scenario.<\/p>\n<p>By making use of Igalia&#8217;s community work excellence, <a href=\"https:\/\/codereview.chromium.org\/2457443003\/\">many<\/a> <a href=\"https:\/\/codereview.chromium.org\/2483843003\/\">accomplishments<\/a> <a href=\"https:\/\/codereview.chromium.org\/2490533002\/\">were<\/a> <a href=\"https:\/\/codereview.chromium.org\/2480293011\/\">made<\/a><br \/>\non <a href=\"https:\/\/codereview.chromium.org\/2460853002\/\">this<\/a> <a href=\"https:\/\/codereview.chromium.org\/2445323002\/\">front<\/a>, and now <strong>Ozone\u00a0documentation is up-to-date<\/strong>.<\/p>\n<p>Also, after having fixed Ozone\/Wayland recurring build and execution failures, Fred and I realized\u00a0the Ozone\/Wayland\u00a0codepath in Chromium needed to be exercised by a\u00a0buildbot, so that its maintenance burden is reduced. Fred <a href=\"https:\/\/groups.google.com\/a\/chromium.org\/forum\/#!topic\/ozone-dev\/5lRcidwo7ik\">emailed ozone-dev about it<\/a>\u00a0and we <a href=\"https:\/\/codereview.chromium.org\/2438543002\/\">started<\/a> <a href=\"https:\/\/codereview.chromium.org\/2423833002\/\">contributing<\/a> <a href=\"https:\/\/codereview.chromium.org\/2481033006\/\">to it<\/a>, together with the <a href=\"https:\/\/codereview.chromium.org\/search?closed=1&amp;owner=thomasanderson%40google.com&amp;reviewer=&amp;cc=&amp;repo_guid=&amp;base=&amp;project=&amp;private=1&amp;commit=1&amp;created_before=2016-11-13&amp;created_after=2016-11-02&amp;modified_before=&amp;modified_after=&amp;order=&amp;format=html&amp;keys_only=False&amp;with_messages=False&amp;cursor=&amp;limit=30\">Googler thomasanderson@<\/a>.\u00a0As a result,\u00a0\u00a0Ozone\/Wayland backend was made part of Chromium&#8217;s continuous integration testing system.<\/p>\n<p>Also, Fred made\u00a0<a href=\"http:\/\/frederic-wang.fr\/analysis-of-ozone-wayland.html\">a great post about the current Ozone\/Wayland code<\/a> in Chromium, its main classes and some experimentation done about adding Mojo capability to it. I consider it\u00a0is a must-read follow on on this post.<\/p>\n<h4>Next steps<\/h4>\n<p>Today <em>chrome &#8212;mash<\/em>\u00a0launches within an\u00a0&#8220;ash&#8221; window, where the &#8220;ash&#8221; environment works as a shell for child internal windows, being Chrome one of them.<br \/>\nBeing &#8220;mash&#8221; a shortener for &#8220;mus+ash&#8221;, our next step\u00a0is\u00a0to &#8220;eliminate&#8221;<br \/>\nthe &#8220;ash&#8221; aspects from the execution path, resulting on a &#8220;Chrome Mus&#8221; launch.<\/p>\n<p>This project is sponsored by Renesas Electronics &#8230;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-105\" src=\"http:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/renesas_logomark_l-1-580x99.jpg\" alt=\"renesas_logomark_l\" width=\"580\" height=\"99\" srcset=\"https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/renesas_logomark_l-1-580x99.jpg 580w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/renesas_logomark_l-1-768x131.jpg 768w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/renesas_logomark_l-1-940x161.jpg 940w, https:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/renesas_logomark_l-1.jpg 1526w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/p>\n<p>&#8230; and has been performed by the great Igalian hacker Fr\u00e9d\u00e9ric Wang and I on behalf of Igalia.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-106\" src=\"http:\/\/blogs.igalia.com\/tonikitoo\/files\/2016\/11\/igalia-logo-364x130-2.png\" alt=\"igalia-logo-364x130\" width=\"364\" height=\"130\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the past 2 months my fellow Igalian Fr\u00e9d\u00e9ric Wang and I have been working on improving the Wayland support in Chromium. I will be detailing on this post some of the progresses we&#8217;ve made and what our next steps are. Background The more Wayland\u00a0evolved as a mature alternative to the traditional X11-based environments, the &hellip; <a href=\"https:\/\/blogs.igalia.com\/tonikitoo\/2016\/11\/14\/chromium-ozone-wayland-and-beyond\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Chromium, ozone, wayland and beyond<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"footnotes":""},"categories":[9,8,13,11,10,12],"tags":[],"class_list":["post-67","post","type-post","status-publish","format-image","hentry","category-browsers","category-chromium","category-igalia","category-ozone","category-wayland","category-weston","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":28,"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":107,"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/posts\/67\/revisions\/107"}],"wp:attachment":[{"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}