{"id":7,"date":"2016-05-18T20:21:30","date_gmt":"2016-05-18T20:21:30","guid":{"rendered":"http:\/\/blogs.igalia.com\/tonikitoo\/?p=7"},"modified":"2016-05-20T15:09:51","modified_gmt":"2016-05-20T15:09:51","slug":"chromium-content_shell-running-on-wayland-desktop-weston-compositor","status":"publish","type":"post","link":"https:\/\/blogs.igalia.com\/tonikitoo\/2016\/05\/18\/chromium-content_shell-running-on-wayland-desktop-weston-compositor\/","title":{"rendered":"[Chromium] content_shell running on Wayland desktop (Weston Compositor)"},"content":{"rendered":"<p style=\"text-align: justify\">During\u00a0my first weeks\u00a0at Igalia, I got an interesting and promising task of <strong>Understand the status of Wayland support in Chromium upstream<\/strong>.<\/p>\n<p style=\"text-align: justify\">At first I could\u00a0see clear signs that <a href=\"https:\/\/wayland.freedesktop.org\/\">Wayland<\/a> is being actively considered by the Chromium community:<\/p>\n<ol style=\"text-align: justify\">\n<li><a href=\"https:\/\/github.com\/01org\/ozone-wayland\">Ozone\/Wayland project<\/a> by Intel &#8211; which was my starting point as described later on.<\/li>\n<li>The\u00a0meta\u00a0bug &#8220;<a href=\"https:\/\/bugs.chromium.org\/p\/chromium\/issues\/detail?id=578890\">upstream wayland backend for ozone (20% project)<\/a>&#8220;, which has some recent activity by the Chromium community.<\/li>\n<li><a href=\"https:\/\/groups.google.com\/a\/chromium.org\/forum\/?fromgroups#!topic\/chromium-dev\/KESYtLi2lvI\">This comment in the chromium-dev mailing list<\/a>\u00a0(by a Googler):<\/li>\n<li>\n<blockquote><p>&#8220;(..) I &#8216;d recommend using ToT. Wayland support is a work-in-progress\u00a0and newer trees will probably be better.&#8221;.<\/p><\/blockquote>\n<p>Chromium&#8217;s <a href=\"https:\/\/code.google.com\/p\/chromium\/codesearch#chromium\/src\/DEPS\">DEPS<\/a> file has &#8220;wayland&#8221; as one its\u00a0core dependency (search for &#8220;wayland&#8221;).<\/li>\n<\/ol>\n<p style=\"text-align: justify\">Next step, naturally, was get my hands dirty, compiling and experimenting with it. I decided to start with <a href=\"https:\/\/www.chromium.org\/developers\/content-module\">content_shell<\/a>.<\/p>\n<hr \/>\n<p><strong>Environment<\/strong>:<\/p>\n<p>Ubuntu 16.04 LTS, regular Gnome session (with X) and Weston Wayland compositor running (no &#8216;xwayland&#8217;\u00a0installed) to run Wayland apps.<\/p>\n<p><strong>GYP_DEFINES<\/strong><\/p>\n<p style=\"padding-left: 30px\"><em>component=static_library use_ash=1 use_aura=1 <strong>chromeos=0<\/strong> use_ozone=1 ozone_platform_wayland=1 use_wayland_egl=1 ozone_auto_platforms=0 use_xkbcommon=1 clang=0 use_sysroot=0 linux_use_bundled_gold=0<\/em><\/p>\n<p>(note: GYP was used for personal familiarity with it, but GN applies fine here).<\/p>\n<p><strong>Chromium version<\/strong><\/p>\n<p>Base SHA 5da650481 (as of 2016\/May\/17)<\/p>\n<p><strong>Initial results<\/strong><\/p>\n<p style=\"text-align: justify\">As is, content_shell\u00a0built fine, but hung\u00a0at runtime upon launch, hitting a CHECK at desktop_factory_ozone.cc(21).<\/p>\n<p><strong>Analysis and Action<\/strong><\/p>\n<p>After\u00a0understanding current <a href=\"https:\/\/www.chromium.org\/developers\/design-documents\/ozone\">Ozone<\/a>\/Wayland upstream support,\u00a0compare designs\/code against <a href=\"https:\/\/github.com\/01org\/ozone-wayland\">01.org<\/a>,\u00a0I could start\u00a0connecting some of the missing dots.<\/p>\n<p style=\"text-align: justify\">The following files were &#8220;ported&#8221; from 01.org:<\/p>\n<ul>\n<li>ui\/views\/widget\/desktop_aura\/desktop_drag_drop_client_wayland.cc \/ h<\/li>\n<li>ui\/views\/widget\/desktop_aura\/desktop_screen_ozone_wayland.cc \/ h<\/li>\n<li>ui\/views\/widget\/desktop_aura\/desktop_window_tree_host_ozone_wayland.cc \/ h<\/li>\n<\/ul>\n<p style=\"text-align: justify\">And then, I implemented\u00a0<em>DesktopFactoryOzoneWayland<\/em> class (ui\/views\/widget\/desktop_factory_ozone_wayland.cc\/h) &#8211; it inherits from <em>DesktopFactoryOzone<\/em>, and implements the following pure virtual methods ::CreateWindowTreeHost and ::CreateDesktopScreen.<\/p>\n<p style=\"text-align: justify\"><strong>Initial result<\/strong><\/p>\n<p style=\"text-align: justify\">After that, I could build and run content_shell with Weston Wayland Compositor (with no &#8216;xwayland&#8217; installed). See a quick preview\u00a0below.<\/p>\n<p><iframe loading=\"lazy\" title=\"content_shell (as of 2016\/may\/17) running on Wayland (Weston compositor)\" width=\"604\" height=\"453\" src=\"https:\/\/www.youtube.com\/embed\/yQWyDZvwX9U?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p><strong>Remarks<\/strong><\/p>\n<p>As is, the UI process owns the the Wayland connection, and <strong>GPU process runs without GL support<\/strong>.<\/p>\n<p>UI processes initializes Ozone by calling:<\/p>\n<div>\n<blockquote>\n<div>#0 ui::WaylandSurfaceFactory::WaylandSurfaceFactory<\/div>\n<div>#1 ui::OzonePlatformWayland::InitializeUI<\/div>\n<div>#2 ui::OzonePlatform::InitializeForUI();<\/div>\n<div>#3 aura::Env::Init()<\/div>\n<div>#4 aura::Env::CreateInstance()<\/div>\n<div>#5 content::BrowserMainLoop::InitializeToolkit()<\/div>\n<div>(&#8230;)<\/div>\n<div>#X content::ContentMain()<\/div>\n<div>&lt;UI PROCESS LAUNCH&gt;<\/div>\n<\/blockquote>\n<\/div>\n<div>On the other side, GPU process gets initialized by calling:<\/div>\n<blockquote>\n<div>#0 ui::WaylandSurfaceFactory::WaylandSurfaceFactory<\/div>\n<div>#1 ui::OzonePlatformWayland::InitializeGPU<\/div>\n<div>#2 ui::OzonePlatform::InitializeForGPU();<\/div>\n<div>\n<div>\n<div>#3 gfx::InitializeStaticGLBindings()<\/div>\n<div>#4 gfx::GLSurface::InitializeOneOffImplementation()<\/div>\n<div>#5 gfx::GLSurface::InitializeOneOff()<\/div>\n<div>#6 content::GpuMain()<\/div>\n<div>&lt;GPU PROCESS LAUNCH&gt;<\/div>\n<\/div>\n<\/div>\n<\/blockquote>\n<div><\/div>\n<p style=\"text-align: left\">Differently from UI process, the GPU process\u00a0call does not initialize <em>OzonePlatformWayland::display_<\/em> and instead passes &#8216;nullptr&#8217; to <em>WaylandSurfaceFactory<\/em> ctor.<\/p>\n<p>Down the road\u00a0on the\u00a0GPU processes initialization <em>WaylandSurfaceFactory::LoadEGLGLES2Bindings<\/em> is called but bails out earlier explicitly because <em>display_<\/em> is NIL.<br \/>\nThen, UI process falls back to software rendering (see call to <em>WaylandSurfaceFactory::CreateCanvasForWidget<\/em>).<\/p>\n<p><strong>Next step<\/strong><\/p>\n<ul>\n<li style=\"text-align: justify\">So far\u00a0I have experimented Ozone\/Wayland support using\u00a0&#8220;linux&#8221; as the target OS. As far as I can tell, most of the Ozone work upstream though has been focusing\u00a0on &#8220;chromeos&#8221; builds instead (e.g. ozone\/x11).<\/li>\n<li style=\"text-align: justify\">Hence the idea is to clean up the code and agree\u00a0with\u00a0Googlers \/ 01.org (Intel) people about how to best make use of this code.<\/li>\n<li style=\"text-align: justify\">It is being also discussed with some Googlers what the best way to tackle this lack of GL support is. <strong>Some real nice stuff are on the pipe here<\/strong>.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>During\u00a0my first weeks\u00a0at Igalia, I got an interesting and promising task of Understand the status of Wayland support in Chromium upstream. At first I could\u00a0see clear signs that Wayland is being actively considered by the Chromium community: Ozone\/Wayland project by Intel &#8211; which was my starting point as described later on. The\u00a0meta\u00a0bug &#8220;upstream wayland backend &hellip; <a href=\"https:\/\/blogs.igalia.com\/tonikitoo\/2016\/05\/18\/chromium-content_shell-running-on-wayland-desktop-weston-compositor\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">[Chromium] content_shell running on Wayland desktop (Weston Compositor)<\/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":"standard","meta":{"footnotes":""},"categories":[13],"tags":[4,3,2,7,5,6],"class_list":["post-7","post","type-post","status-publish","format-standard","hentry","category-igalia","tag-browser","tag-chromium","tag-igalia","tag-ozone","tag-wayland","tag-weston"],"_links":{"self":[{"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/posts\/7","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=7"}],"version-history":[{"count":13,"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":20,"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/posts\/7\/revisions\/20"}],"wp:attachment":[{"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/media?parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/categories?post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.igalia.com\/tonikitoo\/wp-json\/wp\/v2\/tags?post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}