Live data from Hacker News

I hate: Programming Wayland applications

p4m.dev

121–130 of 184 posts

Re: I hate: Programming Wayland applications

#121
post #56
post #4

Seems like complaining about how difficult to use Win32 and COM are. And they are if you use them directly! You don't do that - you use libraries that others have sweated over, as you did with raylib.

Here is how to get Win32 up and running: https://learn.microsoft.com/en-us/windows/win32/learnwin32/y... It's absolutely trivial in comparison. Same thing with Xlib; < 100 lines of C code is enough for a simple app.

I have written some OpenGL applications in X11, so they did not use much of X11 besides setting up windows for the OpenGL contexts, after which the rest of the programs were written using the OpenGL API.

Those applications seemed quite simple to write in comparison with what is described in the parent article, despite doing animation in real time based on the mouse and keyboard inputs.

Re: I hate: Programming Wayland applications

#122
post #6

As a user, I like wayland. X11 was a security disaster. Wayland is much better about tearing. What scares me though are all the responsibilities passed to compositors, because what ends up happening is that each compositor may reimplement what should be common functionality in annoying ways. This is especially true for input things, like key remapping. This ultimately fragments linux desktop experiences even harder t…

Win32 has managed to do this without any API change, all the existing APIs work. The same approach would've worked for X11. What it does is simple - all the functions that deal with windows/handles or events simply do not work on ones that you don't have access to, for example, the EnumWindows function allows you to wall through the tree of windows simply do not see the ones the process has no access to. SetWindowsHo…

Indeed, this is the right approach.

Moreover, it is possible to choose as the default policy that no program may access a window that it did not open, but then there must exist a very simple method for the user to specify when access is permitted, e.g. by clicking a set of windows to grant access to them.

Re: I hate: Programming Wayland applications

#123
post #70
post #52

Earlier quoted context omitted.

Th point is the decoupling. sxkhd runs irrespective of wm and means your en can optionally choose not to handle key bindings at all. With Wayland you end up depending on whether or not and how your compositor supports it.

How many keybings do you have and how often do you try new window managers? Compromising the security of the whole system just to save you a few `sed`s when writing some config files seems like a bad trade off.

There's no need to compromise the security of the whole system. A trivially safe option would have been to restrict the ability to acquire global keybindings to specific clients, and require the user to confirm either once or every time (or any other policy you'd prefer). An X server could do that without breaking anything.

This issue is typical of the thinking that went into Wayland: No consideration was made when Wayland was announced of the fact that there were far simpler ways of achieving the same level of security.

Re: I hate: Programming Wayland applications

#124
post #101
post #6

As a user, I like wayland. X11 was a security disaster. Wayland is much better about tearing. What scares me though are all the responsibilities passed to compositors, because what ends up happening is that each compositor may reimplement what should be common functionality in annoying ways. This is especially true for input things, like key remapping. This ultimately fragments linux desktop experiences even harder t…

IMHO the security advantage of Wayland is mostly a myth and probably the same is true regarding tearing. The later is probably more an issue with respect to drivers and defaults.

On my desktop computers and on most of my laptops I have never experienced tearing in X11, at least during the last 25 years, using mostly NVIDIA GPUs, but also Intel GPUs and AMD GPUs.

I have experienced tearing only once, on a laptop about 10 years ago, which used NVIDIA Optimus, i.e. an NVIDIA GPU without direct video output, which used the Intel GPU to provide outputs. NVIDIA Optimus was a known source of problems in Linux and unlike with any separate NVIDIA GPU, which always worked out-of-the-box without any problems for me, with that NVIDIA Optimus I had to fiddle with the settings for a couple of days until I solved all problems, including the tearing problem.

Perhaps Wayland never had tearing problems, but I have used X11 for several decades on a variety of desktops and laptops and tearing has almost never been a problem.

However, most of the time I have used only NVIDIA or Intel GPUs for display and it seems that most complaints about tearing have been about AMD. I have always used and I am still using AMD GPUs too, but I use those for computations, not connected to monitors, so I do not know if they could have tearing problems.

Re: I hate: Programming Wayland applications

#125
>and I still don't know what's the difference between them (wl_display_roundtrip() & wl_display_dispatch()) and in what order to call them on

I've been struggling with this initially as well, it's pretty poorly explained in docs. Short explanation:

Wayland-client library implements a queues over the socket. So to get it, you have to think about when is the socket read from and written to, and when are the queues pulled from or pushed to. There is always a default queue, but for example EGL+OpenGL creates it's own queue, which further makes it more confusing.

- `wl_display_dispatch_pending()` only pulls messages from default queue to callbacks

- `wl_display_dispatch()` also tries to do blocking read on the socket if no messages are in queue

