How XMir and Mir fit together
Jul. 15th, 2013 12:09 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Mir is Canonical's new display server. It fulfils a broadly similar role to Wayland and Android's Surfaceflinger, in that it takes final responsibility for getting pixels onto the screen. XMir is an X server that runs on top of Mir. It permits applications that know how to speak the X protocol but don't know how to speak to Mir (ie, approximately all of them at present) to run in a Mir-based environment.
For Ubuntu 13.10, Canonical are proposing to use Mir by default. This doesn't mean that most applications will be using Mir, though - instead, the default session will run XMir as a full-screen client and a normal X environment will be run on that. This lets Canonical deploy Mir without forcing anyone to update their applications, allowing them to take a gradual approach. By 14.10, Canonical expect the default Unity session to be a Mir client rather than an X client. In theory it will then be possible to run an Ubuntu system without any X applications at all, leaving XMir to do nothing other than run legacy applications.
Of course, this requires a certain amount of replumbing. X would normally be responsible for doing things like setting up the screen and pushing the pixels out to the hardware, but this is now handled by Mir instead. Where a native X server would allocate a framebuffer in video memory and render into it, XMir asks Mir for a window corresponding to the size of the screen and renders into that and then simply asks Mir to display it. This step is actually more interesting than it sounds.
Unless you're willing to throw lots of CPU at them, unaccelerated graphics are slow. Even if you are, you're going to end up consuming more power for the same performance, so XMir would be impractical if it didn't provide access to accelerated hardware graphics functions. It makes use of the existing Xorg accelerated X drivers to do this, which is as simple as telling the drivers to render into the window that XMir requested from Mir rather than into the video framebuffer directly. In other words, when displaying through XMir, you're using exactly the same display driver stack as you would be if you were using Xorg. In theory you'd expect identical performance - in practice there's a 10-20% performance hit right now, but that's being actively worked on. Fullscreen 3D apps will also currently take a hit due to there being no support for skipping compositing, which is being fixed. XMir should certainly be capable of performing around as well as native X, but there's no reason for it to be any faster.
The output drivers aren't the only part of the stack. XMir still needs some way to get input events. You might naively expect that Mir would forward input events to XMir, but the current state of affairs is that XMir loads the existing X input drivers which in turn open the input devices themselves. This explains why XMir currently shows two cursors[1] - the first cursor is the Mir cursor that's being driven by the input events Mir is receiving, while the second is the cursor being drawn by XMir in response to the input events that it's receiving[2].
The final main piece of duplicated functionality is output management. In the case where X is its own display server, it can simply ask the kernel to program the outputs. XMir can't do that, so would have to ask Mir to do it instead. Sadly, that functionality's not implemented yet. Running xrandr on Xmir gives:
Obviously, this is still software under active development. There's three months from now until until Ubuntu is due to release with this functionality enabled by default, and the only significant missing features are xrandr and DPMS support. As long as Mir exposes interfaces for controlling those, they shouldn't be a problem to implement. To most users, the transition from native Xorg to XMir should be completely invisible.
Which is kind of the problem. What benefits does the user gain from using XMir on Mir rather than native Xorg?
Features? XMir is a total of around 1000 lines of code on top of Xorg. It implements no functionality that isn't present in Xorg.
Performance? XMir effectively is Xorg - it's the same code running the same drivers. It's not going to be any faster. At the moment it's actually slower, but that's probably fixable.
Security? Again, XMir is effectively Xorg. It still runs as root. It has the same privileges. There's no security benefit to using XMir instead of Xorg.
Like I said, the transition should be completely invisible - no drawbacks, but no benefits. What it does do is get Mir deployed on a larger number of systems, which means Canonical can both get wider testing of the basic Mir functionality and argue that the number of deployed Mir systems means hardware vendors should support it. Users won't see any of the benefits until Unity transitions to being a native Mir client, which is slated for 14.10 next year.
As a PR move, it's pretty great. The public perception is that Mir has gone from not existing to being sufficient to run a full desktop environment in very little time, and it's natural to compare it to Wayland which has been in development for longer and still isn't running a fully featured desktop session. The problem with that perception is that Mir is doing very little at the moment. It's setting an output mode (by asking the kernel to), allocating a window for XMir to draw into and then pushing that window onto the screen whenever XMir tells it that it's changed. This isn't advanced display server functionality, it's the bare minimum that a display server could possibly do[4]. Which is a shame, because Mir is significantly more functional than that, it's just not being used to do anything we couldn't already do.
In summary: XMir on Mir in Ubuntu provides no user benefits and isn't a compelling technology demo. Mir itself will permit a range of additional features, but isn't slated to be running a user session itself until 14.10. The only obvious benefit to Canonical in shipping XMir on Mir is to gain additional testing, which makes using it in 14.04, a supposedly stable and long term release, a somewhat surprising choice.
[1] Although this is in the process of being fixed
[2] This also explains why, on systems with a trackpoint and a touchpad, only the trackpoint moves the Mir cursor while both move the XMir cursor. The X touchpad driver has put the touchpad in absolute mode, which means it's now reporting events that Mir currently ignores.
[3] "XMIR mode of death" is hardcoded into XMir. I'm really hoping it's a Regular Show reference.
[4] So why hasn't anyone done this with Wayland? Mostly because, as described above, there's no technical benefit in doing so. Wayland does have an X server for compatibility purposes, and if you wanted you could run it as a full screen client and run an entire session underneath it. But you'd gain nothing by doing so. The Wayland X server is intended for running individual clients rather than an entire X session. Run an X client under Wayland and it'll pop up in its own individual window and managed by your Wayland session's window manager, just like it would under X. XMir currently has no support for this "rootless" mode - right now if you want to run X apps under Mir, you'll need to launch an entire X session with its own window manager.
For Ubuntu 13.10, Canonical are proposing to use Mir by default. This doesn't mean that most applications will be using Mir, though - instead, the default session will run XMir as a full-screen client and a normal X environment will be run on that. This lets Canonical deploy Mir without forcing anyone to update their applications, allowing them to take a gradual approach. By 14.10, Canonical expect the default Unity session to be a Mir client rather than an X client. In theory it will then be possible to run an Ubuntu system without any X applications at all, leaving XMir to do nothing other than run legacy applications.
Of course, this requires a certain amount of replumbing. X would normally be responsible for doing things like setting up the screen and pushing the pixels out to the hardware, but this is now handled by Mir instead. Where a native X server would allocate a framebuffer in video memory and render into it, XMir asks Mir for a window corresponding to the size of the screen and renders into that and then simply asks Mir to display it. This step is actually more interesting than it sounds.
Unless you're willing to throw lots of CPU at them, unaccelerated graphics are slow. Even if you are, you're going to end up consuming more power for the same performance, so XMir would be impractical if it didn't provide access to accelerated hardware graphics functions. It makes use of the existing Xorg accelerated X drivers to do this, which is as simple as telling the drivers to render into the window that XMir requested from Mir rather than into the video framebuffer directly. In other words, when displaying through XMir, you're using exactly the same display driver stack as you would be if you were using Xorg. In theory you'd expect identical performance - in practice there's a 10-20% performance hit right now, but that's being actively worked on. Fullscreen 3D apps will also currently take a hit due to there being no support for skipping compositing, which is being fixed. XMir should certainly be capable of performing around as well as native X, but there's no reason for it to be any faster.
The output drivers aren't the only part of the stack. XMir still needs some way to get input events. You might naively expect that Mir would forward input events to XMir, but the current state of affairs is that XMir loads the existing X input drivers which in turn open the input devices themselves. This explains why XMir currently shows two cursors[1] - the first cursor is the Mir cursor that's being driven by the input events Mir is receiving, while the second is the cursor being drawn by XMir in response to the input events that it's receiving[2].
The final main piece of duplicated functionality is output management. In the case where X is its own display server, it can simply ask the kernel to program the outputs. XMir can't do that, so would have to ask Mir to do it instead. Sadly, that functionality's not implemented yet. Running xrandr on Xmir gives:
Screen 0: minimum 320 x 320, current 1366 x 768, maximum 8192 x 8192 XMIR-1 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm XMIR mode of death[3] 60.0*+which translates as "I have a screen that can be any size from 320x320 to 8192x8192, and have one output of unknown physical size that can only display 1366x768 at 60Hz". Other than the 1366x768, the result will be identical no matter how many outputs you have - XMir currently has no support for configuring multiple displays, and will always report 60Hz. It also has no support for placing monitors into any kind of DPMS state.
Obviously, this is still software under active development. There's three months from now until until Ubuntu is due to release with this functionality enabled by default, and the only significant missing features are xrandr and DPMS support. As long as Mir exposes interfaces for controlling those, they shouldn't be a problem to implement. To most users, the transition from native Xorg to XMir should be completely invisible.
Which is kind of the problem. What benefits does the user gain from using XMir on Mir rather than native Xorg?
Features? XMir is a total of around 1000 lines of code on top of Xorg. It implements no functionality that isn't present in Xorg.
Performance? XMir effectively is Xorg - it's the same code running the same drivers. It's not going to be any faster. At the moment it's actually slower, but that's probably fixable.
Security? Again, XMir is effectively Xorg. It still runs as root. It has the same privileges. There's no security benefit to using XMir instead of Xorg.
Like I said, the transition should be completely invisible - no drawbacks, but no benefits. What it does do is get Mir deployed on a larger number of systems, which means Canonical can both get wider testing of the basic Mir functionality and argue that the number of deployed Mir systems means hardware vendors should support it. Users won't see any of the benefits until Unity transitions to being a native Mir client, which is slated for 14.10 next year.
As a PR move, it's pretty great. The public perception is that Mir has gone from not existing to being sufficient to run a full desktop environment in very little time, and it's natural to compare it to Wayland which has been in development for longer and still isn't running a fully featured desktop session. The problem with that perception is that Mir is doing very little at the moment. It's setting an output mode (by asking the kernel to), allocating a window for XMir to draw into and then pushing that window onto the screen whenever XMir tells it that it's changed. This isn't advanced display server functionality, it's the bare minimum that a display server could possibly do[4]. Which is a shame, because Mir is significantly more functional than that, it's just not being used to do anything we couldn't already do.
In summary: XMir on Mir in Ubuntu provides no user benefits and isn't a compelling technology demo. Mir itself will permit a range of additional features, but isn't slated to be running a user session itself until 14.10. The only obvious benefit to Canonical in shipping XMir on Mir is to gain additional testing, which makes using it in 14.04, a supposedly stable and long term release, a somewhat surprising choice.
[1] Although this is in the process of being fixed
[2] This also explains why, on systems with a trackpoint and a touchpad, only the trackpoint moves the Mir cursor while both move the XMir cursor. The X touchpad driver has put the touchpad in absolute mode, which means it's now reporting events that Mir currently ignores.
[3] "XMIR mode of death" is hardcoded into XMir. I'm really hoping it's a Regular Show reference.
[4] So why hasn't anyone done this with Wayland? Mostly because, as described above, there's no technical benefit in doing so. Wayland does have an X server for compatibility purposes, and if you wanted you could run it as a full screen client and run an entire session underneath it. But you'd gain nothing by doing so. The Wayland X server is intended for running individual clients rather than an entire X session. Run an X client under Wayland and it'll pop up in its own individual window and managed by your Wayland session's window manager, just like it would under X. XMir currently has no support for this "rootless" mode - right now if you want to run X apps under Mir, you'll need to launch an entire X session with its own window manager.
ouch....
Date: 2013-07-15 05:47 pm (UTC)I also assumed that this was a big hurry to make an LTS release, which is 14.04(?). But there doesn't seem to be a way that they will be Mir-native by then, and does it really make sense to support some version of this Frankenstack for five years?! Blimey.
Re: ouch....
Date: 2013-07-15 07:08 pm (UTC)so, well, x11 for 3 or 5 more years, whichever fits LTS best, looks good to me
Re: ouch....
Date: 2013-07-15 07:54 pm (UTC)I had just assumed the one thing that Mir would buy them would be the ability to move faster than everyone else. Right now I'd bet native Wayland distros appear well before native Mir. I just don't get the point of why they've done it.
Re: ouch....
Date: 2013-07-15 09:41 pm (UTC)Re: ouch....
Date: 2013-07-16 07:58 am (UTC)Canonical may have a wonderful super-special licensing position, but the obvious question to ask is, "Who cares?". Why is someone going to pick Android-based Ubuntu when they can just write their own Android skin? Is Ubuntu One really going to sell it?
I think 2014/15 are going to be sad years for Canonical. All this "convergence" tech will have to be released at some point, and then we'll see what the market makes of it.
Re: ouch....
Date: 2013-07-16 04:59 pm (UTC)I believe the way Android rolled in and gobbled up ODM mindshare was an outright shock to the company, but they didn't recognize what it meant soon enough, and when they did they took away the wrong lesson. The focused on making absolutely fantastic non-functional demo to capture buzz to steal the thunder from the likes of FirefoxOS. Not that it matters, firefoxOS has shipping hardware and is going for an underserved commodity phone market where Android and iOS are not focused. FirefoxOS is growing the smartphone market to some extent for people who don't need top of the line phones. So Canonical's big splash doesn't really hurt FireFoxOS at all in the long run. Canonical is aiming to displace Android, on high end devices and that's far riskier.
So this time around, the led the push into mobile with their non-usable touch demo interface running on top of Android core to turn heads at the MWC, and now have to scramble to backfill in the actual working technology they can build a business around. The learned the wrong lesson. Mir isn't even the biggest risk, strategically. Their reuse/abuse of deb packaging to build their next-gent "click" packages for their mobile "app" system is going to be a much bigger problem for them. Mir is just a sideshow that is draining engineering resources for them.
Canonical is absolutely a minimum of a full year away from beta testing a mobile solution that can be competitive in the marketplace. And until I see an unlocked developer handset or tablet show up with U* anything pre-installed, then its impossible to consider them a serious contender in the consumer device space.... no matter how much talk and engineering effort is expended to polish the software. If they can't make the leap to pre-installed devphone hardware they are not a not even on the battlefield.
Re: ouch....
Date: 2013-07-15 10:16 pm (UTC)Re: ouch....
Date: 2013-07-15 10:33 pm (UTC)Re: ouch....
Date: 2013-07-16 02:34 pm (UTC)I'd say it's a fair question. But I wouldn't say your response was. I would even say that it lacks the least bit of decency.
Re: ouch....
Date: 2013-07-16 02:36 pm (UTC)http://mjg59.dreamwidth.org/26254.html?thread=995470#cmt995470
Re: ouch....
Date: 2013-07-16 11:21 am (UTC)Re: ouch....
Date: 2013-07-16 08:52 am (UTC)> that many of the really hard problems haven't yet been touched
I think that is known as 'doing an Ubuntu', no?
wayland on jolla
Date: 2013-07-15 07:31 pm (UTC)http://www.phoronix.com/scan.php?page=news_item&px=MTQxMDA
Re: wayland on jolla
Date: 2013-07-15 07:37 pm (UTC)Re: wayland on jolla
Date: 2013-07-15 10:32 pm (UTC)https://twitter.com/JollaHQ/status/356061760089890816
https://twitter.com/JollaHQ/status/353189447052963840
no subject
Date: 2013-07-15 08:12 pm (UTC)From the end user standpoint, if you've gained a system compositor, LightDM can now be used as lock screen, user/session switching is much smoother and you can now run several concurrent sessions in multi-head setups.
P.S. this blog doesn't work with Launchpad OpenID for some reason. I'm https://launchpad.net/~shnatsel
pfah
Date: 2013-07-15 09:04 pm (UTC)no subject
Date: 2013-07-15 09:03 pm (UTC)This is scheduled for 14.04 with Unity 8. In fact 13.10 is planned to have an optional Unity 8 preview session included.
no subject
Date: 2013-07-15 09:07 pm (UTC)no subject
Date: 2013-07-16 02:07 pm (UTC)Re: benefits to real users, testing, and binary-blobs
Date: 2013-08-30 02:35 pm (UTC)However, now I'm starting to think that's not what the ubuntu folks meant by "test-driven" development... they weren't talking about auto-QA regression tests, they were talking about in-the-wild *beta* tests. Ubuntu 14.04 LTS is going to have a full copy of Mir, and a full copy of Unity8, and a full copy of all the rest of the future-Ubuntu-graphics-stack.
They have to support that for five years... but recently, they've started doing *rolling* kernel release on the LTS stuff. Which means, 12.04 LTS came out with kernel 3.2, but later 12.10 came out with kernel 3.5, which was then 'backported' to be the new kernel for 12.04 LTS part deux. Basically, the LTS series will be getting kernel upgrades every six months, shortly after the non-LTS flavor has beta-tested that kernel in the wild.
I fully expect the same approach will apply to 14.04 -- it will get rolling kernel updates, and prolly rolling Mir updates, so that ubuntu need not maintain a "frankenstack". Now, whether rolling kernel upgrades to an LTS distro is a good idea or not remains to be seen -- RHEL/CentOS does not do that (it's their main selling point), although Oracle's downstream RHEL clone *does* seem to be doing the Ubuntu trick of rolling kernel upgrades.
As for graphics stacks, whether Mir's approach to release-early-release-often is able to beat Wayland also remains to be seen. But one thing is for sure: releasing Mir into 13.10 isn't just a PR move, it has real benefits for endusers. Just not the *13.10* endusers -- the downside of releasing Mir into 13.10 is that those endusers will prolly experience bugs and instabilities and whatnot. The upside, for the 14.04 and later endusers, is that Mir will have already gone through a six-month beta, so *their* experiences with Mir will be improved.
p.s. One last note: the crucial difference between Mir and Wayland, which remains to be determined, is how well and how fully they will get support from the proprietary GPU drivers. Not *just* the NVIDIA and AMD binary-blob stuff for the x86 desktops however.
More crucial methinks is the Mali/Tegra/PowerVR/Vivante/OMAP/BroadcomVideoCoreAkaRaspberryPi/etc for the tablet and phone markets, using ARM CPUs. Both the wayland and mir teams -- unfortunately to my mind -- are eagerly pursuing the binary-blob folks, with Wayland aiming more at the ARM stuff (Daniel Stone of the Wayland team has already been involved with a proprietary wayland port to Raspberry Pi), and with Mir seeming to be more interested in the desktop GPU vendors (their homepage explicitly states they are trying to get NVIDIA and AMD onboard with Mir... but also strongly hints they are pursuing ARM vendors, and says outright they want Mir to work with existing binary-blob drivers for Android).
Just when the Mesa9/gallium/radeon/r600/libdrm open-source drivers for the desktop were within striking distance of performance-parity (on 2011-era chipsets at least), too.... As the old fortune cookie curse says: may you live in interesting times.
Why?
Date: 2013-07-15 11:01 pm (UTC)User-visible benefits
Date: 2013-07-16 05:37 am (UTC)Oh, and someone (ie: me) has done this with Wayland ☺ - https://github.com/RAOF/weston and https://github.com/RAOF/xserver/tree/xwayland-1.12.2
Kinda sucky that dreamwidth doesn't understand Launchpad OpenID urls ☹.
Re: User-visible benefits
Date: 2013-07-16 05:39 am (UTC)Both xwayland and xmir feel smoother.
Date: 2013-07-16 12:27 pm (UTC)wayland has client side allocation.
Mir has server side allocation.
There are already a livecd using weston running wayland weston and running x.org inside. So there is no reason to bench mir vs x.org alone. It should be benched against weston as well. So yes wayland is running a fully featured desktop session inside X11.
Both Mir and Wayland are at the same area of development.
XWayland
Date: 2013-07-17 04:14 am (UTC)It's not possible to directly benchmark Weston+XWayland against unity-system-compositor+XMir.
Re: Both xwayland and xmir feel smoother.
Date: 2013-07-17 06:58 am (UTC)no subject
Date: 2013-07-16 07:02 pm (UTC)no subject
Date: 2013-07-16 09:35 pm (UTC)no subject
Date: 2013-07-17 09:21 pm (UTC)Again... (remembering accelerated Intel drivers...)
no subject
Date: 2013-07-18 06:30 am (UTC)