Collaborator-8-3-CTA-banner

What Wayland Means for Developers

For two decades, X has been the foundation for Linux graphics. Ubuntu’s decision late in 2010 to switch to Wayland shakes things up all the way to those roots. Just over a month ago, the official 1.0.0 release of Wayland appeared, as well as its associated Weston project. How will these milestones affect working GUI programmers? What will happen to all the existing toolkits — Qt, wxWindows, Tk, and others — on which so many graphical applications already depend?

The hope is that Wayland will make things better. With luck, or at least optimism, graphics will be faster and richer, and perhaps no more difficult than now – possibly even easier to maintain. In this article, I explain why, and explore the challenges that remain.

Let’s start by considering what an end user will see. In casual language, future releases of Ubuntu will base their graphics on Wayland rather than X. Since Wayland is designed for 3D displays, the Linux applications of the future will look three-dimensional!

That summary hides considerable detail. When this will actually happen is not set in stone. Certainly it was not in time for Quantal Quetzal 12.10 in mid-October 2012, and I doubt that 13.04, scheduled for spring 2013, will include Wayland as Ubuntu’s default display protocol. The Ubuntu Developer Summit in Copenhagen at the end of October 2012 hinted at plans for Wayland adoption. While Wayland would nicely complement 14.04′s planned break-out to a wide variety of display devices, including televisions and smartphones, I doubt that anyone can be certain how many Wayland-targeted device drivers will be ready by then.

3D on a Single 2D Screen — Through Time

Wayland supports three-dimensional effects; it doesn’t magically create them.

3d glasses“Three-dimensional” has a peculiar meaning among graphics programmers. While stereoscopic displays that provide perceived depth do exist, “3D” for this introduction involves no funny glasses. This kind of 3D is generally understood as a contrast to typical applications’ elements: “Flatland” text, perhaps layered in a simple fashion over a background of images. 3D in this sense refers more to the representation within the computer, and only secondarily to what a viewer sees at any instant of time.

So, for the purpose of this article, 3D graphics involve an implementation of objects in a volumetric, rather than planar, space.

For end users, a 3D implementation has advantages. It is comparatively easy to move, turn and otherwise transform scenes through time, so the viewer can see the sides and backs of objects, not just their fronts. While it would be nice for me to illustrate such effects with a graphic, part of the point is that the two-dimensional medium where you’re reading this description doesn’t support static three-dimensionality. What you can do, though, is run these videos from HowStuffWorks for a “moving-picture” sense of what 3D computer graphics shows. This video, released at the end of summer 2012, focuses particularly on how OpenGL-based three-dimensional display renders a three-dimensional scene as one moves around and through it.

Knowledgeable people agree that Wayland’s 3D-savvy OpenGL-based API gives developers pleasant access to hardware capabilities. The contrast is with X, which does wonders with graphics cards and resources from the 1990s, but has accumulated 15 years of scar tissue that get in the way of efficient solution of today’s problems.

Wayland’s breakthrough is to abstract the notions of buffer and compositor so that they’re coupled as weakly as possible. Wayland gives graphical toolkit designers the relatively easy task of managing the buffers given them, and it takes responsibility for combining the buffers into a visible screen display. For programmers, this brings several conveniences, including easier access to 3D graphics, potentially complete control over every display frame, and slick ways to emulate other hardware or styles.

Wayland’s refactoring of the graphics stack also holds out hope that it will be easier to write device drivers and other low-level hardware interfaces, and thus Ubuntu will become nimbler at support of new products.

Developer considerations

How will you update your graphical applications to run in the new Wayland desktop, once it arrives? You might have to do … nothing. Your GUI application is itself probably written against one of the popular GUI toolkits, such as wxWindows, Tk, or Qt. Suppose, as is often true, your application is dynamically-linked. Once these toolkits are migrated to Wayland, your application immediately becomes available as a Wayland application, without recompilation.

The Wayland 1.0 release is intended to remove any technical barriers to migration. Wayland 1.0 arrives with a commitment “to never break backwards compatibility of interfaces.” Qt 5, for instance, already has Wayland compatibility in development.

Compatible in all directions

