March 6, 2013

Canonical's Windowing Shift: More than a Mir Techie Footnote

Soon after Canonical's unveiling of its slick Ubuntu Touch platform for phones and tablets, and on the same day it released the first beta of Ubuntu 13.04, the Ubuntu project announced a potentially significant -- and already controversial -- change in windowing interfaces.

Starting with the Ubuntu Touch smartphone implementation in this coming October's Ubuntu 13.10 release, a revised version of Ubuntu's Unity environment will shift from the X.org Server implementation of X Window to a homegrown display server called Mir. Two years ago, Canonical had said it would instead switch to the Wayland windowing interface. According to a MirSpec wiki written by Canonical's Mir project leader, Robert Ancell, Wayland was unable to meet Ubuntu 14.04's  goal of being able to smoothly display window environments from the same code running on different desktop and mobile devices.

Ubuntu Mir display stackThe Mir-equipped "Unity Next" environment will be rebuilt entirely on the Qt framework and QML (Qt Meta-Object-Language) Javascript language, says Canonical. Unity Next and Mir will be fully integrated into Ubuntu 14.04, the platform-convergent LTS release due in April 2014.

Mir will support Android drivers right from the start. According to Ancell, in an email to Linux.com, the first two targets will be the Android-based Galaxy Nexus and the Nexus 4 smartphones, which were already slated as the first devices to run Ubuntu Touch.

"We expect this list to grow in the future," said Ancell. The current Ubuntu Touch version running on those devices uses the Android-based SurfaceFlinger windowing technology, which will be swapped out for Mir in October.

Moving Beyond X

Unix- and Linux-based systems have been depending on X Window for some three decades, and it's definitely showing its age. When Canonical's Mark Shuttleworth announced in Nov. 2010 that Ubuntu would scrap the venerable display server in favor of the newer Wayland interface, there was relatively little grumbling. After all, other Linux distros such as Fedora were looking to adopt Wayland, and Google took a pass on using X in Android.

The shift from X was nowhere near as controversial as the earlier decision to swap out GNOME in favor of Canonical's Unity UI environment. Nor did it stir the same angst that came from the Jan.  2011 announcement that in Ubuntu 11.04 Canonical would scrap the GTK+-like "Nux" OpenGL toolkit in favor of Qt.

All three changes would help Ubuntu support both desktop and mobile devices with a single binary, promised Shuttleworth. Unity was quickly cemented as the default Ubuntu environment, despite some defections to other distros, but Qt has only been partially integrated, and Wayland has been missing in action.

Like Wayland, Mir is faster and less complicated than X.org, and it similarly adds built-in support for the hardware-accelerated graphics commonly found on modern computers and mobile devices. In fact, Mir requires a GPU, says Ancell.

They are also both similarly well-suited to work with Qt, he adds. "Qt doesn't matter here," says Ancell. "Qt has a Wayland backend and we have developed a Mir backend, so applications will work in both."

According to Ancell, Wayland is less flexible than Mir in supporting existing resources like hardware-based compositors or Android device drivers, while at the same time has difficulty adapting to new input methods like 3D gesture technology. Unlike the more rigid Wayland, Mir offers a well-crafted "protocol-agnostic inner core" as well as an "outer-shell together with a frontend-firewall that allow us to port our display server to arbitrary graphics stacks and bind it to multiple protocols," according to Ancell's wiki.

The switch to Mir means that "certain legacy applications" will require "an in-session rootless X server that is integrated with Mir," according to the wiki. Ancell told me these potentially include some major apps like LibreOffice and Firefox, "though we will investigate if it's possible to have them running natively on Mir." Ancell added, "GTK+ and Qt applications should run on Mir fine, which will cover the vast majority of current applications out there. Cases that won't be native are Java applications and other toolkits." In any case, he says, "The end user shouldn't notice."

Another challenge may be getting GPU manufacturers to quickly support the technology. So far, Canonical has yet to announce any specific Ubuntu Touch support from chip vendors, hardware manufacturers, or carriers. The wiki notes that the Mir project plans to "distill a reusable and unified [OpenGL-based] EGL-centric driver model that further eases display server development."

Ancell expanded on this in his email, saying, "Currently Mir doesn't work on closed source drivers and we want to change that. We are working actively to solve that and the timeframe will be dependent on working with those driver developers."

Another Ubuntu Controversy?

Mir is already proving more controversial than the switch to Wayland, according to some Google+ discussions summarized by Michael Larabel on Phoronix. Wayland developers led by Kristian Høgsberg claim that Mir's benefits over Wayland are overstated, and that Wayland's input handling is not nearly as bad as Canonical says. Open source driver developer Jerome Glisse argues that the architecture described on the wiki appears to be missing key components like atomic commit or frame synchronization.

At this point, it is difficult to determine how serious the alleged gaps may be, and whether they will delay Canonical's proposed timeline. Although there do appear to be some issues here beyond sour grapes over the late-stage switch, there is also a lot of pent-up anger at Canonical for insisting on homegrown solutions rather than established open source technologies.

Larabel himself seems to agree with the overall critique, writing, "If there is one thing though that Canonical is becoming wildly successful at is alienating and fragmenting the core upstream Linux communities with their 'Not Invented Here' syndrome."