- quite recently `wl_display_dispatch_queue_timeout()` was finally added, so you can do non-blocking read from the socket. earlier you had to hack the function yourself

- `wl_display_flush()` writes enqueued messages in queue to socket

- `wl_display_roundtrip()` sends a ping message and does blocking wait for response. the purpose is that you also send all enqueued requests and receive and process all responses. for example during init you call it to create registry and enumerate the objects, and you call it for second time to enumerate further protocol objects that got registered in registry callback, such as seat

- `eglSwapBuffers()` operates on its own queue, but reading from socket also enqueues to default queue, so you should always call `wl_display_dispatch_pending()` (on default queue) afterwards

There is also a way to get around being stuck in `eglSwapBuffers()` during window inhibition: disable the blocking with `eglSwapInterval(0)` and use `wl_surface_frame()` callback, and you get notified in callback when you can redraw and swap again. But you can't do blocking reads with `wl_display_dispatch()` anymore, have to use the timeout variant. After using it this way, you can also easily manage multiple vsynced windows independently on the same thread, and even use wayland socket in epoll event loop. None of this is documented of course.

The clipboard interface is definitely compromised a bit by being shared with drag-and-drop events, but it's not that complicated. Also there is a pitfall when you copy-paste to your own application and don't use any async event loop, you can get deadlocked by being expected to write and read on the same file descriptor at the same time.

Re: I hate: Programming Wayland applications

#127

Earlier quoted context omitted.

The commenter above appeared to reference Wayland preventing apps from having unrestricted access to screen contents and clipboard, so those.

Having some kind of access control list or other method of enforcing access rights for windows and clipboards is definitely a good thing. However, such a thing could be relatively easily added to X11 without changing the X protocol, so this does not appear as a sufficient motivation for the existence of Wayland. I have not tried Wayland yet, because I have never heard anyone describing an important enough advantage o…

Having a medium understanding of graphics hardware and software stack, and being an everyday desktop Linux user recently, it's hard to square these kinds of complaints with the actual technical situation. Like, people say X11 is network transparent but that's not in practice true. People argue the same problems could be solved in X11, but in practice despite a decade + of complaining about Wayland nobody did the work make the improvements to X. Unlike say the systemd situation Wayland just seems like a better and necessary design?

At a higher level, I've never found someone who is deeply familiar with the Linux GUI software stack who also thinks Wayland is the wrong path, while subjectively as a user most or all of my Linux GUI machines are using Wayland and there's no noticeable difference.

From an app dev perspective, I have a small app I maintain that runs on Mac and Linux with GPU acceleration and at no point did I need to a make any choices related to Wayland vs X.

So, overall, the case that Wayland has some grave technical or strategic flaws just don't pass the smell test. Maybe I'm missing something?

Re: I hate: Programming Wayland applications

#128
post #95

Earlier quoted context omitted.

A security disaster? Howso?

Keyloggers for example. Linux always has been a system were the existence of malware was ignored, specially Desktop, contrary to other OSes (tooling included). But since a couple of years ago can be observed (I observe) slooow movements trying to correct this colossal mistake. If this is the best way to do it or not, I do not enter. I particularly just welcome most of the advancements about this matter in Linux due s…

so the security um, hack here is that someone has unauthorized access to your machine. its not related to x11. If you run untrusted code, thats it... who cares about x11?

Re: I hate: Programming Wayland applications

#129
post #78
post #58

Earlier quoted context omitted.

> Defeats the point of sandboxing Sandboxing defeats the point of said applications. If you want your computer to have no functionality, check out Figma. A clickable prototype sounds like precisely the security the world needs right now.

So accordingly, ActiveX was a brilliant idea and any web page should be able to execute code in the kernel context, otherwise no meaningful functionality can be provided

The whole problem with wayland is this mistaken absurd belief that the security standards of a desktop are equivalent to those of a website.

Re: I hate: Programming Wayland applications

#130
post #98

Earlier quoted context omitted.

No, nothing deserves this constant whining and crying day in and day out. Especially coming from people who don't put in the work to build something else. It's really bizarre how the opensource community degraded into this space of constant aggresive, insulting screeching over every single project thats actually moving something in the Linux world. Coming from people who don't put any code behind it or do anything bu…

Tbh, it's quite delusional to think that a better alternative solution would win that's not backed by Redhat and GNOME. In a purely competitive environment, a design like Wayland could never have "won" as an X11 replacement, it was pushed long enough until it was "too big to fail".

If the alternative really was better, why wouldn't they back it?

They backed systemd. I think you need to stop with conspiracy thinking and admit to yourself that maybe the solution was actually better than before. And as such, if you build something even better, they'll switch too.

But it has to BE better, not just a pile of yelling.

Post reply on HN