logo

drewdevault.com

[mirror] blog and personal website of Drew DeVault git clone https://hacktivis.me/git/mirror/drewdevault.com.git

Wayland-misconceptions-debunked.md (12618B)


  1. ---
  2. date: 2019-02-10
  3. layout: post
  4. title: Wayland misconceptions debunked
  5. tags: ["wayland"]
  6. ---
  7. This article has been on my backburner for a while, but it seems Wayland FUD is
  8. making the news again recently, so I've bumped up the priority a bit. For those
  9. new to my blog, I am the maintainer of
  10. [wlroots](https://github.com/swaywm/wlroots), a library which implements much of
  11. the functionality required of a Wayland compositor and is arguably the single
  12. most influential project in Wayland right now; and [sway](https://swaywm.org), a
  13. popular Wayland compositor which is nearing version 1.0. Let's go over some of
  14. the common misconceptions I hear about Wayland and why they're wrong. Feel free
  15. to pick and choose the misconceptions you believe to read and disregard the
  16. rest.
  17. The art of hating Wayland has become a cult affair. We don't need to put
  18. ourselves into camps at war. Please try not to read this article through the
  19. lens of anger.
  20. ### Wayland isn't more secure, look at this keylogger!
  21. There is an [unfortunate GitHub
  22. project](https://github.com/Aishou/wayland-keylogger) called "Wayland keylogger"
  23. whose mode of operation is using `LD_PRELOAD` to intercept calls to the
  24. libwayland shared library and record keypresses from it. The problem with this
  25. "critique" is stated in the `README.md` file, though most don't read past the
  26. title of the repository. Wayland is only *one part* of an otherwise secure
  27. system. Using `LD_PRELOAD` is effectively equivalent to rewriting client
  28. programs to log keys themselves, and any program which is in a position to do
  29. this has already won. If I rephrased this as "Wayland can be keylogged, assuming
  30. the attacker can sneak some evil code into your .bashrc", the obviousness of
  31. this truth should become immediately apparent.
  32. Some people have also told me that they can log keys by opening `/dev/input/*`
  33. files and reading input events. They're right! Try it yourself: `sudo libinput
  34. debug-events`. The catch should also be immediately obvious: ask
  35. yourself why this needs to be run with `sudo`.
  36. ### Wayland doesn't support screenshots/capture!
  37. The [core Wayland protocol][wayland.xml] does not define a mechanism for taking
  38. screenshots. Here's another thing it doesn't define: how to open application
  39. windows, like gedit and Firefox. The Wayland protocol is very conservative and
  40. general purpose, and is built with use-cases other than desktop systems in mind.
  41. To this end it only implements the lowest common denominator, and leaves the
  42. rest to protocol extensions. There is a process for defining, implementing,
  43. maturing, and standardizing these extensions, though the last part is in need of
  44. improvements - which are under discussion.
  45. [wayland.xml]: https://github.com/wayland-project/wayland/blob/master/protocol/wayland.xml
  46. There are two protocols for the purpose of screenshots and screen recording,
  47. which are developed by wlroots and supported by a strong majority of Wayland
  48. compositors: [screencopy][screencopy.xml] and
  49. [dmabuf-export][dmabuf-export.xml], respectively for copying pixels (best for
  50. screenshots) and exporting DMA buffers (best for real-time video capture).
  51. [screencopy.xml]: https://github.com/swaywm/wlroots/blob/master/protocol/wlr-screencopy-unstable-v1.xml
  52. [dmabuf-export.xml]: https://github.com/swaywm/wlroots/blob/master/protocol/wlr-export-dmabuf-unstable-v1.xml
  53. There are two approaches to this endorsed by different camps in Wayland: these
  54. Wayland protocols, and a dbus protocol based on Pipewire. Progress is being made
  55. on making these approaches talk to each other via [xdg-desktop-portal][portal],
  56. which will make just about every client and compositor work together.
  57. [portal]: https://github.com/emersion/xdg-desktop-portal-wlr
  58. ### Wayland doesn't have a secondary clipboard!
  59. Secondary clipboard support (aka primary selection) was first implemented as
  60. [gtk-primary-selection][gtk.xml] and was recently standardized as
  61. [wp-primary-selection][wp.xml]. It is supported by nearly all Wayland
  62. compositors and clients.
  63. [gtk.xml]: https://github.com/swaywm/wlroots/blob/master/protocol/gtk-primary-selection.xml
  64. [wp.xml]: https://github.com/wayland-project/wayland-protocols/blob/master/unstable/primary-selection/primary-selection-unstable-v1.xml
  65. ### Wayland doesn't support clipboard managers!
  66. See [wl-clipboard](https://github.com/bugaevc/wl-clipboard)
  67. ### Wayland isn't suitable for embedded devices!
  68. Some people argue that Wayland isn't supported on embedded devices or require
  69. proprietary blobs to work. This is *very* untrue. Firstly, Wayland is a
  70. protocol: the *implementations* are the ones that need support from drivers, and
  71. a Wayland implementation could be written for basically any driver. You could
  72. implement Wayland by writing Wayland protocol messages on pieces of paper,
  73. passing them to your friend in class, and having them draw your window on their
  74. notebook with a pencil.
  75. That being said, this is also untrue of the implementations. wlroots, which
  76. contains the most popular Wayland rendering backend, implements KMS+DRM+GBM,
  77. which is supported by all open source graphics drivers, and uses GLESv2, which
  78. is the most broadly supported graphics implementation, including on embedded
  79. (which is what the "E" stands for) and most older hardware. For ancient
  80. hardware, writing an fbdev backend is totally possible and I'd merge it in
  81. wlroots if someone put in the time. Writing a more modern KMS+DRM+GBM
  82. implementation for that hardware is equally possible.
  83. ### Wayland doesn't have network transparency!
  84. This is actually true! But it's not as bad as it's made out to be. Here's why:
  85. X11 forwarding works on Wayland.
  86. Wait, what? Yep: all mainstream desktop Wayland compositors have support for
  87. **Xwayland**, which is an implementation of the X11 server which translates X11
  88. to Wayland, for backwards compatibility. X11 forwarding works with it! So if you
  89. use X11 forwarding on Xorg today, your workflow will work on Wayland unchanged.
  90. However, Wayland itself is not network transparent. The reason for this is that
  91. some protocols rely on file descriptors for transferring information quickly or
  92. in bulk. One example is GPU buffers, so that the Wayland compositor can render
  93. clients without copying data on the GPU - which improves performance
  94. dramatically. However, little about Wayland is inherently network *opaque*.
  95. Things like sending pixel buffers to the compositor are already abstracted on
  96. Wayland and a network-backed implementation could be easily made. The problem is
  97. that no one seems to really care: all of the people who want network
  98. transparency drank the anti-Wayland kool-aid instead of showing up to put the
  99. work in. If you want to implement this, though, we're here and ready to support
  100. you! Drop by the wlroots [IRC channel][#sway-devel] and we're prepared to help
  101. you implement this.
  102. ### Wayland doesn't support remote desktop!
  103. This one is also true, but work is ongoing. Several of the pieces are in place:
  104. screen capture and keyboard simulation are there. If an interested developer
  105. wants to add pointer device simulation and tie it all together with librdesktop,
  106. that would be a great boon to the Wayland ecosystem. [We're waiting to
  107. help!][#sway-devel]
  108. [#sway-devel]: https://webchat.freenode.net/?channels=sway-devel
  109. ### Wayland requires client side decorations!
  110. This was actually true for a long time, but there was deep contention in the
  111. Wayland ecosystem over this matter. We fought long and hard over this and we now
  112. have a protocol for negotiating client- vs server-side decorations, which is now
  113. fairly broadly supported, including among some of its opponents. You're welcome.
  114. ### Wayland doesn't support hotkey daemons!
  115. This is a feature, not a bug, but you're free to disagree once you hear the
  116. rationale. There are lots of problems with the idea of hotkey daemons as it
  117. exists on X. What if there's a conflict between several clients who want the
  118. same hotkey? What if the user wants to pick a different hotkey? On top of this,
  119. designing a protocol carefully to avoid keylogging concerns makes it more
  120. difficult still.
  121. To this end, I've been encouraging client developers who want hotkeys to instead
  122. use some kind of IPC mechanism and a control binary. For example, `mako`, a
  123. notification daemon, allows you to dismiss notifications by running the `makoctl
  124. dismiss` command. Users are then encouraged to use the compositor's own
  125. keybinding facilities to execute this command. This is more flexible even
  126. outside of keybinding - the user might want to execute this behavior through a
  127. script, too.
  128. Still, if you *really* want hotkeys, you should start the discussion for
  129. standardizing a protocol. It will be an uphill battle but I believe that a
  130. protocol which addresses everyone's concerns is theoretically possible. *You*
  131. have to step up, though: no one working on Wayland today seems to care. We are
  132. mostly volunteers working for free in our spare time.
  133. ### Wayland doesn't support Nvidia!
  134. Actually, Nvidia doesn't support us. There are three standard APIs which are
  135. implemented by all graphics drivers in the Linux kernel: DRM (display resource
  136. management), KMS (kernel mode setting), and GBM (generic buffer management). All
  137. three are necessary for most Wayland compositors. Only the first two are
  138. implemented by the Nvidia proprietary driver. In order to support Nvidia,
  139. Wayland compositors need to add code resembling this:
  140. ```c
  141. if (nvidia proprietary driver) {
  142. /* several thousand lines of code */
  143. } else {
  144. /* several thousand lines of code */
  145. }
  146. ```
  147. That's terrible! On top of that, we cannot debug the proprietary driver, we
  148. cannot send fixes upstream, and we cannot read the code to understand its
  149. behavior. The mesa code (where much of the important code for many drivers
  150. lives) is a frequent object of study among Wayland compositor developers. We
  151. cannot do this with the proprietary drivers, and it doesn't even implement the
  152. APIs it needs to. They claim to be working on a replacement for GBM which they
  153. hope will satisfy everyone's concerns, but 52 commits in 3 years with over a
  154. year of inactivity isn't a great sign.
  155. To boot, Nvidia is a bad actor on Linux. Compare the talks at FOSDEM 2018
  156. from the [nouveau developers][nouveau] (the open source Nvidia driver) and the
  157. [AMDGPU developers][amdgpu] (the *only*[^1] AMD driver - also open source). The
  158. Nouveau developers discuss all of the ways that Nvidia makes their lives
  159. difficult, up to and including *signed firmwares*. AMDGPU instead talks about
  160. the process of upstreaming their driver, discuss their new open source Vulkan
  161. driver, and how the community can contribute - and this was presented by paid
  162. AMD staff. I met Intel employees at XDC who were working on a continuous
  163. integration system wherein Intel offers a massive Intel GPU farm to Mesa
  164. developers free-of-charge for working on the open source driver. Nvidia is
  165. clearly a force for bad on the Linux scene and for open source in general, and
  166. the users who reward this by spending oodles of cash on their graphics cards are
  167. not exactly in my good graces.
  168. [^1]: *actively maintained
  169. So in short, people asking for Nvidia proprietary driver support are asking the
  170. wrong people to spend hundreds of hours working for free to write and maintain
  171. an implementation for *one* driver which represents a harmful force on the Linux
  172. ecosystem and a headache for developers trying to work with it. With respect, my
  173. answer is no.
  174. [nouveau]: https://archive.fosdem.org/2018/schedule/event/nouveau/
  175. [amdgpu]: https://archive.fosdem.org/2018/schedule/event/amd_graphics/
  176. ### Wayland doesn't support gaming!
  177. First-person shooters, among other kinds of games, require "locking" the pointer
  178. to their window. This requires [a protocol][pointer-constraints.xml], which was
  179. standardized in 2015. Adoption has been slower, but it landed in wlroots several
  180. months ago and support was added to sway a few weeks ago.
  181. [pointer-constraints.xml]: https://github.com/wayland-project/wayland-protocols/blob/master/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml
  182. ### In conclusion
  183. At some point, some of these things have been true. Some have never been true.
  184. It takes time to replace a 30-year incumbent. To be fair, some of these points
  185. are true on GNOME and KDE, but none are inherently problems with the Wayland
  186. protocol. wlroots is a dominating force in the Wayland ecosystem and the tide is
  187. clearly moving our way.
  188. Another thing I want to note is that Xorg still works. If you find your needs
  189. aren't met by Wayland, just keep using X! We won't be offended. I'm not trying
  190. to force you to use it. Why you heff to be mad?