Even before migration of the toolkits to Wayland, though, you can run your application unchanged within Wayland. This easy transition path is possible because X itself — which is baked into the current implementation of your application — can be served by a Wayland client. Experimental versions of this facility are already in laboratory test. Version 1.14 of the X.org server, scheduled for release in spring 2013, can use Wayland as the back end for X11 service.

Also available, as mentioned above, is Weston 1.0. Wayland, in this perspective, is the C-coded library that supports the development side of the Wayland protocol. Weston is a reference implementation of the other side, the “compositor,” which interacts more directly with hardware. Weston is constructed to port well to mobile devices and other limited-resource contexts.

Another recent breakthrough the Wayland development team has achieved is a “remotable” prototype. While X11 was originally designed to offer a number of benefits, the one that remains most salient is its network transparency: It’s natural with X11 to run a computation here, but view it there. Weston now builds in this capability.

Not everything is rosy for Wayland.A few hurdles remain

Not everything is rosy for Wayland. Many Linux PCs lack graphics hardware to make the most of 3D. As of this writing, for instance, no Chromebook has such a chipset. Clunkiness on some platforms will cramp interest in Wayland. Most crucially, Ubuntu is only one of several distributions for Linux, and Linux itself is at best third in popularity among desktop operating systems.

Over the longer term, though, computing hardware will continue to gain capabilities. It always does. Plus, use of Linux-based mobile devices is exploding. Even if plans for one particular release of one particular product turn out to have problems — as they inevitably will — the care with which compatibility has been designed into Wayland should keep it close to the marketplace’s eventual path. Wayland is positioned to play a crucial role in making displays of all sizes more immersive, and it’s time for aggressive graphics programmers to research for themselves how they will try it out first.

See also:



