During my first weeks at Igalia, I got an interesting and promising task of Understand the status of Wayland support in Chromium upstream.
At first I could see clear signs that Wayland is being actively considered by the Chromium community:
- Ozone/Wayland project by Intel – which was my starting point as described later on.
- The meta bug “upstream wayland backend for ozone (20% project)“, which has some recent activity by the Chromium community.
- This comment in the chromium-dev mailing list (by a Googler):
“(..) I ‘d recommend using ToT. Wayland support is a work-in-progress and newer trees will probably be better.”.
Chromium’s DEPS file has “wayland” as one its core dependency (search for “wayland”).
Next step, naturally, was get my hands dirty, compiling and experimenting with it. I decided to start with content_shell.
Ubuntu 16.04 LTS, regular Gnome session (with X) and Weston Wayland compositor running (no ‘xwayland’ installed) to run Wayland apps.
component=static_library use_ash=1 use_aura=1 chromeos=0 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
(note: GYP was used for personal familiarity with it, but GN applies fine here).
Base SHA 5da650481 (as of 2016/May/17)
As is, content_shell built fine, but hung at runtime upon launch, hitting a CHECK at desktop_factory_ozone.cc(21).
Analysis and Action
The following files were “ported” from 01.org:
- ui/views/widget/desktop_aura/desktop_drag_drop_client_wayland.cc / h
- ui/views/widget/desktop_aura/desktop_screen_ozone_wayland.cc / h
- ui/views/widget/desktop_aura/desktop_window_tree_host_ozone_wayland.cc / h
And then, I implemented DesktopFactoryOzoneWayland class (ui/views/widget/desktop_factory_ozone_wayland.cc/h) – it inherits from DesktopFactoryOzone, and implements the following pure virtual methods ::CreateWindowTreeHost and ::CreateDesktopScreen.
After that, I could build and run content_shell with Weston Wayland Compositor (with no ‘xwayland’ installed). See a quick preview below.
As is, the UI process owns the the Wayland connection, and GPU process runs without GL support.
UI processes initializes Ozone by calling:
#0 ui::WaylandSurfaceFactory::WaylandSurfaceFactory#1 ui::OzonePlatformWayland::InitializeUI#2 ui::OzonePlatform::InitializeForUI();#3 aura::Env::Init()#4 aura::Env::CreateInstance()#5 content::BrowserMainLoop::InitializeToolkit()(…)#X content::ContentMain()<UI PROCESS LAUNCH>
#0 ui::WaylandSurfaceFactory::WaylandSurfaceFactory#1 ui::OzonePlatformWayland::InitializeGPU#2 ui::OzonePlatform::InitializeForGPU();#3 gfx::InitializeStaticGLBindings()#4 gfx::GLSurface::InitializeOneOffImplementation()#5 gfx::GLSurface::InitializeOneOff()#6 content::GpuMain()<GPU PROCESS LAUNCH>
Differently from UI process, the GPU process call does not initialize OzonePlatformWayland::display_ and instead passes ‘nullptr’ to WaylandSurfaceFactory ctor.
Down the road on the GPU processes initialization WaylandSurfaceFactory::LoadEGLGLES2Bindings is called but bails out earlier explicitly because display_ is NIL.
Then, UI process falls back to software rendering (see call to WaylandSurfaceFactory::CreateCanvasForWidget).
- So far I have experimented Ozone/Wayland support using “linux” as the target OS. As far as I can tell, most of the Ozone work upstream though has been focusing on “chromeos” builds instead (e.g. ozone/x11).
- Hence the idea is to clean up the code and agree with Googlers / 01.org (Intel) people about how to best make use of this code.
- It is being also discussed with some Googlers what the best way to tackle this lack of GL support is. Some real nice stuff are on the pipe here.