subscribe-to-our-blog
 








  • Drake Wilson

    My question is whether things like X’s SELinux extensions are going to go away. Is the New Compositing Way going to be able to provide fine-grained security barriers between clients, or is everything going to be coded to assume that no such thing exists? And if the latter is true but only on a basic, not-very-intrusive level, does the design make it possible to work around this efficiently by writing proxies or such, or is anyone who wants interclient security just going to be hosed?

  • Foo

    As a person who works on portable GUI toolkit and desktop development, I can say I have zero interest in Wayland. First of all, proper 3D _is_ hard, mainly because manufacturers disagreements how things should work; haven’t we learned that from the past: composite extension still, after all these years, doesn’t work properly on all hardware? 
     
    The second thing: unless Wayland provide 100% X API compatibility, hardly anyone will be interested in it. Remember XCB and all praises how, by using awesome design, it will solve all X problems? I don’t see any large project is using it yet, except Xorg team as the backend. 
     
    There is serious amount of code written with X API and hardly anyone, including already busy GUI toolkit developers (remember, popular GUI’s have to work on mobile devices too, beside new versions on current OS’es; yes, I’m talking to you Windows 8) will try to rewrite the same thing all over again again, simply because someone decided to make new protocol design providing shining cool API.

  • Nathan Samson

    Foo Wrote: 
     
    There is serious amount of code written with X API and hardly anyone, including already busy GUI toolkit developers (remember, popular GUI’s have to work on mobile devices too, beside new versions on current OS’es; yes, I’m talking to you Windows 8) will try to rewrite the same thing all over again again, simply because someone decided to make new protocol design providing shining cool API.
     
     
    The problem with your point is that both GTK+ (in recent versions) & Qt (development with release 5) are already having Wayland support (gtk+ with some earlier version of Wayland, it is not compatible with Wayland 1.0.0, but this can be changed quite quicly). 
    With GTK+ & Qt, 90% of programs for linux should be covered.

  • jelabarre

    Jon Davidson wrote:  
    > What what I understand about Wayland, 
    > it is not multi-user in the way X11 is. 
    > It’s not written for a server running 
    > on one machine and a client another, 
    > so these wouldn’t be relevant 
     
    So, in other words, Wayland is completely *USELESS* in a multi-user, multi-server, remote access, server-room (or even *mildly* complex) environment. Sounds like it’s about as brain-dead as the MSWindows GUI. Sorry, the *nix world has been built around open transport, network transparency and flexibility. If the Wayland folks want something as limited and restricted as the MSWindows interface, why don’t they just go and develop for Windows, and leave the REAL operating environments for us adults?

  • http://antimatter-studios.com Christopher Thomas

    @jelabarre: because REAL adults want to get their work done, go home and bone the missus, staying at work late because linux is broken because after 12 years they STILL havent fixed a problem is not how REAL adults spend their free time. 
     
    the unix world is a shambles, the windows world, no matter how much you hate it, works better in the REAL world than the unix world ever did. 
     
    technically unix might be better, but the client desktop has won the war, unix lost, time to pack up your toys and do something more productive

  • http://www.laboiteaprog.com Marc Collin

    how many developper ubuntu have on wayland?

  • Foo

    @Nathan: 
     
    Not sure how is the problem? Both Qt and Gtk+ have native XCB support for some time and we are still using X11. Looks like either that 10% is crucial for Linux desktop world or developers simply don’t care.

  • Jon Davidson

    My question is whether things like X’s SELinux extensions are going to go away. 
     
    Drake, 
     
    In a word, yes. In another word, no. What what I understand about Wayland, it is not multi-user in the way X11 is. It’s not written for a server running on one machine and a client another, so these wouldn’t be relevant. Now, I believe there will be an X.org-compatible module which I assume would implement those extensions. It will work similar to how Mac OS X has an OpenGL-accelerated UI and an X.org system running on top of it. So, to reiterate my answer – yes and no. :-)

  • renoX

    You should be careful about you write: “With luck, or at least optimism, graphics will be faster and richer”, so you’re implying that with Wayland, the GUI will be faster, which is basically wrong as Wayland is the equivalent of X’s DRI2 extension: performance will be mostly identical! 
    Yes, in some case Wayland will be *slightly* faster (less context switch) in some case Wayland may be *slower* (remote desktop). 
    Wayland is above all to simplify the maintenance, so implying that it’ll improve performance is wrong and “dangerous”:users will complain when they realize that this isn’t the case.

  • Frinkk

    “Wayland 1.0 arrives with a commitment “to never break backwards compatibility of interfaces.””

    This is rather disappointing. All of the systems I can think of that tried this have devolved into an overly complex mess that nobody really understands (at least at the interface level): MS-DOS, Windows, X11, x86, Javascript. They take over the world, and then the world spends every waking moment writing clever abstractions so they don’t have to deal with this crap.

    OTOH, systems that don’t fear breaking compatibility when it’s useful or necessary, and can communicate changes clearly to developers, at least have the possibility of getting cleaned up over time: Mac OS X, HTML, HTTP, IP. This also happens external to computers, like with gasoline.

    I can’t run Netscape 1.0 on my modern Mac, and if I could it couldn’t GET almost any modern webpage speaking HTTP 1.1, and even if it could there’s a good chance it would be completely unreadable. There’s incompatibility galore, but for somebody who upgrades more than once every 20 years, there are huge benefits. Firefox running on OS X today is far, far ahead of anything in Netscape 1.0. The cost of pushing these interfaces from 90% compatibility to 100% compatibility would have been incredibly high, and the engineers involved wisely decided against it. “90%” compatibility is good enough to keep people on board and get them through the upgrade process.

    The Wayland developers have made the philosophical choice to be popular, not to be good, and that’s kind of sad. They could save themselves a lot of work, and make life better for users in the long run, if they weren’t so committed to this mistaken philosophy.

    • Cameron Laird

      HTML, IP, … *do* have fantastic records of achievement, and I’ve also bemoaned the pathos of Win* chasing after stupid compatibility goals. I’m with you to that point. It’s considerably less clear to me that “[t]he Wayland developers have made the philosophical choice to be popular, not to be good …”; more specifically, I don’t see sufficiently clearly that a different, potentially compatibility-breaking choice, would have been less popular and more “good”. If I get a chance, I’ll ask the Wayland developers for further comment.

  • Cameron Laird

    I don’t know. Do you mean, “Ubuntu”, or “Canonical”? In any case, it sounds like another good question for follow-up.